1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
31 #include "apitools.hxx"
32 #include "dbastrings.hrc"
33 #include "definitioncolumn.hxx"
34 #include "sdbcoretools.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
39 /** === end UNO includes === **/
41 #include <comphelper/property.hxx>
42 #include <comphelper/types.hxx>
43 #include <connectivity/dbtools.hxx>
44 #include <cppuhelper/typeprovider.hxx>
45 #include <tools/debug.hxx>
46 #include <tools/diagnose_ex.h>
48 using namespace ::com::sun::star::sdbc
;
49 using namespace ::com::sun::star::sdbcx
;
50 using namespace ::com::sun::star::beans
;
51 using namespace ::com::sun::star::uno
;
52 using namespace ::com::sun::star::lang
;
53 using namespace ::com::sun::star::container
;
54 using namespace ::cppu
;
55 using namespace ::comphelper
;
56 using namespace ::osl
;
57 using namespace dbaccess
;
59 #define HAS_DESCRIPTION 0x00000001
60 #define HAS_DEFAULTVALUE 0x00000002
61 #define HAS_ROWVERSION 0x00000004
62 #define HAS_AUTOINCREMENT_CREATION 0x00000008
64 //============================================================
65 //= OTableColumnDescriptor
66 //============================================================
67 IMPLEMENT_FORWARD_XINTERFACE2(OTableColumnDescriptor
,OColumn
,TXChild
)
69 //------------------------------------------------------------------------------
70 void OTableColumnDescriptor::impl_registerProperties()
72 sal_Int32 nDefaultAttr
= m_bActAsDescriptor
? 0 : PropertyAttribute::READONLY
;
74 registerProperty( PROPERTY_TYPENAME
, PROPERTY_ID_TYPENAME
, nDefaultAttr
, &m_aTypeName
, ::getCppuType( &m_aTypeName
) );
75 registerProperty( PROPERTY_DESCRIPTION
, PROPERTY_ID_DESCRIPTION
, nDefaultAttr
, &m_aDescription
, ::getCppuType( &m_aDescription
) );
76 registerProperty( PROPERTY_DEFAULTVALUE
, PROPERTY_ID_DEFAULTVALUE
, nDefaultAttr
, &m_aDefaultValue
, ::getCppuType( &m_aDefaultValue
) );
78 if ( m_bActAsDescriptor
)
79 registerProperty( PROPERTY_AUTOINCREMENTCREATION
, PROPERTY_ID_AUTOINCREMENTCREATION
, nDefaultAttr
, &m_aAutoIncrementValue
, ::getCppuType( &m_aAutoIncrementValue
) );
81 registerProperty( PROPERTY_TYPE
, PROPERTY_ID_TYPE
, nDefaultAttr
, &m_nType
, ::getCppuType( &m_nType
) );
82 registerProperty( PROPERTY_PRECISION
, PROPERTY_ID_PRECISION
, nDefaultAttr
, &m_nPrecision
, ::getCppuType( &m_nPrecision
) );
83 registerProperty( PROPERTY_SCALE
, PROPERTY_ID_SCALE
, nDefaultAttr
, &m_nScale
, ::getCppuType( &m_nScale
) );
84 registerProperty( PROPERTY_ISNULLABLE
, PROPERTY_ID_ISNULLABLE
, nDefaultAttr
, &m_nIsNullable
, ::getCppuType( &m_nIsNullable
) );
85 registerProperty( PROPERTY_ISAUTOINCREMENT
, PROPERTY_ID_ISAUTOINCREMENT
, nDefaultAttr
, &m_bAutoIncrement
, ::getCppuType( &m_bAutoIncrement
) );
86 registerProperty( PROPERTY_ISROWVERSION
, PROPERTY_ID_ISROWVERSION
, nDefaultAttr
, &m_bRowVersion
, ::getCppuType( &m_bRowVersion
) );
87 registerProperty( PROPERTY_ISCURRENCY
, PROPERTY_ID_ISCURRENCY
, nDefaultAttr
, &m_bCurrency
, ::getCppuType( &m_bCurrency
) );
89 OColumnSettings::registerProperties( *this );
92 //--------------------------------------------------------------------------
93 IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptor
)
95 // ::com::sun::star::lang::XServiceInfo
96 //------------------------------------------------------------------------------
97 rtl::OUString
OTableColumnDescriptor::getImplementationName( ) throw (RuntimeException
)
99 return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumnDescriptor");
102 //------------------------------------------------------------------------------
103 Sequence
< ::rtl::OUString
> OTableColumnDescriptor::getSupportedServiceNames( ) throw (RuntimeException
)
105 Sequence
< ::rtl::OUString
> aSNS( 2 );
106 aSNS
[0] = m_bActAsDescriptor
? SERVICE_SDBCX_COLUMNDESCRIPTOR
: SERVICE_SDBCX_COLUMN
;
107 aSNS
[1] = SERVICE_SDB_COLUMNSETTINGS
;
111 // comphelper::OPropertyArrayUsageHelper
112 //------------------------------------------------------------------------------
113 ::cppu::IPropertyArrayHelper
* OTableColumnDescriptor::createArrayHelper( ) const
115 Sequence
< Property
> aProps
;
116 describeProperties( aProps
);
117 return new ::cppu::OPropertyArrayHelper( aProps
);
120 // cppu::OPropertySetHelper
121 //------------------------------------------------------------------------------
122 ::cppu::IPropertyArrayHelper
& OTableColumnDescriptor::getInfoHelper()
124 return *static_cast< ::comphelper::OPropertyArrayUsageHelper
< OTableColumnDescriptor
>* >(this)->getArrayHelper();
127 //------------------------------------------------------------------------------
128 void OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const Any
& rValue
) throw (Exception
)
130 OColumn::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
131 ::dbaccess::notifyDataSourceModified( m_xParent
, sal_True
);
134 // -----------------------------------------------------------------------------
135 Reference
< XInterface
> SAL_CALL
OTableColumnDescriptor::getParent( ) throw (RuntimeException
)
137 ::osl::MutexGuard
aGuard(m_aMutex
);
140 // -----------------------------------------------------------------------------
141 void SAL_CALL
OTableColumnDescriptor::setParent( const Reference
< XInterface
>& _xParent
) throw (NoSupportException
, RuntimeException
)
143 ::osl::MutexGuard
aGuard(m_aMutex
);
144 m_xParent
= _xParent
;
146 //============================================================
148 //============================================================
149 DBG_NAME(OTableColumn
);
151 // -------------------------------------------------------------------------
152 OTableColumn::OTableColumn( const ::rtl::OUString
& _rName
)
153 :OTableColumnDescriptor( false /* do not act as descriptor */ )
155 DBG_CTOR(OTableColumn
,NULL
);
159 // -----------------------------------------------------------------------------
160 OTableColumn::~OTableColumn()
162 DBG_DTOR(OTableColumn
,NULL
);
165 //--------------------------------------------------------------------------
166 IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumn
)
168 //------------------------------------------------------------------------------
169 rtl::OUString
OTableColumn::getImplementationName( ) throw (RuntimeException
)
171 return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumn");
174 //------------------------------------------------------------------------------
175 ::cppu::IPropertyArrayHelper
& SAL_CALL
OTableColumn::getInfoHelper()
177 return *OTableColumn_PBase::getArrayHelper();
180 //------------------------------------------------------------------------------
181 ::cppu::IPropertyArrayHelper
* OTableColumn::createArrayHelper( ) const
183 return OTableColumnDescriptor::createArrayHelper();
186 // =========================================================================
188 // =========================================================================
189 DBG_NAME( OQueryColumn
);
191 // -------------------------------------------------------------------------
192 OQueryColumn::OQueryColumn( const Reference
< XPropertySet
>& _rxParserColumn
, const Reference
< XConnection
>& _rxConnection
,const ::rtl::OUString i_sLabel
)
193 :OTableColumnDescriptor( false /* do not act as descriptor */ )
196 const sal_Int32 nPropAttr
= PropertyAttribute::READONLY
;
197 registerProperty( PROPERTY_CATALOGNAME
, PROPERTY_ID_CATALOGNAME
, nPropAttr
, &m_sCatalogName
, ::getCppuType( &m_sCatalogName
) );
198 registerProperty( PROPERTY_SCHEMANAME
, PROPERTY_ID_SCHEMANAME
, nPropAttr
, &m_sSchemaName
, ::getCppuType( &m_sSchemaName
) );
199 registerProperty( PROPERTY_TABLENAME
, PROPERTY_ID_TABLENAME
, nPropAttr
, &m_sTableName
, ::getCppuType( &m_sTableName
) );
200 registerProperty( PROPERTY_REALNAME
, PROPERTY_ID_REALNAME
, nPropAttr
, &m_sRealName
, ::getCppuType( &m_sRealName
) );
201 registerProperty( PROPERTY_LABEL
, PROPERTY_ID_LABEL
, nPropAttr
, &m_sLabel
, ::getCppuType( &m_sLabel
) );
203 DBG_CTOR( OQueryColumn
, NULL
);
205 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_TYPENAME
) >>= m_aTypeName
);
206 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_ISNULLABLE
) >>= m_nIsNullable
);
207 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_PRECISION
) >>= m_nPrecision
);
208 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_SCALE
) >>= m_nScale
);
209 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_TYPE
) >>= m_nType
);
210 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_ISAUTOINCREMENT
) >>= m_bAutoIncrement
);
211 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_ISCURRENCY
) >>= m_bCurrency
);
212 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_NAME
) >>= m_sName
);
214 m_bRowVersion
= sal_False
;
216 Reference
< XPropertySetInfo
> xPSI( _rxParserColumn
->getPropertySetInfo(), UNO_SET_THROW
);
217 if ( xPSI
->hasPropertyByName( PROPERTY_DEFAULTVALUE
) )
218 OSL_VERIFY( _rxParserColumn
->getPropertyValue( PROPERTY_DEFAULTVALUE
) >>= m_aDefaultValue
);
220 // copy some optional properties from the parser column
221 struct PropertyDescriptor
223 ::rtl::OUString sName
;
226 PropertyDescriptor aProps
[] =
228 { PROPERTY_CATALOGNAME
, PROPERTY_ID_CATALOGNAME
},
229 { PROPERTY_SCHEMANAME
, PROPERTY_ID_SCHEMANAME
},
230 { PROPERTY_TABLENAME
, PROPERTY_ID_TABLENAME
},
231 { PROPERTY_REALNAME
, PROPERTY_ID_REALNAME
}
233 for ( size_t i
=0; i
< sizeof( aProps
) / sizeof( aProps
[0] ); ++i
)
235 if ( xPSI
->hasPropertyByName( aProps
[i
].sName
) )
236 setFastPropertyValue_NoBroadcast( aProps
[i
].nHandle
, _rxParserColumn
->getPropertyValue( aProps
[i
].sName
) );
239 // determine the table column we're based on
240 osl_incrementInterlockedCount( &m_refCount
);
242 m_xOriginalTableColumn
= impl_determineOriginalTableColumn( _rxConnection
);
244 osl_decrementInterlockedCount( &m_refCount
);
247 //--------------------------------------------------------------------------
248 OQueryColumn::~OQueryColumn()
250 DBG_DTOR( OQueryColumn
, NULL
);
253 //--------------------------------------------------------------------------
254 Reference
< XPropertySet
> OQueryColumn::impl_determineOriginalTableColumn( const Reference
< XConnection
>& _rxConnection
)
256 OSL_PRECOND( _rxConnection
.is(), "OQueryColumn::impl_determineOriginalTableColumn: illegal connection!" );
257 if ( !_rxConnection
.is() )
260 Reference
< XPropertySet
> xOriginalTableColumn
;
263 // determine the composed table name, plus the column name, as indicated by the
264 // respective properties
265 ::rtl::OUString sCatalog
, sSchema
, sTable
;
266 OSL_VERIFY( getPropertyValue( PROPERTY_CATALOGNAME
) >>= sCatalog
);
267 OSL_VERIFY( getPropertyValue( PROPERTY_SCHEMANAME
) >>= sSchema
);
268 OSL_VERIFY( getPropertyValue( PROPERTY_TABLENAME
) >>= sTable
);
269 if ( !sCatalog
.getLength() && !sSchema
.getLength() && !sTable
.getLength() )
272 ::rtl::OUString sComposedTableName
= ::dbtools::composeTableName(
273 _rxConnection
->getMetaData(), sCatalog
, sSchema
, sTable
, sal_False
, ::dbtools::eComplete
);
275 // retrieve the table in question
276 Reference
< XTablesSupplier
> xSuppTables( _rxConnection
, UNO_QUERY_THROW
);
277 Reference
< XNameAccess
> xTables( xSuppTables
->getTables(), UNO_QUERY_THROW
);
278 if ( !xTables
->hasByName( sComposedTableName
) )
281 Reference
< XColumnsSupplier
> xSuppCols( xTables
->getByName( sComposedTableName
), UNO_QUERY_THROW
);
282 Reference
< XNameAccess
> xColumns( xSuppCols
->getColumns(), UNO_QUERY_THROW
);
284 ::rtl::OUString sColumn
;
285 OSL_VERIFY( getPropertyValue( PROPERTY_REALNAME
) >>= sColumn
);
286 if ( !xColumns
->hasByName( sColumn
) )
289 xOriginalTableColumn
.set( xColumns
->getByName( sColumn
), UNO_QUERY
);
291 catch( const Exception
& )
293 DBG_UNHANDLED_EXCEPTION();
295 return xOriginalTableColumn
;
298 //--------------------------------------------------------------------------
299 IMPLEMENT_GET_IMPLEMENTATION_ID( OQueryColumn
)
301 //--------------------------------------------------------------------------
302 ::rtl::OUString SAL_CALL
OQueryColumn::getImplementationName( ) throw(RuntimeException
)
304 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.dbaccess.OQueryColumn" ) );
307 //------------------------------------------------------------------------------
308 ::cppu::IPropertyArrayHelper
& SAL_CALL
OQueryColumn::getInfoHelper()
310 return *OQueryColumn_PBase::getArrayHelper();
313 //--------------------------------------------------------------------------
314 ::cppu::IPropertyArrayHelper
* OQueryColumn::createArrayHelper() const
316 return OTableColumnDescriptor::createArrayHelper();
319 //--------------------------------------------------------------------------
320 void SAL_CALL
OQueryColumn::getFastPropertyValue( Any
& _rValue
, sal_Int32 _nHandle
) const
322 OTableColumnDescriptor::getFastPropertyValue( _rValue
, _nHandle
);
324 // special treatment for column settings:
325 if ( !OColumnSettings::isColumnSettingProperty( _nHandle
) )
328 // If the setting has its default value, then try to obtain the value from the table column which
329 // this query column is based on
330 if ( !OColumnSettings::isDefaulted( _nHandle
, _rValue
) )
333 if ( !m_xOriginalTableColumn
.is() )
338 // determine original property name
339 ::rtl::OUString sPropName
;
340 sal_Int16
nAttributes( 0 );
341 const_cast< OQueryColumn
* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName
, &nAttributes
, _nHandle
);
342 OSL_ENSURE( sPropName
.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
344 _rValue
= m_xOriginalTableColumn
->getPropertyValue( sPropName
);
346 catch( const Exception
& )
348 DBG_UNHANDLED_EXCEPTION();
352 //==========================================================================
354 //==========================================================================
355 DBG_NAME(OColumnWrapper
);
356 //--------------------------------------------------------------------------
357 OColumnWrapper::OColumnWrapper( const Reference
< XPropertySet
> & rCol
, const bool _bNameIsReadOnly
)
358 :OColumn( _bNameIsReadOnly
)
362 DBG_CTOR(OColumnWrapper
,NULL
);
363 // which type of aggregate property do we have?
364 // we distingish the properties by the containment of optional properties
366 if ( m_xAggregate
.is() )
368 Reference
<XPropertySetInfo
> xInfo(m_xAggregate
->getPropertySetInfo());
369 m_nColTypeID
|= xInfo
->hasPropertyByName(PROPERTY_DESCRIPTION
) ? HAS_DESCRIPTION
: 0;
370 m_nColTypeID
|= xInfo
->hasPropertyByName(PROPERTY_DEFAULTVALUE
) ? HAS_DEFAULTVALUE
: 0;
371 m_nColTypeID
|= xInfo
->hasPropertyByName(PROPERTY_ISROWVERSION
) ? HAS_ROWVERSION
: 0;
372 m_nColTypeID
|= xInfo
->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION
) ? HAS_AUTOINCREMENT_CREATION
: 0;
374 m_xAggregate
->getPropertyValue(PROPERTY_NAME
) >>= m_sName
;
377 // -----------------------------------------------------------------------------
378 OColumnWrapper::~OColumnWrapper()
380 DBG_DTOR(OColumnWrapper
,NULL
);
383 //------------------------------------------------------------------------------
384 ::rtl::OUString
OColumnWrapper::impl_getPropertyNameFromHandle( const sal_Int32 _nHandle
) const
386 ::rtl::OUString sPropName
;
387 sal_Int16
nAttributes( 0 );
388 const_cast< OColumnWrapper
* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName
, &nAttributes
, _nHandle
);
389 OSL_ENSURE( sPropName
.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
393 //------------------------------------------------------------------------------
394 void OColumnWrapper::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
396 // derived classes are free to either use the OPropertyContainer(Helper) mechanisms for properties,
397 // or to declare additional properties which are to be forwarded to the wrapped object. So we need
398 // to distinguish those cases.
399 if ( OColumn::isRegisteredProperty( nHandle
) )
401 OColumn::getFastPropertyValue( rValue
, nHandle
);
405 rValue
= m_xAggregate
->getPropertyValue( impl_getPropertyNameFromHandle( nHandle
) );
409 //------------------------------------------------------------------------------
410 sal_Bool
OColumnWrapper::convertFastPropertyValue( Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
,
411 const Any
& rValue
) throw (IllegalArgumentException
)
413 sal_Bool
bModified( sal_False
);
414 if ( OColumn::isRegisteredProperty( nHandle
) )
416 bModified
= OColumn::convertFastPropertyValue( rConvertedValue
, rOldValue
, nHandle
, rValue
);
420 getFastPropertyValue( rOldValue
, nHandle
);
421 if ( rOldValue
!= rValue
)
423 rConvertedValue
= rValue
;
424 bModified
= sal_True
;
430 //------------------------------------------------------------------------------
431 void OColumnWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const Any
& rValue
) throw (Exception
)
433 if ( OColumn::isRegisteredProperty( nHandle
) )
435 OColumn::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
439 m_xAggregate
->setPropertyValue( impl_getPropertyNameFromHandle( nHandle
), rValue
);
443 // -----------------------------------------------------------------------------
444 sal_Int64 SAL_CALL
OColumnWrapper::getSomething( const Sequence
< sal_Int8
>& aIdentifier
) throw(RuntimeException
)
446 Reference
< XUnoTunnel
> xTunnel( m_xAggregate
, UNO_QUERY
);
448 return xTunnel
->getSomething( aIdentifier
);
452 //============================================================
453 //= OTableColumnDescriptorWrapper
454 //============================================================
455 //--------------------------------------------------------------------------
456 OTableColumnDescriptorWrapper::OTableColumnDescriptorWrapper( const Reference
< XPropertySet
>& _rCol
, const bool _bPureWrap
, const bool _bIsDescriptor
)
457 :OColumnWrapper( _rCol
, !_bIsDescriptor
)
458 ,m_bPureWrap( _bPureWrap
)
459 ,m_bIsDescriptor( _bIsDescriptor
)
461 // let the ColumnSettings register its properties
462 OColumnSettings::registerProperties( *this );
465 // com::sun::star::lang::XTypeProvider
466 //--------------------------------------------------------------------------
467 IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptorWrapper
)
469 // ::com::sun::star::lang::XServiceInfo
470 //------------------------------------------------------------------------------
471 rtl::OUString
OTableColumnDescriptorWrapper::getImplementationName( ) throw (RuntimeException
)
473 return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumnDescriptorWrapper");
476 //------------------------------------------------------------------------------
477 Sequence
< ::rtl::OUString
> OTableColumnDescriptorWrapper::getSupportedServiceNames( ) throw (RuntimeException
)
479 Sequence
< ::rtl::OUString
> aSNS( 2 );
480 aSNS
[0] = SERVICE_SDBCX_COLUMNDESCRIPTOR
;
481 aSNS
[1] = SERVICE_SDB_COLUMNSETTINGS
;
485 // comphelper::OPropertyArrayUsageHelper
486 //------------------------------------------------------------------------------
487 ::cppu::IPropertyArrayHelper
* OTableColumnDescriptorWrapper::createArrayHelper( sal_Int32 nId
) const
489 const sal_Int32 nHaveAlways
= 7;
491 // Which optional properties are contained?
492 sal_Int32 nHaveOptionally
= 0;
493 if (nId
& HAS_DESCRIPTION
)
495 if (nId
& HAS_DEFAULTVALUE
)
497 if (nId
& HAS_ROWVERSION
)
499 if ( nId
& HAS_AUTOINCREMENT_CREATION
)
502 const sal_Int32
nPropertyCount( nHaveAlways
+ nHaveOptionally
);
503 Sequence
< Property
> aTableDescProperties( nPropertyCount
);
504 Property
* pDesc
= aTableDescProperties
.getArray();
507 DECL_PROP0_BOOL( ISAUTOINCREMENT
);
508 DECL_PROP0_BOOL( ISCURRENCY
);
509 DECL_PROP0( ISNULLABLE
, sal_Int32
);
510 DECL_PROP0( PRECISION
, sal_Int32
);
511 DECL_PROP0( SCALE
, sal_Int32
);
512 DECL_PROP0( TYPE
, sal_Int32
);
513 DECL_PROP0( TYPENAME
, ::rtl::OUString
);
515 if ( nId
& HAS_AUTOINCREMENT_CREATION
)
517 DECL_PROP1( AUTOINCREMENTCREATION
, ::rtl::OUString
, MAYBEVOID
);
519 if ( nId
& HAS_DEFAULTVALUE
)
521 DECL_PROP0( DEFAULTVALUE
, ::rtl::OUString
);
523 if ( nId
& HAS_DESCRIPTION
)
525 DECL_PROP0( DESCRIPTION
, ::rtl::OUString
);
527 if ( nId
& HAS_ROWVERSION
)
529 DECL_PROP0_BOOL( ISROWVERSION
);
532 OSL_ENSURE( nPos
== nPropertyCount
, "OTableColumnDescriptorWrapper::createArrayHelper: something went wrong!" );
534 if ( !m_bIsDescriptor
)
536 for ( Property
* prop
= aTableDescProperties
.getArray();
537 prop
!= aTableDescProperties
.getArray() + aTableDescProperties
.getLength();
541 prop
->Attributes
|= PropertyAttribute::READONLY
;
545 // finally also describe the properties which are maintained by our base class, in particular the OPropertyContainerHelper
546 Sequence
< Property
> aBaseProperties
;
547 describeProperties( aBaseProperties
);
549 Sequence
< Property
> aAllProperties( ::comphelper::concatSequences( aTableDescProperties
, aBaseProperties
) );
550 return new ::cppu::OPropertyArrayHelper( aAllProperties
, sal_False
);
553 // cppu::OPropertySetHelper
554 //------------------------------------------------------------------------------
555 ::cppu::IPropertyArrayHelper
& OTableColumnDescriptorWrapper::getInfoHelper()
557 return *static_cast< OIdPropertyArrayUsageHelper
< OTableColumnDescriptorWrapper
>* >(this)->getArrayHelper(m_nColTypeID
);
560 //------------------------------------------------------------------------------
561 void OTableColumnDescriptorWrapper::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
565 rValue
= m_xAggregate
->getPropertyValue( impl_getPropertyNameFromHandle( nHandle
) );
569 OColumnWrapper::getFastPropertyValue( rValue
, nHandle
);
573 //------------------------------------------------------------------------------
574 sal_Bool
OTableColumnDescriptorWrapper::convertFastPropertyValue( Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
, const Any
& rValue
) throw (IllegalArgumentException
)
576 sal_Bool
bModified(sal_False
);
579 // do not delegate to OColumnWrapper: It would, for the properties which were registered with registerProperty,
580 // ask the OPropertyContainer base class, which is not what we want here.
581 // TODO: the whole "m_bPureWrap"-thingie is strange. We should have a dedicated class doing this wrapping,
582 // not a class which normally serves other purposes, and only sometimes does a "pure wrap". It makes the
583 // code unnecessarily hard to maintain, and error prone.
584 rOldValue
= m_xAggregate
->getPropertyValue( impl_getPropertyNameFromHandle( nHandle
) );
585 if ( rOldValue
!= rValue
)
587 rConvertedValue
= rValue
;
588 bModified
= sal_True
;
593 bModified
= OColumnWrapper::convertFastPropertyValue( rConvertedValue
, rOldValue
, nHandle
, rValue
);
598 //------------------------------------------------------------------------------
599 void OTableColumnDescriptorWrapper::setFastPropertyValue_NoBroadcast(
607 m_xAggregate
->setPropertyValue( impl_getPropertyNameFromHandle( nHandle
), rValue
);
611 OColumnWrapper::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
615 //============================================================
616 //= OTableColumnWrapper
617 //============================================================
618 //--------------------------------------------------------------------------
619 OTableColumnWrapper::OTableColumnWrapper( const Reference
< XPropertySet
>& rCol
, const Reference
< XPropertySet
>& _xColDefintion
,
620 const bool _bPureWrap
)
621 :OTableColumnDescriptorWrapper( rCol
, _bPureWrap
, false )
623 osl_incrementInterlockedCount( &m_refCount
);
624 if ( _xColDefintion
.is() )
628 ::comphelper::copyProperties( _xColDefintion
, this );
630 catch( const Exception
& )
632 DBG_UNHANDLED_EXCEPTION();
635 osl_decrementInterlockedCount( &m_refCount
);
638 //--------------------------------------------------------------------------
639 OTableColumnWrapper::~OTableColumnWrapper()
643 //--------------------------------------------------------------------------
644 IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnWrapper
)
646 //------------------------------------------------------------------------------
647 rtl::OUString
OTableColumnWrapper::getImplementationName( ) throw (RuntimeException
)
649 return rtl::OUString::createFromAscii( "com.sun.star.sdb.OTableColumnWrapper" );
652 //------------------------------------------------------------------------------
653 Sequence
< ::rtl::OUString
> OTableColumnWrapper::getSupportedServiceNames( ) throw (RuntimeException
)
655 Sequence
< ::rtl::OUString
> aSNS( 2 );
656 aSNS
[0] = SERVICE_SDBCX_COLUMN
;
657 aSNS
[1] = SERVICE_SDB_COLUMNSETTINGS
;
661 //------------------------------------------------------------------------------
662 ::cppu::IPropertyArrayHelper
& OTableColumnWrapper::getInfoHelper()
664 return *static_cast< OIdPropertyArrayUsageHelper
< OTableColumnWrapper
>* >(this)->getArrayHelper(m_nColTypeID
);
667 // comphelper::OPropertyArrayUsageHelper
668 //------------------------------------------------------------------------------
669 ::cppu::IPropertyArrayHelper
* OTableColumnWrapper::createArrayHelper( sal_Int32 nId
) const
671 return OTableColumnDescriptorWrapper::createArrayHelper( nId
);