diff options
author | Frank Schönheit [fs] <frank.schoenheit@sun.com> | 2009-11-02 14:41:02 +0100 |
---|---|---|
committer | Frank Schönheit [fs] <frank.schoenheit@sun.com> | 2009-11-02 14:41:02 +0100 |
commit | 8b8a260028bd6cc8162cc86585575fed4df25695 (patch) | |
tree | abb823b46753d5cd684d33cb297c44d817a5cf72 | |
parent | 136de0033d9df7a17d6e65d509b8bddd08f46552 (diff) |
more column class refactoring in preparation of #i67202#. Removed unneeded classes, consolidated the property handling of the various Column classes
-rw-r--r-- | dbaccess/source/core/api/CRowSetColumn.cxx | 206 | ||||
-rw-r--r-- | dbaccess/source/core/api/CRowSetColumn.hxx | 35 | ||||
-rw-r--r-- | dbaccess/source/core/api/CRowSetDataColumn.cxx | 154 | ||||
-rw-r--r-- | dbaccess/source/core/api/TableDeco.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/core/api/column.cxx | 190 | ||||
-rw-r--r-- | dbaccess/source/core/api/columnsettings.cxx | 148 | ||||
-rw-r--r-- | dbaccess/source/core/api/definitioncolumn.cxx | 807 | ||||
-rw-r--r-- | dbaccess/source/core/api/preparedstatement.cxx | 73 | ||||
-rw-r--r-- | dbaccess/source/core/api/resultcolumn.cxx | 196 | ||||
-rw-r--r-- | dbaccess/source/core/api/table.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/ComponentDefinition.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/core/inc/column.hxx | 128 | ||||
-rw-r--r-- | dbaccess/source/core/inc/columnsettings.hxx | 67 | ||||
-rw-r--r-- | dbaccess/source/core/inc/definitioncolumn.hxx | 152 |
14 files changed, 629 insertions, 1543 deletions
diff --git a/dbaccess/source/core/api/CRowSetColumn.cxx b/dbaccess/source/core/api/CRowSetColumn.cxx index bfa770cf2..dbe660853 100644 --- a/dbaccess/source/core/api/CRowSetColumn.cxx +++ b/dbaccess/source/core/api/CRowSetColumn.cxx @@ -31,186 +31,84 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ -#include <cppuhelper/typeprovider.hxx> -#endif -#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX #include "CRowSetColumn.hxx" -#endif -#ifndef _COM_SUN_STAR_SDB_XCOLUMN_HPP_ + #include <com/sun/star/sdb/XColumn.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif +#include <comphelper/types.hxx> +#include <cppuhelper/typeprovider.hxx> -using namespace dbaccess; -// using namespace connectivity; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -// using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -// using namespace ::com::sun::star::util; -using namespace cppu; -using namespace osl; +using namespace ::com::sun::star::beans; +//.............................................................................. +namespace dbaccess +{ +//.............................................................................. -// ------------------------------------------------------------------------- -//ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, -// const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XRow >& _xRow, -// sal_Int32 _nPos, -// ORowSetMatrix::iterator& _rColumnValue, -// ORowSetMatrix::iterator& _rEnd) -// : ORowSetDataColumn(_xMetaData,_xRow,NULL,_nPos,_rColumnValue,_rEnd) -//{ -// -//} //------------------------------------------------------------------------------ -Any SAL_CALL ORowSetColumn::queryInterface( const Type & _rType ) throw (RuntimeException) +ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData, const Reference < XRow >& _xRow, sal_Int32 _nPos, + const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, ORowSetCacheIterator& _rColumnValue ) + :ORowSetDataColumn( _xMetaData, _xRow, NULL, _nPos, _rxDBMeta, _rDescription, _rColumnValue ) { - Any aReturn = OResultColumn::queryInterface(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType,static_cast< XColumn* >(this)); - return aReturn; } -// ------------------------------------------------------------------------- -// comphelper::OPropertyArrayUsageHelper + //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* ORowSetColumn::createArrayHelper( ) const { - BEGIN_PROPERTY_HELPER(30) - DECL_PROP2(ALIGN, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP1(CATALOGNAME, ::rtl::OUString, READONLY); - DECL_PROP2(CONTROLDEFAULT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_IFACE(CONTROLMODEL, XPropertySet, BOUND ); - DECL_PROP1(DISPLAYSIZE, sal_Int32, READONLY); - DECL_PROP2(NUMBERFORMAT, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP2(HELPTEXT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_BOOL(HIDDEN, BOUND); - DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY); - DECL_PROP1_BOOL(ISCASESENSITIVE, READONLY); - DECL_PROP1_BOOL(ISCURRENCY, READONLY); - DECL_PROP1_BOOL(ISDEFINITELYWRITABLE, READONLY); - DECL_PROP1(ISNULLABLE, sal_Int32, READONLY); - DECL_PROP1_BOOL(ISREADONLY, READONLY); - DECL_PROP1_BOOL(ISROWVERSION, READONLY); - DECL_PROP1_BOOL(ISSEARCHABLE, READONLY); - DECL_PROP1_BOOL(ISSIGNED, READONLY); - DECL_PROP1_BOOL(ISWRITABLE, READONLY); - DECL_PROP1(LABEL, ::rtl::OUString, READONLY); - DECL_PROP1(NAME, ::rtl::OUString, READONLY); - DECL_PROP1(PRECISION, sal_Int32, READONLY); - DECL_PROP2(RELATIVEPOSITION, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP1(SCALE, sal_Int32, READONLY); - DECL_PROP1(SCHEMANAME, ::rtl::OUString, READONLY); - DECL_PROP1(SERVICENAME, ::rtl::OUString, READONLY); - DECL_PROP1(TABLENAME, ::rtl::OUString, READONLY); - DECL_PROP1(TYPE, sal_Int32, READONLY); - DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY); - DECL_PROP2(VALUE, Any, READONLY,BOUND); - DECL_PROP1(WIDTH, sal_Int32, MAYBEVOID); - END_PROPERTY_HELPER(); + const sal_Int32 nDerivedProperties = 21; + Sequence< Property> aDerivedProperties( nDerivedProperties ); + Property* pDesc = aDerivedProperties.getArray(); + sal_Int32 nPos = 0; + + DECL_PROP1( CATALOGNAME, ::rtl::OUString, READONLY ); + DECL_PROP1( DISPLAYSIZE, sal_Int32, READONLY ); + DECL_PROP1_BOOL( ISAUTOINCREMENT, READONLY ); + DECL_PROP1_BOOL( ISCASESENSITIVE, READONLY ); + DECL_PROP1_BOOL( ISCURRENCY, READONLY ); + DECL_PROP1_BOOL( ISDEFINITELYWRITABLE, READONLY ); + DECL_PROP1( ISNULLABLE, sal_Int32, READONLY ); + DECL_PROP1_BOOL( ISREADONLY, READONLY ); + DECL_PROP1_BOOL( ISROWVERSION, READONLY ); + DECL_PROP1_BOOL( ISSEARCHABLE, READONLY ); + DECL_PROP1_BOOL( ISSIGNED, READONLY ); + DECL_PROP1_BOOL( ISWRITABLE, READONLY ); + DECL_PROP1( LABEL, ::rtl::OUString, READONLY ); + DECL_PROP1( PRECISION, sal_Int32, READONLY ); + DECL_PROP1( SCALE, sal_Int32, READONLY ); + DECL_PROP1( SCHEMANAME, ::rtl::OUString, READONLY ); + DECL_PROP1( SERVICENAME, ::rtl::OUString, READONLY ); + DECL_PROP1( TABLENAME, ::rtl::OUString, READONLY ); + DECL_PROP1( TYPE, sal_Int32, READONLY ); + DECL_PROP1( TYPENAME, ::rtl::OUString, READONLY ); + DECL_PROP2( VALUE, Any, READONLY, BOUND ); + OSL_ENSURE( nPos == nDerivedProperties, "ORowSetColumn::createArrayHelper: inconsistency!" ); + + Sequence< Property > aRegisteredProperties; + describeProperties( aRegisteredProperties ); + + return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDerivedProperties, aRegisteredProperties ), sal_False ); } -// cppu::OPropertySetHelper //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper& ORowSetColumn::getInfoHelper() { return *static_cast< ::comphelper::OPropertyArrayUsageHelper< ORowSetColumn >* >(this)->getArrayHelper(); } -// ------------------------------------------------------------------------- -void SAL_CALL ORowSetColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const -{ - switch(nHandle) - { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - OColumnSettings::getFastPropertyValue( rValue, nHandle ); - break; - case PROPERTY_ID_VALUE: - if ( !m_aColumnValue.isNull() && (*m_aColumnValue).isValid() ) - rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny(); - break; - default: - ORowSetDataColumn::getFastPropertyValue(rValue,nHandle); - } -} -// ------------------------------------------------------------------------- + +//------------------------------------------------------------------------------ void SAL_CALL ORowSetColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception) { - switch(nHandle) - { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - OColumnSettings::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - break; - case PROPERTY_ID_VALUE: - break; - default: - ORowSetDataColumn::setFastPropertyValue_NoBroadcast(nHandle,rValue ); - } + OSL_ENSURE( nHandle != PROPERTY_ID_VALUE, "ORowSetColumn::setFastPropertyValue_NoBroadcast: hmm? This property is marked as READONLY!" ); + if ( nHandle != PROPERTY_ID_VALUE ) + ORowSetDataColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); } -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL ORowSetColumn::convertFastPropertyValue( Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) throw (IllegalArgumentException) -{ - sal_Bool bModified = sal_False; - switch(nHandle) - { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - bModified = OColumnSettings::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - break; - case PROPERTY_ID_VALUE: - rConvertedValue = rValue; - getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE); - bModified = !::comphelper::compare(rConvertedValue, rOldValue); - break; - default: - bModified = ORowSetDataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue); - - } - return bModified; -} -// com::sun::star::lang::XTypeProvider -//-------------------------------------------------------------------------- -Sequence< Type > ORowSetColumn::getTypes() throw (RuntimeException) -{ - OTypeCollection aTypes(::getCppuType( (const Reference< XColumn > *)0 ),OColumn::getTypes()); - return aTypes.getTypes(); -} -//-------------------------------------------------------------------------- +//.............................................................................. +} // namespace dbaccess +//.............................................................................. diff --git a/dbaccess/source/core/api/CRowSetColumn.hxx b/dbaccess/source/core/api/CRowSetColumn.hxx index c1113b335..dee4af984 100644 --- a/dbaccess/source/core/api/CRowSetColumn.hxx +++ b/dbaccess/source/core/api/CRowSetColumn.hxx @@ -46,11 +46,9 @@ namespace dbaccess { class ORowSetColumn; - typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetColumn> ORowSetColumn_PROP; - - // ------------------------------------------------------------------------- - class ORowSetColumn : public ORowSetColumn_PROP, - public ORowSetDataColumn + class ORowSetColumn :public ORowSetDataColumn + ,public ::comphelper::OPropertyArrayUsageHelper< ORowSetColumn > + { public: ORowSetColumn( const ::com::sun::star::uno::Reference < ::com::sun::star::sdbc::XResultSetMetaData >& _xMetaData, @@ -58,34 +56,13 @@ namespace dbaccess sal_Int32 _nPos, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, - ORowSetCacheIterator& _rColumnValue) - : ORowSetDataColumn(_xMetaData,_xRow,NULL,_nPos,_rxDBMeta,_rDescription,_rColumnValue) - { - } - - // com::sun::star::lang::XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + ORowSetCacheIterator& _rColumnValue); - // com::sun::star::uno::XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); - - // comphelper::OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; - - // cppu::OPropertySetHelper virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); - - virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue )throw (::com::sun::star::uno::Exception); - - protected: - using ORowSetDataColumn::getFastPropertyValue; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue )throw (::com::sun::star::uno::Exception ); }; } -#endif // DBACCESS_CORE_API_CROWSETCOLUMN_HXX +#endif // DBACCESS_CORE_API_CROWSETCOLUMN_HXX diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index d3591da06..217c87743 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -75,11 +75,13 @@ ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _x const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rDescription, const ORowSetCacheIterator& _rColumnValue) - : ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) + :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) ,m_aColumnValue(_rColumnValue) ,m_aDescription(_rDescription) { DBG_CTOR(ORowSetDataColumn,NULL); + OColumnSettings::registerProperties( *this ); + registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, ::getCppuType( &m_aDescription ) ); } // ------------------------------------------------------------------------- ORowSetDataColumn::~ORowSetDataColumn() @@ -91,39 +93,38 @@ ORowSetDataColumn::~ORowSetDataColumn() //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const { - BEGIN_PROPERTY_HELPER(31) - DECL_PROP2(ALIGN, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP1(CATALOGNAME, ::rtl::OUString, READONLY); - DECL_PROP2(CONTROLDEFAULT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_IFACE(CONTROLMODEL, XPropertySet, BOUND ); - DECL_PROP1(DESCRIPTION, ::rtl::OUString, READONLY); - DECL_PROP1(DISPLAYSIZE, sal_Int32, READONLY); - DECL_PROP2(NUMBERFORMAT, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP2(HELPTEXT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_BOOL(HIDDEN, BOUND); - DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY); - DECL_PROP1_BOOL(ISCASESENSITIVE, READONLY); - DECL_PROP1_BOOL(ISCURRENCY, READONLY); - DECL_PROP1_BOOL(ISDEFINITELYWRITABLE, READONLY); - DECL_PROP1(ISNULLABLE, sal_Int32, READONLY); - DECL_PROP1_BOOL(ISREADONLY, READONLY); - DECL_PROP1_BOOL(ISROWVERSION, READONLY); - DECL_PROP1_BOOL(ISSEARCHABLE, READONLY); - DECL_PROP1_BOOL(ISSIGNED, READONLY); - DECL_PROP1_BOOL(ISWRITABLE, READONLY); - DECL_PROP1(LABEL, ::rtl::OUString, READONLY); - DECL_PROP1(NAME, ::rtl::OUString, READONLY); - DECL_PROP1(PRECISION, sal_Int32, READONLY); - DECL_PROP2(RELATIVEPOSITION, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP1(SCALE, sal_Int32, READONLY); - DECL_PROP1(SCHEMANAME, ::rtl::OUString, READONLY); - DECL_PROP1(SERVICENAME, ::rtl::OUString, READONLY); - DECL_PROP1(TABLENAME, ::rtl::OUString, READONLY); - DECL_PROP1(TYPE, sal_Int32, READONLY); - DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY); - DECL_PROP1(VALUE, Any, BOUND); - DECL_PROP1(WIDTH, sal_Int32, MAYBEVOID); - END_PROPERTY_HELPER(); + const sal_Int32 nDerivedProperties = 21; + Sequence< Property> aDerivedProperties( nDerivedProperties ); + Property* pDesc = aDerivedProperties.getArray(); + sal_Int32 nPos = 0; + + DECL_PROP1( CATALOGNAME, ::rtl::OUString, READONLY ); + DECL_PROP1( DISPLAYSIZE, sal_Int32, READONLY ); + DECL_PROP1_BOOL( ISAUTOINCREMENT, READONLY ); + DECL_PROP1_BOOL( ISCASESENSITIVE, READONLY ); + DECL_PROP1_BOOL( ISCURRENCY, READONLY ); + DECL_PROP1_BOOL( ISDEFINITELYWRITABLE, READONLY ); + DECL_PROP1( ISNULLABLE, sal_Int32, READONLY ); + DECL_PROP1_BOOL( ISREADONLY, READONLY ); + DECL_PROP1_BOOL( ISROWVERSION, READONLY ); + DECL_PROP1_BOOL( ISSEARCHABLE, READONLY ); + DECL_PROP1_BOOL( ISSIGNED, READONLY ); + DECL_PROP1_BOOL( ISWRITABLE, READONLY ); + DECL_PROP1( LABEL, ::rtl::OUString, READONLY ); + DECL_PROP1( PRECISION, sal_Int32, READONLY ); + DECL_PROP1( SCALE, sal_Int32, READONLY ); + DECL_PROP1( SCHEMANAME, ::rtl::OUString, READONLY ); + DECL_PROP1( SERVICENAME, ::rtl::OUString, READONLY ); + DECL_PROP1( TABLENAME, ::rtl::OUString, READONLY ); + DECL_PROP1( TYPE, sal_Int32, READONLY ); + DECL_PROP1( TYPENAME, ::rtl::OUString, READONLY ); + DECL_PROP1( VALUE, Any, BOUND ); + OSL_ENSURE( nPos == nDerivedProperties, "ORowSetDataColumn::createArrayHelper: inconsistency!" ); + + Sequence< Property > aRegisteredProperties; + describeProperties( aRegisteredProperties ); + + return new ::cppu::OPropertyArrayHelper( ::comphelper::concatSequences( aDerivedProperties, aRegisteredProperties ), sal_False ); } // cppu::OPropertySetHelper @@ -135,57 +136,33 @@ ORowSetDataColumn::~ORowSetDataColumn() // ------------------------------------------------------------------------- void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const { - switch(nHandle) + if ( PROPERTY_ID_VALUE == nHandle ) { - case PROPERTY_ID_DESCRIPTION: - rValue <<= m_aDescription; - break; - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - OColumnSettings::getFastPropertyValue( rValue, nHandle ); - break; - case PROPERTY_ID_VALUE: - if ( !m_aColumnValue.isNull() && m_aColumnValue->isValid() ) - { - ::osl::Mutex* pMutex = m_aColumnValue.getMutex(); - ::osl::MutexGuard aGuard( *pMutex ); + if ( !m_aColumnValue.isNull() && m_aColumnValue->isValid() ) + { + ::osl::Mutex* pMutex = m_aColumnValue.getMutex(); + ::osl::MutexGuard aGuard( *pMutex ); #if OSL_DEBUG_LEVEL > 0 - ORowSetRow aRow = *m_aColumnValue; + ORowSetRow aRow = *m_aColumnValue; #endif - OSL_ENSURE((sal_Int32)aRow->get().size() > m_nPos,"Pos is greater than size of vector"); - rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny(); - } - break; - default: - ODataColumn::getFastPropertyValue(rValue,nHandle); + OSL_ENSURE((sal_Int32)aRow->get().size() > m_nPos,"Pos is greater than size of vector"); + rValue = ((*m_aColumnValue)->get())[m_nPos].makeAny(); + } } + else + ODataColumn::getFastPropertyValue( rValue, nHandle ); } + // ------------------------------------------------------------------------- void SAL_CALL ORowSetDataColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue )throw (Exception) { - switch(nHandle) + if ( PROPERTY_ID_VALUE == nHandle ) + { + updateObject(rValue); + } + else { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - OColumnSettings::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - break; - case PROPERTY_ID_VALUE: - updateObject(rValue); - break; - default: - ODataColumn::setFastPropertyValue_NoBroadcast(nHandle,rValue ); + ODataColumn::setFastPropertyValue_NoBroadcast( nHandle,rValue ); } } // ------------------------------------------------------------------------- @@ -195,27 +172,14 @@ sal_Bool SAL_CALL ORowSetDataColumn::convertFastPropertyValue( Any & rConvertedV const Any& rValue ) throw (IllegalArgumentException) { sal_Bool bModified = sal_False; - switch(nHandle) + if ( PROPERTY_ID_VALUE == nHandle ) { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - bModified = OColumnSettings::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - break; - case PROPERTY_ID_VALUE: - rConvertedValue = rValue; - getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE); - bModified = !::comphelper::compare(rConvertedValue, rOldValue); - break; - default: - bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue); - + rConvertedValue = rValue; + getFastPropertyValue(rOldValue, PROPERTY_ID_VALUE); + bModified = rConvertedValue != rOldValue; } + else + bModified = ODataColumn::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue); return bModified; } diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx index b3742ae59..b6aa113a2 100644 --- a/dbaccess/source/core/api/TableDeco.cxx +++ b/dbaccess/source/core/api/TableDeco.cxx @@ -706,7 +706,7 @@ OColumn* ODBTableDecorator::createColumn(const ::rtl::OUString& _rName) const if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName)) xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY); - pReturn = new OTableColumnWrapper(xProp,xColumnDefintion); + pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false ); } } return pReturn; @@ -734,8 +734,8 @@ Reference< XPropertySet > ODBTableDecorator::createColumnDescriptor() if(m_xTable.is()) xNames.set(m_xTable->getColumns(),UNO_QUERY); Reference< XPropertySet > xRet; - if(xNames.is()) - xRet = new OTableColumnDescriptorWrapper(xNames->createDataDescriptor()); + if ( xNames.is() ) + xRet = new OTableColumnDescriptorWrapper( xNames->createDataDescriptor(), false, true ); return xRet; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx index d3238afc7..650197052 100644 --- a/dbaccess/source/core/api/column.cxx +++ b/dbaccess/source/core/api/column.cxx @@ -31,78 +31,31 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBA_COREAPI_COLUMN_HXX_ +#include "ContainerMediator.hxx" +#include "apitools.hxx" #include "column.hxx" -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC -#include "dbastrings.hrc" -#endif -#ifndef _DBA_CORE_RESOURCE_HXX_ -#include "core_resource.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HRC_ #include "core_resource.hrc" -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ -#include "apitools.hxx" -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include "core_resource.hxx" +#include "dbastrings.hrc" +#include "sdbcoretools.hxx" + +#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ -#include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ #include <com/sun/star/sdbc/DataType.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ -#include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ -#include <comphelper/sequence.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ -#include <comphelper/property.hxx> -#endif -#ifndef _COMPHELPER_ENUMHELPER_HXX_ + +#include <comphelper/basicio.hxx> #include <comphelper/enumhelper.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> -#endif -#ifndef _OSL_DIAGNOSE_H_ -#include <osl/diagnose.h> -#endif -#ifndef _COMPHELPER_SEQSTREAM_HXX +#include <comphelper/property.hxx> #include <comphelper/seqstream.hxx> -#endif -#ifndef _COMPHELPER_BASIC_IO_HXX_ -#include <comphelper/basicio.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif -#ifndef CONNECTIVITY_TABLEHELPER_HXX +#include <comphelper/sequence.hxx> +#include <comphelper/types.hxx> #include <connectivity/TTableHelper.hxx> -#endif -#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_ -#include "definitioncolumn.hxx" -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> -#endif -#ifndef DBA_CONTAINERMEDIATOR_HXX -#include "ContainerMediator.hxx" -#endif -#ifndef DBACORE_SDBCORETOOLS_HXX -#include "sdbcoretools.hxx" -#endif +#include <connectivity/dbtools.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <osl/diagnose.h> +#include <tools/debug.hxx> #include <algorithm> @@ -128,11 +81,14 @@ DBG_NAME(OColumn) //= OColumn //============================================================ //-------------------------------------------------------------------------- -OColumn::OColumn() - :OColumnBase(m_aMutex) - , OPropertySetHelper(OColumnBase::rBHelper) +OColumn::OColumn( const bool _bNameIsReadOnly ) + :OColumnBase( m_aMutex ) + ,::comphelper::OPropertyContainer( OColumnBase::rBHelper ) { DBG_CTOR(OColumn, NULL); + + registerProperty( PROPERTY_NAME, PROPERTY_ID_NAME, _bNameIsReadOnly ? PropertyAttribute::READONLY : 0, + &m_sName, ::getCppuType( &m_sName ) ); } //-------------------------------------------------------------------------- @@ -145,37 +101,14 @@ OColumn::~OColumn() //-------------------------------------------------------------------------- Sequence< Type > OColumn::getTypes() throw (RuntimeException) { - OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ), - ::getCppuType( (const Reference< XMultiPropertySet > *)0 ), - OColumnBase::getTypes()); - return aTypes.getTypes(); + return ::comphelper::concatSequences( + OColumnBase::getTypes(), + ::comphelper::OPropertyContainer::getTypes() + ); } // com::sun::star::uno::XInterface -//-------------------------------------------------------------------------- -Any OColumn::queryInterface( const Type & rType ) throw (RuntimeException) -{ - Any aIface = OColumnBase::queryInterface( rType ); - if (!aIface.hasValue()) - aIface = ::cppu::queryInterface( - rType, - static_cast< XPropertySet * >( this ), - static_cast< XMultiPropertySet * >( this )); - - return aIface; -} - -//-------------------------------------------------------------------------- -void OColumn::acquire() throw() -{ - OColumnBase::acquire(); -} - -//-------------------------------------------------------------------------- -void OColumn::release() throw() -{ - OColumnBase::release(); -} +IMPLEMENT_FORWARD_XINTERFACE2( OColumn, OColumnBase, ::comphelper::OPropertyContainer ) // ::com::sun::star::lang::XServiceInfo //------------------------------------------------------------------------------ @@ -202,7 +135,7 @@ Sequence< ::rtl::OUString > OColumn::getSupportedServiceNames( ) throw (Runtime //------------------------------------------------------------------------------ void OColumn::disposing() { - OPropertySetHelper::disposing(); + OPropertyContainer::disposing(); } // com::sun::star::beans::XPropertySet @@ -212,52 +145,6 @@ Reference< XPropertySetInfo > OColumn::getPropertySetInfo() throw (RuntimeExcept return createPropertySetInfo( getInfoHelper() ) ; } -//------------------------------------------------------------------------------ -void OColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const -{ - switch (nHandle) - { - case PROPERTY_ID_NAME: - rValue <<= m_sName; - break; - } -} - -//------------------------------------------------------------------------------ -sal_Bool OColumn::convertFastPropertyValue( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) - throw (IllegalArgumentException) -{ - sal_Bool bModified = sal_False; - switch (nHandle) - { - case PROPERTY_ID_NAME: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sName); - break; - } - return bModified; -} - -//------------------------------------------------------------------------------ -void OColumn::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& rValue - ) - throw (Exception) -{ - switch (nHandle) - { - case PROPERTY_ID_NAME: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< ::rtl::OUString* >(NULL))), - "OColumn::setFastPropertyValue_NoBroadcast(NAME) : invalid value !"); - rValue >>= m_sName; - break; - } -} - //-------------------------------------------------------------------------- Sequence< sal_Int8 > OColumn::getUnoTunnelImplementationId() { @@ -293,11 +180,31 @@ void SAL_CALL OColumn::setName( const ::rtl::OUString& _rName ) throw(::com::sun { m_sName = _rName; } + // ----------------------------------------------------------------------------- void OColumn::fireValueChange(const ::connectivity::ORowSetValue& /*_rOldValue*/) { DBG_ERROR( "OColumn::fireValueChange: not implemented!" ); } + +//------------------------------------------------------------------------------ +void OColumn::registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const Type& _rMemberType ) +{ + ::comphelper::OPropertyContainer::registerProperty( _rName, _nHandle, _nAttributes, _pPointerToMember, _rMemberType ); +} + +//------------------------------------------------------------------------------ +void OColumn::registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, Any* _pPointerToMember, const Type& _rExpectedType ) +{ + ::comphelper::OPropertyContainer::registerMayBeVoidProperty( _rName, _nHandle, _nAttributes, _pPointerToMember, _rExpectedType ); +} + +//------------------------------------------------------------------------------ +void OColumn::registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const Type& _rType, const void* _pInitialValue ) +{ + ::comphelper::OPropertyContainer::registerPropertyNoMember( _rName, _nHandle, _nAttributes, _rType, _pInitialValue ); +} + //============================================================ //= OColumns //============================================================ @@ -323,6 +230,7 @@ OColumns::OColumns(::cppu::OWeakObject& _rParent, { DBG_CTOR(OColumns, NULL); } + // ------------------------------------------------------------------------- OColumns::OColumns(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns, diff --git a/dbaccess/source/core/api/columnsettings.cxx b/dbaccess/source/core/api/columnsettings.cxx index 8aefe21ae..b6a242127 100644 --- a/dbaccess/source/core/api/columnsettings.cxx +++ b/dbaccess/source/core/api/columnsettings.cxx @@ -30,6 +30,7 @@ #include "dbastrings.hrc" /** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyAttribute.hpp> /** === end UNO includes === **/ #include <cppuhelper/typeprovider.hxx> @@ -56,6 +57,7 @@ namespace dbaccess using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::beans::XPropertySet; /** === end UNO using === **/ + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; //============================================================================== //= OColumnSettings @@ -65,7 +67,6 @@ namespace dbaccess OColumnSettings::OColumnSettings() :m_bHidden(sal_False) { - OSL_TRACE( "ColumnSettings: +%p", this ); DBG_CTOR( OColumnSettings, NULL ); } @@ -73,7 +74,6 @@ namespace dbaccess OColumnSettings::~OColumnSettings() { DBG_DTOR( OColumnSettings, NULL ); - OSL_TRACE( "ColumnSettings: -%p", this ); } // XUnoTunnel @@ -105,131 +105,35 @@ namespace dbaccess } //------------------------------------------------------------------------------ - void OColumnSettings::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const + void OColumnSettings::registerProperties( IPropertyContainer& _rPropertyContainer ) { - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - rValue = m_aAlignment; - break; - case PROPERTY_ID_NUMBERFORMAT: - rValue = m_aFormatKey; - break; - case PROPERTY_ID_RELATIVEPOSITION: - rValue = m_aRelativePosition; - break; - case PROPERTY_ID_WIDTH: - rValue = m_aWidth; - break; - case PROPERTY_ID_HIDDEN: - rValue.setValue(&m_bHidden, getBooleanCppuType()); - break; - case PROPERTY_ID_CONTROLMODEL: - rValue <<= m_xControlModel; - break; - case PROPERTY_ID_HELPTEXT: - rValue = m_aHelpText; - break; - case PROPERTY_ID_CONTROLDEFAULT: - rValue = m_aControlDefault; - break; - } + const sal_Int32 nBoundAttr = PropertyAttribute::BOUND; + const sal_Int32 nMayBeVoidAttr = PropertyAttribute::MAYBEVOID | nBoundAttr; + + const Type& rSalInt32Type = ::getCppuType( static_cast< sal_Int32* >( NULL ) ); + const Type& rStringType = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); + + _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_ALIGN, PROPERTY_ID_ALIGN, nMayBeVoidAttr, &m_aAlignment, rSalInt32Type ); + _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT, nMayBeVoidAttr, &m_aFormatKey, rSalInt32Type ); + _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION, nMayBeVoidAttr, &m_aRelativePosition, rSalInt32Type ); + _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_WIDTH, PROPERTY_ID_WIDTH, nMayBeVoidAttr, &m_aWidth, rSalInt32Type ); + _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT, nMayBeVoidAttr, &m_aHelpText, rStringType ); + _rPropertyContainer.registerMayBeVoidProperty( PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT, nMayBeVoidAttr, &m_aControlDefault, rStringType ); + _rPropertyContainer.registerProperty( PROPERTY_CONTROLMODEL, PROPERTY_ID_CONTROLMODEL, nBoundAttr, &m_xControlModel, ::getCppuType( &m_xControlModel ) ); + _rPropertyContainer.registerProperty( PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN, nBoundAttr, &m_bHidden, ::getCppuType( &m_bHidden ) ); } //------------------------------------------------------------------------------ - sal_Bool OColumnSettings::convertFastPropertyValue( Any& rConvertedValue, Any & rOldValue, sal_Int32 nHandle, - const Any& rValue ) throw (IllegalArgumentException) + bool OColumnSettings::isMine( const sal_Int32 _nPropertyHandle ) const { - sal_Bool bModified = sal_False; - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aAlignment, - ::getCppuType(static_cast< sal_Int32* >(NULL))); - break; - case PROPERTY_ID_WIDTH: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, - ::getCppuType(static_cast< sal_Int32* >(NULL))); - break; - case PROPERTY_ID_HIDDEN: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bHidden); - break; - case PROPERTY_ID_RELATIVEPOSITION: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aRelativePosition, - ::getCppuType(static_cast< sal_Int32* >(NULL))); - break; - case PROPERTY_ID_NUMBERFORMAT: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aFormatKey, - ::getCppuType(static_cast< sal_Int32* >(NULL))); - break; - case PROPERTY_ID_CONTROLMODEL: - { - Reference< XPropertySet > xTest; - if (!::cppu::extractInterface(xTest, rValue)) - throw IllegalArgumentException(); - if (xTest.get() != m_xControlModel.get()) - { - bModified = sal_True; - rOldValue <<= m_xControlModel; - rConvertedValue <<= rValue; - } - } - break; - case PROPERTY_ID_HELPTEXT: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aHelpText, - ::getCppuType(static_cast< ::rtl::OUString* >(NULL))); - break; - case PROPERTY_ID_CONTROLDEFAULT: - bModified = rValue != m_aControlDefault; - if ( bModified ) - { - rConvertedValue = rValue; - rOldValue = m_aControlDefault; - } - break; - } - return bModified; - } - - //------------------------------------------------------------------------------ - void OColumnSettings::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) - { - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - OSL_ENSURE(!rValue.hasValue() || rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OColumnSettings::setFastPropertyValue_NoBroadcast(ALIGN) : invalid value !"); - m_aAlignment = rValue; - break; - case PROPERTY_ID_WIDTH: - OSL_ENSURE(!rValue.hasValue() || rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OColumnSettings::setFastPropertyValue_NoBroadcast(WIDTH) : invalid value !"); - m_aWidth = rValue; - break; - case PROPERTY_ID_NUMBERFORMAT: - OSL_ENSURE(!rValue.hasValue() || rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OColumnSettings::setFastPropertyValue_NoBroadcast(NUMBERFORMAT) : invalid value !"); - m_aFormatKey = rValue; - break; - case PROPERTY_ID_RELATIVEPOSITION: - OSL_ENSURE(!rValue.hasValue() || rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OColumnSettings::setFastPropertyValue_NoBroadcast(ID_RELATIVEPOSITION) : invalid value !"); - m_aRelativePosition = rValue; - break; - case PROPERTY_ID_HIDDEN: - OSL_ENSURE(rValue.getValueType().equals(::getBooleanCppuType()), - "OColumnSettings::setFastPropertyValue_NoBroadcast(HIDDEN) : invalid value !"); - OSL_VERIFY( rValue >>= m_bHidden ); - break; - case PROPERTY_ID_HELPTEXT: - OSL_ENSURE(!rValue.hasValue() || rValue.getValueType().equals(::getCppuType(static_cast< ::rtl::OUString* >(NULL))), - "OColumnSettings::setFastPropertyValue_NoBroadcast(ID_RELATIVEPOSITION) : invalid value !"); - m_aHelpText = rValue; - break; - case PROPERTY_ID_CONTROLDEFAULT: - m_aControlDefault = rValue; - break; - } + return ( _nPropertyHandle == PROPERTY_ID_ALIGN ) + || ( _nPropertyHandle == PROPERTY_ID_NUMBERFORMAT ) + || ( _nPropertyHandle == PROPERTY_ID_RELATIVEPOSITION ) + || ( _nPropertyHandle == PROPERTY_ID_WIDTH ) + || ( _nPropertyHandle == PROPERTY_ID_HELPTEXT ) + || ( _nPropertyHandle == PROPERTY_ID_CONTROLDEFAULT ) + || ( _nPropertyHandle == PROPERTY_ID_CONTROLMODEL ) + || ( _nPropertyHandle == PROPERTY_ID_HIDDEN ); } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index f58e8b9b2..297f923ee 100644 --- a/dbaccess/source/core/api/definitioncolumn.cxx +++ b/dbaccess/source/core/api/definitioncolumn.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,34 +31,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBA_COREAPI_DEFINITIONSETTINGS_HXX_ +#include "apitools.hxx" +#include "dbastrings.hrc" #include "definitioncolumn.hxx" -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ -#include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ +#include "sdbcoretools.hxx" + +#include <com/sun/star/beans/PropertyAttribute.hpp> + #include <comphelper/property.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC -#include "dbastrings.hrc" -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ -#include "apitools.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX +#include <cppuhelper/typeprovider.hxx> #include <tools/debug.hxx> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ -#include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef DBACORE_SDBCORETOOLS_HXX -#include "sdbcoretools.hxx" -#endif - +#include <tools/diagnose_ex.h> using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; @@ -79,7 +63,29 @@ using namespace dbaccess; //============================================================ IMPLEMENT_FORWARD_XINTERFACE2(OTableColumnDescriptor,OColumn,TXChild) -// com::sun::star::lang::XTypeProvider +//------------------------------------------------------------------------------ +void OTableColumnDescriptor::impl_registerProperties( const bool _bActAsDescriptor ) +{ + sal_Int32 nDefaultAttr = _bActAsDescriptor ? 0 : PropertyAttribute::READONLY; + + registerProperty( PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, nDefaultAttr, &m_aTypeName, ::getCppuType( &m_aTypeName ) ); + registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, nDefaultAttr, &m_aDescription, ::getCppuType( &m_aDescription ) ); + registerProperty( PROPERTY_DEFAULTVALUE, PROPERTY_ID_DEFAULTVALUE, nDefaultAttr, &m_aDefaultValue, ::getCppuType( &m_aDefaultValue ) ); + + if ( _bActAsDescriptor ) + registerProperty( PROPERTY_AUTOINCREMENTCREATION, PROPERTY_ID_AUTOINCREMENTCREATION, nDefaultAttr, &m_aAutoIncrementValue, ::getCppuType( &m_aAutoIncrementValue ) ); + + registerProperty( PROPERTY_TYPE, PROPERTY_ID_TYPE, nDefaultAttr, &m_nType, ::getCppuType( &m_nType ) ); + registerProperty( PROPERTY_PRECISION, PROPERTY_ID_PRECISION, nDefaultAttr, &m_nPrecision, ::getCppuType( &m_nPrecision ) ); + registerProperty( PROPERTY_SCALE, PROPERTY_ID_SCALE, nDefaultAttr, &m_nScale, ::getCppuType( &m_nScale ) ); + registerProperty( PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, nDefaultAttr, &m_nIsNullable, ::getCppuType( &m_nIsNullable ) ); + registerProperty( PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, nDefaultAttr, &m_bAutoIncrement, ::getCppuType( &m_bAutoIncrement ) ); + registerProperty( PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, nDefaultAttr, &m_bRowVersion, ::getCppuType( &m_bRowVersion ) ); + registerProperty( PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, nDefaultAttr, &m_bCurrency, ::getCppuType( &m_bCurrency ) ); + + OColumnSettings::registerProperties( *this ); +} + //-------------------------------------------------------------------------- Sequence< sal_Int8 > OTableColumnDescriptor::getImplementationId() throw (RuntimeException) { @@ -116,28 +122,9 @@ Sequence< ::rtl::OUString > OTableColumnDescriptor::getSupportedServiceNames( ) //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* OTableColumnDescriptor::createArrayHelper( ) const { - BEGIN_PROPERTY_HELPER(20) - DECL_PROP2(ALIGN, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP1(AUTOINCREMENTCREATION,::rtl::OUString, MAYBEVOID); - DECL_PROP2(CONTROLDEFAULT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_IFACE(CONTROLMODEL, XPropertySet, BOUND ); - DECL_PROP0(DEFAULTVALUE, ::rtl::OUString ); - DECL_PROP0(DESCRIPTION, ::rtl::OUString ); - DECL_PROP2(NUMBERFORMAT, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP2(HELPTEXT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_BOOL(HIDDEN, BOUND); - DECL_PROP0_BOOL(ISAUTOINCREMENT ); - DECL_PROP0_BOOL(ISCURRENCY ); - DECL_PROP0(ISNULLABLE, sal_Int32 ); - DECL_PROP0_BOOL(ISROWVERSION ); - DECL_PROP0(NAME, ::rtl::OUString ); - DECL_PROP0(PRECISION, sal_Int32 ); - DECL_PROP2(RELATIVEPOSITION, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP0(SCALE, sal_Int32 ); - DECL_PROP0(TYPE, sal_Int32 ); - DECL_PROP0(TYPENAME, ::rtl::OUString ); - DECL_PROP2(WIDTH, sal_Int32, BOUND, MAYBEVOID); - END_PROPERTY_HELPER(); + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); } // cppu::OPropertySetHelper @@ -148,159 +135,10 @@ Sequence< ::rtl::OUString > OTableColumnDescriptor::getSupportedServiceNames( ) } //------------------------------------------------------------------------------ -void OTableColumnDescriptor::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +void OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) { - switch (nHandle) - { - case PROPERTY_ID_TYPE: - rValue <<= m_nType; - break; - case PROPERTY_ID_PRECISION: - rValue <<= m_nPrecision; - break; - case PROPERTY_ID_SCALE: - rValue <<= m_nScale; - break; - case PROPERTY_ID_ISNULLABLE: - rValue <<= m_nIsNullable; - break; - case PROPERTY_ID_TYPENAME: - rValue <<= m_aTypeName; - break; - case PROPERTY_ID_DESCRIPTION: - rValue <<= m_aDescription; - break; - case PROPERTY_ID_DEFAULTVALUE: - rValue <<= m_aDefaultValue; - break; - case PROPERTY_ID_AUTOINCREMENTCREATION: - rValue <<= m_aAutoIncrementValue; - break; - case PROPERTY_ID_ISAUTOINCREMENT: - { - sal_Bool bVal = m_bAutoIncrement; - rValue.setValue(&bVal, getBooleanCppuType()); - } break; - case PROPERTY_ID_ISCURRENCY: - { - sal_Bool bVal = m_bCurrency; - rValue.setValue(&bVal, getBooleanCppuType()); - } break; - case PROPERTY_ID_ISROWVERSION: - { - sal_Bool bVal = m_bRowVersion; - rValue.setValue(&bVal, getBooleanCppuType()); - } break; - case PROPERTY_ID_NAME: - OColumn::getFastPropertyValue( rValue, nHandle ); - break; - default: - OColumnSettings::getFastPropertyValue( rValue, nHandle ); - } -} - -//------------------------------------------------------------------------------ -sal_Bool OTableColumnDescriptor::convertFastPropertyValue( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) - throw (IllegalArgumentException) -{ - sal_Bool bModified = sal_False; - switch (nHandle) - { - case PROPERTY_ID_TYPE: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nType); - break; - case PROPERTY_ID_PRECISION: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nPrecision); - break; - case PROPERTY_ID_SCALE: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nScale); - break; - case PROPERTY_ID_ISNULLABLE: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nIsNullable); - break; - case PROPERTY_ID_TYPENAME: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTypeName); - break; - case PROPERTY_ID_DESCRIPTION: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDescription); - break; - case PROPERTY_ID_DEFAULTVALUE: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefaultValue); - break; - case PROPERTY_ID_AUTOINCREMENTCREATION: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aAutoIncrementValue); - break; - case PROPERTY_ID_ISAUTOINCREMENT: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAutoIncrement); - break; - case PROPERTY_ID_ISCURRENCY: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bCurrency); - break; - case PROPERTY_ID_ISROWVERSION: - bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bRowVersion); - break; - case PROPERTY_ID_NAME: - bModified = OColumn::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - break; - default: - bModified = OColumnSettings::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - } - return bModified; -} - -//------------------------------------------------------------------------------ -void OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& rValue - ) - throw (Exception) -{ - switch (nHandle) - { - case PROPERTY_ID_TYPE: - OSL_VERIFY( rValue >>= m_nType ); - break; - case PROPERTY_ID_PRECISION: - OSL_VERIFY( rValue >>= m_nPrecision ); - break; - case PROPERTY_ID_SCALE: - OSL_VERIFY( rValue >>= m_nScale ); - break; - case PROPERTY_ID_ISNULLABLE: - OSL_VERIFY( rValue >>= m_nIsNullable ); - break; - case PROPERTY_ID_TYPENAME: - OSL_VERIFY( rValue >>= m_aTypeName ); - break; - case PROPERTY_ID_DESCRIPTION: - OSL_VERIFY( rValue >>= m_aDescription ); - break; - case PROPERTY_ID_DEFAULTVALUE: - OSL_VERIFY( rValue >>= m_aDefaultValue ); - break; - case PROPERTY_ID_AUTOINCREMENTCREATION: - OSL_VERIFY( rValue >>= m_aAutoIncrementValue ); - break; - case PROPERTY_ID_ISAUTOINCREMENT: - OSL_VERIFY( rValue >>= m_bAutoIncrement ); - break; - case PROPERTY_ID_ISCURRENCY: - OSL_VERIFY( rValue >>= m_bCurrency ); - break; - case PROPERTY_ID_ISROWVERSION: - OSL_VERIFY( rValue >>= m_bRowVersion ); - break; - case PROPERTY_ID_NAME: - OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - break; - default: - OColumnSettings::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - } - ::dbaccess::notifyDataSourceModified(m_xParent,sal_True); + OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + ::dbaccess::notifyDataSourceModified( m_xParent, sal_True ); } // ----------------------------------------------------------------------------- @@ -328,13 +166,18 @@ void SAL_CALL OTableColumnDescriptor::setParent( const Reference< XInterface >& //= OTableColumn //============================================================ DBG_NAME(OTableColumn); -OTableColumn::OTableColumn(const ::rtl::OUString& _rName) + +// ------------------------------------------------------------------------- +OTableColumn::OTableColumn( const ::rtl::OUString& _rName ) + :OTableColumnDescriptor( false ) { DBG_CTOR(OTableColumn,NULL); m_sName = _rName; } + // ------------------------------------------------------------------------- -OTableColumn::OTableColumn(const Reference<XPropertySet>& _xColumn) +OTableColumn::OTableColumn(const Reference<XPropertySet>& _xColumn) + :OTableColumnDescriptor( false ) { DBG_CTOR(OTableColumn,NULL); @@ -365,16 +208,14 @@ OTableColumn::OTableColumn(const Reference<XPropertySet>& _xColumn) { PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION }, { PROPERTY_ALIGN, PROPERTY_ID_ALIGN }, { PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT }, - { PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT } + { PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT }, + { PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN } }; for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i ) { if ( xPSI->hasPropertyByName( aProps[i].sName ) ) - OColumnSettings::setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _xColumn->getPropertyValue( aProps[i].sName ) ); + OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _xColumn->getPropertyValue( aProps[i].sName ) ); } - - if ( xPSI->hasPropertyByName( PROPERTY_HIDDEN ) ) - OColumnSettings::setFastPropertyValue_NoBroadcast( PROPERTY_ID_HIDDEN, _xColumn->getPropertyValue( PROPERTY_HIDDEN ) ); } // ----------------------------------------------------------------------------- @@ -426,27 +267,7 @@ Sequence< ::rtl::OUString > OTableColumn::getSupportedServiceNames( ) throw (Ru //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const { - BEGIN_PROPERTY_HELPER(19) - DECL_PROP2(ALIGN, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP2(CONTROLDEFAULT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_IFACE(CONTROLMODEL, XPropertySet , BOUND); - DECL_PROP1(DEFAULTVALUE, ::rtl::OUString, READONLY); - DECL_PROP1(DESCRIPTION, ::rtl::OUString, READONLY); - DECL_PROP2(NUMBERFORMAT, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP2(HELPTEXT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_BOOL(HIDDEN, BOUND); - DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY); - DECL_PROP1_BOOL(ISCURRENCY, READONLY); - DECL_PROP1(ISNULLABLE, sal_Int32, READONLY); - DECL_PROP1_BOOL(ISROWVERSION, READONLY); - DECL_PROP1(NAME, ::rtl::OUString, READONLY); - DECL_PROP1(PRECISION, sal_Int32, READONLY); - DECL_PROP2(RELATIVEPOSITION, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP1(SCALE, sal_Int32, READONLY); - DECL_PROP1(TYPE, sal_Int32, READONLY); - DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY); - DECL_PROP2(WIDTH, sal_Int32, BOUND, MAYBEVOID); - END_PROPERTY_HELPER(); + return OTableColumnDescriptor::createArrayHelper(); } //============================================================ @@ -454,29 +275,24 @@ Sequence< ::rtl::OUString > OTableColumn::getSupportedServiceNames( ) throw (Ru //============================================================ DBG_NAME(OColumnWrapper); //-------------------------------------------------------------------------- -OColumnWrapper::OColumnWrapper(const Reference< XPropertySet > & rCol) - :m_xAggregate(rCol) - ,m_nColTypeID(-1) +OColumnWrapper::OColumnWrapper( const Reference< XPropertySet > & rCol, const bool _bNameIsReadOnly ) + :OColumn( _bNameIsReadOnly ) + ,m_xAggregate(rCol) + ,m_nColTypeID(-1) { DBG_CTOR(OColumnWrapper,NULL); - // which type of aggregate property do we have - if (m_nColTypeID == -1) + // which type of aggregate property do we have? + // we distingish the properties by the containment of optional properties + m_nColTypeID = 0; + if ( m_xAggregate.is() ) { - // we distingish the properties by the containment of optional properties, these are: - // Description 0x0001 - // Hidden 0x0002 - // IsRowVersion 0x0004 - m_nColTypeID = 0; - if ( m_xAggregate.is() ) - { - Reference <XPropertySetInfo > xInfo(m_xAggregate->getPropertySetInfo()); - m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DESCRIPTION) ? HAS_DESCRIPTION : 0; - m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) ? HAS_DEFAULTVALUE : 0; - m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_ISROWVERSION) ? HAS_ROWVERSION : 0; - m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) ? HAS_AUTOINCREMENT_CREATION : 0; + Reference <XPropertySetInfo > xInfo(m_xAggregate->getPropertySetInfo()); + m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DESCRIPTION) ? HAS_DESCRIPTION : 0; + m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) ? HAS_DEFAULTVALUE : 0; + m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_ISROWVERSION) ? HAS_ROWVERSION : 0; + m_nColTypeID |= xInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) ? HAS_AUTOINCREMENT_CREATION : 0; - m_xAggregate->getPropertyValue(PROPERTY_NAME) >>= m_sName; - } + m_xAggregate->getPropertyValue(PROPERTY_NAME) >>= m_sName; } } // ----------------------------------------------------------------------------- @@ -486,59 +302,65 @@ OColumnWrapper::~OColumnWrapper() } //------------------------------------------------------------------------------ +::rtl::OUString OColumnWrapper::impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const +{ + ::rtl::OUString sPropName; + sal_Int16 nAttributes( 0 ); + const_cast< OColumnWrapper* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle ); + OSL_ENSURE( sPropName.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" ); + return sPropName; +} + +//------------------------------------------------------------------------------ void OColumnWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const { - switch (nHandle) + // derived classes are free to either use the OPropertyContainer(Helper) mechanisms for properties, + // or to declare additional properties which are to be forwarded to the wrapped object. So we need + // to distinguish those cases. + if ( OColumn::isRegisteredProperty( nHandle ) ) { - case PROPERTY_ID_NAME: - rValue <<= m_sName; - break; - default: - { - // get the property name - ::rtl::OUString aPropName; - sal_Int16 nAttributes; - const_cast<OColumnWrapper*>(this)->getInfoHelper(). - fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle); - OSL_ENSURE(aPropName.getLength(), "property not found?"); - - // now read the value - rValue = m_xAggregate->getPropertyValue(aPropName); - } + OColumn::getFastPropertyValue( rValue, nHandle ); + } + else + { + rValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) ); } } //------------------------------------------------------------------------------ -sal_Bool OColumnWrapper::convertFastPropertyValue( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) - throw (IllegalArgumentException) +sal_Bool OColumnWrapper::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, + const Any& rValue ) throw (IllegalArgumentException) { - // used for the name - sal_Bool bModified = OColumn::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - - // get the property name - ::rtl::OUString aPropName; - sal_Int16 nAttributes; - getInfoHelper().fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle); - OSL_ENSURE(aPropName.getLength(), "property not found?"); - - // now read the value - m_xAggregate->setPropertyValue(aPropName, rValue); + sal_Bool bModified( sal_False ); + if ( OColumn::isRegisteredProperty( nHandle ) ) + { + bModified = OColumn::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); + } + else + { + getFastPropertyValue( rOldValue, nHandle ); + if ( rOldValue != rValue ) + { + rConvertedValue = rValue; + bModified = sal_True; + } + } return bModified; } //------------------------------------------------------------------------------ -void OColumnWrapper::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& rValue - ) - throw (Exception) +void OColumnWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) { - OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + if ( OColumn::isRegisteredProperty( nHandle ) ) + { + OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + } + else + { + m_xAggregate->setPropertyValue( impl_getPropertyNameFromHandle( nHandle ), rValue ); + } } + // ----------------------------------------------------------------------------- sal_Int64 SAL_CALL OColumnWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException) { @@ -551,9 +373,20 @@ sal_Int64 SAL_CALL OColumnWrapper::getSomething( const Sequence< sal_Int8 >& aId } return nRet; } + //============================================================ //= OTableColumnDescriptorWrapper //============================================================ +//-------------------------------------------------------------------------- +OTableColumnDescriptorWrapper::OTableColumnDescriptorWrapper( const Reference< XPropertySet >& _rCol, const bool _bPureWrap, const bool _bIsDescriptor ) + :OColumnWrapper( _rCol, !_bIsDescriptor ) + ,m_bPureWrap( _bPureWrap ) + ,m_bIsDescriptor( _bIsDescriptor ) +{ + // let the ColumnSettings register its properties + OColumnSettings::registerProperties( *this ); +} + // com::sun::star::lang::XTypeProvider //-------------------------------------------------------------------------- Sequence< sal_Int8 > OTableColumnDescriptorWrapper::getImplementationId() throw (RuntimeException) @@ -600,61 +433,68 @@ sal_Int64 SAL_CALL OTableColumnDescriptorWrapper::getSomething( const Sequence< //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* OTableColumnDescriptorWrapper::createArrayHelper( sal_Int32 nId ) const { - // BEGIN_PROPERTY_HELPER(17) - sal_Int32 nPropertyCount = 16; - // How many properties do we have? + const sal_Int32 nHaveAlways = 7; + // Which optional properties are contained? + sal_Int32 nHaveOptionally = 0; if (nId & HAS_DESCRIPTION) - ++nPropertyCount; + ++nHaveOptionally; if (nId & HAS_DEFAULTVALUE) - ++nPropertyCount; + ++nHaveOptionally; if (nId & HAS_ROWVERSION) - ++nPropertyCount; + ++nHaveOptionally; if ( nId & HAS_AUTOINCREMENT_CREATION ) - ++nPropertyCount; + ++nHaveOptionally; - Sequence< Property> aDescriptor(nPropertyCount); - Property* pDesc = aDescriptor.getArray(); + const sal_Int32 nPropertyCount( nHaveAlways + nHaveOptionally ); + Sequence< Property > aTableDescProperties( nPropertyCount ); + Property* pDesc = aTableDescProperties.getArray(); sal_Int32 nPos = 0; - // Description, Defaultvalue, IsRowVersion - DECL_PROP2(ALIGN, sal_Int32, BOUND,MAYBEVOID); - if ( nId & HAS_AUTOINCREMENT_CREATION ) - { - DECL_PROP1(AUTOINCREMENTCREATION,::rtl::OUString, MAYBEVOID); - } - DECL_PROP2(CONTROLDEFAULT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_IFACE(CONTROLMODEL, XPropertySet, BOUND ); - if (nId & HAS_DEFAULTVALUE) - { - DECL_PROP0(DEFAULTVALUE, ::rtl::OUString ); - } + DECL_PROP0_BOOL( ISAUTOINCREMENT ); + DECL_PROP0_BOOL( ISCURRENCY ); + DECL_PROP0( ISNULLABLE, sal_Int32 ); + DECL_PROP0( PRECISION, sal_Int32 ); + DECL_PROP0( SCALE, sal_Int32 ); + DECL_PROP0( TYPE, sal_Int32 ); + DECL_PROP0( TYPENAME, ::rtl::OUString ); - if (nId & HAS_DESCRIPTION) - { - DECL_PROP0(DESCRIPTION, ::rtl::OUString ); - } + if ( nId & HAS_AUTOINCREMENT_CREATION ) + { + DECL_PROP1( AUTOINCREMENTCREATION, ::rtl::OUString, MAYBEVOID ); + } + if ( nId & HAS_DEFAULTVALUE ) + { + DECL_PROP0( DEFAULTVALUE, ::rtl::OUString ); + } + if ( nId & HAS_DESCRIPTION ) + { + DECL_PROP0( DESCRIPTION, ::rtl::OUString ); + } + if ( nId & HAS_ROWVERSION ) + { + DECL_PROP0_BOOL( ISROWVERSION ); + } - DECL_PROP2(NUMBERFORMAT, sal_Int32, BOUND,MAYBEVOID); - DECL_PROP2(HELPTEXT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_BOOL(HIDDEN, BOUND); - DECL_PROP0_BOOL(ISAUTOINCREMENT ); - DECL_PROP0_BOOL(ISCURRENCY ); - DECL_PROP0(ISNULLABLE, sal_Int32 ); + OSL_ENSURE( nPos == nPropertyCount, "OTableColumnDescriptorWrapper::createArrayHelper: something went wrong!" ); - if (nId & HAS_ROWVERSION) + if ( !m_bIsDescriptor ) + { + for ( Property* prop = aTableDescProperties.getArray(); + prop != aTableDescProperties.getArray() + aTableDescProperties.getLength(); + ++prop + ) { - DECL_PROP0_BOOL(ISROWVERSION ); + prop->Attributes |= PropertyAttribute::READONLY; } + } - DECL_PROP0(NAME, ::rtl::OUString ); - DECL_PROP0(PRECISION, sal_Int32 ); - DECL_PROP2(RELATIVEPOSITION, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP0(SCALE, sal_Int32 ); - DECL_PROP0(TYPE, sal_Int32 ); - DECL_PROP0(TYPENAME, ::rtl::OUString ); - DECL_PROP1(WIDTH, sal_Int32, MAYBEVOID); - END_PROPERTY_HELPER(); + // finally also describe the properties which are maintained by our base class, in particular the OPropertyContainerHelper + Sequence< Property > aBaseProperties; + describeProperties( aBaseProperties ); + + Sequence< Property > aAllProperties( ::comphelper::concatSequences( aTableDescProperties, aBaseProperties ) ); + return new ::cppu::OPropertyArrayHelper( aAllProperties, sal_False ); } // cppu::OPropertySetHelper @@ -669,75 +509,36 @@ void OTableColumnDescriptorWrapper::getFastPropertyValue( Any& rValue, sal_Int32 { if ( m_bPureWrap ) { - // get the property name - ::rtl::OUString aPropName; - sal_Int16 nAttributes; - const_cast<OTableColumnDescriptorWrapper*>(this)->getInfoHelper(). - fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle); - OSL_ENSURE(aPropName.getLength(), "property not found?"); - - // now read the value - rValue = m_xAggregate->getPropertyValue(aPropName); + rValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) ); } else { - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - OColumnSettings::getFastPropertyValue( rValue, nHandle ); - break; - default: - { - // get the property name - ::rtl::OUString aPropName; - sal_Int16 nAttributes; - const_cast<OTableColumnDescriptorWrapper*>(this)->getInfoHelper(). - fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle); - OSL_ENSURE(aPropName.getLength(), "property not found?"); - - // now read the value - rValue = m_xAggregate->getPropertyValue(aPropName); - } - } + OColumnWrapper::getFastPropertyValue( rValue, nHandle ); } } //------------------------------------------------------------------------------ -sal_Bool OTableColumnDescriptorWrapper::convertFastPropertyValue( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) - throw (IllegalArgumentException) +sal_Bool OTableColumnDescriptorWrapper::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException) { sal_Bool bModified(sal_False); if ( m_bPureWrap ) - bModified = OColumnWrapper::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - else { - switch (nHandle) + // do not delegate to OColumnWrapper: It would, for the properties which were registered with registerProperty, + // ask the OPropertyContainer base class, which is not what we want here. + // TODO: the whole "m_bPureWrap"-thingie is strange. We should have a dedicated class doing this wrapping, + // not a class which normally serves other purposes, and only sometimes does a "pure wrap". It makes the + // code unnecessarily hard to maintain, and error prone. + rOldValue = m_xAggregate->getPropertyValue( impl_getPropertyNameFromHandle( nHandle ) ); + if ( rOldValue != rValue ) { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - bModified = OColumnSettings::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); - break; - default: - bModified = OColumnWrapper::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); + rConvertedValue = rValue; + bModified = sal_True; } } + else + { + bModified = OColumnWrapper::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue ); + } return bModified; } @@ -749,24 +550,12 @@ void OTableColumnDescriptorWrapper::setFastPropertyValue_NoBroadcast( throw (Exception) { if ( m_bPureWrap ) - OColumnWrapper::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + { + m_xAggregate->setPropertyValue( impl_getPropertyNameFromHandle( nHandle ), rValue ); + } else { - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - case PROPERTY_ID_NUMBERFORMAT: - case PROPERTY_ID_RELATIVEPOSITION: - case PROPERTY_ID_WIDTH: - case PROPERTY_ID_HIDDEN: - case PROPERTY_ID_CONTROLMODEL: - case PROPERTY_ID_HELPTEXT: - case PROPERTY_ID_CONTROLDEFAULT: - OColumnSettings::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - break; - default: - OColumnWrapper::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - } + OColumnWrapper::setFastPropertyValue_NoBroadcast( nHandle, rValue ); } } @@ -774,24 +563,23 @@ void OTableColumnDescriptorWrapper::setFastPropertyValue_NoBroadcast( //= OTableColumnWrapper //============================================================ //-------------------------------------------------------------------------- -OTableColumnWrapper::OTableColumnWrapper(const Reference< XPropertySet >& rCol - ,const Reference< XPropertySet >& _xColDefintion - ,sal_Bool _bPureWrap) - :OTableColumnDescriptorWrapper(rCol,_bPureWrap) +OTableColumnWrapper::OTableColumnWrapper( const Reference< XPropertySet >& rCol, const Reference< XPropertySet >& _xColDefintion, + bool _bPureWrap ) + :OTableColumnDescriptorWrapper( rCol, _bPureWrap, false ) { - osl_incrementInterlockedCount(&m_refCount); + osl_incrementInterlockedCount( &m_refCount ); if ( _xColDefintion.is() ) { try { - ::comphelper::copyProperties(_xColDefintion,this); + ::comphelper::copyProperties( _xColDefintion, this ); } - catch(Exception&) + catch( const Exception& ) { - OSL_ENSURE(sal_False, "OTableColumnWrapper::OTableColumnWrapper: caught an exception!"); + DBG_UNHANDLED_EXCEPTION(); } } - osl_decrementInterlockedCount(&m_refCount); + osl_decrementInterlockedCount( &m_refCount ); } //-------------------------------------------------------------------------- @@ -815,11 +603,12 @@ Sequence< sal_Int8 > OTableColumnWrapper::getImplementationId() throw (RuntimeEx } return pId->getImplementationId(); } + // ::com::sun::star::lang::XServiceInfo //------------------------------------------------------------------------------ rtl::OUString OTableColumnWrapper::getImplementationName( ) throw (RuntimeException) { - return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumnWrapper"); + return rtl::OUString::createFromAscii( "com.sun.star.sdb.OTableColumnWrapper" ); } //------------------------------------------------------------------------------ @@ -841,206 +630,6 @@ Sequence< ::rtl::OUString > OTableColumnWrapper::getSupportedServiceNames( ) th //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper* OTableColumnWrapper::createArrayHelper( sal_Int32 nId ) const { - // BEGIN_PROPERTY_HELPER(17) - sal_Int32 nPropertyCount = 16; - // How many properties do we have? - // Which optional properties are contained? - if (nId & HAS_DESCRIPTION) - nPropertyCount++; - if (nId & HAS_DEFAULTVALUE) - nPropertyCount++; - if (nId & HAS_ROWVERSION) - nPropertyCount++; - if ( nId & HAS_AUTOINCREMENT_CREATION ) - ++nPropertyCount; - - Sequence< Property> aDescriptor(nPropertyCount); - Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - - // Description, Defaultvalue, IsRowVersion - DECL_PROP2(ALIGN, sal_Int32, BOUND, MAYBEVOID); - if ( nId & HAS_AUTOINCREMENT_CREATION ) - { - DECL_PROP1(AUTOINCREMENTCREATION,::rtl::OUString, MAYBEVOID); - } - DECL_PROP2(CONTROLDEFAULT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_IFACE(CONTROLMODEL, XPropertySet , BOUND); - if (nId & HAS_DEFAULTVALUE) - { - DECL_PROP1(DEFAULTVALUE, ::rtl::OUString, READONLY); - } - - if (nId & HAS_DESCRIPTION) - { - DECL_PROP1(DESCRIPTION, ::rtl::OUString, READONLY); - } - - DECL_PROP2(NUMBERFORMAT, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP2(HELPTEXT, ::rtl::OUString, BOUND,MAYBEVOID); - DECL_PROP1_BOOL(HIDDEN, BOUND); - DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY); - DECL_PROP1_BOOL(ISCURRENCY, READONLY); - - DECL_PROP1(ISNULLABLE, sal_Int32, READONLY); - - if (nId & HAS_ROWVERSION) - { - DECL_PROP1_BOOL(ISROWVERSION, READONLY); - } - - DECL_PROP1(NAME, ::rtl::OUString, READONLY); - DECL_PROP1(PRECISION, sal_Int32, READONLY); - DECL_PROP2(RELATIVEPOSITION, sal_Int32, BOUND, MAYBEVOID); - DECL_PROP1(SCALE, sal_Int32, READONLY); - DECL_PROP1(TYPE, sal_Int32, READONLY); - DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY); - DECL_PROP2(WIDTH, sal_Int32, BOUND, MAYBEVOID); - END_PROPERTY_HELPER(); -} - -//============================================================ -//= OIndexColumnWrapper -//============================================================ -// com::sun::star::lang::XTypeProvider -//-------------------------------------------------------------------------- -Sequence< sal_Int8 > OIndexColumnWrapper::getImplementationId() throw (RuntimeException) -{ - static OImplementationId * pId = 0; - if (! pId) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! pId) - { - static OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} -// ::com::sun::star::lang::XServiceInfo -//------------------------------------------------------------------------------ -rtl::OUString OIndexColumnWrapper::getImplementationName( ) throw (RuntimeException) -{ - return rtl::OUString::createFromAscii("com.sun.star.sdb.OIndexColumnWrapper"); -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > OIndexColumnWrapper::getSupportedServiceNames( ) throw (RuntimeException) -{ - Sequence< ::rtl::OUString > aSNS( 2 ); - aSNS[0] = SERVICE_SDBCX_COLUMN; - aSNS[1] = SERVICE_SDBCX_INDEXCOLUMN; - return aSNS; -} - -//------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper& OIndexColumnWrapper::getInfoHelper() -{ - return *static_cast< OPropertyArrayUsageHelper< OIndexColumnWrapper >* >(this)->getArrayHelper(); + return OTableColumnDescriptorWrapper::createArrayHelper( nId ); } -// comphelper::OPropertyArrayUsageHelper -//------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper* OIndexColumnWrapper::createArrayHelper() const -{ - BEGIN_PROPERTY_HELPER(9) - DECL_PROP1_BOOL(ISASCENDING, READONLY); - DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY); - DECL_PROP1_BOOL(ISCURRENCY, READONLY); - DECL_PROP1(ISNULLABLE, sal_Int32, READONLY); - DECL_PROP1(NAME, ::rtl::OUString, READONLY); - DECL_PROP1(PRECISION, sal_Int32, READONLY); - DECL_PROP1(SCALE, sal_Int32, READONLY); - DECL_PROP1(TYPE, sal_Int32, READONLY); - DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY); - END_PROPERTY_HELPER(); -} - -//------------------------------------------------------------------------------ -void OIndexColumnWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const -{ - switch (nHandle) - { - case PROPERTY_ID_ISASCENDING: - { - sal_Bool bVal = m_bAscending; - rValue.setValue(&bVal, getBooleanCppuType()); - } break; - default: - OColumnWrapper::getFastPropertyValue( rValue, nHandle ); - } -} - -//============================================================ -//= OKeyColumnWrapper -//============================================================ -// com::sun::star::lang::XTypeProvider -//-------------------------------------------------------------------------- -Sequence< sal_Int8 > OKeyColumnWrapper::getImplementationId() throw (RuntimeException) -{ - static OImplementationId * pId = 0; - if (! pId) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! pId) - { - static OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} -// ::com::sun::star::lang::XServiceInfo -//------------------------------------------------------------------------------ -rtl::OUString OKeyColumnWrapper::getImplementationName( ) throw (RuntimeException) -{ - return rtl::OUString::createFromAscii("com.sun.star.sdb.OIndexColumnWrapper"); -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > OKeyColumnWrapper::getSupportedServiceNames( ) throw (RuntimeException) -{ - Sequence< ::rtl::OUString > aSNS( 2 ); - aSNS[0] = SERVICE_SDBCX_COLUMN; - aSNS[1] = SERVICE_SDBCX_KEYCOLUMN; - return aSNS; -} - -//------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper& OKeyColumnWrapper::getInfoHelper() -{ - return *static_cast< OPropertyArrayUsageHelper< OKeyColumnWrapper >* >(this)->getArrayHelper(); -} - -// comphelper::OPropertyArrayUsageHelper -//------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper* OKeyColumnWrapper::createArrayHelper() const -{ - BEGIN_PROPERTY_HELPER(9) - DECL_PROP1_BOOL(ISAUTOINCREMENT, READONLY); - DECL_PROP1_BOOL(ISCURRENCY, READONLY); - DECL_PROP1(ISNULLABLE, sal_Int32, READONLY); - DECL_PROP1(NAME, ::rtl::OUString, READONLY); - DECL_PROP1(PRECISION, sal_Int32, READONLY); - DECL_PROP1(RELATEDCOLUMN, ::rtl::OUString, READONLY); - DECL_PROP1(SCALE, sal_Int32, READONLY); - DECL_PROP1(TYPE, sal_Int32, READONLY); - DECL_PROP1(TYPENAME, ::rtl::OUString, READONLY); - END_PROPERTY_HELPER(); -} - -//------------------------------------------------------------------------------ -void OKeyColumnWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const -{ - switch (nHandle) - { - case PROPERTY_ID_RELATEDCOLUMN: - rValue <<= m_aRelatedColumn; - break; - default: - OColumnWrapper::getFastPropertyValue( rValue, nHandle ); - } -} - - diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx index 8f0d96082..0b20f5cc2 100644 --- a/dbaccess/source/core/api/preparedstatement.cxx +++ b/dbaccess/source/core/api/preparedstatement.cxx @@ -30,39 +30,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBA_COREAPI_PREPAREDSTATEMENT_HXX_ -#include <preparedstatement.hxx> -#endif -#ifndef _DBA_COREAPI_RESULTSET_HXX_ -#include <resultset.hxx> -#endif -#ifndef _DBA_COREAPI_RESULTCOLUMN_HXX_ -#include <resultcolumn.hxx> -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC + #include "dbastrings.hrc" -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ + #include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ + +#include <comphelper/property.hxx> #include <comphelper/sequence.hxx> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ #include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ -#include <comphelper/property.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX //autogen +#include <preparedstatement.hxx> +#include <resultcolumn.hxx> +#include <resultset.hxx> #include <tools/debug.hxx> -#endif +#include <tools/diagnose_ex.h> using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; @@ -203,27 +185,23 @@ Reference< ::com::sun::star::container::XNameAccess > OPreparedStatement::getCol { try { - // get the metadata - Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xAggregateAsSet, UNO_QUERY)->getMetaData(); - // do we have columns - if ( xMetaData.is() ) + Reference< XResultSetMetaDataSupplier > xSuppMeta( m_xAggregateAsSet, UNO_QUERY_THROW ); + Reference< XResultSetMetaData > xMetaData( xSuppMeta->getMetaData(), UNO_SET_THROW ); + + Reference< XConnection > xConn( getConnection(), UNO_SET_THROW ); + Reference< XDatabaseMetaData > xDBMeta( xConn->getMetaData(), UNO_SET_THROW ); + + for (sal_Int32 i = 0, nCount = xMetaData->getColumnCount(); i < nCount; ++i) { - Reference< XDatabaseMetaData > xDBMeta; - Reference< XConnection > xConn( getConnection() ); - if ( xConn.is() ) - xDBMeta = xConn->getMetaData(); - - for (sal_Int32 i = 0, nCount = xMetaData->getColumnCount(); i < nCount; ++i) - { - // retrieve the name of the column - rtl::OUString aName = xMetaData->getColumnName(i + 1); - OResultColumn* pColumn = new OResultColumn(xMetaData, i + 1, xDBMeta); - m_pColumns->append(aName, pColumn); - } + // retrieve the name of the column + rtl::OUString aName = xMetaData->getColumnName(i + 1); + OResultColumn* pColumn = new OResultColumn(xMetaData, i + 1, xDBMeta); + m_pColumns->append(aName, pColumn); } } - catch (SQLException) + catch (const SQLException& ) { + DBG_UNHANDLED_EXCEPTION(); } m_pColumns->setInitialized(); } @@ -236,7 +214,7 @@ Reference< XResultSetMetaData > OPreparedStatement::getMetaData(void) throw( SQL { MutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); - return Reference< XResultSetMetaDataSupplier >(m_xAggregateAsSet, UNO_QUERY)->getMetaData(); + return Reference< XResultSetMetaDataSupplier >( m_xAggregateAsSet, UNO_QUERY_THROW )->getMetaData(); } // XPreparedStatement @@ -249,7 +227,7 @@ Reference< XResultSet > OPreparedStatement::executeQuery() throw( SQLException, disposeResultSet(); Reference< XResultSet > xResultSet; - Reference< XResultSet > xDrvResultSet = Reference< XPreparedStatement >(m_xAggregateAsSet, UNO_QUERY)->executeQuery(); + Reference< XResultSet > xDrvResultSet = Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->executeQuery(); if (xDrvResultSet.is()) { xResultSet = new OResultSet(xDrvResultSet, *this, m_pColumns->isCaseSensitive()); @@ -268,7 +246,7 @@ sal_Int32 OPreparedStatement::executeUpdate() throw( SQLException, RuntimeExcept disposeResultSet(); - return Reference< XPreparedStatement >(m_xAggregateAsSet, UNO_QUERY)->executeUpdate(); + return Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->executeUpdate(); } //------------------------------------------------------------------------------ @@ -278,7 +256,8 @@ sal_Bool OPreparedStatement::execute() throw( SQLException, RuntimeException ) ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); disposeResultSet(); - return Reference< XPreparedStatement >(m_xAggregateAsSet, UNO_QUERY)->execute(); + + return Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->execute(); } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/core/api/resultcolumn.cxx b/dbaccess/source/core/api/resultcolumn.cxx index b49d92867..37cf7a997 100644 --- a/dbaccess/source/core/api/resultcolumn.cxx +++ b/dbaccess/source/core/api/resultcolumn.cxx @@ -82,13 +82,12 @@ using namespace dbaccess; DBG_NAME(OResultColumn) //-------------------------------------------------------------------------- -OResultColumn::OResultColumn( - const Reference < XResultSetMetaData >& _xMetaData, - sal_Int32 _nPos, - const Reference< XDatabaseMetaData >& _rxDBMeta ) - :m_xMetaData(_xMetaData) - ,m_xDBMetaData(_rxDBMeta) - ,m_nPos(_nPos) +OResultColumn::OResultColumn( const Reference < XResultSetMetaData >& _xMetaData, sal_Int32 _nPos, + const Reference< XDatabaseMetaData >& _rxDBMeta ) + :OColumn( true ) + ,m_xMetaData( _xMetaData ) + ,m_xDBMetaData( _rxDBMeta ) + ,m_nPos( _nPos ) { DBG_CTOR(OResultColumn,NULL); } @@ -216,112 +215,95 @@ void OResultColumn::disposing() } //------------------------------------------------------------------------------ +namespace +{ + template< typename TYPE > + void obtain( Any& _out_rValue, ::boost::optional< TYPE > _rCache, const sal_Int32 _nPos, const Reference < XResultSetMetaData >& _rxResultMeta, TYPE (SAL_CALL XResultSetMetaData::*Getter)( sal_Int32 ) ) + { + if ( !_rCache ) + _rCache.reset( (_rxResultMeta.get()->*Getter)( _nPos ) ); + _out_rValue <<= *_rCache; + } +} + +//------------------------------------------------------------------------------ void OResultColumn::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const { try { - switch (nHandle) + if ( OColumn::isRegisteredProperty( nHandle ) ) { - case PROPERTY_ID_ISROWVERSION: - const_cast< OResultColumn* >( this )->impl_determineIsRowVersion_nothrow(); - rValue = m_aIsRowVersion; - break; - case PROPERTY_ID_TABLENAME: - rValue <<= m_xMetaData->getTableName(m_nPos); - break; - case PROPERTY_ID_SCHEMANAME: - rValue <<= m_xMetaData->getSchemaName(m_nPos); - break; - case PROPERTY_ID_CATALOGNAME: - rValue <<= m_xMetaData->getCatalogName(m_nPos); - break; - case PROPERTY_ID_ISSIGNED: - { - if ( !m_isSigned ) - m_isSigned.reset( m_xMetaData->isSigned(m_nPos)); - rValue <<= *m_isSigned; - } break; - case PROPERTY_ID_ISCURRENCY: - { - if ( !m_isCurrency ) - m_isCurrency.reset( m_xMetaData->isCurrency(m_nPos)); - rValue <<= *m_isCurrency; - } break; - case PROPERTY_ID_ISSEARCHABLE: - { - if ( !m_bSearchable ) - m_bSearchable.reset( m_xMetaData->isSearchable(m_nPos)); - rValue <<= *m_bSearchable; - } break; - case PROPERTY_ID_ISCASESENSITIVE: - { - if ( !m_isCaseSensitive ) - m_isCaseSensitive.reset( m_xMetaData->isCaseSensitive(m_nPos)); - rValue <<= *m_isCaseSensitive; - } break; - case PROPERTY_ID_ISREADONLY: - { - if ( !m_isReadOnly ) - m_isReadOnly.reset( m_xMetaData->isReadOnly(m_nPos)); - rValue <<= *m_isReadOnly; - } break; - case PROPERTY_ID_ISWRITABLE: - { - if ( !m_isWritable ) - m_isWritable.reset( m_xMetaData->isWritable(m_nPos)); - rValue <<= *m_isWritable; - } break; - case PROPERTY_ID_ISDEFINITELYWRITABLE: - { - if ( !m_isDefinitelyWritable ) - m_isDefinitelyWritable.reset( m_xMetaData->isDefinitelyWritable(m_nPos)); - rValue <<= *m_isDefinitelyWritable; - } break; - case PROPERTY_ID_ISAUTOINCREMENT: + OColumn::getFastPropertyValue( rValue, nHandle ); + } + else + { + switch (nHandle) { - if ( !m_isAutoIncrement ) - m_isAutoIncrement.reset( m_xMetaData->isAutoIncrement(m_nPos)); - rValue <<= *m_isAutoIncrement; - } break; - case PROPERTY_ID_SERVICENAME: - rValue <<= m_xMetaData->getColumnServiceName(m_nPos); - break; - case PROPERTY_ID_LABEL: - if ( !m_sColumnLabel ) - m_sColumnLabel.reset( m_xMetaData->getColumnLabel(m_nPos)); - rValue <<= *m_sColumnLabel; - break; - case PROPERTY_ID_DISPLAYSIZE: - if ( !m_nColumnDisplaySize ) - m_nColumnDisplaySize.reset( m_xMetaData->getColumnDisplaySize(m_nPos)); - rValue <<= *m_nColumnDisplaySize; - break; - case PROPERTY_ID_TYPE: - if ( !m_nColumnType ) - m_nColumnType.reset( m_xMetaData->getColumnType(m_nPos)); - rValue <<= *m_nColumnType; - break; - case PROPERTY_ID_PRECISION: - if ( !m_nPrecision ) - m_nPrecision.reset( m_xMetaData->getPrecision(m_nPos)); - rValue <<= *m_nPrecision; - break; - case PROPERTY_ID_SCALE: - if ( !m_nScale ) - m_nScale.reset( m_xMetaData->getScale(m_nPos)); - rValue <<= *m_nScale; - break; - case PROPERTY_ID_ISNULLABLE: - if ( !m_isNullable ) - m_isNullable.reset( m_xMetaData->isNullable(m_nPos)); - rValue <<= *m_isNullable; - break; - case PROPERTY_ID_TYPENAME: - rValue <<= m_xMetaData->getColumnTypeName(m_nPos); - break; - case PROPERTY_ID_NAME: - OColumn::getFastPropertyValue( rValue, nHandle ); - break; + case PROPERTY_ID_ISROWVERSION: + const_cast< OResultColumn* >( this )->impl_determineIsRowVersion_nothrow(); + rValue = m_aIsRowVersion; + break; + case PROPERTY_ID_TABLENAME: + rValue <<= m_xMetaData->getTableName(m_nPos); + break; + case PROPERTY_ID_SCHEMANAME: + rValue <<= m_xMetaData->getSchemaName(m_nPos); + break; + case PROPERTY_ID_CATALOGNAME: + rValue <<= m_xMetaData->getCatalogName(m_nPos); + break; + case PROPERTY_ID_ISSIGNED: + obtain( rValue, m_isSigned, m_nPos, m_xMetaData, &XResultSetMetaData::isSigned ); + break; + case PROPERTY_ID_ISCURRENCY: + obtain( rValue, m_isCurrency, m_nPos, m_xMetaData, &XResultSetMetaData::isCurrency ); + break; + case PROPERTY_ID_ISSEARCHABLE: + obtain( rValue, m_bSearchable, m_nPos, m_xMetaData, &XResultSetMetaData::isSearchable ); + break; + case PROPERTY_ID_ISCASESENSITIVE: + obtain( rValue, m_isCaseSensitive, m_nPos, m_xMetaData, &XResultSetMetaData::isCaseSensitive ); + break; + case PROPERTY_ID_ISREADONLY: + obtain( rValue, m_isReadOnly, m_nPos, m_xMetaData, &XResultSetMetaData::isReadOnly ); + break; + case PROPERTY_ID_ISWRITABLE: + obtain( rValue, m_isWritable, m_nPos, m_xMetaData, &XResultSetMetaData::isWritable ); + break; + case PROPERTY_ID_ISDEFINITELYWRITABLE: + obtain( rValue, m_isDefinitelyWritable, m_nPos, m_xMetaData, &XResultSetMetaData::isDefinitelyWritable ); + break; + case PROPERTY_ID_ISAUTOINCREMENT: + obtain( rValue, m_isAutoIncrement, m_nPos, m_xMetaData, &XResultSetMetaData::isAutoIncrement ); + break; + case PROPERTY_ID_SERVICENAME: + rValue <<= m_xMetaData->getColumnServiceName(m_nPos); + break; + case PROPERTY_ID_LABEL: + obtain( rValue, m_sColumnLabel, m_nPos, m_xMetaData, &XResultSetMetaData::getColumnLabel ); + break; + case PROPERTY_ID_DISPLAYSIZE: + obtain( rValue, m_nColumnDisplaySize, m_nPos, m_xMetaData, &XResultSetMetaData::getColumnDisplaySize ); + break; + case PROPERTY_ID_TYPE: + obtain( rValue, m_nColumnType, m_nPos, m_xMetaData, &XResultSetMetaData::getColumnType ); + break; + case PROPERTY_ID_PRECISION: + obtain( rValue, m_nPrecision, m_nPos, m_xMetaData, &XResultSetMetaData::getPrecision ); + break; + case PROPERTY_ID_SCALE: + obtain( rValue, m_nScale, m_nPos, m_xMetaData, &XResultSetMetaData::getScale ); + break; + case PROPERTY_ID_ISNULLABLE: + obtain( rValue, m_isNullable, m_nPos, m_xMetaData, &XResultSetMetaData::isNullable ); + break; + case PROPERTY_ID_TYPENAME: + rValue <<= m_xMetaData->getColumnTypeName(m_nPos); + break; + default: + OSL_ENSURE( false, "OResultColumn::getFastPropertyValue: unknown property handle!" ); + break; + } } } catch (SQLException& ) diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx index 07ad7fcd3..7076b7f09 100644 --- a/dbaccess/source/core/api/table.cxx +++ b/dbaccess/source/core/api/table.cxx @@ -182,7 +182,7 @@ OColumn* ODBTable::createColumn(const ::rtl::OUString& _rName) const Reference<XPropertySet> xColumnDefintion; if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName) ) xColumnDefintion.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY); - pReturn = new OTableColumnWrapper(xProp,xColumnDefintion); + pReturn = new OTableColumnWrapper( xProp, xColumnDefintion, false ); return pReturn; } @@ -468,7 +468,7 @@ Sequence< sal_Int8 > ODBTable::getUnoTunnelImplementationId() Reference< XPropertySet > ODBTable::createColumnDescriptor() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumnDescriptor" ); - return new OTableColumnDescriptor(); + return new OTableColumnDescriptor( true ); } // ----------------------------------------------------------------------------- sdbcx::OCollection* ODBTable::createColumns(const TStringVector& _rNames) diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx index a118a4087..9888bd8e6 100644 --- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx +++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx @@ -280,14 +280,14 @@ OColumn* OComponentDefinition::createColumn(const ::rtl::OUString& _rName) const if ( aFind != rDefinition.end() ) { aFind->second->addPropertyChangeListener(::rtl::OUString(),m_xColumnPropertyListener.getRef()); - return new OTableColumnWrapper( aFind->second, aFind->second, sal_True ); + return new OTableColumnWrapper( aFind->second, aFind->second, true ); } return new OTableColumn( _rName ); } // ----------------------------------------------------------------------------- Reference< XPropertySet > OComponentDefinition::createColumnDescriptor() { - return new OTableColumnDescriptor(); + return new OTableColumnDescriptor( true ); } // ----------------------------------------------------------------------------- void OComponentDefinition::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) @@ -307,7 +307,7 @@ void OComponentDefinition::columnAppended( const Reference< XPropertySet >& _rxS ::rtl::OUString sName; _rxSourceDescriptor->getPropertyValue( PROPERTY_NAME ) >>= sName; - Reference<XPropertySet> xColDesc = new OTableColumnDescriptor(); + Reference<XPropertySet> xColDesc = new OTableColumnDescriptor( true ); ::comphelper::copyProperties( _rxSourceDescriptor, xColDesc ); getDefinition().insert( sName, xColDesc ); diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx index e17b2904f..2cf85b88d 100644 --- a/dbaccess/source/core/inc/column.hxx +++ b/dbaccess/source/core/inc/column.hxx @@ -31,92 +31,40 @@ #ifndef _DBA_COREAPI_COLUMN_HXX_ #define _DBA_COREAPI_COLUMN_HXX_ -#include <hash_map> +#include "columnsettings.hxx" -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ -#include <com/sun/star/container/XNamed.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ -#include <com/sun/star/sdbc/XResultSet.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ -#include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HPP_ -#include <com/sun/star/lang/WrappedTargetException.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ -#include <com/sun/star/container/XNameAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ #include <com/sun/star/container/XIndexAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/io/IOException.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_ -#include <com/sun/star/io/XObjectOutputStream.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_ #include <com/sun/star/io/XObjectInputStream.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/io/XObjectOutputStream.hpp> +#include <com/sun/star/lang/WrappedTargetException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> #include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ #include <com/sun/star/sdbcx/XDrop.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ -#include <com/sun/star/lang/XUnoTunnel.hpp> -#endif -#ifndef _OSL_DIAGNOSE_H_ -#include <osl/diagnose.h> -#endif -#ifndef _CPPUHELPER_COMPBASE3_HXX_ -#include <cppuhelper/compbase3.hxx> -#endif -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ -#include <cppuhelper/implbase1.hxx> -#endif -#ifndef _CPPUHELPER_COMPBASE4_HXX_ -#include <cppuhelper/compbase4.hxx> -#endif -#ifndef _CPPUHELPER_PROPSHLP_HXX -#include <cppuhelper/propshlp.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + +#include <comphelper/broadcasthelper.hxx> #include <comphelper/proparrhlp.hxx> -#endif -#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <comphelper/propertycontainer.hxx> +#include <comphelper/stl_types.hxx> #include <connectivity/CommonTools.hxx> -#endif -#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ -#include <comphelper/broadcasthelper.hxx> -#endif -#ifndef CONNECTIVITY_COLUMNSHELPER_HXX -#include <connectivity/TColumnsHelper.hxx> -#endif -#ifndef _CONNECTIVITY_FILE_VALUE_HXX_ #include <connectivity/FValue.hxx> -#endif -#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include <connectivity/TColumnsHelper.hxx> #include <connectivity/sdbcx/IRefreshable.hxx> -#endif -#ifndef _COMPHELPER_STLTYPES_HXX_ -#include <comphelper/stl_types.hxx> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ -#include <com/sun/star/container/XChild.hpp> -#endif +#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/propshlp.hxx> +#include <osl/diagnose.h> + +#include <hash_map> namespace dbaccess { @@ -131,8 +79,8 @@ namespace dbaccess //------------------------------------------------------------ class OColumn :public comphelper::OBaseMutex ,public OColumnBase - ,public ::cppu::OPropertySetHelper - + ,public ::comphelper::OPropertyContainer + ,public IPropertyContainer // convenience for the derived class which also derive from OColumnSettings { friend class OColumns; @@ -142,7 +90,7 @@ namespace dbaccess // </properties> protected: - OColumn(); + OColumn( const bool _bNameIsReadOnly ); public: virtual ~OColumn(); @@ -159,23 +107,6 @@ namespace dbaccess // com::sun::star::beans::XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - // ::cppu::OPropertySetHelper - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception); - // com::sun::star::lang::XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); @@ -192,10 +123,13 @@ namespace dbaccess virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setName( const ::rtl::OUString& _rName ) throw(::com::sun::star::uno::RuntimeException); - virtual void fireValueChange(const ::connectivity::ORowSetValue& _rOldValue); + virtual void fireValueChange( const ::connectivity::ORowSetValue& _rOldValue ); protected: - using ::cppu::OPropertySetHelper::getFastPropertyValue; + // IPropertyContainer + virtual void registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const ::com::sun::star::uno::Type& _rMemberType ); + virtual void registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, ::com::sun::star::uno::Any* _pPointerToMember, const ::com::sun::star::uno::Type& _rExpectedType ); + virtual void registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const ::com::sun::star::uno::Type& _rType, const void* _pInitialValue ); }; //============================================================ diff --git a/dbaccess/source/core/inc/columnsettings.hxx b/dbaccess/source/core/inc/columnsettings.hxx index 9d78f9dec..c44b6cdaf 100644 --- a/dbaccess/source/core/inc/columnsettings.hxx +++ b/dbaccess/source/core/inc/columnsettings.hxx @@ -35,12 +35,41 @@ namespace dbaccess { //........................................................................ - //************************************************************ - // OColumnSettings - //************************************************************ + // TODO: move the following to comphelper/propertycontainerhelper.hxx + class IPropertyContainer + { + public: + virtual void registerProperty( + const ::rtl::OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + void* _pPointerToMember, + const ::com::sun::star::uno::Type& _rMemberType + ) = 0; + + virtual void registerMayBeVoidProperty( + const ::rtl::OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + ::com::sun::star::uno::Any* _pPointerToMember, + const ::com::sun::star::uno::Type& _rExpectedType + ) = 0; + + virtual void registerPropertyNoMember( + const ::rtl::OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + const ::com::sun::star::uno::Type& _rType, + const void* _pInitialValue + ) = 0; + }; + + //==================================================================== + //= OColumnSettings + //==================================================================== class OColumnSettings { - // <properties> + // <properties> ::com::sun::star::uno::Any m_aWidth; // sal_Int32 or void ::com::sun::star::uno::Any m_aFormatKey; // sal_Int32 or void ::com::sun::star::uno::Any m_aRelativePosition; // sal_Int32 or void @@ -49,34 +78,26 @@ namespace dbaccess ::com::sun::star::uno::Any m_aControlDefault; // the default value which should be displayed as by a control when moving to a new row ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xControlModel; - sal_Bool m_bHidden; - // </properties> + // </properties> - // Setting of values - public: - OColumnSettings(); + protected: virtual ~OColumnSettings(); - sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception); - void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; - + public: + OColumnSettings(); virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); - public: + protected: + void registerProperties( IPropertyContainer& _rPropertyContainer ); + + /** determines whether the property with the given handle is handled by the class + */ + bool isMine( const sal_Int32 _nPropertyHandle ) const; + public: /** check if the persistent settings have their default value */ sal_Bool isDefaulted() const; diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx index 11bebe556..d2f50062b 100644 --- a/dbaccess/source/core/inc/definitioncolumn.hxx +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -70,20 +70,27 @@ namespace dbaccess sal_Bool m_bRowVersion; sal_Bool m_bCurrency; // </properties> + public: - OTableColumnDescriptor():m_nType(::com::sun::star::sdbc::DataType::SQLNULL) - ,m_nPrecision(0) - ,m_nScale(0) - ,m_nIsNullable(::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN) - ,m_bAutoIncrement(sal_False) - ,m_bRowVersion(sal_False) - ,m_bCurrency(sal_False){} + OTableColumnDescriptor( const bool _bActAsDescriptor ) + :OColumn( !_bActAsDescriptor ) + ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL ) + ,m_nPrecision( 0 ) + ,m_nScale( 0 ) + ,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN ) + ,m_bAutoIncrement( sal_False ) + ,m_bRowVersion( sal_False ) + ,m_bCurrency( sal_False ) + { + impl_registerProperties( _bActAsDescriptor ); + } DECLARE_XINTERFACE( ) - // com::sun::star::lang::XTypeProvider + + // com::sun::star::lang::XTypeProvider virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); - // ::com::sun::star::lang::XServiceInfo + // ::com::sun::star::lang::XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); @@ -91,31 +98,20 @@ namespace dbaccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); 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); - // ::comphelper::OPropertyArrayUsageHelper + // ::comphelper::OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; - // ::cppu::OPropertySetHelper + // ::cppu::OPropertySetHelper virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); protected: // XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + private: + void impl_registerProperties( const bool _bActAsDescriptor ); + protected: using OColumn::getFastPropertyValue; }; @@ -149,7 +145,7 @@ namespace dbaccess * describes all properties for a columns of a table. Only the view parts are provided * directly, all the other parts are derived from a driver implementation */ - class OColumnWrapper : public OColumn + class OColumnWrapper :public OColumn { protected: // definition which is provided by a driver! @@ -159,7 +155,7 @@ namespace dbaccess sal_Int32 m_nColTypeID; protected: - OColumnWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol); + OColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rCol, const bool _bNameIsReadOnly ); virtual ~OColumnWrapper(); public: @@ -180,8 +176,9 @@ namespace dbaccess throw (::com::sun::star::uno::Exception); virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - // Helper -// sal_Int32 getColumnTypeID() const {return m_nColTypeID;} + + protected: + ::rtl::OUString impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const; protected: using OColumn::getFastPropertyValue; @@ -190,14 +187,16 @@ namespace dbaccess /** * provides the properties for description. A descriptor could be used to create a new table column. */ - class OTableColumnDescriptorWrapper : public OColumnWrapper, - public OColumnSettings, - public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnDescriptorWrapper > + class OTableColumnDescriptorWrapper :public OColumnWrapper + ,public OColumnSettings + ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnDescriptorWrapper > { - sal_Bool m_bPureWrap; + const bool m_bPureWrap; + const bool m_bIsDescriptor; + public: - OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol,sal_Bool _bPureWrap = sal_False) - :OColumnWrapper(rCol),m_bPureWrap(_bPureWrap){} + OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol, + const bool _bPureWrap, const bool _bIsDescriptor ); // com::sun::star::lang::XTypeProvider virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); @@ -239,15 +238,16 @@ namespace dbaccess * describes all properties for a columns of a table. Only the view parts are provided * directly, all the other parts are derived from a driver implementation */ - class OTableColumnWrapper : public OTableColumnDescriptorWrapper, - public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnWrapper > + class OTableColumnWrapper :public OTableColumnDescriptorWrapper + ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnWrapper > { protected: ~OTableColumnWrapper(); + public: - OTableColumnWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol - ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rColDefintion - ,sal_Bool _bPureWrap = sal_False); + OTableColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rColDefintion, + const bool _bPureWrap ); // ::com::sun::star::lang::XTypeProvider virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); @@ -260,76 +260,6 @@ namespace dbaccess virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; }; - - /** - * describes all properties for a columns of an index. - */ - class OIndexColumnWrapper : public OColumnWrapper, - public ::comphelper::OPropertyArrayUsageHelper < OIndexColumnWrapper > - { - protected: - // <properties> - sal_Bool m_bAscending; - // </properties> - - public: - OIndexColumnWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol ) - :OColumnWrapper(rCol) {} - - // com::sun::star::lang::XTypeProvider - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); - virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; - - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - - protected: - using OColumnWrapper::getFastPropertyValue; - }; - - /** - * describes all properties for a columns of an key column. - */ - class OKeyColumnWrapper : public OColumnWrapper, - public ::comphelper::OPropertyArrayUsageHelper < OKeyColumnWrapper > - { - protected: - // <properties> - rtl::OUString m_aRelatedColumn; - // </properties> - - public: - OKeyColumnWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol) - :OColumnWrapper(rCol) {} - - // com::sun::star::lang::XTypeProvider - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); - virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; - - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - - protected: - using OColumnWrapper::getFastPropertyValue; - }; } #endif // _DBACORE_DEFINITIONCOLUMN_HXX_ |