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 .
22 #include "columnsettings.hxx"
24 #include <com/sun/star/sdbc/DataType.hpp>
25 #include <com/sun/star/sdbc/ColumnValue.hpp>
26 #include <com/sun/star/sdbc/XConnection.hpp>
27 #include <com/sun/star/container/XChild.hpp>
29 #include <comphelper/IdPropArrayHelper.hxx>
30 #include <comphelper/proparrhlp.hxx>
31 #include <comphelper/uno3.hxx>
32 #include <cppuhelper/implbase1.hxx>
37 typedef ::cppu::ImplHelper1
< css::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 css::uno::Reference
< css::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( css::sdbc::DataType::SQLNULL
)
72 ,m_nIsNullable( css::sdbc::ColumnValue::NULLABLE_UNKNOWN
)
73 ,m_bAutoIncrement( false )
74 ,m_bRowVersion( false )
77 impl_registerProperties();
82 // css::lang::XTypeProvider
83 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
85 // css::lang::XServiceInfo
86 virtual OUString SAL_CALL
getImplementationName( ) override
;
87 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
89 // css::container::XChild
90 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) override
;
91 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) override
;
93 // ::comphelper::OPropertyArrayUsageHelper
94 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const override
;
96 // ::cppu::OPropertySetHelper
97 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
98 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
) 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() override
;
116 OTableColumn(const OUString
& _rName
);
119 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
122 virtual OUString SAL_CALL
getImplementationName( ) override
;
124 // OPropertyArrayUsageHelper
125 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
126 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const 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 css::uno::Reference
< css::beans::XPropertySet
> m_xOriginalTableColumn
;
148 virtual ~OQueryColumn() override
;
152 const css::uno::Reference
< css::beans::XPropertySet
>& _rxParserColumn
,
153 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
,
158 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
161 virtual OUString SAL_CALL
getImplementationName( ) override
;
164 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
165 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const override
;
166 virtual void SAL_CALL
getFastPropertyValue( css::uno::Any
& rValue
, sal_Int32 nHandle
) const override
;
169 css::uno::Reference
< css::beans::XPropertySet
>
170 impl_determineOriginalTableColumn(
171 const css::uno::Reference
< css::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 css::uno::Reference
< css::beans::XPropertySet
>
189 sal_Int32 m_nColTypeID
;
192 OColumnWrapper( const css::uno::Reference
< css::beans::XPropertySet
>& _rCol
, const bool _bNameIsReadOnly
);
193 virtual ~OColumnWrapper() override
;
196 virtual void SAL_CALL
getFastPropertyValue(
197 css::uno::Any
& rValue
,
200 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
201 css::uno::Any
& rConvertedValue
,
202 css::uno::Any
& rOldValue
,
204 const css::uno::Any
& rValue
) override
;
205 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
207 const css::uno::Any
& rValue
211 OUString
impl_getPropertyNameFromHandle( const sal_Int32 _nHandle
) const;
214 using OColumn::getFastPropertyValue
;
217 // OTableColumnDescriptorWrapper
219 * provides the properties for description. A descriptor could be used to create a new table column.
221 class OTableColumnDescriptorWrapper
:public OColumnWrapper
222 ,public OColumnSettings
223 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OTableColumnDescriptorWrapper
>
225 const bool m_bPureWrap
;
226 const bool m_bIsDescriptor
;
229 OTableColumnDescriptorWrapper(const css::uno::Reference
< css::beans::XPropertySet
>& rCol
,
230 const bool _bPureWrap
, const bool _bIsDescriptor
);
232 // css::lang::XTypeProvider
233 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
235 // css::lang::XServiceInfo
236 virtual OUString SAL_CALL
getImplementationName( ) override
;
237 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
239 // OIdPropertyArrayUsageHelper
240 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const override
;
242 // cppu::OPropertySetHelper
243 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
244 virtual void SAL_CALL
getFastPropertyValue(
245 css::uno::Any
& rValue
,
248 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
249 css::uno::Any
& rConvertedValue
,
250 css::uno::Any
& rOldValue
,
252 const css::uno::Any
& rValue
) override
;
253 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
255 const css::uno::Any
& rValue
259 using OColumnWrapper::getFastPropertyValue
;
262 // OTableColumnWrapper
264 * describes all properties for a columns of a table. Only the view parts are provided
265 * directly, all the other parts are derived from a driver implementation
267 class OTableColumnWrapper
:public OTableColumnDescriptorWrapper
268 ,public ::comphelper::OIdPropertyArrayUsageHelper
< OTableColumnWrapper
>
271 virtual ~OTableColumnWrapper() override
;
274 OTableColumnWrapper( const css::uno::Reference
< css::beans::XPropertySet
>& rCol
,
275 const css::uno::Reference
< css::beans::XPropertySet
>& rColDefinition
,
276 const bool _bPureWrap
);
278 // css::lang::XTypeProvider
279 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
281 // css::lang::XServiceInfo
282 virtual OUString SAL_CALL
getImplementationName( ) override
;
283 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
285 // OIdPropertyArrayUsageHelper
286 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
287 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 nId
) const override
;
291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */