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 0 : OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
36 0 : ,m_pConnection(_pCon)
37 : {
38 : SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileCatalog::OFileCatalog" );
39 0 : }
40 :
41 0 : void SAL_CALL OFileCatalog::disposing()
42 : {
43 : SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileCatalog::disposing" );
44 0 : ::osl::MutexGuard aGuard(m_aMutex);
45 :
46 : typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
47 0 : m_xMetaData.clear();
48 0 : OFileCatalog_BASE::disposing();
49 0 : }
50 :
51 0 : OUString OFileCatalog::buildName(const Reference< XRow >& _xRow)
52 : {
53 : SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileCatalog::buildName" );
54 0 : return _xRow->getString(3);
55 : }
56 :
57 0 : void OFileCatalog::refreshTables()
58 : {
59 : SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileCatalog::refreshTables" );
60 0 : TStringVector aVector;
61 0 : Sequence< OUString > aTypes;
62 0 : Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
63 0 : OUString("%"),OUString("%"),aTypes);
64 0 : fillNames(xResult,aVector);
65 :
66 0 : if(m_pTables)
67 0 : m_pTables->reFill(aVector);
68 : else
69 0 : m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
70 0 : }
71 :
72 :
73 0 : Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
74 : {
75 : SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileCatalog::queryInterface" );
76 0 : if( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
77 0 : rType == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
78 0 : rType == ::getCppuType((const Reference<XViewsSupplier>*)0))
79 0 : return Any();
80 :
81 :
82 : typedef sdbcx::OCatalog OFileCatalog_BASE;
83 0 : return OFileCatalog_BASE::queryInterface(rType);
84 : }
85 :
86 0 : Sequence< Type > SAL_CALL OFileCatalog::getTypes( ) throw(RuntimeException, std::exception)
87 : {
88 : SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileCatalog::getTypes" );
89 : typedef sdbcx::OCatalog OFileCatalog_BASE;
90 :
91 0 : Sequence< Type > aTypes = OFileCatalog_BASE::getTypes();
92 0 : ::std::vector<Type> aOwnTypes;
93 0 : aOwnTypes.reserve(aTypes.getLength());
94 0 : const Type* pBegin = aTypes.getConstArray();
95 0 : const Type* pEnd = pBegin + aTypes.getLength();
96 0 : for(;pBegin != pEnd;++pBegin)
97 : {
98 0 : if(!(*pBegin == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
99 0 : *pBegin == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
100 0 : *pBegin == ::getCppuType((const Reference<XViewsSupplier>*)0)))
101 : {
102 0 : aOwnTypes.push_back(*pBegin);
103 : }
104 : }
105 0 : const Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
106 0 : return Sequence< Type >(pTypes, aOwnTypes.size());
107 : }
108 :
109 :
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|