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