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