xref: /AOO41X/main/connectivity/source/drivers/file/FCatalog.cxx (revision 9b5730f6ddef7eb82608ca4d31dc0d7678e652cf)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "file/FCatalog.hxx"
27 #include "file/FConnection.hxx"
28 #include "file/FTables.hxx"
29 #include <com/sun/star/sdbc/XRow.hpp>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <rtl/logfile.hxx>
32 
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::sdbcx;
36 using namespace ::com::sun::star::sdbc;
37 using namespace ::com::sun::star::container;
38 
39 // -------------------------------------------------------------------------
40 using namespace connectivity::file;
41 // -------------------------------------------------------------------------
OFileCatalog(OConnection * _pCon)42 OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
43                 ,m_pConnection(_pCon)
44 {
45     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::OFileCatalog" );
46 }
47 // -------------------------------------------------------------------------
disposing()48 void SAL_CALL OFileCatalog::disposing()
49 {
50     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::disposing" );
51     ::osl::MutexGuard aGuard(m_aMutex);
52 
53     typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
54 m_xMetaData.clear();
55     OFileCatalog_BASE::disposing();
56 }
57 // -----------------------------------------------------------------------------
buildName(const Reference<XRow> & _xRow)58 ::rtl::OUString OFileCatalog::buildName(const Reference< XRow >& _xRow)
59 {
60     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::buildName" );
61     return _xRow->getString(3);
62 }
63 // -------------------------------------------------------------------------
refreshTables()64 void OFileCatalog::refreshTables()
65 {
66     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::refreshTables" );
67     TStringVector aVector;
68     Sequence< ::rtl::OUString > aTypes;
69     Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
70         ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
71     fillNames(xResult,aVector);
72 
73     if(m_pTables)
74         m_pTables->reFill(aVector);
75     else
76         m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
77 }
78 
79 // -------------------------------------------------------------------------
queryInterface(const Type & rType)80 Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException)
81 {
82     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::queryInterface" );
83     if( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
84         rType == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
85         rType == ::getCppuType((const Reference<XViewsSupplier>*)0))
86         return Any();
87 
88 
89     typedef sdbcx::OCatalog OFileCatalog_BASE;
90     return OFileCatalog_BASE::queryInterface(rType);
91 }
92 // -----------------------------------------------------------------------------
getTypes()93 Sequence< Type > SAL_CALL OFileCatalog::getTypes(  ) throw(RuntimeException)
94 {
95     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::getTypes" );
96     typedef sdbcx::OCatalog OFileCatalog_BASE;
97 
98     Sequence< Type > aTypes = OFileCatalog_BASE::getTypes();
99     ::std::vector<Type> aOwnTypes;
100     aOwnTypes.reserve(aTypes.getLength());
101     const Type* pBegin = aTypes.getConstArray();
102     const Type* pEnd = pBegin + aTypes.getLength();
103     for(;pBegin != pEnd;++pBegin)
104     {
105         if(!(*pBegin == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
106             *pBegin == ::getCppuType((const Reference<XUsersSupplier>*)0)   ||
107             *pBegin == ::getCppuType((const Reference<XViewsSupplier>*)0)))
108         {
109             aOwnTypes.push_back(*pBegin);
110         }
111     }
112     const Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
113     return Sequence< Type >(pTypes, aOwnTypes.size());
114 }
115 // -----------------------------------------------------------------------------
116 
117 
118