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 INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCOLUMN_HXX
20 #define INCLUDED_DBACCESS_SOURCE_CORE_INC_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>
37 typedef ::cppu::ImplHelper1
< ::com::sun::star::container::XChild
> TXChild
;
38 // OTableColumnDescriptor
40 * provides the properties for description. A descriptor could be used to create a new table column.
42 class OTableColumnDescriptor
: public OColumn
43 ,public OColumnSettings
44 ,public ::comphelper::OPropertyArrayUsageHelper
< OTableColumnDescriptor
>
47 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> m_xParent
;
48 const bool m_bActAsDescriptor
;
53 OUString m_aDescription
;
54 OUString m_aDefaultValue
;
55 OUString m_aAutoIncrementValue
;
57 sal_Int32 m_nPrecision
;
59 sal_Int32 m_nIsNullable
;
60 bool m_bAutoIncrement
;
66 OTableColumnDescriptor( const bool _bActAsDescriptor
)
67 :OColumn( !_bActAsDescriptor
)
68 ,m_bActAsDescriptor( _bActAsDescriptor
)
69 ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL
)
72 ,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN
)
73 ,m_bAutoIncrement( false )
74 ,m_bRowVersion( false )
77 impl_registerProperties();
82 // com::sun::star::lang::XTypeProvider
83 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
85 // ::com::sun::star::lang::XServiceInfo
86 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
89 // ::com::sun::star::container::XChild
90 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getParent( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 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
, std::exception
) SAL_OVERRIDE
;
93 // ::comphelper::OPropertyArrayUsageHelper
94 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const SAL_OVERRIDE
;
96 // ::cppu::OPropertySetHelper
97 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
98 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
101 void impl_registerProperties();
106 typedef ::comphelper::OPropertyArrayUsageHelper
< OTableColumn
> OTableColumn_PBase
;
107 /** describes a column of a table
109 class OTableColumn
:public OTableColumnDescriptor
110 ,public OTableColumn_PBase
113 virtual ~OTableColumn();
116 OTableColumn(const OUString
& _rName
);
119 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
122 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
124 // OPropertyArrayUsageHelper
125 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
126 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const SAL_OVERRIDE
;
131 typedef ::comphelper::OPropertyArrayUsageHelper
< OQueryColumn
> OQueryColumn_PBase
;
132 /** a column of a Query, with additional information obtained from parsing the query statement
134 class OQueryColumn
:public OTableColumnDescriptor
135 ,public OQueryColumn_PBase
138 OUString m_sCatalogName
;
139 OUString m_sSchemaName
;
140 OUString m_sTableName
;
141 OUString m_sRealName
;
145 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xOriginalTableColumn
;
148 virtual ~OQueryColumn();
152 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxParserColumn
,
153 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
154 const OUString
&i_sLabel
158 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
164 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
165 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const SAL_OVERRIDE
;
166 virtual void SAL_CALL
getFastPropertyValue( ::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const SAL_OVERRIDE
;
169 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
170 impl_determineOriginalTableColumn(
171 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
174 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
179 * describes all properties for a columns of a table. Only the view parts are provided
180 * directly, all the other parts are derived from a driver implementation
182 class OColumnWrapper
:public OColumn
185 // definition which is provided by a driver!
186 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
189 sal_Int32 m_nColTypeID
;
192 OColumnWrapper( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rCol
, const bool _bNameIsReadOnly
);
193 virtual ~OColumnWrapper();
196 virtual void SAL_CALL
getFastPropertyValue(
197 ::com::sun::star::uno::Any
& rValue
,
199 ) const SAL_OVERRIDE
;
200 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
201 ::com::sun::star::uno::Any
& rConvertedValue
,
202 ::com::sun::star::uno::Any
& rOldValue
,
204 const ::com::sun::star::uno::Any
& rValue
)
205 throw (::com::sun::star::lang::IllegalArgumentException
) SAL_OVERRIDE
;
206 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
208 const ::com::sun::star::uno::Any
& rValue
210 throw (::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
212 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
215 OUString
impl_getPropertyNameFromHandle( const sal_Int32 _nHandle
) const;
218 using OColumn::getFastPropertyValue
;
221 // OTableColumnDescriptorWrapper
223 * provides the properties for description. A descriptor could be used to create a new table column.
225 class OTableColumnDescriptorWrapper
:public OColumnWrapper
226 ,public OColumnSettings
227 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OTableColumnDescriptorWrapper
>
229 const bool m_bPureWrap
;
230 const bool m_bIsDescriptor
;
233 OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rCol
,
234 const bool _bPureWrap
, const bool _bIsDescriptor
);
236 // com::sun::star::lang::XTypeProvider
237 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
239 // ::com::sun::star::lang::XServiceInfo
240 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
241 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
243 // OIdPropertyArrayUsageHelper
244 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const SAL_OVERRIDE
;
246 // cppu::OPropertySetHelper
247 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
248 virtual void SAL_CALL
getFastPropertyValue(
249 ::com::sun::star::uno::Any
& rValue
,
251 ) const SAL_OVERRIDE
;
252 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
253 ::com::sun::star::uno::Any
& rConvertedValue
,
254 ::com::sun::star::uno::Any
& rOldValue
,
256 const ::com::sun::star::uno::Any
& rValue
)
257 throw (::com::sun::star::lang::IllegalArgumentException
) SAL_OVERRIDE
;
258 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
260 const ::com::sun::star::uno::Any
& rValue
262 throw (::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
265 using OColumnWrapper::getFastPropertyValue
;
268 // OTableColumnWrapper
270 * describes all properties for a columns of a table. Only the view parts are provided
271 * directly, all the other parts are derived from a driver implementation
273 class OTableColumnWrapper
:public OTableColumnDescriptorWrapper
274 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OTableColumnWrapper
>
277 virtual ~OTableColumnWrapper();
280 OTableColumnWrapper( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rCol
,
281 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& rColDefintion
,
282 const bool _bPureWrap
);
284 // ::com::sun::star::lang::XTypeProvider
285 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
287 // ::com::sun::star::lang::XServiceInfo
288 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
289 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
291 // OIdPropertyArrayUsageHelper
292 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
293 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const SAL_OVERRIDE
;
296 #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCOLUMN_HXX
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */