1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "file/FCatalog.hxx"
30 #include "file/FConnection.hxx"
31 #include "file/FTables.hxx"
32 #include <com/sun/star/sdbc/XRow.hpp>
33 #include <com/sun/star/sdbc/XResultSet.hpp>
34 #include <rtl/logfile.hxx>
36 using namespace ::com::sun::star::uno
;
37 using namespace ::com::sun::star::beans
;
38 using namespace ::com::sun::star::sdbcx
;
39 using namespace ::com::sun::star::sdbc
;
40 using namespace ::com::sun::star::container
;
42 // -------------------------------------------------------------------------
43 using namespace connectivity::file
;
44 // -------------------------------------------------------------------------
45 OFileCatalog::OFileCatalog(OConnection
* _pCon
) : connectivity::sdbcx::OCatalog(_pCon
)
48 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::OFileCatalog" );
50 // -------------------------------------------------------------------------
51 void SAL_CALL
OFileCatalog::disposing()
53 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::disposing" );
54 ::osl::MutexGuard
aGuard(m_aMutex
);
56 typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE
;
58 OFileCatalog_BASE::disposing();
60 // -----------------------------------------------------------------------------
61 ::rtl::OUString
OFileCatalog::buildName(const Reference
< XRow
>& _xRow
)
63 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::buildName" );
64 return _xRow
->getString(3);
66 // -------------------------------------------------------------------------
67 void OFileCatalog::refreshTables()
69 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::refreshTables" );
70 TStringVector aVector
;
71 Sequence
< ::rtl::OUString
> aTypes
;
72 Reference
< XResultSet
> xResult
= m_xMetaData
->getTables(Any(),
73 ::rtl::OUString("%"),::rtl::OUString("%"),aTypes
);
74 fillNames(xResult
,aVector
);
77 m_pTables
->reFill(aVector
);
79 m_pTables
= new OTables(m_xMetaData
,*this,m_aMutex
,aVector
);
82 // -------------------------------------------------------------------------
83 Any SAL_CALL
OFileCatalog::queryInterface( const Type
& rType
) throw(RuntimeException
)
85 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::queryInterface" );
86 if( rType
== ::getCppuType((const Reference
<XGroupsSupplier
>*)0) ||
87 rType
== ::getCppuType((const Reference
<XUsersSupplier
>*)0) ||
88 rType
== ::getCppuType((const Reference
<XViewsSupplier
>*)0))
92 typedef sdbcx::OCatalog OFileCatalog_BASE
;
93 return OFileCatalog_BASE::queryInterface(rType
);
95 // -----------------------------------------------------------------------------
96 Sequence
< Type
> SAL_CALL
OFileCatalog::getTypes( ) throw(RuntimeException
)
98 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "file", "Ocke.Janssen@sun.com", "OFileCatalog::getTypes" );
99 typedef sdbcx::OCatalog OFileCatalog_BASE
;
101 Sequence
< Type
> aTypes
= OFileCatalog_BASE::getTypes();
102 ::std::vector
<Type
> aOwnTypes
;
103 aOwnTypes
.reserve(aTypes
.getLength());
104 const Type
* pBegin
= aTypes
.getConstArray();
105 const Type
* pEnd
= pBegin
+ aTypes
.getLength();
106 for(;pBegin
!= pEnd
;++pBegin
)
108 if(!(*pBegin
== ::getCppuType((const Reference
<XGroupsSupplier
>*)0) ||
109 *pBegin
== ::getCppuType((const Reference
<XUsersSupplier
>*)0) ||
110 *pBegin
== ::getCppuType((const Reference
<XViewsSupplier
>*)0)))
112 aOwnTypes
.push_back(*pBegin
);
115 const Type
*pTypes
= aOwnTypes
.empty() ? 0 : &aOwnTypes
[0];
116 return Sequence
< Type
>(pTypes
, aOwnTypes
.size());
118 // -----------------------------------------------------------------------------
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */