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