Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
25 :
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;
31 :
32 :
33 : using namespace connectivity::file;
34 :
35 62 : OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
36 62 : ,m_pConnection(_pCon)
37 : {
38 62 : }
39 :
40 62 : void SAL_CALL OFileCatalog::disposing()
41 : {
42 62 : ::osl::MutexGuard aGuard(m_aMutex);
43 :
44 : typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
45 62 : m_xMetaData.clear();
46 62 : OFileCatalog_BASE::disposing();
47 62 : }
48 :
49 0 : OUString OFileCatalog::buildName(const Reference< XRow >& _xRow)
50 : {
51 0 : return _xRow->getString(3);
52 : }
53 :
54 0 : void OFileCatalog::refreshTables()
55 : {
56 0 : TStringVector aVector;
57 0 : Sequence< OUString > aTypes;
58 0 : Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
59 0 : OUString("%"),OUString("%"),aTypes);
60 0 : fillNames(xResult,aVector);
61 :
62 0 : if(m_pTables)
63 0 : m_pTables->reFill(aVector);
64 : else
65 0 : m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
66 0 : }
67 :
68 :
69 380 : Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
70 : {
71 1078 : if( rType == cppu::UnoType<XGroupsSupplier>::get()||
72 636 : rType == cppu::UnoType<XUsersSupplier>::get()||
73 256 : rType == cppu::UnoType<XViewsSupplier>::get())
74 186 : return Any();
75 :
76 :
77 : typedef sdbcx::OCatalog OFileCatalog_BASE;
78 194 : return OFileCatalog_BASE::queryInterface(rType);
79 : }
80 :
81 0 : Sequence< Type > SAL_CALL OFileCatalog::getTypes( ) throw(RuntimeException, std::exception)
82 : {
83 : typedef sdbcx::OCatalog OFileCatalog_BASE;
84 :
85 0 : Sequence< Type > aTypes = OFileCatalog_BASE::getTypes();
86 0 : ::std::vector<Type> aOwnTypes;
87 0 : aOwnTypes.reserve(aTypes.getLength());
88 0 : const Type* pBegin = aTypes.getConstArray();
89 0 : const Type* pEnd = pBegin + aTypes.getLength();
90 0 : for(;pBegin != pEnd;++pBegin)
91 : {
92 0 : if(!(*pBegin == cppu::UnoType<XGroupsSupplier>::get()||
93 0 : *pBegin == cppu::UnoType<XUsersSupplier>::get()||
94 0 : *pBegin == cppu::UnoType<XViewsSupplier>::get()))
95 : {
96 0 : aOwnTypes.push_back(*pBegin);
97 : }
98 : }
99 0 : const Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
100 0 : return Sequence< Type >(pTypes, aOwnTypes.size());
101 : }
102 :
103 :
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|