1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FCatalog.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "file/FCatalog.hxx"
34 #include "file/FConnection.hxx"
35 #include "file/FTables.hxx"
36 #include <com/sun/star/sdbc/XRow.hpp>
37 #include <com/sun/star/sdbc/XResultSet.hpp>
38 #include <rtl/logfile.hxx>
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::beans
;
42 using namespace ::com::sun::star::sdbcx
;
43 using namespace ::com::sun::star::sdbc
;
44 using namespace ::com::sun::star::container
;
46 // -------------------------------------------------------------------------
47 using namespace connectivity::file
;
48 // -------------------------------------------------------------------------
49 OFileCatalog::OFileCatalog(OConnection
* _pCon
) : connectivity::sdbcx::OCatalog(_pCon
)
52 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::OFileCatalog" );
54 // -------------------------------------------------------------------------
55 void SAL_CALL
OFileCatalog::disposing()
57 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::disposing" );
58 ::osl::MutexGuard
aGuard(m_aMutex
);
60 typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE
;
62 OFileCatalog_BASE::disposing();
64 // -----------------------------------------------------------------------------
65 ::rtl::OUString
OFileCatalog::buildName(const Reference
< XRow
>& _xRow
)
67 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::buildName" );
68 return _xRow
->getString(3);
70 // -------------------------------------------------------------------------
71 void OFileCatalog::refreshTables()
73 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::refreshTables" );
74 TStringVector aVector
;
75 Sequence
< ::rtl::OUString
> aTypes
;
76 Reference
< XResultSet
> xResult
= m_xMetaData
->getTables(Any(),
77 ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes
);
78 fillNames(xResult
,aVector
);
81 m_pTables
->reFill(aVector
);
83 m_pTables
= new OTables(m_xMetaData
,*this,m_aMutex
,aVector
);
86 // -------------------------------------------------------------------------
87 Any SAL_CALL
OFileCatalog::queryInterface( const Type
& rType
) throw(RuntimeException
)
89 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::queryInterface" );
90 if( rType
== ::getCppuType((const Reference
<XGroupsSupplier
>*)0) ||
91 rType
== ::getCppuType((const Reference
<XUsersSupplier
>*)0) ||
92 rType
== ::getCppuType((const Reference
<XViewsSupplier
>*)0))
96 typedef sdbcx::OCatalog OFileCatalog_BASE
;
97 return OFileCatalog_BASE::queryInterface(rType
);
99 // -----------------------------------------------------------------------------
100 Sequence
< Type
> SAL_CALL
OFileCatalog::getTypes( ) throw(RuntimeException
)
102 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::getTypes" );
103 typedef sdbcx::OCatalog OFileCatalog_BASE
;
105 Sequence
< Type
> aTypes
= OFileCatalog_BASE::getTypes();
106 ::std::vector
<Type
> aOwnTypes
;
107 aOwnTypes
.reserve(aTypes
.getLength());
108 const Type
* pBegin
= aTypes
.getConstArray();
109 const Type
* pEnd
= pBegin
+ aTypes
.getLength();
110 for(;pBegin
!= pEnd
;++pBegin
)
112 if(!(*pBegin
== ::getCppuType((const Reference
<XGroupsSupplier
>*)0) ||
113 *pBegin
== ::getCppuType((const Reference
<XUsersSupplier
>*)0) ||
114 *pBegin
== ::getCppuType((const Reference
<XViewsSupplier
>*)0)))
116 aOwnTypes
.push_back(*pBegin
);
119 const Type
*pTypes
= aOwnTypes
.empty() ? 0 : &aOwnTypes
[0];
120 return Sequence
< Type
>(pTypes
, aOwnTypes
.size());
122 // -----------------------------------------------------------------------------