1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
20 #define _DBACORE_DEFINITIONCOLUMN_HXX_
22 #include "apitools.hxx"
24 #include "columnsettings.hxx"
26 #include <com/sun/star/sdbc/DataType.hpp>
27 #include <com/sun/star/sdbc/ColumnValue.hpp>
28 #include <com/sun/star/container/XChild.hpp>
30 #include <comphelper/IdPropArrayHelper.hxx>
31 #include <comphelper/uno3.hxx>
32 #include <cppuhelper/implbase1.hxx>
38 typedef ::cppu::ImplHelper1
< ::com::sun::star::container::XChild
> TXChild
;
39 // =========================================================================
40 //= OTableColumnDescriptor
41 // =========================================================================
43 * provides the properties for description. A descriptor could be used to create a new table column.
45 class OTableColumnDescriptor
: public OColumn
46 ,public OColumnSettings
47 ,public ::comphelper::OPropertyArrayUsageHelper
< OTableColumnDescriptor
>
50 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> m_xParent
;
51 const bool m_bActAsDescriptor
;
55 rtl::OUString m_aTypeName
;
56 rtl::OUString m_aDescription
;
57 rtl::OUString m_aDefaultValue
;
58 rtl::OUString m_aAutoIncrementValue
;
60 sal_Int32 m_nPrecision
;
62 sal_Int32 m_nIsNullable
;
63 sal_Bool m_bAutoIncrement
;
64 sal_Bool m_bRowVersion
;
69 OTableColumnDescriptor( const bool _bActAsDescriptor
)
70 :OColumn( !_bActAsDescriptor
)
71 ,m_bActAsDescriptor( _bActAsDescriptor
)
72 ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL
)
75 ,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN
)
76 ,m_bAutoIncrement( sal_False
)
77 ,m_bRowVersion( sal_False
)
78 ,m_bCurrency( sal_False
)
80 impl_registerProperties();
85 // com::sun::star::lang::XTypeProvider
86 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
);
88 // ::com::sun::star::lang::XServiceInfo
89 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
90 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
92 // ::com::sun::star::container::XChild
93 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getParent( ) throw (::com::sun::star::uno::RuntimeException
);
94 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
);
96 // ::comphelper::OPropertyArrayUsageHelper
97 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const;
99 // ::cppu::OPropertySetHelper
100 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
101 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
);
104 void impl_registerProperties();
107 // =========================================================================
109 // =========================================================================
111 typedef ::comphelper::OPropertyArrayUsageHelper
< OTableColumn
> OTableColumn_PBase
;
112 /** describes a column of a table
114 class OTableColumn
:public OTableColumnDescriptor
115 ,public OTableColumn_PBase
118 virtual ~OTableColumn();
121 OTableColumn(const ::rtl::OUString
& _rName
);
124 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
);
127 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
129 // OPropertyArrayUsageHelper
130 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
131 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const;
134 // =========================================================================
136 // =========================================================================
138 typedef ::comphelper::OPropertyArrayUsageHelper
< OQueryColumn
> OQueryColumn_PBase
;
139 /** a column of a Query, with additional information obtained from parsing the query statement
141 class OQueryColumn
:public OTableColumnDescriptor
142 ,public OQueryColumn_PBase
145 ::rtl::OUString m_sCatalogName
;
146 ::rtl::OUString m_sSchemaName
;
147 ::rtl::OUString m_sTableName
;
148 ::rtl::OUString m_sRealName
;
149 ::rtl::OUString m_sLabel
;
152 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xOriginalTableColumn
;
159 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxParserColumn
,
160 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
161 const ::rtl::OUString
&i_sLabel
165 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
);
168 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
171 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
172 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const;
173 virtual void SAL_CALL
getFastPropertyValue( ::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
176 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
177 impl_determineOriginalTableColumn(
178 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
181 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
184 // =========================================================================
186 // =========================================================================
188 * describes all properties for a columns of a table. Only the view parts are provided
189 * directly, all the other parts are derived from a driver implementation
191 class OColumnWrapper
:public OColumn
194 // definition which is provided by a driver!
195 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
198 sal_Int32 m_nColTypeID
;
201 OColumnWrapper( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rCol
, const bool _bNameIsReadOnly
);
202 virtual ~OColumnWrapper();
205 virtual void SAL_CALL
getFastPropertyValue(
206 ::com::sun::star::uno::Any
& rValue
,
209 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
210 ::com::sun::star::uno::Any
& rConvertedValue
,
211 ::com::sun::star::uno::Any
& rOldValue
,
213 const ::com::sun::star::uno::Any
& rValue
)
214 throw (::com::sun::star::lang::IllegalArgumentException
);
215 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
217 const ::com::sun::star::uno::Any
& rValue
219 throw (::com::sun::star::uno::Exception
);
221 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
224 ::rtl::OUString
impl_getPropertyNameFromHandle( const sal_Int32 _nHandle
) const;
227 using OColumn::getFastPropertyValue
;
230 // =========================================================================
231 // = OTableColumnDescriptorWrapper
232 // =========================================================================
234 * provides the properties for description. A descriptor could be used to create a new table column.
236 class OTableColumnDescriptorWrapper
:public OColumnWrapper
237 ,public OColumnSettings
238 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OTableColumnDescriptorWrapper
>
240 const bool m_bPureWrap
;
241 const bool m_bIsDescriptor
;
244 OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rCol
,
245 const bool _bPureWrap
, const bool _bIsDescriptor
);
247 // com::sun::star::lang::XTypeProvider
248 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
);
250 // ::com::sun::star::lang::XServiceInfo
251 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
252 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
254 // OIdPropertyArrayUsageHelper
255 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const;
257 // cppu::OPropertySetHelper
258 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
259 virtual void SAL_CALL
getFastPropertyValue(
260 ::com::sun::star::uno::Any
& rValue
,
263 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
264 ::com::sun::star::uno::Any
& rConvertedValue
,
265 ::com::sun::star::uno::Any
& rOldValue
,
267 const ::com::sun::star::uno::Any
& rValue
)
268 throw (::com::sun::star::lang::IllegalArgumentException
);
269 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
271 const ::com::sun::star::uno::Any
& rValue
273 throw (::com::sun::star::uno::Exception
);
276 using OColumnWrapper::getFastPropertyValue
;
279 // =========================================================================
280 // = OTableColumnWrapper
281 // =========================================================================
283 * describes all properties for a columns of a table. Only the view parts are provided
284 * directly, all the other parts are derived from a driver implementation
286 class OTableColumnWrapper
:public OTableColumnDescriptorWrapper
287 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OTableColumnWrapper
>
290 ~OTableColumnWrapper();
293 OTableColumnWrapper( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rCol
,
294 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rColDefintion
,
295 const bool _bPureWrap
);
297 // ::com::sun::star::lang::XTypeProvider
298 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
);
300 // ::com::sun::star::lang::XServiceInfo
301 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
302 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
304 // OIdPropertyArrayUsageHelper
305 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
306 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const;
309 #endif // _DBACORE_DEFINITIONCOLUMN_HXX_
311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */