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 #ifndef DBA_HELPERCOLLECTIONS_HXX
28 #define DBA_HELPERCOLLECTIONS_HXX
29 
30 #ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_
31 #include "connectivity/sdbcx/VCollection.hxx"
32 #endif
33 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
34 #include <connectivity/dbtools.hxx>
35 #endif
36 #ifndef _DBHELPER_DBCONVERSION_HXX_
37 #include <connectivity/dbconversion.hxx>
38 #endif
39 #ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
40 #include <connectivity/PColumn.hxx>
41 #endif
42 #ifndef _VOS_REF_HXX_
43 #include <vos/ref.hxx>
44 #endif
45 
46 namespace dbaccess
47 {
48 	using namespace dbtools;
49 	using namespace comphelper;
50 	using namespace connectivity;
51 	using namespace ::com::sun::star::uno;
52 	using namespace ::com::sun::star::beans;
53 	using namespace ::com::sun::star::sdbc;
54 	using namespace ::com::sun::star::sdb;
55 	using namespace ::com::sun::star::sdbcx;
56 	using namespace ::com::sun::star::container;
57 	using namespace ::com::sun::star::lang;
58 	using namespace ::com::sun::star::script;
59 	using namespace ::cppu;
60 	using namespace ::osl;
61 	// -----------------------------------------------------------------------------
62 	typedef connectivity::sdbcx::OCollection OPrivateColumns_Base;
63 	class OPrivateColumns : public OPrivateColumns_Base
64 	{
65 		::vos::ORef< ::connectivity::OSQLColumns>	m_aColumns;
66 	protected:
67 		virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
68 		virtual void impl_refresh() throw(RuntimeException) {}
69 		virtual Reference< XPropertySet > createDescriptor()
70 		{
71 			return NULL;
72 		}
73 	public:
74 		OPrivateColumns(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
75 						sal_Bool _bCase,
76 						::cppu::OWeakObject& _rParent,
77 						::osl::Mutex& _rMutex,
78 						const ::std::vector< ::rtl::OUString> &_rVector,
79 						sal_Bool _bUseAsIndex = sal_False
80 					);
81 
82         /** creates a columns instance as above, but taking the names from the columns itself
83         */
84 		static OPrivateColumns* createWithIntrinsicNames(
85             const ::vos::ORef< ::connectivity::OSQLColumns >& _rColumns,
86 			sal_Bool _bCase,
87 			::cppu::OWeakObject& _rParent,
88 			::osl::Mutex& _rMutex
89 		);
90 
91 		virtual void SAL_CALL disposing(void);
92 	};
93 	typedef connectivity::sdbcx::OCollection OPrivateTables_BASE;
94 
95 	//==========================================================================
96 	//= OPrivateTables
97 	//==========================================================================
98 	class OPrivateTables : public OPrivateTables_BASE
99 	{
100 		OSQLTables	m_aTables;
101 	protected:
102 		virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
103 		virtual void impl_refresh() throw(RuntimeException) {}
104 		virtual Reference< XPropertySet > createDescriptor()
105 		{
106 			return NULL;
107 		}
108 	public:
109 		OPrivateTables(	const OSQLTables& _rTables,
110 						sal_Bool _bCase,
111 						::cppu::OWeakObject& _rParent,
112 						::osl::Mutex& _rMutex,
113 						const ::std::vector< ::rtl::OUString> &_rVector
114 					) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
115 						,m_aTables(_rTables)
116 		{
117 		}
118 		virtual void SAL_CALL disposing(void)
119 		{
120 			clear_NoDispose();
121 				// we're not owner of the objects we're holding, instead the object we got in our ctor is
122 				// So we're not allowed to dispose our elements.
123 			m_aTables.clear();
124 			OPrivateTables_BASE::disposing();
125 		}
126 	};
127 }
128 #endif // DBA_HELPERCOLLECTIONS_HXX
129