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 #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
24cdf0e10cSrcweir #define _DBACORE_DEFINITIONCOLUMN_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "apitools.hxx"
27cdf0e10cSrcweir #include "column.hxx"
28cdf0e10cSrcweir #include "columnsettings.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp>
32cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <comphelper/IdPropArrayHelper.hxx>
35cdf0e10cSrcweir #include <comphelper/uno3.hxx>
36cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace dbaccess
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
43cdf0e10cSrcweir     // =========================================================================
44cdf0e10cSrcweir     //= OTableColumnDescriptor
45cdf0e10cSrcweir     // =========================================================================
46cdf0e10cSrcweir 	/**
47cdf0e10cSrcweir 	 *	provides the properties for description. A descriptor could be used to create a new table column.
48cdf0e10cSrcweir 	 */
49cdf0e10cSrcweir 	class OTableColumnDescriptor : public OColumn
50cdf0e10cSrcweir 								  ,public OColumnSettings
51cdf0e10cSrcweir 								  ,public ::comphelper::OPropertyArrayUsageHelper < OTableColumnDescriptor >
52cdf0e10cSrcweir 								  ,public TXChild
53cdf0e10cSrcweir 	{
54cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >   m_xParent;
55cdf0e10cSrcweir         const bool                                                              m_bActAsDescriptor;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	protected:
58cdf0e10cSrcweir 	//	<properties>
59cdf0e10cSrcweir 		rtl::OUString			m_aTypeName;
60cdf0e10cSrcweir 		rtl::OUString			m_aDescription;
61cdf0e10cSrcweir 		rtl::OUString			m_aDefaultValue;
62cdf0e10cSrcweir 		rtl::OUString			m_aAutoIncrementValue;
63cdf0e10cSrcweir 		sal_Int32				m_nType;
64cdf0e10cSrcweir 		sal_Int32				m_nPrecision;
65cdf0e10cSrcweir 		sal_Int32				m_nScale;
66cdf0e10cSrcweir 		sal_Int32				m_nIsNullable;
67cdf0e10cSrcweir 		sal_Bool				m_bAutoIncrement;
68cdf0e10cSrcweir 		sal_Bool				m_bRowVersion;
69cdf0e10cSrcweir 		sal_Bool				m_bCurrency;
70cdf0e10cSrcweir 	//	</properties>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	public:
OTableColumnDescriptor(const bool _bActAsDescriptor)73cdf0e10cSrcweir 		OTableColumnDescriptor( const bool _bActAsDescriptor )
74cdf0e10cSrcweir             :OColumn( !_bActAsDescriptor )
75cdf0e10cSrcweir             ,m_bActAsDescriptor( _bActAsDescriptor )
76cdf0e10cSrcweir             ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL )
77cdf0e10cSrcweir 			,m_nPrecision( 0 )
78cdf0e10cSrcweir 			,m_nScale( 0 )
79cdf0e10cSrcweir 			,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN )
80cdf0e10cSrcweir 			,m_bAutoIncrement( sal_False )
81cdf0e10cSrcweir 			,m_bRowVersion( sal_False )
82cdf0e10cSrcweir 			,m_bCurrency( sal_False )
83cdf0e10cSrcweir         {
84cdf0e10cSrcweir             impl_registerProperties();
85cdf0e10cSrcweir         }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		DECLARE_XINTERFACE( )
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	    // com::sun::star::lang::XTypeProvider
90cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	    // ::com::sun::star::lang::XServiceInfo
93cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 		// ::com::sun::star::container::XChild
97cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir 		virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	    // ::comphelper::OPropertyArrayUsageHelper
101cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	    // ::cppu::OPropertySetHelper
104cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
105cdf0e10cSrcweir 		virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     private:
108cdf0e10cSrcweir         void    impl_registerProperties();
109cdf0e10cSrcweir 	};
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     // =========================================================================
112cdf0e10cSrcweir     // = OTableColumn
113cdf0e10cSrcweir     // =========================================================================
114cdf0e10cSrcweir     class OTableColumn;
115cdf0e10cSrcweir     typedef ::comphelper::OPropertyArrayUsageHelper < OTableColumn >    OTableColumn_PBase;
116cdf0e10cSrcweir 	/** describes a column of a table
117cdf0e10cSrcweir 	 */
118cdf0e10cSrcweir 	class OTableColumn  :public OTableColumnDescriptor
119cdf0e10cSrcweir 						,public OTableColumn_PBase
120cdf0e10cSrcweir 	{
121cdf0e10cSrcweir 	protected:
122cdf0e10cSrcweir 		virtual ~OTableColumn();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     public:
125cdf0e10cSrcweir 		OTableColumn(const ::rtl::OUString& _rName);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	    // XTypeProvider
128cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	    // XServiceInfo
131cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	    // OPropertyArrayUsageHelper
134cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
135cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
136cdf0e10cSrcweir 	};
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     // =========================================================================
139cdf0e10cSrcweir     // = OQueryColumn
140cdf0e10cSrcweir     // =========================================================================
141cdf0e10cSrcweir     class OQueryColumn;
142cdf0e10cSrcweir     typedef ::comphelper::OPropertyArrayUsageHelper< OQueryColumn > OQueryColumn_PBase;
143cdf0e10cSrcweir     /** a column of a Query, with additional information obtained from parsing the query statement
144cdf0e10cSrcweir     */
145cdf0e10cSrcweir     class OQueryColumn  :public OTableColumnDescriptor
146cdf0e10cSrcweir 						,public OQueryColumn_PBase
147cdf0e10cSrcweir     {
148cdf0e10cSrcweir         // <properties>
149cdf0e10cSrcweir         ::rtl::OUString m_sCatalogName;
150cdf0e10cSrcweir         ::rtl::OUString m_sSchemaName;
151cdf0e10cSrcweir         ::rtl::OUString m_sTableName;
152cdf0e10cSrcweir         ::rtl::OUString m_sRealName;
153cdf0e10cSrcweir         ::rtl::OUString m_sLabel;
154cdf0e10cSrcweir         // </properties>
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xOriginalTableColumn;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     protected:
159cdf0e10cSrcweir         ~OQueryColumn();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     public:
162cdf0e10cSrcweir 		OQueryColumn(
163cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn,
164cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
165cdf0e10cSrcweir             const ::rtl::OUString i_sLabel
166cdf0e10cSrcweir         );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	    // XTypeProvider
169cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	    // XServiceInfo
172cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	    // *Property*
175cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
176cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
177cdf0e10cSrcweir 		virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     private:
180cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
181cdf0e10cSrcweir                 impl_determineOriginalTableColumn(
182cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
183cdf0e10cSrcweir                 );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir         using ::cppu::OPropertySetHelper::getFastPropertyValue;
186cdf0e10cSrcweir     };
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     // =========================================================================
189cdf0e10cSrcweir     // = OColumnWrapper
190cdf0e10cSrcweir     // =========================================================================
191cdf0e10cSrcweir 	/**
192cdf0e10cSrcweir 	 *	describes all properties for a columns of a table. Only the view parts are provided
193cdf0e10cSrcweir 	 *	directly, all the other parts are derived from a driver implementation
194cdf0e10cSrcweir 	 */
195cdf0e10cSrcweir 	class OColumnWrapper    :public OColumn
196cdf0e10cSrcweir 	{
197cdf0e10cSrcweir 	protected:
198cdf0e10cSrcweir 		// definition which is provided by a driver!
199cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
200cdf0e10cSrcweir 								m_xAggregate;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 		sal_Int32				m_nColTypeID;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	protected:
205cdf0e10cSrcweir 		OColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rCol, const bool _bNameIsReadOnly );
206cdf0e10cSrcweir 		virtual ~OColumnWrapper();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	public:
209cdf0e10cSrcweir 		virtual void SAL_CALL getFastPropertyValue(
210cdf0e10cSrcweir 								::com::sun::star::uno::Any& rValue,
211cdf0e10cSrcweir 								sal_Int32 nHandle
212cdf0e10cSrcweir 								 ) const;
213cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL convertFastPropertyValue(
214cdf0e10cSrcweir 								::com::sun::star::uno::Any & rConvertedValue,
215cdf0e10cSrcweir 								::com::sun::star::uno::Any & rOldValue,
216cdf0e10cSrcweir 								sal_Int32 nHandle,
217cdf0e10cSrcweir 								const ::com::sun::star::uno::Any& rValue )
218cdf0e10cSrcweir 									throw (::com::sun::star::lang::IllegalArgumentException);
219cdf0e10cSrcweir 		virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
220cdf0e10cSrcweir 									sal_Int32 nHandle,
221cdf0e10cSrcweir 									const ::com::sun::star::uno::Any& rValue
222cdf0e10cSrcweir 													 )
223cdf0e10cSrcweir 													 throw (::com::sun::star::uno::Exception);
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 		virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     protected:
228cdf0e10cSrcweir         ::rtl::OUString impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     protected:
231cdf0e10cSrcweir         using OColumn::getFastPropertyValue;
232cdf0e10cSrcweir 	};
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     // =========================================================================
235cdf0e10cSrcweir     // = OTableColumnDescriptorWrapper
236cdf0e10cSrcweir     // =========================================================================
237cdf0e10cSrcweir 	/**
238cdf0e10cSrcweir 	 *	provides the properties for description. A descriptor could be used to create a new table column.
239cdf0e10cSrcweir 	 */
240cdf0e10cSrcweir     class OTableColumnDescriptorWrapper :public OColumnWrapper
241cdf0e10cSrcweir                                         ,public OColumnSettings
242cdf0e10cSrcweir                                         ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnDescriptorWrapper >
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir 		const bool  m_bPureWrap;
245cdf0e10cSrcweir         const bool  m_bIsDescriptor;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	public:
248cdf0e10cSrcweir 		OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol,
249cdf0e10cSrcweir             const bool _bPureWrap, const bool _bIsDescriptor );
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	// com::sun::star::lang::XTypeProvider
252cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	// ::com::sun::star::lang::XServiceInfo
255cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
256cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	// OIdPropertyArrayUsageHelper
259cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	// cppu::OPropertySetHelper
262cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
263cdf0e10cSrcweir 		virtual void SAL_CALL getFastPropertyValue(
264cdf0e10cSrcweir 									::com::sun::star::uno::Any& rValue,
265cdf0e10cSrcweir 									sal_Int32 nHandle
266cdf0e10cSrcweir 										 ) const;
267cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL convertFastPropertyValue(
268cdf0e10cSrcweir 								::com::sun::star::uno::Any & rConvertedValue,
269cdf0e10cSrcweir 								::com::sun::star::uno::Any & rOldValue,
270cdf0e10cSrcweir 								sal_Int32 nHandle,
271cdf0e10cSrcweir 								const ::com::sun::star::uno::Any& rValue )
272cdf0e10cSrcweir 									throw (::com::sun::star::lang::IllegalArgumentException);
273cdf0e10cSrcweir 		virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
274cdf0e10cSrcweir 									sal_Int32 nHandle,
275cdf0e10cSrcweir 									const ::com::sun::star::uno::Any& rValue
276cdf0e10cSrcweir 													 )
277cdf0e10cSrcweir 													 throw (::com::sun::star::uno::Exception);
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     protected:
280cdf0e10cSrcweir         using OColumnWrapper::getFastPropertyValue;
281cdf0e10cSrcweir 	};
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     // =========================================================================
284cdf0e10cSrcweir     // = OTableColumnWrapper
285cdf0e10cSrcweir     // =========================================================================
286cdf0e10cSrcweir 	/**
287cdf0e10cSrcweir 	 *	describes all properties for a columns of a table. Only the view parts are provided
288cdf0e10cSrcweir 	 *	directly, all the other parts are derived from a driver implementation
289cdf0e10cSrcweir 	 */
290cdf0e10cSrcweir 	class OTableColumnWrapper   :public OTableColumnDescriptorWrapper
291cdf0e10cSrcweir 								,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnWrapper >
292cdf0e10cSrcweir 	{
293cdf0e10cSrcweir     protected:
294cdf0e10cSrcweir         ~OTableColumnWrapper();
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     public:
297cdf0e10cSrcweir 		OTableColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol,
298cdf0e10cSrcweir 							 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rColDefintion,
299cdf0e10cSrcweir 							 const bool _bPureWrap );
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 	// ::com::sun::star::lang::XTypeProvider
302cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	// ::com::sun::star::lang::XServiceInfo
305cdf0e10cSrcweir 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
306cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	// OIdPropertyArrayUsageHelper
309cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
310cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
311cdf0e10cSrcweir 	};
312cdf0e10cSrcweir }
313cdf0e10cSrcweir #endif // _DBACORE_DEFINITIONCOLUMN_HXX_
314cdf0e10cSrcweir 
315