Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / file / FCatalog.cxx
blob2026f4244d785467ac88e2c6b0a2ff12a4da8d11
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "file/FCatalog.hxx"
21 #include "file/FConnection.hxx"
22 #include "file/FTables.hxx"
23 #include <com/sun/star/sdbc/XRow.hpp>
24 #include <com/sun/star/sdbc/XResultSet.hpp>
26 using namespace ::com::sun::star::uno;
27 using namespace ::com::sun::star::beans;
28 using namespace ::com::sun::star::sdbcx;
29 using namespace ::com::sun::star::sdbc;
30 using namespace ::com::sun::star::container;
33 using namespace connectivity::file;
35 OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
36 ,m_pConnection(_pCon)
40 void SAL_CALL OFileCatalog::disposing()
42 ::osl::MutexGuard aGuard(m_aMutex);
44 typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
45 m_xMetaData.clear();
46 OFileCatalog_BASE::disposing();
49 OUString OFileCatalog::buildName(const Reference< XRow >& _xRow)
51 return _xRow->getString(3);
54 void OFileCatalog::refreshTables()
56 TStringVector aVector;
57 Sequence< OUString > aTypes;
58 Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
59 OUString("%"),OUString("%"),aTypes);
60 fillNames(xResult,aVector);
62 if(m_pTables)
63 m_pTables->reFill(aVector);
64 else
65 m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
69 Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
71 if( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
72 rType == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
73 rType == ::getCppuType((const Reference<XViewsSupplier>*)0))
74 return Any();
77 typedef sdbcx::OCatalog OFileCatalog_BASE;
78 return OFileCatalog_BASE::queryInterface(rType);
81 Sequence< Type > SAL_CALL OFileCatalog::getTypes( ) throw(RuntimeException, std::exception)
83 typedef sdbcx::OCatalog OFileCatalog_BASE;
85 Sequence< Type > aTypes = OFileCatalog_BASE::getTypes();
86 ::std::vector<Type> aOwnTypes;
87 aOwnTypes.reserve(aTypes.getLength());
88 const Type* pBegin = aTypes.getConstArray();
89 const Type* pEnd = pBegin + aTypes.getLength();
90 for(;pBegin != pEnd;++pBegin)
92 if(!(*pBegin == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
93 *pBegin == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
94 *pBegin == ::getCppuType((const Reference<XViewsSupplier>*)0)))
96 aOwnTypes.push_back(*pBegin);
99 const Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
100 return Sequence< Type >(pTypes, aOwnTypes.size());
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */