1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
25cdf0e10cSrcweir #define _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE3_HXX_
28cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
31cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _OSL_MUTEX_HXX_
34cdf0e10cSrcweir #include <osl/mutex.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
38cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
41cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
44cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_
48cdf0e10cSrcweir #include "apitools.hxx"
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _DBA_COREAPI_COLUMN_HXX_
51cdf0e10cSrcweir #include "column.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _DBA_CORE_DATASETTINGS_HXX_
54cdf0e10cSrcweir #include "datasettings.hxx"
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _DBA_CORE_COMMANDBASE_HXX_
57cdf0e10cSrcweir #include "commandbase.hxx"
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
60cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #ifndef _COMPHELPER_UNO3_HXX_
63cdf0e10cSrcweir #include <comphelper/uno3.hxx>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //........................................................................
67cdf0e10cSrcweir namespace dbaccess
68cdf0e10cSrcweir {
69cdf0e10cSrcweir //........................................................................
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //==========================================================================
72cdf0e10cSrcweir //= OQueryDescriptor_Base - a query descriptor (as the name suggests :)
73cdf0e10cSrcweir //==========================================================================
74cdf0e10cSrcweir typedef ::cppu::ImplHelper3<
75cdf0e10cSrcweir 		::com::sun::star::sdbcx::XColumnsSupplier,
76cdf0e10cSrcweir 		::com::sun::star::lang::XUnoTunnel,
77cdf0e10cSrcweir 		::com::sun::star::lang::XServiceInfo >	OQueryDescriptor_BASE;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir class OQueryDescriptor_Base
80cdf0e10cSrcweir 		:public OQueryDescriptor_BASE
81cdf0e10cSrcweir 		,public OCommandBase
82cdf0e10cSrcweir 		,public IColumnFactory
83cdf0e10cSrcweir 		,public ::connectivity::sdbcx::IRefreshableColumns
84cdf0e10cSrcweir {
85cdf0e10cSrcweir private:
86cdf0e10cSrcweir 	sal_Bool		m_bColumnsOutOfDate : 1;	// the columns have to be rebuild on the next getColumns ?
87cdf0e10cSrcweir 	::osl::Mutex&	m_rMutex;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir protected:
90cdf0e10cSrcweir 	OColumns*		m_pColumns;					// our column descriptions
91cdf0e10cSrcweir 	::rtl::OUString m_sElementName;
92cdf0e10cSrcweir 	virtual ~OQueryDescriptor_Base();
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	void		setColumnsOutOfDate( sal_Bool _bOutOfDate = sal_True );
isColumnsOutOfDate() const95cdf0e10cSrcweir 	sal_Bool	isColumnsOutOfDate() const { return m_bColumnsOutOfDate; }
96cdf0e10cSrcweir 
getColumnCount() const97cdf0e10cSrcweir 	sal_Int32	getColumnCount() const { return m_pColumns ? m_pColumns->getCount() : 0; }
98cdf0e10cSrcweir 	void		clearColumns( );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	void		implAppendColumn( const ::rtl::OUString& _rName, OColumn* _pColumn );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir public:
103cdf0e10cSrcweir 	OQueryDescriptor_Base(::osl::Mutex&	_rMutex,::cppu::OWeakObject& _rMySelf);
104cdf0e10cSrcweir 	/** constructs the object with a UNO QueryDescriptor. If you use this ctor, the resulting object
105cdf0e10cSrcweir 		won't have any column informations (the column container will be empty)
106cdf0e10cSrcweir 	*/
107cdf0e10cSrcweir 	OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir // ::com::sun::star::sdbcx::XColumnsSupplier
110cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns(  ) throw(::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // ::com::sun::star::lang::XUnoTunnel
113cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir 	DECLARE_IMPLEMENTATION_ID( );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
117cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir protected:
122cdf0e10cSrcweir 
123cdf0e10cSrcweir // IColumnFactory
124cdf0e10cSrcweir 	virtual OColumn*	createColumn(const ::rtl::OUString& _rName) const;
125cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
126cdf0e10cSrcweir     virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
127cdf0e10cSrcweir 	virtual void columnDropped(const ::rtl::OUString& _sName);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	/** rebuild our columns set
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         clearColumns has already been called before, do <em>NOT</em> call it, again
132cdf0e10cSrcweir     */
133cdf0e10cSrcweir 	virtual void rebuildColumns( );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	virtual void disposeColumns();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     // IRefreshableColumns overridables
138cdf0e10cSrcweir 	virtual void refreshColumns();
139cdf0e10cSrcweir };
140cdf0e10cSrcweir 
141cdf0e10cSrcweir class OQueryDescriptor : public comphelper::OMutexAndBroadcastHelper
142cdf0e10cSrcweir 						,public ::cppu::OWeakObject
143cdf0e10cSrcweir 						,public OQueryDescriptor_Base
144cdf0e10cSrcweir 						,public ::comphelper::OPropertyArrayUsageHelper< OQueryDescriptor_Base >
145cdf0e10cSrcweir 						,public ODataSettings
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     OQueryDescriptor(const OQueryDescriptor&);
148cdf0e10cSrcweir     void operator =(const OQueryDescriptor&);
149cdf0e10cSrcweir 	// helper
150cdf0e10cSrcweir 	void registerProperties();
151cdf0e10cSrcweir protected:
152cdf0e10cSrcweir 	// OPropertyArrayUsageHelper
153cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	// OPropertySetHelper
156cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     virtual ~OQueryDescriptor();
159cdf0e10cSrcweir public:
160cdf0e10cSrcweir 	OQueryDescriptor();
161cdf0e10cSrcweir 	OQueryDescriptor(const OQueryDescriptor_Base& _rSource);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	// com::sun::star::lang::XTypeProvider
164cdf0e10cSrcweir 	DECLARE_TYPEPROVIDER( );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
167cdf0e10cSrcweir 	DECLARE_XINTERFACE( )
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	// ::com::sun::star::beans::XPropertySet
170cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir 
172cdf0e10cSrcweir };
173cdf0e10cSrcweir //........................................................................
174cdf0e10cSrcweir }	// namespace dbaccess
175cdf0e10cSrcweir //........................................................................
176cdf0e10cSrcweir 
177cdf0e10cSrcweir #endif // _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
180