diff options
author | Ingrid Halama <iha@openoffice.org> | 2010-01-28 16:29:55 +0100 |
---|---|---|
committer | Ingrid Halama <iha@openoffice.org> | 2010-01-28 16:29:55 +0100 |
commit | 25eec801f8569ba58e0e7f92bb8c6d39967ed3b2 (patch) | |
tree | ddbb42dbeed442a5dbfa2ff7d66d64e9cf01bc7c /dbaccess/source | |
parent | a6515886f60f4b42a190101a631bd59a9a22ea62 (diff) | |
parent | 351f7cf2ab5fdcab464ee21ee910bd4fa0f96d21 (diff) |
chartmultiline: merge with DEV300_m70
Diffstat (limited to 'dbaccess/source')
179 files changed, 4505 insertions, 5247 deletions
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index 74b925f47..5dc22b0f8 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -270,7 +270,10 @@ void OBookmarkSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParamet case DataType::LONGVARBINARY: _xParameter->updateBytes(nPos,_rValue); break; - + case DataType::BLOB: + case DataType::CLOB: + _xParameter->updateObject(nPos,_rValue.getAny()); + break; } } } 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/CRowSetDataColumn.hxx b/dbaccess/source/core/api/CRowSetDataColumn.hxx index 2d386de95..02490975b 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.hxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.hxx @@ -30,21 +30,13 @@ #ifndef DBACCESS_CORE_API_CROWSETDATACOLUMN_HXX #define DBACCESS_CORE_API_CROWSETDATACOLUMN_HXX -#ifndef _DBACORE_DATACOLUMN_HXX_ #include "datacolumn.hxx" -#endif -#ifndef DBACCESS_CORE_API_ROWSETROW_HXX #include "RowSetRow.hxx" -#endif -#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include "RowSetCacheIterator.hxx" +#include "columnsettings.hxx" + #include <connectivity/CommonTools.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ #include <comphelper/proparrhlp.hxx> -#endif -#ifndef DBACCESS_ROWSETCACHEITERATOR_HXX -#include "RowSetCacheIterator.hxx" -#endif namespace dbaccess { diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index 796cf39f4..e44173ed6 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -515,88 +515,7 @@ void OCacheSet::setParameter(sal_Int32 nPos { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::setParameter" ); sal_Int32 nType = ( _nType != DataType::OTHER ) ? _nType : _rValue.getTypeKind(); - if(!_rValue.isNull()) - { - - switch(nType) - { - case DataType::DECIMAL: - case DataType::NUMERIC: - _xParameter->setObjectWithInfo(nPos,_rValue.makeAny(),nType,_nScale); - break; - case DataType::CHAR: - case DataType::VARCHAR: - case DataType::LONGVARCHAR: - _xParameter->setString(nPos,_rValue); - break; - case DataType::BIGINT: - if ( _rValue.isSigned() ) - _xParameter->setLong(nPos,_rValue); - else - _xParameter->setString(nPos,_rValue); - break; - case DataType::BIT: - case DataType::BOOLEAN: - _xParameter->setBoolean(nPos,_rValue); - break; - case DataType::TINYINT: - if ( _rValue.isSigned() ) - _xParameter->setByte(nPos,_rValue); - else - _xParameter->setShort(nPos,_rValue); - break; - case DataType::SMALLINT: - if ( _rValue.isSigned() ) - _xParameter->setShort(nPos,_rValue); - else - _xParameter->setInt(nPos,_rValue); - break; - case DataType::INTEGER: - if ( _rValue.isSigned() ) - _xParameter->setInt(nPos,_rValue); - else - _xParameter->setLong(nPos,_rValue); - break; - case DataType::FLOAT: - _xParameter->setFloat(nPos,_rValue); - break; - case DataType::DOUBLE: - case DataType::REAL: - _xParameter->setDouble(nPos,_rValue); - break; - case DataType::DATE: - _xParameter->setDate(nPos,_rValue); - break; - case DataType::TIME: - _xParameter->setTime(nPos,_rValue); - break; - case DataType::TIMESTAMP: - _xParameter->setTimestamp(nPos,_rValue); - break; - case DataType::BINARY: - case DataType::VARBINARY: - case DataType::LONGVARBINARY: - _xParameter->setBytes(nPos,_rValue); - break; - case DataType::CLOB: - { - Reference<XInputStream> xStream(_rValue.getAny(),UNO_QUERY); - _xParameter->setCharacterStream(nPos,xStream,xStream.is() ? xStream->available() : sal_Int32(0)); - } - break; - case DataType::BLOB: - { - Reference<XInputStream> xStream(_rValue.getAny(),UNO_QUERY); - _xParameter->setBinaryStream(nPos,xStream,xStream.is() ? xStream->available() : sal_Int32(0)); - } - break; - case DataType::SQLNULL: - _xParameter->setNull(nPos,nType); - break; - } - } - else - _xParameter->setNull(nPos,nType); + ::dbtools::setObjectWithInfo(_xParameter,nPos,_rValue,nType,_nScale); } // ------------------------------------------------------------------------- void OCacheSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition) diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 56c87c7b5..50aa4b6cd 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -211,8 +211,33 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) Reference<XColumnsSupplier> xSup(m_xComposer,UNO_QUERY); Reference<XNameAccess> xSourceColumns = m_xTable->getColumns(); - ::dbaccess::getColumnPositions(xSup->getColumns(),xKeyColumns,m_sUpdateTableName,(*m_pKeyColumnNames)); - ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns,m_sUpdateTableName,(*m_pColumnNames)); + ::rtl::OUString sCatalog,sSchema,sTable; + + Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); + Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME); + aCatalog >>= sCatalog; + xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; + xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; + + ::std::vector< ::rtl::OUString> aBestRowColumnNames; + Reference<XResultSet> xBestRes(xMeta->getBestRowIdentifier(aCatalog,sSchema,sTable,0,sal_False)); + Reference<XRow> xBestRow(xBestRes,uno::UNO_QUERY); + while ( xBestRes->next() ) + { + aBestRowColumnNames.push_back(xBestRow->getString(2)); + } + + Sequence< ::rtl::OUString> aBestColumnNames; + if ( aBestRowColumnNames.empty() ) + { + if ( xKeyColumns.is() ) + aBestColumnNames = xKeyColumns->getElementNames(); + } + else + aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size()); + + ::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames)); + ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames)); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); @@ -235,16 +260,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); - ::rtl::OUString aQuote = getIdentifierQuoteString(); - - ::rtl::OUStringBuffer aFilter; - ::rtl::OUString sCatalog,sSchema,sTable; - - Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); - xTableProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; - xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; - xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; - + const ::rtl::OUString aQuote = getIdentifierQuoteString(); m_aSelectComposedTableName = getComposedTableName(sCatalog,sSchema,sTable); ::rtl::OUString sComposedName; @@ -252,6 +268,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation ); + ::rtl::OUStringBuffer aFilter; static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // create the where clause @@ -286,21 +303,20 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false ); Reference<XNameAccess > xSelectColumns = xSup->getColumns(); - ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns(),sSelectTableName,(*m_pForeignColumnNames)); + ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames)); - uno::Sequence< ::rtl::OUString> aSelectColumnNames = xSelectColumns->getElementNames(); - const ::rtl::OUString* pSelectColumnName = aSelectColumnNames.getConstArray(); - const ::rtl::OUString* pSelectColumnEnd = pSelectColumnName + aSelectColumnNames.getLength(); - for( ; pSelectColumnName != pSelectColumnEnd ; ++pSelectColumnName) + aPosEnd = (*m_pForeignColumnNames).end(); + for(aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter) { // look for columns not in the source columns to use them as filter as well - if ( !xSourceColumns->hasByName(*pSelectColumnName) ) + // if ( !xSourceColumns->hasByName(aPosIter->first) ) { + if ( aFilter.getLength() ) + aFilter.append(aAnd); + aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName)); aFilter.append(s_sDot); - aFilter.append(::dbtools::quoteName( aQuote,*pSelectColumnName)); + aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first)); aFilter.append(s_sParam); - if ( (pSelectColumnName+1) != pSelectColumnEnd ) - aFilter.append(aAnd); } } break; @@ -310,7 +326,10 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) const ::rtl::OUString sOldFilter = xAnalyzer->getFilter(); if ( sOldFilter.getLength() ) { - aFilter = sOldFilter + aAnd + aFilter.makeStringAndClear(); + FilterCreator aFilterCreator; + aFilterCreator.append( sOldFilter ); + aFilterCreator.append( aFilter.makeStringAndClear() ); + aFilter = aFilterCreator.getComposedAndClear(); } xAnalyzer->setFilter(aFilter.makeStringAndClear()); m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution()); @@ -499,7 +518,8 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); for(;aIter != aEnd;++aIter,++i) { - if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) + //if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) + if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) { sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rOrginalRow->get())[aIter->second.nPosition].isNull()) @@ -594,7 +614,8 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin(); ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); j = 0; - for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j) + aIter = m_pColumnNames->begin(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter) { setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -826,7 +847,7 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit sal_Int32 i = 1; for(i = 1;aIter != aEnd;++aIter,++i) { - if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) + if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) { aSql.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) @@ -879,7 +900,8 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit // now we have to set the index values ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin(); ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); - for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i) + aIter = m_pColumnNames->begin(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++aIter) { setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -1394,7 +1416,7 @@ sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException) namespace dbaccess { void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, - const Reference<XNameAccess>& _rxColumns, + const Sequence< ::rtl::OUString>& _aColumnNames, const ::rtl::OUString& _rsUpdateTableName, SelectColumnsMetaData& _rColumnNames) { @@ -1403,9 +1425,8 @@ namespace dbaccess const ::rtl::OUString* pSelBegin = aSelNames.getConstArray(); const ::rtl::OUString* pSelEnd = pSelBegin + aSelNames.getLength(); - Sequence< ::rtl::OUString> aColumnNames(_rxColumns->getElementNames()); - const ::rtl::OUString* pColumnIter = aColumnNames.getConstArray(); - const ::rtl::OUString* pColumnEnd = pColumnIter + aColumnNames.getLength(); + const ::rtl::OUString* pColumnIter = _aColumnNames.getConstArray(); + const ::rtl::OUString* pColumnEnd = pColumnIter + _aColumnNames.getLength(); ::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp()); ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive()); @@ -1439,7 +1460,7 @@ namespace dbaccess break; } } - pColumnIter = aColumnNames.getConstArray(); + pColumnIter = _aColumnNames.getConstArray(); } } } diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 3bda294c1..c7b2e71d5 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -83,7 +83,7 @@ namespace dbaccess // the elements of _rxQueryColumns must have the properties PROPERTY_REALNAME and PROPERTY_TABLENAME void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns, + const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aColumnNames, const ::rtl::OUString& _rsUpdateTableName, SelectColumnsMetaData& _rColumnNames /* out */); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 1a0a6cbbc..9deed7522 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -36,156 +36,56 @@ #include "sdbcoretools.hxx" #include "SingleSelectQueryComposer.hxx" #include "module_dba.hxx" +#include "sdbcoretools.hxx" +#include "CRowSetColumn.hxx" +#include "CRowSetDataColumn.hxx" +#include "RowSetCache.hxx" +#include "core_resource.hrc" +#include "core_resource.hxx" +#include "tablecontainer.hxx" -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +/** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _CPPUHELPER_INTERFACECONTAINER_H_ -#include <cppuhelper/interfacecontainer.h> -#endif -#ifndef _CPPUHELPER_EXC_HLP_HXX_ -#include <cppuhelper/exc_hlp.hxx> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ -#include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ -#include <comphelper/sequence.hxx> -#endif -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX -#include <comphelper/componentcontext.hxx> -#endif -#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ -#include <com/sun/star/sdb/XCompletedConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_ +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> +#include <com/sun/star/sdb/RowChangeAction.hpp> #include <com/sun/star/sdb/RowSetVetoException.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_ +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdbc/FetchDirection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ -#include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ -#include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ #include <com/sun/star/sdbc/XDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ -#include <com/sun/star/sdb/XQueriesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ROWCHANGEACTION_HPP_ -#include <com/sun/star/sdb/RowChangeAction.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_ -#include <com/sun/star/sdb/ErrorCondition.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ #include <com/sun/star/sdbc/XDriverAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ #include <com/sun/star/sdbcx/CompareBookmark.hpp> -#endif -#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ -#include <com/sun/star/uno/XNamingService.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ #include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX -#include "RowSetCache.hxx" -#endif -#if OSL_DEBUG_LEVEL > 1 -#ifndef _COM_SUN_STAR_SDBC_XDRIVERMANAGER_HPP_ -#include <com/sun/star/sdbc/XDriverManager.hpp> -#endif -#endif -#ifndef _DBACORE_DATACOLUMN_HXX_ -#include "CRowSetDataColumn.hxx" -#endif -#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX -#include "CRowSetColumn.hxx" -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef _COMPHELPER_SEQSTREAM_HXX -#include <comphelper/seqstream.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H -#include <tools/diagnose_ex.h> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _DBA_CORE_TABLECONTAINER_HXX_ -#include "tablecontainer.hxx" -#endif -#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ -#include <com/sun/star/sdb/ParametersRequest.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ -#include <com/sun/star/sdb/ParametersRequest.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ -#include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ -#include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#include <com/sun/star/uno/XNamingService.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#endif -#ifndef _COMPHELPER_INTERACTION_HXX_ +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <comphelper/extract.hxx> #include <comphelper/interaction.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ #include <comphelper/property.hxx> -#endif -#ifndef _UTL_CONFIGMGR_HXX_ -#include <unotools/configmgr.hxx> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/seqstream.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/types.hxx> #include <comphelper/uno3.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ -#include <com/sun/star/sdbcx/CompareBookmark.hpp> -#endif -#ifndef _DBA_CORE_RESOURCE_HXX_ -#include "core_resource.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HRC_ -#include "core_resource.hrc" -#endif -#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include <connectivity/BlobHelper.hxx> #include <connectivity/dbconversion.hxx> -#endif -#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> -#endif -#ifndef _RTL_LOGFILE_HXX_ +#include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <cppuhelper/typeprovider.hxx> #include <rtl/logfile.hxx> -#endif +#include <unotools/syslocale.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/configmgr.hxx> using namespace utl; using namespace dbaccess; @@ -814,7 +714,18 @@ void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) // XRowUpdate void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - updateValue(columnIndex,ORowSetValue()); + ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); + + ::osl::MutexGuard aGuard( *m_pMutex ); + checkUpdateConditions(columnIndex); + checkUpdateIterator(); + + ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]); + m_pCache->updateNull(columnIndex); + // we have to notify all listeners + ((*m_aCurrentRow)->get())[columnIndex].setNull(); + firePropertyChange(columnIndex-1 ,aOldValue); + fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) @@ -886,25 +797,23 @@ void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Referenc checkUpdateConditions(columnIndex); checkUpdateIterator(); - ::connectivity::ORowSetValue aOldValue; - if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB) - { - m_pCache->updateBinaryStream(columnIndex,x,length); - aOldValue = ((*m_aCurrentRow)->get())[columnIndex]; - ((*m_aCurrentRow)->get())[columnIndex] = makeAny(x); - } - else + + //if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB) + //{ + // ::connectivity::ORowSetValue aOldValue = ((*m_aCurrentRow)->get())[columnIndex]; + // m_pCache->updateBinaryStream(columnIndex,x,length); + // ((*m_aCurrentRow)->get())[columnIndex] = makeAny(x); + // ((*m_aCurrentRow)->get())[columnIndex].setTypeKind(DataType::BLOB); + // firePropertyChange(columnIndex-1 ,aOldValue); + // fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); + //} + //else { Sequence<sal_Int8> aSeq; if(x.is()) x->readBytes(aSeq,length); updateValue(columnIndex,aSeq); - aOldValue = ((*m_aCurrentRow)->get())[columnIndex]; - ((*m_aCurrentRow)->get())[columnIndex] = aSeq; } - - firePropertyChange(columnIndex-1 ,aOldValue); - fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) @@ -1481,14 +1390,19 @@ Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQ return Reference< XRef >(); } // ------------------------------------------------------------------------- -Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - return Reference< XBlob >(); + if ( m_pCache && isInsertRow() ) + { + checkCache(); + return new ::connectivity::BlobHelper(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence()); + } + return ORowSetBase::getBlob(columnIndex); } // ------------------------------------------------------------------------- -Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - return Reference< XClob >(); + return Reference< XClob >(getInsertValue(columnIndex).makeAny(),UNO_QUERY); } // ------------------------------------------------------------------------- Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) @@ -2191,37 +2105,37 @@ Reference< XConnection > ORowSet::calcConnection(const Reference< XInteractionH if (!m_xActiveConnection.is()) { Reference< XConnection > xNewConn; - if (m_aDataSourceName.getLength()) + if ( m_aDataSourceName.getLength() ) { - // is it a file url? - Reference< XNameAccess > xNamingContext; - if ( m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT, xNamingContext ) ) - if (xNamingContext.is() ) + Reference< XNameAccess > xDatabaseContext( + m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT ), + UNO_QUERY_THROW ); + try { - try - { - if(_rxHandler.is()) - { - Reference< XCompletedConnection> xComplConn(xNamingContext->getByName(m_aDataSourceName), UNO_QUERY); - if(xComplConn.is()) - xNewConn = xComplConn->connectWithCompletion(_rxHandler); - } - else - { - Reference< XDataSource > xDataSource(xNamingContext->getByName(m_aDataSourceName), UNO_QUERY); - if (xDataSource.is()) - xNewConn = xDataSource->getConnection(m_aUser, m_aPassword); - } - } - catch (SQLException &e) + Reference< XDataSource > xDataSource( xDatabaseContext->getByName( m_aDataSourceName ), UNO_QUERY_THROW ); + + // try connecting with the interaction handler + Reference< XCompletedConnection > xComplConn( xDataSource, UNO_QUERY ); + if ( _rxHandler.is() && xComplConn.is() ) { - throw e; + xNewConn = xComplConn->connectWithCompletion( _rxHandler ); } - catch (Exception&) + else { - throw SQLException(); + xNewConn = xDataSource->getConnection( m_aUser, m_aPassword ); } } + catch ( const SQLException& e ) + { + throw; + } + catch ( const Exception& e ) + { + Any aError = ::cppu::getCaughtException(); + ::rtl::OUString sMessage = ResourceManager::loadString( RID_NO_SUCH_DATA_SOURCE, + "$name$", m_aDataSourceName, "$error$", extractExceptionMessage( m_aContext, aError ) ); + ::dbtools::throwGenericSQLException( sMessage, *this ); + } } setActiveConnection(xNewConn); m_bOwnConnection = sal_True; @@ -2245,7 +2159,7 @@ Reference< XNameAccess > ORowSet::impl_getTables_throw() else { if ( !m_xActiveConnection.is() ) - throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() ); + throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() ); sal_Bool bCase = sal_True; try @@ -2838,7 +2752,8 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo m_aDataColumns.push_back(pColumn); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN)); - sal_Int32 nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)); + sal_Int32 nFormatKey = 0; + xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey; if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is()) nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index bbd2e825a..6e202b8da 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -469,18 +469,16 @@ Reference< XRef > SAL_CALL ORowSetBase::getRef( sal_Int32 /*columnIndex*/ ) thro return NULL; } // ------------------------------------------------------------------------- -Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBlob" ); - ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *m_pMySelf ); - return NULL; + return Reference< XBlob >(getValue(columnIndex).makeAny(),UNO_QUERY); } // ------------------------------------------------------------------------- -Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getClob" ); - ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *m_pMySelf ); - return NULL; + return Reference< XClob >(getValue(columnIndex).makeAny(),UNO_QUERY); } // ------------------------------------------------------------------------- Reference< XArray > SAL_CALL ORowSetBase::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 91ba4a0c7..355b4afdd 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -168,6 +168,16 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference< XIndexAccess> xUpdateTableKeys; ::rtl::OUString aUpdateTableName = _rUpdateTableName; Reference< XConnection> xConnection; + // first we need a connection + Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY); + if(xStmt.is()) + xConnection = xStmt->getConnection(); + else + { + Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY); + xConnection = xPrepStmt->getConnection(); + } + OSL_ENSURE(xConnection.is(),"No connection!"); if(_xAnalyzer.is()) { try @@ -215,16 +225,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if(xColumnsSupplier.is()) { - // first we need a connection - Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY); - if(xStmt.is()) - xConnection = xStmt->getConnection(); - else - { - Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY); - xConnection = xPrepStmt->getConnection(); - } - OSL_ENSURE(xConnection.is(),"No connection!"); + Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns(); Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY); @@ -233,7 +234,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference<XNameAccess> xSelColumns = xColSup->getColumns(); Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false); - ::dbaccess::getColumnPositions(xSelColumns,xColumns,aUpdateTableName,aColumnNames); + ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames); bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xColumns->getElementNames().getLength(); } } @@ -303,7 +304,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY); Reference<XNameAccess> xSelColumns = xColSup->getColumns(); Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns(); - ::dbaccess::getColumnPositions(xSelColumns,xColumns,aUpdateTableName,aColumnNames); + ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames); // check privileges m_nPrivileges = Privilege::SELECT; @@ -560,10 +561,18 @@ sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) // ------------------------------------------------------------------------- // XRowUpdate // ----------------------------------------------------------------------------- -void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) +void ORowSetCache::updateNull(sal_Int32 columnIndex) { checkUpdateConditions(columnIndex); + ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True); + ((*m_aInsertRow)->get())[columnIndex].setNull(); + ((*m_aInsertRow)->get())[columnIndex].setModified(); +} +// ----------------------------------------------------------------------------- +void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) +{ + checkUpdateConditions(columnIndex); ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True); ((*m_aInsertRow)->get())[columnIndex] = x; @@ -1342,11 +1351,12 @@ void ORowSetCache::moveToInsertRow( ) // we don't unbound the bookmark column ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1; ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end(); - for(;aIter != aEnd;++aIter) + for(sal_Int32 i = 1;aIter != aEnd;++aIter,++i) { aIter->setBound(sal_False); aIter->setModified(sal_False); aIter->setNull(); + aIter->setTypeKind(m_xMetaData->getColumnType(i)); } } // ------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx index 94ea9822e..74b36ec35 100644 --- a/dbaccess/source/core/api/RowSetCache.hxx +++ b/dbaccess/source/core/api/RowSetCache.hxx @@ -225,6 +225,7 @@ namespace dbaccess void updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ); void updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ); void updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ); + void updateNull(sal_Int32 columnIndex); // ::com::sun::star::sdbc::XResultSet sal_Bool next( ); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index d62ee8d8b..bff178eb8 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -58,7 +58,7 @@ #include <comphelper/types.hxx> #include <cppuhelper/typeprovider.hxx> #include <rtl/logfile.hxx> -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <unotools/configmgr.hxx> @@ -1530,6 +1530,27 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert aSQL.append( STR_LIKE ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); break; + case DataType::CLOB: + { + Reference< XClob > xClob(aValue,UNO_QUERY); + if ( xClob.is() ) + { + const ::sal_Int64 nLength = xClob->length(); + if ( sal_Int64(nLength + aSQL.getLength() + STR_LIKE.getLength() ) < sal_Int64(SAL_MAX_INT32) ) + { + aSQL.append( STR_LIKE ); + aSQL.appendAscii("'"); + aSQL.append( xClob->getSubString(1,(sal_Int32)nLength) ); + aSQL.appendAscii("'"); + } + } + else + { + aSQL.append( STR_LIKE ); + aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); + } + } + break; case DataType::VARBINARY: case DataType::BINARY: case DataType::LONGVARBINARY: 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 577d267d6..4d03a72b7 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,77 +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() -{ - static ::cppu::OImplementationId * pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} - -// com::sun::star::lang::XUnoTunnel -//------------------------------------------------------------------ -sal_Int64 OColumn::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) -{ - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return reinterpret_cast<sal_Int64>(this); - - return 0; -} // ----------------------------------------------------------------------------- ::rtl::OUString SAL_CALL OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException) { @@ -293,235 +155,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!" ); } -// ----------------------------------------------------------------------------- -//============================================================ -//= OColumnSettings -//============================================================ -DBG_NAME( OColumnSettings ) -//------------------------------------------------------------------------------ -OColumnSettings::OColumnSettings() - :m_bHidden(sal_False) -{ - DBG_CTOR( OColumnSettings, NULL ); -} //------------------------------------------------------------------------------ -OColumnSettings::~OColumnSettings() +void OColumn::registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const Type& _rMemberType ) { - DBG_DTOR( OColumnSettings, NULL ); -} - -// com::sun::star::lang::XUnoTunnel -//------------------------------------------------------------------ -sal_Int64 OColumnSettings::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) -{ - if ( ( rId.getLength() == 16 ) - && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - ) - return reinterpret_cast< sal_Int64 >( this ); - - return 0; -} - -//-------------------------------------------------------------------------- -Sequence< sal_Int8 > OColumnSettings::getUnoTunnelImplementationId() -{ - static ::cppu::OImplementationId * pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); + ::comphelper::OPropertyContainer::registerProperty( _rName, _nHandle, _nAttributes, _pPointerToMember, _rMemberType ); } //------------------------------------------------------------------------------ -void OColumnSettings::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +void OColumn::registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, Any* _pPointerToMember, const Type& _rExpectedType ) { - 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; - } + ::comphelper::OPropertyContainer::registerMayBeVoidProperty( _rName, _nHandle, _nAttributes, _pPointerToMember, _rExpectedType ); } //------------------------------------------------------------------------------ -sal_Bool OColumnSettings::convertFastPropertyValue( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) - throw (IllegalArgumentException) -{ - sal_Bool bModified = sal_False; - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - bModified = !uno_type_equalData( - const_cast< void* >( m_aAlignment.getValue() ), m_aAlignment.getValueType().getTypeLibType(), - const_cast< void* >( rValue.getValue() ), rValue.getValueType().getTypeLibType(), - reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ), - reinterpret_cast< uno_ReleaseFunc >( cpp_release ) - ); - if ( bModified ) - { - rConvertedValue = rValue; - rOldValue = m_aAlignment; - } - 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) +void OColumn::registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const Type& _rType, const void* _pInitialValue ) { - switch (nHandle) - { - case PROPERTY_ID_ALIGN: - { - if ( rValue.hasValue() ) - { - sal_Int32 nAlign = 0; - sal_Bool bSuccess = - // copy the data from the to-be-set value - uno_type_assignData( - static_cast< void* >( &nAlign ), ::getCppuType(static_cast< sal_Int32* >(NULL)).getTypeLibType(), - const_cast< void* >( rValue.getValue() ), rValue.getValueType().getTypeLibType(), - reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ), - reinterpret_cast< uno_AcquireFunc >( cpp_acquire ), - reinterpret_cast< uno_ReleaseFunc >( cpp_release ) ); - - OSL_ENSURE( bSuccess, - "OPropertyStateContainer::setFastPropertyValue_NoBroadcast : ooops .... the value could not be assigned!"); - if ( bSuccess ) - m_aAlignment <<= nAlign; - } - else - 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 !"); - m_bHidden = ::comphelper::getBOOL(rValue); - 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; - } + ::comphelper::OPropertyContainer::registerPropertyNoMember( _rName, _nHandle, _nAttributes, _rType, _pInitialValue ); } - -//------------------------------------------------------------------------------ -sal_Bool OColumnSettings::isDefaulted() const -{ - return !m_aAlignment.hasValue() - && !m_aWidth.hasValue() - && !m_aFormatKey.hasValue() - && !m_aRelativePosition.hasValue() - && !m_aHelpText.hasValue() - && !m_aControlDefault.hasValue() - && !m_bHidden; -} - - //============================================================ //= OColumns //============================================================ @@ -547,6 +205,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 new file mode 100644 index 000000000..fb118602d --- /dev/null +++ b/dbaccess/source/core/api/columnsettings.cxx @@ -0,0 +1,181 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "columnsettings.hxx" +#include "dbastrings.hrc" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyAttribute.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/property.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::beans::XPropertySetInfo; + /** === end UNO using === **/ + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + + //============================================================================== + //= OColumnSettings + //============================================================================== + DBG_NAME( OColumnSettings ) + //------------------------------------------------------------------------------ + OColumnSettings::OColumnSettings() + :m_bHidden(sal_False) + { + DBG_CTOR( OColumnSettings, NULL ); + } + + //------------------------------------------------------------------------------ + OColumnSettings::~OColumnSettings() + { + DBG_DTOR( OColumnSettings, NULL ); + } + + //------------------------------------------------------------------------------ + void OColumnSettings::registerProperties( IPropertyContainer& _rPropertyContainer ) + { + 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 ) ); + } + + //------------------------------------------------------------------------------ + bool OColumnSettings::isColumnSettingProperty( const sal_Int32 _nPropertyHandle ) + { + 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 ); + } + + //------------------------------------------------------------------------------ + bool OColumnSettings::isDefaulted( const sal_Int32 _nPropertyHandle, const Any& _rPropertyValue ) + { + switch ( _nPropertyHandle ) + { + case PROPERTY_ID_ALIGN: + case PROPERTY_ID_NUMBERFORMAT: + case PROPERTY_ID_RELATIVEPOSITION: + case PROPERTY_ID_WIDTH: + case PROPERTY_ID_HELPTEXT: + case PROPERTY_ID_CONTROLDEFAULT: + return !_rPropertyValue.hasValue(); + + case PROPERTY_ID_CONTROLMODEL: + return !Reference< XPropertySet >( _rPropertyValue, UNO_QUERY ).is(); + + case PROPERTY_ID_HIDDEN: + { + sal_Bool bHidden = sal_False; + OSL_VERIFY( _rPropertyValue >>= bHidden ); + return !bHidden; + } + } + OSL_ENSURE( false, "OColumnSettings::isDefaulted: illegal property handle!" ); + return sal_False; + } + + //------------------------------------------------------------------------------ + bool OColumnSettings::hasDefaultSettings( const Reference< XPropertySet >& _rxColumn ) + { + ENSURE_OR_THROW( _rxColumn.is(), "illegal column" ); + try + { + Reference< XPropertySetInfo > xPSI( _rxColumn->getPropertySetInfo(), UNO_SET_THROW ); + + struct PropertyDescriptor + { + ::rtl::OUString sName; + sal_Int32 nHandle; + }; + PropertyDescriptor aProps[] = + { + { PROPERTY_ALIGN, PROPERTY_ID_ALIGN }, + { PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT }, + { PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION }, + { PROPERTY_WIDTH, PROPERTY_ID_WIDTH }, + { PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT }, + { PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT }, + { PROPERTY_CONTROLMODEL, PROPERTY_ID_CONTROLMODEL }, + { PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN } + }; + + for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i ) + { + if ( xPSI->hasPropertyByName( aProps[i].sName ) ) + if ( !isDefaulted( aProps[i].nHandle, _rxColumn->getPropertyValue( aProps[i].sName ) ) ) + return false; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return true; + } + +//........................................................................ +} // namespace dbaccess +//........................................................................ diff --git a/dbaccess/source/core/api/datasettings.cxx b/dbaccess/source/core/api/datasettings.cxx index ae079d309..d0a2bf648 100644 --- a/dbaccess/source/core/api/datasettings.cxx +++ b/dbaccess/source/core/api/datasettings.cxx @@ -69,6 +69,7 @@ #include <com/sun/star/awt/FontWidth.hpp> #endif + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; @@ -157,19 +158,25 @@ ODataSettings_Base::ODataSettings_Base() //-------------------------------------------------------------------------- ODataSettings_Base::ODataSettings_Base(const ODataSettings_Base& _rSource) + :m_sFilter( _rSource.m_sFilter ) + ,m_sHavingClause( _rSource.m_sHavingClause ) + ,m_sGroupBy( _rSource.m_sGroupBy ) + ,m_sOrder( _rSource.m_sOrder ) + ,m_bApplyFilter( _rSource.m_bApplyFilter ) + ,m_aFont( _rSource.m_aFont ) + ,m_aRowHeight( _rSource.m_aRowHeight ) + ,m_aTextColor( _rSource.m_aTextColor ) + ,m_aTextLineColor( _rSource.m_aTextLineColor ) + ,m_nFontEmphasis( _rSource.m_nFontEmphasis ) + ,m_nFontRelief( _rSource.m_nFontRelief ) +{ +} + +// ----------------------------------------------------------------------------- +ODataSettings_Base::~ODataSettings_Base() { - m_sFilter = _rSource.m_sFilter; - m_sHavingClause = _rSource.m_sHavingClause; - m_sGroupBy = _rSource.m_sGroupBy; - m_sOrder = _rSource.m_sOrder; - m_bApplyFilter = _rSource.m_bApplyFilter; - m_aFont = _rSource.m_aFont; - m_aRowHeight = _rSource.m_aRowHeight; - m_aTextColor = _rSource.m_aTextColor; - m_aTextLineColor= _rSource.m_aTextLineColor; - m_nFontEmphasis = _rSource.m_nFontEmphasis; - m_nFontRelief = _rSource.m_nFontRelief; } + // ----------------------------------------------------------------------------- void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const { diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index 6cb16e8c7..e12c4dab9 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,39 +31,29 @@ // 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" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +/** === end UNO includes === **/ + #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 <connectivity/dbtools.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::sdbcx; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; using namespace ::cppu; using namespace ::comphelper; using namespace ::osl; @@ -79,23 +69,32 @@ using namespace dbaccess; //============================================================ IMPLEMENT_FORWARD_XINTERFACE2(OTableColumnDescriptor,OColumn,TXChild) -// com::sun::star::lang::XTypeProvider -//-------------------------------------------------------------------------- -Sequence< sal_Int8 > OTableColumnDescriptor::getImplementationId() throw (RuntimeException) +//------------------------------------------------------------------------------ +void OTableColumnDescriptor::impl_registerProperties() { - static OImplementationId * pId = 0; - if (! pId) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! pId) - { - static OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); + sal_Int32 nDefaultAttr = m_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 ( m_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 ); } +//-------------------------------------------------------------------------- +IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptor ) + // ::com::sun::star::lang::XServiceInfo //------------------------------------------------------------------------------ rtl::OUString OTableColumnDescriptor::getImplementationName( ) throw (RuntimeException) @@ -107,7 +106,7 @@ rtl::OUString OTableColumnDescriptor::getImplementationName( ) throw (RuntimeEx Sequence< ::rtl::OUString > OTableColumnDescriptor::getSupportedServiceNames( ) throw (RuntimeException) { Sequence< ::rtl::OUString > aSNS( 2 ); - aSNS[0] = SERVICE_SDBCX_COLUMNDESCRIPTOR; + aSNS[0] = m_bActAsDescriptor ? SERVICE_SDBCX_COLUMNDESCRIPTOR : SERVICE_SDBCX_COLUMN; aSNS[1] = SERVICE_SDB_COLUMNSETTINGS; return aSNS; } @@ -116,28 +115,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,190 +128,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_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(TYPE) : invalid value !"); - rValue >>= m_nType; - break; - case PROPERTY_ID_PRECISION: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(PRECISION) : invalid value !"); - rValue >>= m_nPrecision; - break; - case PROPERTY_ID_SCALE: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(SCALE) : invalid value !"); - rValue >>= m_nScale; - break; - case PROPERTY_ID_ISNULLABLE: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Int32* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(ISNULLABLE) : invalid value !"); - rValue >>= m_nIsNullable; - break; - case PROPERTY_ID_TYPENAME: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< rtl::OUString* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(TYPENAME) : invalid value !"); - rValue >>= m_aTypeName; - break; - case PROPERTY_ID_DESCRIPTION: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< rtl::OUString* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(DESCRIPTION) : invalid value !"); - rValue >>= m_aDescription; - break; - case PROPERTY_ID_DEFAULTVALUE: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< rtl::OUString* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(DEFAULTVALUE) : invalid value !"); - rValue >>= m_aDefaultValue; - break; - case PROPERTY_ID_AUTOINCREMENTCREATION: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< rtl::OUString* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(AUTOINCREMENTVALUE) : invalid value !"); - rValue >>= m_aAutoIncrementValue; - break; - case PROPERTY_ID_ISAUTOINCREMENT: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Bool* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(ISAUTOINCREMENT) : invalid value !"); - m_bAutoIncrement = ::comphelper::getBOOL(rValue); - break; - case PROPERTY_ID_ISCURRENCY: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Bool* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(ISCURRENCY) : invalid value !"); - m_bCurrency = ::comphelper::getBOOL(rValue); - break; - case PROPERTY_ID_ISROWVERSION: - OSL_ENSURE(rValue.getValueType().equals(::getCppuType(static_cast< sal_Bool* >(NULL))), - "OTableColumnDescriptor::setFastPropertyValue_NoBroadcast(ISROWVERSION) : invalid value !"); - m_bRowVersion = ::comphelper::getBOOL(rValue); - break; - case PROPERTY_ID_NAME: - OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - break; - default: - OColumnSettings::setFastPropertyValue_NoBroadcast( nHandle, rValue ); - } - ::dbaccess::notifyDataSourceModified(m_xParent,sal_True); -} - -// ----------------------------------------------------------------------------- -sal_Int64 SAL_CALL OTableColumnDescriptor::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException) -{ - sal_Int64 nReturn = OColumn::getSomething( aIdentifier ); - if ( !nReturn ) - nReturn = OColumnSettings::getSomething( aIdentifier ); - return nReturn; + OColumn::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + ::dbaccess::notifyDataSourceModified( m_xParent, sal_True ); } // ----------------------------------------------------------------------------- @@ -350,51 +150,24 @@ 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 /* do not act as descriptor */ ) { DBG_CTOR(OTableColumn,NULL); m_sName = _rName; } -// ------------------------------------------------------------------------- -OTableColumn::OTableColumn(const Reference<XPropertySet>& _xColumn) -{ - DBG_CTOR(OTableColumn,NULL); - m_aTypeName = (::comphelper::getString(_xColumn->getPropertyValue(PROPERTY_TYPENAME))); - if(_xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE)) - m_aDefaultValue = (::comphelper::getString(_xColumn->getPropertyValue(PROPERTY_DEFAULTVALUE))); - m_nIsNullable = (::comphelper::getINT32(_xColumn->getPropertyValue(PROPERTY_ISNULLABLE))); - m_nPrecision = (::comphelper::getINT32(_xColumn->getPropertyValue(PROPERTY_PRECISION))); - m_nScale = (::comphelper::getINT32(_xColumn->getPropertyValue(PROPERTY_SCALE))); - m_nType = (::comphelper::getINT32(_xColumn->getPropertyValue(PROPERTY_TYPE))); - m_bAutoIncrement = (::comphelper::getBOOL(_xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT))); - m_bRowVersion = (sal_False); - m_bCurrency = (::comphelper::getBOOL(_xColumn->getPropertyValue(PROPERTY_ISCURRENCY))); - _xColumn->getPropertyValue(PROPERTY_NAME) >>= m_sName; -} // ----------------------------------------------------------------------------- OTableColumn::~OTableColumn() { DBG_DTOR(OTableColumn,NULL); } -// com::sun::star::lang::XTypeProvider + //-------------------------------------------------------------------------- -Sequence< sal_Int8 > OTableColumn::getImplementationId() throw (RuntimeException) -{ - static OImplementationId * pId = 0; - if (! pId) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! pId) - { - static OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} +IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumn ) -// ::com::sun::star::lang::XServiceInfo //------------------------------------------------------------------------------ rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException) { @@ -402,75 +175,203 @@ rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException) } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > OTableColumn::getSupportedServiceNames( ) throw (RuntimeException) +::cppu::IPropertyArrayHelper& SAL_CALL OTableColumn::getInfoHelper() { - Sequence< ::rtl::OUString > aSNS( 2 ); - aSNS[0] = SERVICE_SDBCX_COLUMN; - aSNS[1] = SERVICE_SDB_COLUMNSETTINGS; - return aSNS; + return *OTableColumn_PBase::getArrayHelper(); } //------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper& OTableColumn::getInfoHelper() +::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const { - return *static_cast< ::comphelper::OPropertyArrayUsageHelper< OTableColumn >* >(this)->getArrayHelper(); + return OTableColumnDescriptor::createArrayHelper(); +} + +// ========================================================================= +//= OQueryColumn +// ========================================================================= +DBG_NAME( OQueryColumn ); + +// ------------------------------------------------------------------------- +OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection ) + :OTableColumnDescriptor( false /* do not act as descriptor */ ) +{ + const sal_Int32 nPropAttr = PropertyAttribute::READONLY; + registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, ::getCppuType( &m_sCatalogName ) ); + registerProperty( PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nPropAttr, &m_sSchemaName, ::getCppuType( &m_sSchemaName ) ); + registerProperty( PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nPropAttr, &m_sTableName, ::getCppuType( &m_sTableName ) ); + registerProperty( PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nPropAttr, &m_sRealName, ::getCppuType( &m_sRealName ) ); + + DBG_CTOR( OQueryColumn, NULL ); + + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPENAME ) >>= m_aTypeName ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= m_nIsNullable ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_PRECISION ) >>= m_nPrecision ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_SCALE ) >>= m_nScale ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency ); + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName ); + m_bRowVersion = sal_False; + + Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW ); + if ( xPSI->hasPropertyByName( PROPERTY_DEFAULTVALUE ) ) + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_DEFAULTVALUE ) >>= m_aDefaultValue ); + + // copy some optional properties from the parser column + struct PropertyDescriptor + { + ::rtl::OUString sName; + sal_Int32 nHandle; + }; + PropertyDescriptor aProps[] = + { + { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME }, + { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME }, + { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME }, + { PROPERTY_REALNAME, PROPERTY_ID_REALNAME } + }; + for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i ) + { + if ( xPSI->hasPropertyByName( aProps[i].sName ) ) + setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _rxParserColumn->getPropertyValue( aProps[i].sName ) ); + } + + // determine the table column we're based on + osl_incrementInterlockedCount( &m_refCount ); + { + m_xOriginalTableColumn = impl_determineOriginalTableColumn( _rxConnection ); + } + osl_decrementInterlockedCount( &m_refCount ); +} + +//-------------------------------------------------------------------------- +OQueryColumn::~OQueryColumn() +{ + DBG_DTOR( OQueryColumn, NULL ); +} + +//-------------------------------------------------------------------------- +Reference< XPropertySet > OQueryColumn::impl_determineOriginalTableColumn( const Reference< XConnection >& _rxConnection ) +{ + OSL_PRECOND( _rxConnection.is(), "OQueryColumn::impl_determineOriginalTableColumn: illegal connection!" ); + if ( !_rxConnection.is() ) + return NULL; + + Reference< XPropertySet > xOriginalTableColumn; + try + { + // determine the composed table name, plus the column name, as indicated by the + // respective properties + ::rtl::OUString sCatalog, sSchema, sTable; + OSL_VERIFY( getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog ); + OSL_VERIFY( getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema ); + OSL_VERIFY( getPropertyValue( PROPERTY_TABLENAME ) >>= sTable ); + if ( !sCatalog.getLength() && !sSchema.getLength() && !sTable.getLength() ) + return NULL; + + ::rtl::OUString sComposedTableName = ::dbtools::composeTableName( + _rxConnection->getMetaData(), sCatalog, sSchema, sTable, sal_False, ::dbtools::eComplete ); + + // retrieve the table in question + Reference< XTablesSupplier > xSuppTables( _rxConnection, UNO_QUERY_THROW ); + Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW ); + if ( !xTables->hasByName( sComposedTableName ) ) + return NULL; + + Reference< XColumnsSupplier > xSuppCols( xTables->getByName( sComposedTableName ), UNO_QUERY_THROW ); + Reference< XNameAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW ); + + ::rtl::OUString sColumn; + OSL_VERIFY( getPropertyValue( PROPERTY_REALNAME ) >>= sColumn ); + if ( !xColumns->hasByName( sColumn ) ) + return NULL; + + xOriginalTableColumn.set( xColumns->getByName( sColumn ), UNO_QUERY ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xOriginalTableColumn; +} + +//-------------------------------------------------------------------------- +IMPLEMENT_GET_IMPLEMENTATION_ID( OQueryColumn ) + +//-------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OQueryColumn::getImplementationName( ) throw(RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.dbaccess.OQueryColumn" ) ); } -// comphelper::OPropertyArrayUsageHelper //------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const +::cppu::IPropertyArrayHelper& SAL_CALL OQueryColumn::getInfoHelper() { - 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 *OQueryColumn_PBase::getArrayHelper(); } -//============================================================ +//-------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OQueryColumn::createArrayHelper() const +{ + return OTableColumnDescriptor::createArrayHelper(); +} + +//-------------------------------------------------------------------------- +void SAL_CALL OQueryColumn::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const +{ + OTableColumnDescriptor::getFastPropertyValue( _rValue, _nHandle ); + + // special treatment for column settings: + if ( !OColumnSettings::isColumnSettingProperty( _nHandle ) ) + return; + + // If the setting has its default value, then try to obtain the value from the table column which + // this query column is based on + if ( !OColumnSettings::isDefaulted( _nHandle, _rValue ) ) + return; + + if ( !m_xOriginalTableColumn.is() ) + return; + + try + { + // determine original property name + ::rtl::OUString sPropName; + sal_Int16 nAttributes( 0 ); + const_cast< OQueryColumn* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle ); + OSL_ENSURE( sPropName.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" ); + + _rValue = m_xOriginalTableColumn->getPropertyValue( sPropName ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//========================================================================== //= OColumnWrapper -//============================================================ +//========================================================================== 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; } } // ----------------------------------------------------------------------------- @@ -480,91 +381,91 @@ 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) { - sal_Int64 nRet = OColumn::getSomething(aIdentifier); - if(!nRet) - { - Reference<XUnoTunnel> xTunnel(m_xAggregate,UNO_QUERY); - if(xTunnel.is()) - nRet = xTunnel->getSomething(aIdentifier); - } - return nRet; + Reference< XUnoTunnel > xTunnel( m_xAggregate, UNO_QUERY); + if ( xTunnel.is() ) + return xTunnel->getSomething( aIdentifier ); + return 0; } + //============================================================ //= OTableColumnDescriptorWrapper //============================================================ -// com::sun::star::lang::XTypeProvider //-------------------------------------------------------------------------- -Sequence< sal_Int8 > OTableColumnDescriptorWrapper::getImplementationId() throw (RuntimeException) +OTableColumnDescriptorWrapper::OTableColumnDescriptorWrapper( const Reference< XPropertySet >& _rCol, const bool _bPureWrap, const bool _bIsDescriptor ) + :OColumnWrapper( _rCol, !_bIsDescriptor ) + ,m_bPureWrap( _bPureWrap ) + ,m_bIsDescriptor( _bIsDescriptor ) { - static OImplementationId * pId = 0; - if (! pId) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (! pId) - { - static OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); + // let the ColumnSettings register its properties + OColumnSettings::registerProperties( *this ); } +// com::sun::star::lang::XTypeProvider +//-------------------------------------------------------------------------- +IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptorWrapper ) + // ::com::sun::star::lang::XServiceInfo //------------------------------------------------------------------------------ rtl::OUString OTableColumnDescriptorWrapper::getImplementationName( ) throw (RuntimeException) @@ -581,74 +482,72 @@ Sequence< ::rtl::OUString > OTableColumnDescriptorWrapper::getSupportedServiceNa return aSNS; } -// ----------------------------------------------------------------------------- -sal_Int64 SAL_CALL OTableColumnDescriptorWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException) -{ - sal_Int64 nReturn = OColumnWrapper::getSomething( aIdentifier ); - if ( !nReturn ) - nReturn = OColumnSettings::getSomething( aIdentifier ); - return nReturn; -} - // comphelper::OPropertyArrayUsageHelper //------------------------------------------------------------------------------ ::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; } + } + + // finally also describe the properties which are maintained by our base class, in particular the OPropertyContainerHelper + Sequence< Property > aBaseProperties; + describeProperties( aBaseProperties ); - 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(); + Sequence< Property > aAllProperties( ::comphelper::concatSequences( aTableDescProperties, aBaseProperties ) ); + return new ::cppu::OPropertyArrayHelper( aAllProperties, sal_False ); } // cppu::OPropertySetHelper @@ -663,75 +562,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; } @@ -743,24 +603,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 ); } } @@ -768,24 +616,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, + const 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 ); } //-------------------------------------------------------------------------- @@ -793,27 +640,13 @@ OTableColumnWrapper::~OTableColumnWrapper() { } -// com::sun::star::lang::XTypeProvider //-------------------------------------------------------------------------- -Sequence< sal_Int8 > OTableColumnWrapper::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 +IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnWrapper ) + //------------------------------------------------------------------------------ rtl::OUString OTableColumnWrapper::getImplementationName( ) throw (RuntimeException) { - return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumnWrapper"); + return rtl::OUString::createFromAscii( "com.sun.star.sdb.OTableColumnWrapper" ); } //------------------------------------------------------------------------------ @@ -835,206 +668,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(); -} - -// 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 ); - } + return OTableColumnDescriptorWrapper::createArrayHelper( nId ); } -//============================================================ -//= 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/makefile.mk b/dbaccess/source/core/api/makefile.mk index 59d89fb90..f983db38b 100644 --- a/dbaccess/source/core/api/makefile.mk +++ b/dbaccess/source/core/api/makefile.mk @@ -73,7 +73,8 @@ SLOFILES= \ $(SLO)$/tablecontainer.obj \ $(SLO)$/SingleSelectQueryComposer.obj \ $(SLO)$/HelperCollections.obj \ - $(SLO)$/datasettings.obj + $(SLO)$/datasettings.obj \ + $(SLO)$/columnsettings.obj # --- Targets ---------------------------------- 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/query.cxx b/dbaccess/source/core/api/query.cxx index cb4f568a4..924a4c24f 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -241,13 +241,12 @@ void OQuery::rebuildColumns() for ( ;pBegin != pEnd; ++pBegin) { Reference<XPropertySet> xSource(xColumns->getByName( *pBegin ),UNO_QUERY); - OTableColumn* pColumn = new OTableColumn( xSource ); - Reference<XChild> xChild(*pColumn,UNO_QUERY); - if ( xChild.is() ) - xChild->setParent(*this); + OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection ); + Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW ); + xChild->setParent( *this ); implAppendColumn( *pBegin, pColumn ); - Reference<XPropertySet> xDest(*pColumn,UNO_QUERY); + Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW ); if ( m_pColumnMediator.is() ) m_pColumnMediator->notifyElementCreated( *pBegin, xDest ); } diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx index 2e30ceaa7..6b17ad97e 100644 --- a/dbaccess/source/core/api/querycomposer.cxx +++ b/dbaccess/source/core/api/querycomposer.cxx @@ -86,7 +86,7 @@ #include <com/sun/star/i18n/XLocaleData.hpp> #endif #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #endif #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx index 3a7e6a83f..b4b8534cc 100644 --- a/dbaccess/source/core/api/querycontainer.cxx +++ b/dbaccess/source/core/api/querycontainer.cxx @@ -163,6 +163,10 @@ OQueryContainer::~OQueryContainer() } // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_XINTERFACE2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base) + +//------------------------------------------------------------------------------ +IMPLEMENT_FORWARD_XTYPEPROVIDER2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base) + //------------------------------------------------------------------------------ void OQueryContainer::disposing() { diff --git a/dbaccess/source/core/api/querydescriptor.cxx b/dbaccess/source/core/api/querydescriptor.cxx index 33ccca7f2..999d0cbd8 100644 --- a/dbaccess/source/core/api/querydescriptor.cxx +++ b/dbaccess/source/core/api/querydescriptor.cxx @@ -89,29 +89,6 @@ OQueryDescriptor::OQueryDescriptor() } //-------------------------------------------------------------------------- -OQueryDescriptor::OQueryDescriptor(const Reference< XPropertySet >& _rxCommandDefinition) - :OQueryDescriptor_Base(m_aMutex,*this) - ,ODataSettings(m_aBHelper,sal_True) -{ - DBG_CTOR(OQueryDescriptor,NULL); - registerProperties(); - ODataSettings::registerPropertiesFor(this); - - osl_incrementInterlockedCount(&m_refCount); - - OSL_ENSURE(_rxCommandDefinition.is(), "OQueryDescriptor_Base::OQueryDescriptor_Base : invalid source property set !"); - try - { - ::comphelper::copyProperties(_rxCommandDefinition,this); - } - catch(Exception&) - { - OSL_ENSURE(sal_False, "OQueryDescriptor_Base::OQueryDescriptor_Base: caught an exception!"); - } - osl_decrementInterlockedCount(&m_refCount); -} - -//-------------------------------------------------------------------------- OQueryDescriptor::OQueryDescriptor(const OQueryDescriptor_Base& _rSource) :OQueryDescriptor_Base(_rSource,*this) ,ODataSettings(m_aBHelper,sal_True) @@ -265,7 +242,7 @@ Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( ) throw (Ru { rebuildColumns(); } - catch(...) + catch ( const Exception& ) { setColumnsOutOfDate( sal_True ); throw; @@ -336,9 +313,10 @@ void OQueryDescriptor_Base::refreshColumns() } //------------------------------------------------------------------------------ -OColumn* OQueryDescriptor_Base::createColumn(const ::rtl::OUString& _rName) const +OColumn* OQueryDescriptor_Base::createColumn( const ::rtl::OUString& /*_rName*/ ) const { - return new OTableColumn(_rName); + // creating a column/descriptor for a query/descriptor does not make sense at all + return NULL; } // ----------------------------------------------------------------------------- //........................................................................ diff --git a/dbaccess/source/core/api/querydescriptor.hxx b/dbaccess/source/core/api/querydescriptor.hxx index 14a4d9c03..0424a538f 100644 --- a/dbaccess/source/core/api/querydescriptor.hxx +++ b/dbaccess/source/core/api/querydescriptor.hxx @@ -165,10 +165,6 @@ protected: virtual ~OQueryDescriptor(); public: OQueryDescriptor(); - /** constructs the object with a UNO QueryDescriptor. If you use this ctor, the resulting object - won't have any column informations (the column container will be empty) - */ - OQueryDescriptor(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForeignDescriptor); OQueryDescriptor(const OQueryDescriptor_Base& _rSource); // com::sun::star::lang::XTypeProvider 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/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx index 610c15127..3894e978e 100644 --- a/dbaccess/source/core/api/tablecontainer.cxx +++ b/dbaccess/source/core/api/tablecontainer.cxx @@ -364,15 +364,11 @@ ObjectType OTableContainer::appendObject( const ::rtl::OUString& _rForName, cons if ( !xColumnDefinitions->hasByName(*pIter) ) { Reference<XPropertySet> xColumn(xNames->getByName(*pIter),UNO_QUERY); - OColumnSettings* pColumnSettings = NULL; - if ( ::comphelper::getImplementation( pColumnSettings, xColumn ) ) + if ( !OColumnSettings::hasDefaultSettings( xColumn ) ) { - if ( ( pColumnSettings && !pColumnSettings->isDefaulted() ) ) - { - ::comphelper::copyProperties(xColumn,xProp); - xAppend->appendByDescriptor(xProp); - bModified = sal_True; - } + ::comphelper::copyProperties( xColumn, xProp ); + xAppend->appendByDescriptor( xProp ); + bModified = sal_True; } } } diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx index a118a4087..9f3605571 100644 --- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx +++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx @@ -280,14 +280,16 @@ 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 ); } + OSL_ENSURE( false, "OComponentDefinition::createColumn: is this a valid case?" ); + // This here is the last place creating a OTableColumn, and somehow /me thinks it is not needed ... 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 +309,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/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 022cddf65..365159b3a 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -143,11 +143,13 @@ class DocumentStorageAccess : public ::cppu::WeakImplHelper2< XDocumentSubStor NamedStorages m_aExposedStorages; ODatabaseModelImpl* m_pModelImplementation; bool m_bPropagateCommitToRoot; + bool m_bDisposingSubStorages; public: DocumentStorageAccess( ODatabaseModelImpl& _rModelImplementation ) :m_pModelImplementation( &_rModelImplementation ) ,m_bPropagateCommitToRoot( true ) + ,m_bDisposingSubStorages( false ) { DBG_CTOR( DocumentStorageAccess, NULL ); } @@ -161,19 +163,8 @@ protected: public: void dispose(); - void suspendCommitPropagation() - { - DBG_ASSERT( m_bPropagateCommitToRoot, "DocumentStorageAccess:: suspendCommitPropagation: already suspended" ); - m_bPropagateCommitToRoot = false; - } - void resumeCommitPropagation() - { - DBG_ASSERT( !m_bPropagateCommitToRoot, "DocumentStorageAccess:: suspendCommitPropagation: already suspended" ); - m_bPropagateCommitToRoot = true; - } - // XDocumentSubStorageSupplier - virtual Reference< XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException); + virtual Reference< XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 _nMode ) throw (RuntimeException); virtual Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (IOException, RuntimeException); // XTransactionListener @@ -184,6 +175,32 @@ public: // XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + /// disposes all storages managed by this instance + void disposeStorages(); + + /// disposes all known sub storages + void commitStorages() SAL_THROW(( IOException, RuntimeException )); + + /// commits the dedicated "database" storage + bool commitEmbeddedStorage( bool _bPreventRootCommits ); + +private: + /** opens the sub storage with the given name, in the given mode + */ + Reference< XStorage > impl_openSubStorage_nothrow( const ::rtl::OUString& _rStorageName, sal_Int32 _nMode ); + + void impl_suspendCommitPropagation() + { + OSL_ENSURE( m_bPropagateCommitToRoot, "DocumentStorageAccess::impl_suspendCommitPropagation: already suspended" ); + m_bPropagateCommitToRoot = false; + } + void impl_resumeCommitPropagation() + { + OSL_ENSURE( !m_bPropagateCommitToRoot, "DocumentStorageAccess::impl_resumeCommitPropagation: not suspended" ); + m_bPropagateCommitToRoot = true; + } + }; //-------------------------------------------------------------------------- @@ -214,17 +231,117 @@ void DocumentStorageAccess::dispose() } //-------------------------------------------------------------------------- -Reference< XStorage > SAL_CALL DocumentStorageAccess::getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException) +Reference< XStorage > DocumentStorageAccess::impl_openSubStorage_nothrow( const ::rtl::OUString& _rStorageName, sal_Int32 _nDesiredMode ) +{ + OSL_ENSURE( _rStorageName.getLength(),"ODatabaseModelImpl::impl_openSubStorage_nothrow: Invalid storage name!" ); + + Reference< XStorage > xStorage; + try + { + Reference< XStorage > xRootStorage( m_pModelImplementation->getOrCreateRootStorage() ); + if ( xRootStorage.is() ) + { + sal_Int32 nRealMode = m_pModelImplementation->m_bDocumentReadOnly ? ElementModes::READ : _nDesiredMode; + if ( nRealMode == ElementModes::READ ) + { + Reference< XNameAccess > xSubStorageNames( xRootStorage, UNO_QUERY ); + if ( xSubStorageNames.is() && !xSubStorageNames->hasByName( _rStorageName ) ) + return xStorage; + } + + xStorage = xRootStorage->openStorageElement( _rStorageName, nRealMode ); + + Reference< XTransactionBroadcaster > xBroad( xStorage, UNO_QUERY ); + if ( xBroad.is() ) + xBroad->addTransactionListener( this ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return xStorage; +} + +//-------------------------------------------------------------------------- +void DocumentStorageAccess::disposeStorages() +{ + m_bDisposingSubStorages = true; + + NamedStorages::iterator aEnd = m_aExposedStorages.end(); + for ( NamedStorages::iterator aIter = m_aExposedStorages.begin(); + aIter != aEnd ; + ++aIter + ) + { + try + { + ::comphelper::disposeComponent( aIter->second ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + m_aExposedStorages.clear(); + + m_bDisposingSubStorages = false; +} + +//-------------------------------------------------------------------------- +void DocumentStorageAccess::commitStorages() SAL_THROW(( IOException, RuntimeException )) +{ + try + { + for ( NamedStorages::const_iterator aIter = m_aExposedStorages.begin(); + aIter != m_aExposedStorages.end(); + ++aIter + ) + { + m_pModelImplementation->commitStorageIfWriteable( aIter->second ); + } + } + catch(const WrappedTargetException&) + { + // WrappedTargetException not allowed to leave + throw IOException(); + } +} + +//-------------------------------------------------------------------------- +bool DocumentStorageAccess::commitEmbeddedStorage( bool _bPreventRootCommits ) +{ + if ( _bPreventRootCommits ) + impl_suspendCommitPropagation(); + + bool bSuccess = false; + try + { + NamedStorages::const_iterator pos = m_aExposedStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) ); + if ( pos != m_aExposedStorages.end() ) + bSuccess = m_pModelImplementation->commitStorageIfWriteable( pos->second ); + } + catch( Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( _bPreventRootCommits ) + impl_resumeCommitPropagation(); + + return bSuccess; + +} + +//-------------------------------------------------------------------------- +Reference< XStorage > SAL_CALL DocumentStorageAccess::getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 _nDesiredMode ) throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); NamedStorages::iterator pos = m_aExposedStorages.find( aStorageName ); if ( pos == m_aExposedStorages.end() ) { - Reference< XStorage > xResult = m_pModelImplementation->getStorage( aStorageName, nMode ); - Reference< XTransactionBroadcaster > xBroadcaster( xResult, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->addTransactionListener( this ); - + Reference< XStorage > xResult = impl_openSubStorage_nothrow( aStorageName, _nDesiredMode ); pos = m_aExposedStorages.insert( NamedStorages::value_type( aStorageName, xResult ) ).first; } @@ -269,8 +386,14 @@ void SAL_CALL DocumentStorageAccess::commited( const css::lang::EventObject& aEv if ( m_pModelImplementation && m_bPropagateCommitToRoot ) { Reference< XStorage > xStorage( aEvent.Source, UNO_QUERY ); - if ( m_pModelImplementation->isDatabaseStorage( xStorage ) ) + + // check if this is the dedicated "database" sub storage + NamedStorages::const_iterator pos = m_aExposedStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) ); + if ( ( pos != m_aExposedStorages.end() ) + && ( pos->second == xStorage ) + ) { + // if so, also commit the root storage m_pModelImplementation->commitRootStorage(); } } @@ -291,9 +414,10 @@ void SAL_CALL DocumentStorageAccess::reverted( const css::lang::EventObject& /*a //-------------------------------------------------------------------------- void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& Source ) throw ( RuntimeException ) { - ODatabaseModelImpl* pImpl = m_pModelImplementation; - if ( pImpl ) - pImpl->disposing( Source ); + OSL_ENSURE( Reference< XStorage >( Source.Source, UNO_QUERY ).is(), "DocumentStorageAccess::disposing: No storage? What's this?" ); + + if ( m_bDisposingSubStorages ) + return; for ( NamedStorages::iterator find = m_aExposedStorages.begin(); find != m_aExposedStorages.end(); @@ -318,7 +442,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >& ,m_aMutex() ,m_aMutexFacade( m_aMutex ) ,m_aContainer(4) - ,m_aStorages() ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_pDBContext( &_rDBContext ) @@ -333,7 +456,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >& ,m_bSuppressVersionColumns(sal_True) ,m_bModified(sal_False) ,m_bDocumentReadOnly(sal_False) - ,m_bDisposingSubStorages( sal_False ) ,m_pSharedConnectionManager(NULL) ,m_nControllerLockCount(0) { @@ -357,7 +479,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( ,m_aMutex() ,m_aMutexFacade( m_aMutex ) ,m_aContainer(4) - ,m_aStorages() ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_pDBContext( &_rDBContext ) @@ -373,7 +494,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( ,m_bSuppressVersionColumns(sal_True) ,m_bModified(sal_False) ,m_bDocumentReadOnly(sal_False) - ,m_bDisposingSubStorages( sal_False ) ,m_pSharedConnectionManager(NULL) ,m_nControllerLockCount(0) { @@ -426,7 +546,7 @@ void ODatabaseModelImpl::impl_construct_nothrow() Property aProperty( ::rtl::OUString::createFromAscii( pSettings->AsciiName ), -1, - ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), + pSettings->ValueType, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID ); xSettingsSet->insert( makeAny( aProperty ) ); @@ -506,8 +626,7 @@ namespace try { - Reference< XStorage > xContainerStorage( _rModel.getStorage( - _rModel.getObjectContainerStorageName( _eType ), ElementModes::READWRITE ) ); + Reference< XStorage > xContainerStorage( _rModel.getStorage( _eType, ElementModes::READWRITE ) ); // note the READWRITE here: If the storage already existed before, then the OpenMode will // be ignored, anyway. // If the storage did not yet exist, then it will be created. If the database document @@ -589,16 +708,9 @@ void SAL_CALL ODatabaseModelImpl::disposing( const ::com::sun::star::lang::Event if ( bStore ) commitRootStorage(); } - else // storage + else { - if ( !m_bDisposingSubStorages ) - { - Reference<XStorage> xStorage(Source.Source,UNO_QUERY); - TStorages::iterator aFind = ::std::find_if(m_aStorages.begin(),m_aStorages.end(), - ::std::compose1(::std::bind2nd(::std::equal_to<Reference<XStorage> >(),xStorage),::std::select2nd<TStorages::value_type>())); - if ( aFind != m_aStorages.end() ) - m_aStorages.erase(aFind); - } + OSL_ENSURE( false, "ODatabaseModelImpl::disposing: where does this come from?" ); } } //------------------------------------------------------------------------------ @@ -662,9 +774,11 @@ void ODatabaseModelImpl::dispose() try { - sal_Bool bStore = commitEmbeddedStorage(); + sal_Bool bCouldStore = commitEmbeddedStorage( true ); + // "true" means that committing the embedded storage should not trigger committing the root + // storage. This is because we are going to commit the root storage ourself, anyway disposeStorages(); - if ( bStore ) + if ( bCouldStore ) commitRootStorage(); impl_switchToStorage_throw( NULL ); @@ -731,27 +845,9 @@ Sequence< PropertyValue > ODatabaseModelImpl::stripLoadArguments( const ::comphe // ----------------------------------------------------------------------------- void ODatabaseModelImpl::disposeStorages() SAL_THROW(()) { - m_bDisposingSubStorages = sal_True; - - TStorages::iterator aEnd = m_aStorages.end(); - for ( TStorages::iterator aIter = m_aStorages.begin(); - aIter != aEnd ; - ++aIter - ) - { - try - { - ::comphelper::disposeComponent( aIter->second ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - m_aStorages.clear(); - - m_bDisposingSubStorages = sal_False; + getDocumentStorageAccess()->disposeStorages(); } + // ----------------------------------------------------------------------------- Reference< XSingleServiceFactory > ODatabaseModelImpl::createStorageFactory() const { @@ -849,68 +945,11 @@ Reference< XDocumentSubStorageSupplier > ODatabaseModelImpl::getDocumentSubStora { return getDocumentStorageAccess(); } -// ----------------------------------------------------------------------------- -Reference<XStorage> ODatabaseModelImpl::getStorage( const ::rtl::OUString& _sStorageName, sal_Int32 _nMode ) -{ - OSL_ENSURE(_sStorageName.getLength(),"ODatabaseModelImpl::getStorage: Invalid storage name!"); - Reference<XStorage> xStorage; - TStorages::iterator aFind = m_aStorages.find(_sStorageName); - if ( aFind == m_aStorages.end() ) - { - try - { - Reference< XStorage > xMyStorage( getOrCreateRootStorage() ); - if ( xMyStorage.is() ) - { - sal_Int32 nMode = m_bDocumentReadOnly ? ElementModes::READ : _nMode; - if ( nMode == ElementModes::READ ) - { - Reference< XNameAccess > xSubStorageNames( xMyStorage, UNO_QUERY ); - if ( xSubStorageNames.is() && !xSubStorageNames->hasByName( _sStorageName ) ) - return xStorage; - } - xStorage = xMyStorage->openStorageElement( _sStorageName, nMode ); - Reference< XTransactionBroadcaster > xBroad( xStorage, UNO_QUERY ); - if ( xBroad.is() ) - xBroad->addTransactionListener( getDocumentStorageAccess() ); - aFind = m_aStorages.insert( TStorages::value_type( _sStorageName, xStorage ) ).first; - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - if ( aFind != m_aStorages.end() ) - xStorage = aFind->second; - - return xStorage; -} // ----------------------------------------------------------------------------- -sal_Bool ODatabaseModelImpl::commitEmbeddedStorage( sal_Bool _bPreventRootCommits ) +bool ODatabaseModelImpl::commitEmbeddedStorage( bool _bPreventRootCommits ) { - if ( _bPreventRootCommits && m_pStorageAccess ) - m_pStorageAccess->suspendCommitPropagation(); - - sal_Bool bStore = sal_False; - try - { - TStorages::iterator aFind = m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database"))); - if ( aFind != m_aStorages.end() ) - bStore = commitStorageIfWriteable(aFind->second); - } - catch(Exception&) - { - OSL_ENSURE(0,"Exception Caught: Could not store embedded database!"); - } - - if ( _bPreventRootCommits && m_pStorageAccess ) - m_pStorageAccess->resumeCommitPropagation(); - - return bStore; - + return getDocumentStorageAccess()->commitEmbeddedStorage( _bPreventRootCommits ); } // ----------------------------------------------------------------------------- @@ -1072,18 +1111,13 @@ oslInterlockedCount SAL_CALL ODatabaseModelImpl::release() // ----------------------------------------------------------------------------- void ODatabaseModelImpl::commitStorages() SAL_THROW(( IOException, RuntimeException )) { - try - { - TStorages::iterator aIter = m_aStorages.begin(); - TStorages::iterator aEnd = m_aStorages.end(); - for (; aIter != aEnd ; ++aIter) - commitStorageIfWriteable( aIter->second ); - } - catch(const WrappedTargetException&) - { - // WrappedTargetException not allowed to leave - throw IOException(); - } + getDocumentStorageAccess()->commitStorages(); +} + +// ----------------------------------------------------------------------------- +Reference< XStorage > ODatabaseModelImpl::getStorage( const ObjectType _eType, const sal_Int32 _nDesiredMode ) +{ + return getDocumentStorageAccess()->getDocumentSubStorage( getObjectContainerStorageName( _eType ), _nDesiredMode ); } // ----------------------------------------------------------------------------- @@ -1130,8 +1164,9 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() AsciiPropertyValue( "ParameterNameSubstitution", makeAny( (sal_Bool)sal_False ) ), AsciiPropertyValue( "AddIndexAppendix", makeAny( (sal_Bool)sal_True ) ), AsciiPropertyValue( "IgnoreDriverPrivileges", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "ImplicitCatalogRestriction", Any( ) ), - AsciiPropertyValue( "ImplicitSchemaRestriction", Any( ) ), + AsciiPropertyValue( "ImplicitCatalogRestriction", ::cppu::UnoType< ::rtl::OUString >::get() ), + AsciiPropertyValue( "ImplicitSchemaRestriction", ::cppu::UnoType< ::rtl::OUString >::get() ), + AsciiPropertyValue( "PrimaryKeySupport", ::cppu::UnoType< sal_Bool >::get() ), // known SDB level settings AsciiPropertyValue( "NoNameLengthLimit", makeAny( (sal_Bool)sal_False ) ), AsciiPropertyValue( "AppendTableAliasName", makeAny( (sal_Bool)sal_False ) ), @@ -1148,7 +1183,7 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( (sal_Bool)sal_True ) ), AsciiPropertyValue( "EscapeDateTime", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( NULL, Any() ) + AsciiPropertyValue() }; return aKnownSettings; } @@ -1172,7 +1207,7 @@ TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType ) void ODatabaseModelImpl::revokeDataSource() const { if ( m_pDBContext && m_sDocumentURL.getLength() ) - m_pDBContext->deregisterPrivate( m_sDocumentURL ); + m_pDBContext->revokeDatabaseDocument( *this ); } // ----------------------------------------------------------------------------- @@ -1322,16 +1357,10 @@ Reference< XStorage > ODatabaseModelImpl::impl_switchToStorage_throw( const Refe void ODatabaseModelImpl::switchToURL( const ::rtl::OUString& _rDocumentLocation, const ::rtl::OUString& _rDocumentURL ) { // register at the database context, or change registration - if ( _rDocumentURL != m_sDocumentURL ) + const bool bURLChanged = ( _rDocumentURL != m_sDocumentURL ); + const ::rtl::OUString sOldURL( m_sDocumentURL ); + if ( bURLChanged ) { - if ( m_pDBContext ) - { - if ( m_sDocumentURL.getLength() ) - m_pDBContext->nameChangePrivate( m_sDocumentURL, _rDocumentURL ); - else - m_pDBContext->registerPrivate( _rDocumentURL, this ); - } - if ( ( m_sName == m_sDocumentURL ) // our name is our old URL || ( !m_sName.getLength() ) // we do not have a name, yet (i.e. are not registered at the database context) ) @@ -1348,19 +1377,14 @@ void ODatabaseModelImpl::switchToURL( const ::rtl::OUString& _rDocumentLocation, // remember both m_sDocFileLocation = _rDocumentLocation.getLength() ? _rDocumentLocation : _rDocumentURL; m_sDocumentURL = _rDocumentURL; -} -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::isDatabaseStorage( const Reference< XStorage >& _rxStorage ) const -{ - TStorages::const_iterator pos = m_aStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) ); - if ( ( pos != m_aStorages.end() ) - && ( pos->second == _rxStorage ) - ) + if ( bURLChanged && m_pDBContext ) { - return true; + if ( sOldURL.getLength() ) + m_pDBContext->databaseDocumentURLChange( sOldURL, m_sDocumentURL ); + else + m_pDBContext->registerDatabaseDocument( *this ); } - return false; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx index 287a1fc26..de668ddf7 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.hxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx @@ -104,13 +104,32 @@ struct AsciiPropertyValue // note: the canonic member order would be AsciiName / DefaultValue, but // this crashes on unxlngi6.pro, since there's a bug which somehow results in // getDefaultDataSourceSettings returning corrupted Any instances then. - ::com::sun::star::uno::Any DefaultValue; - const sal_Char* AsciiName; + ::com::sun::star::uno::Any DefaultValue; + const sal_Char* AsciiName; + const ::com::sun::star::uno::Type& ValueType; + + AsciiPropertyValue() + :DefaultValue( ) + ,AsciiName( NULL ) + ,ValueType( ::cppu::UnoType< ::cppu::UnoVoidType >::get() ) + { + } AsciiPropertyValue( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rDefaultValue ) :DefaultValue( _rDefaultValue ) ,AsciiName( _pAsciiName ) + ,ValueType( _rDefaultValue.getValueType() ) + { + OSL_ENSURE( ValueType.getTypeClass() != ::com::sun::star::uno::TypeClass_VOID, + "AsciiPropertyValue::AsciiPropertyValue: NULL values not allowed here, use the other CTOR for this!" ); + } + AsciiPropertyValue( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Type& _rValeType ) + :DefaultValue() + ,AsciiName( _pAsciiName ) + ,ValueType( _rValeType ) { + OSL_ENSURE( ValueType.getTypeClass() != ::com::sun::star::uno::TypeClass_VOID, + "AsciiPropertyValue::AsciiPropertyValue: VOID property values not supported!" ); } }; @@ -143,8 +162,6 @@ private: //============================================================ //= ODatabaseModelImpl //============================================================ -DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >,TStorages); - typedef ::utl::SharedUNOComponent< ::com::sun::star::embed::XStorage > SharedStorage; class ODatabaseContext; @@ -182,7 +199,6 @@ private: ::comphelper::SharedMutex m_aMutex; VosMutexFacade m_aMutexFacade; ::std::vector< TContentPtr > m_aContainer; // one for each ObjectType - TStorages m_aStorages; ::sfx2::DocumentMacroMode m_aMacroMode; sal_Int16 m_nImposedMacroExecMode; @@ -242,7 +258,6 @@ public: sal_Bool m_bSuppressVersionColumns : 1; sal_Bool m_bModified : 1; sal_Bool m_bDocumentReadOnly : 1; - sal_Bool m_bDisposingSubStorages; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyAccess > m_xSettings; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter; @@ -267,10 +282,9 @@ public: call. @return <TRUE/> if the storage could be commited, otherwise <FALSE/> */ - sal_Bool commitEmbeddedStorage( sal_Bool _bPreventRootCommits = sal_False ); + bool commitEmbeddedStorage( bool _bPreventRootCommits = false ); - /** commits all storages storages which have been obtained via getStorage - */ + /// commits all sub storages void commitStorages() SAL_THROW(( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException )); @@ -296,7 +310,10 @@ public: inline ::rtl::OUString getURL() const { return m_sDocumentURL; } inline ::rtl::OUString getDocFileLocation() const { return m_sDocFileLocation; } - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getStorage(const ::rtl::OUString& _sStorageName,sal_Int32 nMode = ::com::sun::star::embed::ElementModes::READWRITE); + ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > + getStorage( + const ObjectType _eType, const sal_Int32 _nDesiredMode = ::com::sun::star::embed::ElementModes::READWRITE ); + // helper const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& getNumberFormatsSupplier(); @@ -403,10 +420,6 @@ public: */ TContentPtr& getObjectContainer( const ObjectType _eType ); - /** determines whether the given storage is the storage of our embedded database (named "database"), if any - */ - bool isDatabaseStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage ) const; - /** returns the name of the storage which is used to stored objects of the given type, if applicable */ static ::rtl::OUString diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index d1e5e8c56..87dde3202 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.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 @@ -36,6 +36,7 @@ #include "core_resource.hxx" #include "databasecontext.hxx" #include "databasedocument.hxx" +#include "databaseregistrations.hxx" #include "datasource.hxx" #include "dbastrings.hrc" #include "module_dba.hxx" @@ -69,8 +70,7 @@ #include <cppuhelper/implbase1.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/exc_hlp.hxx> -#include <svtools/filenotation.hxx> -#include <svtools/pathoptions.hxx> +#include <svl/filenotation.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <tools/fsys.hxx> @@ -114,30 +114,6 @@ namespace dbaccess { //........................................................................ - namespace - { - //-------------------------------------------------------------------- - const ::rtl::OUString& getDbRegisteredNamesNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - const ::rtl::OUString& getDbNameNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Name"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - const ::rtl::OUString& getDbLocationNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Location"); - return s_sNodeName; - } - // ----------------------------------------------------------------------------- - } // ............................................................................. typedef ::cppu::WeakImplHelper1 < XTerminateListener > DatabaseDocumentLoader_Base; @@ -150,8 +126,8 @@ namespace dbaccess public: DatabaseDocumentLoader( const comphelper::ComponentContext& _aContext); - inline void append(const ODatabaseModelImpl& _rModelImpl ) - { + inline void append(const ODatabaseModelImpl& _rModelImpl ) + { m_aDatabaseDocuments.push_back(&_rModelImpl); } inline void remove(const ODatabaseModelImpl& _rModelImpl) { m_aDatabaseDocuments.remove(&_rModelImpl); } @@ -204,7 +180,7 @@ namespace dbaccess ::std::list< const ODatabaseModelImpl* > aCopy(m_aDatabaseDocuments); ::std::for_each(aCopy.begin(),aCopy.end(),TerminateFunctor()); } - + // ............................................................................. void SAL_CALL DatabaseDocumentLoader::notifyTermination( const lang::EventObject& /*Event*/ ) throw (RuntimeException) { @@ -224,6 +200,15 @@ ODatabaseContext::ODatabaseContext( const Reference< XComponentContext >& _rxCon { m_pDatabaseDocumentLoader = new DatabaseDocumentLoader( m_aContext ); ::basic::BasicManagerRepository::registerCreationListener( *this ); + + osl_incrementInterlockedCount( &m_refCount ); + { + m_xDBRegistrationAggregate.set( createDataSourceRegistrations( m_aContext ), UNO_SET_THROW ); + m_xDatabaseRegistrations.set( m_xDBRegistrationAggregate, UNO_QUERY_THROW ); + + m_xDBRegistrationAggregate->setDelegator( *this ); + } + osl_decrementInterlockedCount( &m_refCount ); } //-------------------------------------------------------------------------- @@ -232,6 +217,10 @@ ODatabaseContext::~ODatabaseContext() ::basic::BasicManagerRepository::revokeCreationListener( *this ); if ( m_pDatabaseDocumentLoader ) m_pDatabaseDocumentLoader->release(); + + m_xDBRegistrationAggregate->setDelegator( NULL ); + m_xDBRegistrationAggregate.clear(); + m_xDatabaseRegistrations.clear(); } // Helper @@ -327,25 +316,6 @@ void ODatabaseContext::disposing() m_aDatabaseObjects.clear(); } -//------------------------------------------------------------------------------ -bool ODatabaseContext::getURLForRegisteredObject( const ::rtl::OUString& _rRegisteredName, ::rtl::OUString& _rURL ) -{ - if ( !_rRegisteredName.getLength() ) - throw IllegalArgumentException(); - - // the config node where all pooling relevant info are stored under - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY); - if ( aDbRegisteredNamesRoot.isValid() && aDbRegisteredNamesRoot.hasByName( _rRegisteredName ) ) - { - OConfigurationNode aRegisterObj = aDbRegisteredNamesRoot.openNode( _rRegisteredName ); - aRegisterObj.getNodeValue(getDbLocationNodeName()) >>= _rURL; - _rURL = SvtPathOptions().SubstituteVariable( _rURL ); - return true; - } - return false; -} - // XNamingService //------------------------------------------------------------------------------ Reference< XInterface > ODatabaseContext::getRegisteredObject(const rtl::OUString& _rName) throw( Exception, RuntimeException ) @@ -353,9 +323,7 @@ Reference< XInterface > ODatabaseContext::getRegisteredObject(const rtl::OUStri MutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed); - ::rtl::OUString sURL; - if ( !getURLForRegisteredObject( _rName, sURL ) ) - throw NoSuchElementException(_rName, *this); + ::rtl::OUString sURL( getDatabaseLocation( _rName ) ); if ( !sURL.getLength() ) // there is a registration for this name, but no URL @@ -372,12 +340,12 @@ Reference< XInterface > ODatabaseContext::getRegisteredObject(const rtl::OUStri Reference< XInterface > ODatabaseContext::loadObjectFromURL(const ::rtl::OUString& _rName,const ::rtl::OUString& _sURL) { INetURLObject aURL( _sURL ); - if( aURL.GetProtocol() == INET_PROT_NOT_VALID ) - throw NoSuchElementException(_rName, *this); + if ( aURL.GetProtocol() == INET_PROT_NOT_VALID ) + throw NoSuchElementException( _rName, *this ); try { - ::ucbhelper::Content aContent(_sURL,Reference< ::com::sun::star::ucb::XCommandEnvironment >()); + ::ucbhelper::Content aContent( _sURL, NULL ); if ( !aContent.isDocument() ) throw InteractiveIOException( _sURL, *this, InteractionClassification_ERROR, IOErrorCode_NO_FILE @@ -398,30 +366,23 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const ::rtl::OUStrin SQLException aError; aError.Message = sErrorMessage; - throw WrappedTargetException( _sURL, Reference< XNamingService >( this ), makeAny( aError ) ); + throw WrappedTargetException( _sURL, *this, makeAny( aError ) ); } - throw WrappedTargetException( _sURL, Reference< XNamingService >( this ), ::cppu::getCaughtException() ); + throw WrappedTargetException( _sURL, *this, ::cppu::getCaughtException() ); } catch( const Exception& ) { - throw WrappedTargetException( _sURL, Reference<XNamingService>(this), ::cppu::getCaughtException() ); + throw WrappedTargetException( _sURL, *this, ::cppu::getCaughtException() ); } - ::rtl::Reference< ODatabaseModelImpl > pExistent; - ObjectCache::iterator aFind = m_aDatabaseObjects.find(_sURL); - - if ( aFind != m_aDatabaseObjects.end() ) // we found a object registered under the URL - { // register it under the new name - pExistent = aFind->second; - m_aDatabaseObjects.insert( ObjectCache::value_type( _rName, pExistent.get() ) ); - m_aDatabaseObjects.erase( aFind ); - } + OSL_ENSURE( m_aDatabaseObjects.find( _sURL ) == m_aDatabaseObjects.end(), + "ODatabaseContext::loadObjectFromURL: not intended for already-cached objects!" ); - if ( !pExistent.get() ) + ::rtl::Reference< ODatabaseModelImpl > pModelImpl; { - pExistent.set( new ODatabaseModelImpl( _rName, m_aContext.getLegacyServiceFactory(), *this ) ); + pModelImpl.set( new ODatabaseModelImpl( _rName, m_aContext.getLegacyServiceFactory(), *this ) ); - Reference< XModel > xModel( pExistent->createNewModel_deliverOwnership( false ), UNO_SET_THROW ); + Reference< XModel > xModel( pModelImpl->createNewModel_deliverOwnership( false ), UNO_SET_THROW ); Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW ); ::comphelper::NamedValueCollection aArgs; @@ -434,11 +395,11 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const ::rtl::OUStrin xModel->attachResource( _sURL, aResource ); ::utl::CloseableComponent aEnsureClose( xModel ); - } // if ( !pExistent.get() ) + } - setTransientProperties( _sURL, *pExistent ); + setTransientProperties( _sURL, *pModelImpl ); - return pExistent->getOrCreateDataSource().get(); + return pModelImpl->getOrCreateDataSource().get(); } // ----------------------------------------------------------------------------- void ODatabaseContext::appendAtTerminateListener(const ODatabaseModelImpl& _rDataSourceModel) @@ -500,23 +461,7 @@ void ODatabaseContext::registerObject(const rtl::OUString& _rName, const Referen if ( !sURL.getLength() ) throw IllegalArgumentException( DBACORE_RESSTRING( RID_STR_DATASOURCE_NOT_STORED ), *this, 2 ); - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE); - - if ( aDbRegisteredNamesRoot.isValid() ) - { - OConfigurationNode oDataSourceRegistration; - // the sub-node for the concrete registration - if (aDbRegisteredNamesRoot.hasByName(_rName)) - oDataSourceRegistration = aDbRegisteredNamesRoot.openNode(_rName); - else - oDataSourceRegistration = aDbRegisteredNamesRoot.createNode(_rName); - - // set the values - oDataSourceRegistration.setNodeValue(getDbNameNodeName(), makeAny(_rName)); - oDataSourceRegistration.setNodeValue(getDbLocationNodeName(), makeAny(sURL)); - aDbRegisteredNamesRoot.commit(); - } + registerDatabaseLocation( _rName, sURL ); ODatabaseSource::setName( xDocDataSource, _rName, ODatabaseSource::DBContextAccess() ); @@ -572,6 +517,8 @@ void ODatabaseContext::storeTransientProperties( ODatabaseModelImpl& _rModelImpl } else if ( m_aDatabaseObjects.find( _rModelImpl.m_sName ) != m_aDatabaseObjects.end() ) { + OSL_ENSURE( false, "ODatabaseContext::storeTransientProperties: a database document register by name? This shouldn't happen anymore!" ); + // all the code should have been changed so that registration is by URL only m_aDatasourceProperties[ _rModelImpl.m_sName ] = aRememberProps.getPropertyValues(); } else @@ -596,42 +543,84 @@ void SAL_CALL ODatabaseContext::removeContainerListener( const Reference< XConta //------------------------------------------------------------------------------ void ODatabaseContext::revokeObject(const rtl::OUString& _rName) throw( Exception, RuntimeException ) { - MutexGuard aGuard(m_aMutex); + ClearableMutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed); - Reference< XInterface > xExistent; + ::rtl::OUString sURL = getDatabaseLocation( _rName ); - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE); - if ( aDbRegisteredNamesRoot.isValid() && aDbRegisteredNamesRoot.hasByName(_rName) ) - { - OConfigurationNode aThisDriverSettings = aDbRegisteredNamesRoot.openNode(_rName); - ::rtl::OUString sURL; - aThisDriverSettings.getNodeValue(getDbLocationNodeName()) >>= sURL; - sURL = SvtPathOptions().SubstituteVariable(sURL); + revokeDatabaseLocation( _rName ); + // will throw if something goes wrong - if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() ) - { - m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ]; - } - - // check if URL is already loaded - ObjectCacheIterator aExistent = m_aDatabaseObjects.find(sURL); - if ( aExistent != m_aDatabaseObjects.end() ) - m_aDatabaseObjects.erase(aExistent); - if (!aDbRegisteredNamesRoot.removeNode(_rName)) - throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("An unexpected und unknown error occured.")), static_cast<XNamingService*>(this)); - aDbRegisteredNamesRoot.commit(); + if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() ) + { + OSL_ENSURE( false, "ODatabaseContext::revokeObject: a database document register by name? This shouldn't happen anymore!" ); + // all the code should have been changed so that registration is by URL only + m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ]; } - else - throw NoSuchElementException(_rName,*this); + + // check if URL is already loaded + ObjectCacheIterator aExistent = m_aDatabaseObjects.find( sURL ); + if ( aExistent != m_aDatabaseObjects.end() ) + m_aDatabaseObjects.erase( aExistent ); // notify our container listeners - ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rName), Any(), makeAny(xExistent)); - // note that xExistent may be empty, in case somebody removed the data source while it is not alive at this moment - OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners); - while (aListenerLoop.hasMoreElements()) - static_cast<XContainerListener*>(aListenerLoop.next())->elementRemoved(aEvent); + ContainerEvent aEvent( *this, makeAny( _rName ), Any(), Any() ); + aGuard.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); +} + +//------------------------------------------------------------------------------ +::sal_Bool SAL_CALL ODatabaseContext::hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException) +{ + return m_xDatabaseRegistrations->hasRegisteredDatabase( _Name ); +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL ODatabaseContext::getRegistrationNames() throw (RuntimeException) +{ + return m_xDatabaseRegistrations->getRegistrationNames(); +} + +//------------------------------------------------------------------------------ +::rtl::OUString SAL_CALL ODatabaseContext::getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException) +{ + return m_xDatabaseRegistrations->getDatabaseLocation( _Name ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL ODatabaseContext::registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException) +{ + m_xDatabaseRegistrations->registerDatabaseLocation( _Name, _Location ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL ODatabaseContext::revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException) +{ + m_xDatabaseRegistrations->revokeDatabaseLocation( _Name ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL ODatabaseContext::changeDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException) +{ + m_xDatabaseRegistrations->changeDatabaseLocation( _Name, _NewLocation ); +} + +//------------------------------------------------------------------------------ +::sal_Bool SAL_CALL ODatabaseContext::isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException) +{ + return m_xDatabaseRegistrations->isDatabaseRegistrationReadOnly( _Name ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL ODatabaseContext::addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException) +{ + m_xDatabaseRegistrations->addDatabaseRegistrationsListener( _Listener ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL ODatabaseContext::removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException) +{ + m_xDatabaseRegistrations->removeDatabaseRegistrationsListener( _Listener ); } // ::com::sun::star::container::XElementAccess @@ -670,14 +659,15 @@ Any ODatabaseContext::getByName(const rtl::OUString& _rName) throw( NoSuchElemen try { - Reference< XInterface > xExistent = getObject(_rName); + Reference< XInterface > xExistent = getObject( _rName ); if ( xExistent.is() ) - return makeAny(xExistent); + return makeAny( xExistent ); // see whether this is an registered name ::rtl::OUString sURL; - if ( getURLForRegisteredObject( _rName, sURL ) ) + if ( hasRegisteredDatabase( _rName ) ) { + sURL = getDatabaseLocation( _rName ); // is the object cached under its URL? xExistent = getObject( sURL ); } @@ -704,7 +694,8 @@ Any ODatabaseContext::getByName(const rtl::OUString& _rName) throw( NoSuchElemen } catch (Exception& e) { // exceptions other than the speciafied ones -> wrap - throw WrappedTargetException(_rName, *this, makeAny( e ) ); + Any aError = ::cppu::getCaughtException(); + throw WrappedTargetException(_rName, *this, aError ); } } @@ -714,19 +705,7 @@ Sequence< rtl::OUString > ODatabaseContext::getElementNames(void) throw( Runtime MutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed); - DECLARE_STL_USTRINGACCESS_MAP( bool , TNameMap); - TNameMap aRet; - - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY); - - Sequence< ::rtl::OUString> aSeq; - if ( aDbRegisteredNamesRoot.isValid() ) - { - aSeq = aDbRegisteredNamesRoot.getNodeNames(); - } // if ( aDbRegisteredNamesRoot.isValid() ) - - return aSeq; + return getRegistrationNames(); } //------------------------------------------------------------------------------ @@ -735,42 +714,57 @@ sal_Bool ODatabaseContext::hasByName(const rtl::OUString& _rName) throw( Runtime MutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed); - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY); - - return aDbRegisteredNamesRoot.isValid() && aDbRegisteredNamesRoot.hasByName(_rName); + return hasRegisteredDatabase( _rName ); } + // ----------------------------------------------------------------------------- -Reference< XInterface > ODatabaseContext::getObject(const ::rtl::OUString& _rName) +Reference< XInterface > ODatabaseContext::getObject( const ::rtl::OUString& _rURL ) { - ObjectCacheIterator aFind = m_aDatabaseObjects.find(_rName); + ObjectCacheIterator aFind = m_aDatabaseObjects.find( _rURL ); Reference< XInterface > xExistent; if ( aFind != m_aDatabaseObjects.end() ) xExistent = aFind->second->getOrCreateDataSource(); return xExistent; } // ----------------------------------------------------------------------------- -void ODatabaseContext::registerPrivate(const ::rtl::OUString& _sName - ,const ::rtl::Reference<ODatabaseModelImpl>& _pModelImpl) +void ODatabaseContext::registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl ) { - // OSL_ENSURE(m_aDatabaseObjects.find(_sName) == m_aDatabaseObjects.end(),"Name already exists!"); - if ( m_aDatabaseObjects.find(_sName) == m_aDatabaseObjects.end() ) + ::rtl::OUString sURL( _rModelImpl.getURL() ); +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "DatabaseContext: registering %s", ::rtl::OUStringToOString( sURL, RTL_TEXTENCODING_UTF8 ).getStr() ); +#endif + if ( m_aDatabaseObjects.find( sURL ) == m_aDatabaseObjects.end() ) { - m_aDatabaseObjects.insert(ObjectCache::value_type(_sName,_pModelImpl.get())); - setTransientProperties( _sName, *_pModelImpl ); + m_aDatabaseObjects[ sURL ] = &_rModelImpl; + setTransientProperties( sURL, _rModelImpl ); } + else + OSL_ENSURE( false, "ODatabaseContext::registerDatabaseDocument: already have an object registered for this URL!" ); } // ----------------------------------------------------------------------------- -void ODatabaseContext::deregisterPrivate(const ::rtl::OUString& _sName) +void ODatabaseContext::revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl ) { - m_aDatabaseObjects.erase(_sName); + ::rtl::OUString sURL( _rModelImpl.getURL() ); +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "DatabaseContext: deregistering %s", ::rtl::OUStringToOString( sURL, RTL_TEXTENCODING_UTF8 ).getStr() ); +#endif + m_aDatabaseObjects.erase( sURL ); } // ----------------------------------------------------------------------------- -void ODatabaseContext::nameChangePrivate(const ::rtl::OUString& _sOldName, const ::rtl::OUString& _sNewName) -{ - ObjectCache::iterator aFind = m_aDatabaseObjects.find(_sOldName); - registerPrivate(_sNewName,aFind->second); - m_aDatabaseObjects.erase(aFind); +void ODatabaseContext::databaseDocumentURLChange( const ::rtl::OUString& _rOldURL, const ::rtl::OUString& _rNewURL ) +{ +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "DatabaseContext: changing registration from %s to %s", + ::rtl::OUStringToOString( _rOldURL, RTL_TEXTENCODING_UTF8 ).getStr(), + ::rtl::OUStringToOString( _rNewURL, RTL_TEXTENCODING_UTF8 ).getStr() ); +#endif + ObjectCache::iterator oldPos = m_aDatabaseObjects.find( _rOldURL ); + ENSURE_OR_THROW( oldPos != m_aDatabaseObjects.end(), "illegal old database document URL" ); + ObjectCache::iterator newPos = m_aDatabaseObjects.find( _rNewURL ); + ENSURE_OR_THROW( newPos == m_aDatabaseObjects.end(), "illegal new database document URL" ); + + m_aDatabaseObjects[ _rNewURL ] = oldPos->second; + m_aDatabaseObjects.erase( oldPos ); } // ----------------------------------------------------------------------------- sal_Int64 SAL_CALL ODatabaseContext::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException) diff --git a/dbaccess/source/core/dataaccess/databasecontext.hxx b/dbaccess/source/core/dataaccess/databasecontext.hxx index 645764401..e0d3a39e9 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.hxx +++ b/dbaccess/source/core/dataaccess/databasecontext.hxx @@ -31,57 +31,29 @@ #ifndef _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_ #define _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_ -#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include "ModelImpl.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/container/ElementExistException.hpp> +#include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ -#include <com/sun/star/uno/XNamingService.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ -#include <com/sun/star/lang/XUnoTunnel.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XDATABASEENVIRONMENT_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/sdb/XDatabaseEnvironment.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_ -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ -#include <com/sun/star/container/XContainer.hpp> -#endif -#ifndef _CPPUHELPER_COMPBASE7_HXX_ -#include <cppuhelper/compbase7.hxx> -#endif -#ifndef _COMPHELPER_STLTYPES_HXX_ -#include <comphelper/stl_types.hxx> -#endif -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> +#include <com/sun/star/uno/XNamingService.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +/** === end UNO includes === **/ + +#include <basic/basicmanagerrepository.hxx> #include <comphelper/componentcontext.hxx> -#endif -#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ +#include <comphelper/stl_types.hxx> +#include <cppuhelper/compbase8.hxx> #include <cppuhelper/interfacecontainer.hxx> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_ELEMENTEXISTEXCEPTION_HPP_ -#include <com/sun/star/container/ElementExistException.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ -#include <com/sun/star/lang/XEventListener.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#endif -#ifndef _DBA_COREDATAACCESS_MODELIMPL_HXX_ -#include "ModelImpl.hxx" -#endif -#ifndef BASICMANAGERREPOSITORY_HXX -#include <basic/basicmanagerrepository.hxx> -#endif #include <boost/shared_ptr.hpp> @@ -105,13 +77,14 @@ class DatabaseDocumentLoader; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ODatabaseContext_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&); -typedef ::cppu::WeakComponentImplHelper7 < ::com::sun::star::lang::XServiceInfo +typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::lang::XServiceInfo , ::com::sun::star::container::XEnumerationAccess , ::com::sun::star::container::XNameAccess , ::com::sun::star::uno::XNamingService , ::com::sun::star::container::XContainer , ::com::sun::star::lang::XSingleServiceFactory , ::com::sun::star::lang::XUnoTunnel + , ::com::sun::star::sdb::XDatabaseRegistrations > DatabaseAccessContext_Base; class ODatabaseContext :public DatabaseAccessContext_Base @@ -124,13 +97,7 @@ private: */ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > loadObjectFromURL(const ::rtl::OUString& _rName,const ::rtl::OUString& _sURL); - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getObject(const ::rtl::OUString& _rName); - - /** retrieves the URL for a given registration name, if any - @returns <FALSE/> if and only if there exists a registration for the given name - @throws IllegalArgumentException if the name is empty - */ - bool getURLForRegisteredObject( const ::rtl::OUString& _rRegisteredName, ::rtl::OUString& _rURL ); + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getObject( const ::rtl::OUString& _rURL ); /** sets all properties which were transient at the data source. e.g. password @param _sURL The file URL of the data source @@ -147,6 +114,11 @@ protected: ::osl::Mutex m_aMutex; ::comphelper::ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > + m_xDBRegistrationAggregate; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrations > + m_xDatabaseRegistrations; + DECLARE_STL_USTRINGACCESS_MAP( ODatabaseModelImpl*, ObjectCache ); ObjectCache m_aDatabaseObjects; @@ -166,42 +138,53 @@ public: virtual ~ODatabaseContext(); -// OComponentHelper + // OComponentHelper virtual void SAL_CALL disposing(void); -// ::com::sun::star::lang::XSingleServiceFactory + // XSingleServiceFactory virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); -// ::com::sun::star::lang::XServiceInfo + // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::lang::XServiceInfo - static methods + // XServiceInfo - static methods static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException ); static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException ); static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&); -// ::com::sun::star::container::XElementAccess + // XElementAccess virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XEnumerationAccess + // XEnumerationAccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XNameAccess + // XNameAccess virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::uno::XNamingService + // XNamingService virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL registerObject( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL revokeObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XContainer + // XDatabaseRegistrations + virtual ::sal_Bool SAL_CALL hasRegisteredDatabase( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRegistrationNames() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseLocation( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL registerDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& Location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL revokeDatabaseLocation( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL changeDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& NewLocation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addDatabaseRegistrationsListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrationsListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeDatabaseRegistrationsListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrationsListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + + // XContainer virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); @@ -209,10 +192,9 @@ public: 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(); - void registerPrivate(const ::rtl::OUString& _sName - ,const ::rtl::Reference<ODatabaseModelImpl>& _pModelImpl); - void deregisterPrivate(const ::rtl::OUString& _sName); - void nameChangePrivate(const ::rtl::OUString& _sOldName, const ::rtl::OUString& _sNewName); + void registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl); + void revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl); + void databaseDocumentURLChange(const ::rtl::OUString& _sOldName, const ::rtl::OUString& _sNewName); void storeTransientProperties( ODatabaseModelImpl& _rModelImpl); void appendAtTerminateListener(const ODatabaseModelImpl& _rDataSourceModel); void removeFromTerminateListener(const ODatabaseModelImpl& _rDataSourceModel); diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 233558d16..682b9d7bd 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.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 @@ -40,18 +40,10 @@ #include "documenteventexecutor.hxx" #include "databasecontext.hxx" #include "documentcontainer.hxx" - -#include <comphelper/documentconstants.hxx> -#include <comphelper/namedvaluecollection.hxx> -#include <comphelper/enumhelper.hxx> -#include <comphelper/numberedcollection.hxx> -#include <comphelper/genericpropertyset.hxx> -#include <comphelper/property.hxx> -#include <svtools/saveopt.hxx> - -#include <framework/titlehelper.hxx> +#include "sdbcoretools.hxx" /** === begin UNO includes === **/ +#include <com/sun/star/beans/Optional.hpp> #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> @@ -61,24 +53,30 @@ #include <com/sun/star/embed/XTransactionBroadcaster.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/script/provider/XScriptProviderFactory.hpp> #include <com/sun/star/task/ErrorCodeIOException.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ui/XUIConfigurationStorage.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> /** === end UNO includes === **/ #include <comphelper/documentconstants.hxx> -#include <comphelper/interaction.hxx> #include <comphelper/enumhelper.hxx> +#include <comphelper/genericpropertyset.hxx> +#include <comphelper/interaction.hxx> #include <comphelper/mediadescriptor.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/numberedcollection.hxx> +#include <comphelper/property.hxx> #include <comphelper/storagehelper.hxx> #include <cppuhelper/exc_hlp.hxx> #include <framework/titlehelper.hxx> +#include <unotools/saveopt.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <tools/errcode.hxx> @@ -175,6 +173,7 @@ ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& ,m_bAllowDocumentScripting( false ) { DBG_CTOR(ODatabaseDocument,NULL); + OSL_TRACE( "DD: ctor: %p: %p", this, m_pImpl.get() ); osl_incrementInterlockedCount( &m_refCount ); { @@ -201,6 +200,7 @@ ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& { // if the previous incarnation of the DatabaseDocument already had an URL, then creating this incarnation // here is effectively loading the document. + // #i105505# / 2009-10-01 / frank.schoenheit@sun.com m_aViewMonitor.onLoadedDocument(); } } @@ -209,6 +209,7 @@ ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& //-------------------------------------------------------------------------- ODatabaseDocument::~ODatabaseDocument() { + OSL_TRACE( "DD: dtor: %p: %p", this, m_pImpl.get() ); DBG_DTOR(ODatabaseDocument,NULL); if ( !ODatabaseDocument_OfficeDocument::rBHelper.bInDispose && !ODatabaseDocument_OfficeDocument::rBHelper.bDisposed ) { @@ -438,7 +439,7 @@ void ODatabaseDocument::impl_import_nolck_throw( const ::comphelper::ComponentCo uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(_rResource.getOrDefault("URL",::rtl::OUString()))); xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml")))); - + const sal_Int32 nCount = aFilterArgs.getLength(); aFilterArgs.realloc(nCount + 1); aFilterArgs[nCount] <<= xInfoSet; @@ -815,13 +816,11 @@ void ODatabaseDocument::impl_storeAs_throw( const ::rtl::OUString& _rURL, const throw; } - Exception aExcept; - aError >>= aExcept; - - ::rtl::OUString sErrorMessage = ResourceManager::loadString( + ::rtl::OUString sErrorMessage = extractExceptionMessage( m_pImpl->m_aContext, aError ); + sErrorMessage = ResourceManager::loadString( RID_STR_ERROR_WHILE_SAVING, - "$except$", aError.getValueTypeName(), - "$message$", aExcept.Message + "$location$", _rURL, + "$message$", sErrorMessage ); throw IOException( sErrorMessage, *this ); } @@ -842,8 +841,16 @@ void ODatabaseDocument::impl_storeAs_throw( const ::rtl::OUString& _rURL, const // ----------------------------------------------------------------------------- Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const ::rtl::OUString& _rURL ) const { + Reference < ::com::sun::star::ucb::XSimpleFileAccess > xTempAccess; + m_pImpl->m_aContext.createComponent( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ,xTempAccess); + Reference< io::XStream > xStream = xTempAccess->openFileReadWrite( _rURL ); + Reference< io::XTruncate > xTruncate(xStream,UNO_QUERY); + if ( xTruncate.is() ) + { + xTruncate->truncate(); + } Sequence<Any> aParam(2); - aParam[0] <<= _rURL; + aParam[0] <<= xStream; aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE; Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory(), UNO_SET_THROW ); @@ -979,10 +986,11 @@ void SAL_CALL ODatabaseDocument::storeToURL( const ::rtl::OUString& _rURL, const Exception aExcept; aError >>= aExcept; - ::rtl::OUString sErrorMessage = ResourceManager::loadString( + ::rtl::OUString sErrorMessage = extractExceptionMessage( m_pImpl->m_aContext, aError ); + sErrorMessage = ResourceManager::loadString( RID_STR_ERROR_WHILE_SAVING, - "$except$", aError.getValueTypeName(), - "$message$", aExcept.Message + "$location$", _rURL, + "$message$", sErrorMessage ); throw IOException( sErrorMessage, *this ); } @@ -1152,7 +1160,7 @@ void ODatabaseDocument::impl_closeControllerFrames_nolck_throw( sal_Bool _bDeliv { Controllers aCopy = m_aControllers; - Controllers::iterator aEnd = aCopy.end(); + Controllers::iterator aEnd = aCopy.end(); for ( Controllers::iterator aIter = aCopy.begin(); aIter != aEnd ; ++aIter ) { if ( !aIter->is() ) @@ -1462,6 +1470,7 @@ void ODatabaseDocument::impl_notifyStorageChange_nolck_nothrow( const Reference< //------------------------------------------------------------------------------ void ODatabaseDocument::disposing() { + OSL_TRACE( "DD: disp: %p: %p", this, m_pImpl.get() ); if ( !m_pImpl.is() ) { // this means that we're already disposed @@ -1787,13 +1796,13 @@ Reference< XTitle > ODatabaseDocument::impl_getTitleHelper_throw() m_pImpl->m_aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); uno::Reference< frame::XModel > xThis (getThis(), uno::UNO_QUERY_THROW); - + ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_pImpl->m_aContext.getLegacyServiceFactory()); m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW); pHelper->setOwner (xThis ); pHelper->connectWithUntitledNumbers (xDesktop); } - + return m_xTitleHelper; } @@ -1820,7 +1829,7 @@ uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHel uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* >(this), uno::UNO_QUERY_THROW); ::comphelper::NumberedCollection* pHelper = new ::comphelper::NumberedCollection(); xNumberedControllers.set(static_cast< ::cppu::OWeakObject* >(pHelper), uno::UNO_QUERY_THROW); - + pHelper->setOwner (xThis); //pHelper->setUntitledPrefix (::rtl::OUString::createFromAscii(" : ")); @@ -1828,7 +1837,7 @@ uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHel } else xNumberedControllers = aFind->second; - + return xNumberedControllers; } @@ -1865,7 +1874,7 @@ void SAL_CALL ODatabaseDocument::addTitleChangeListener( const uno::Reference< f uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW ); xBroadcaster->addTitleChangeListener( xListener ); } - + //============================================================================= // css.frame.XTitleChangeBroadcaster void SAL_CALL ODatabaseDocument::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener ) @@ -1887,7 +1896,7 @@ void SAL_CALL ODatabaseDocument::removeTitleChangeListener( const uno::Reference DocumentGuard aGuard( *this ); return impl_getUntitledHelper_throw(xComponent)->leaseNumber (xComponent); } - + //============================================================================= // css.frame.XUntitledNumbers void SAL_CALL ODatabaseDocument::releaseNumber( ::sal_Int32 nNumber ) @@ -1897,7 +1906,7 @@ void SAL_CALL ODatabaseDocument::releaseNumber( ::sal_Int32 nNumber ) DocumentGuard aGuard( *this ); impl_getUntitledHelper_throw()->releaseNumber (nNumber); } - + //============================================================================= // css.frame.XUntitledNumbers void SAL_CALL ODatabaseDocument::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent ) diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.cxx b/dbaccess/source/core/dataaccess/databaseregistrations.cxx new file mode 100644 index 000000000..8f470c45a --- /dev/null +++ b/dbaccess/source/core/dataaccess/databaseregistrations.cxx @@ -0,0 +1,398 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/implbase1.hxx> +#include <rtl/ustrbuf.hxx> +#include <unotools/pathoptions.hxx> +#include <tools/urlobj.hxx> +#include <unotools/confignode.hxx> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::container::NoSuchElementException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::lang::IllegalAccessException; + using ::com::sun::star::container::ElementExistException; + using ::com::sun::star::sdb::XDatabaseRegistrations; + using ::com::sun::star::sdb::XDatabaseRegistrationsListener; + using ::com::sun::star::sdb::DatabaseRegistrationEvent; + using ::com::sun::star::uno::XAggregation; + /** === end UNO using === **/ + + //-------------------------------------------------------------------- + static const ::rtl::OUString& getConfigurationRootPath() + { + static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames"); + return s_sNodeName; + } + + //-------------------------------------------------------------------- + const ::rtl::OUString& getLocationNodeName() + { + static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii( "Location" ); + return s_sNodeName; + } + + //-------------------------------------------------------------------- + const ::rtl::OUString& getNameNodeName() + { + static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii( "Name" ); + return s_sNodeName; + } + + //==================================================================== + //= DatabaseRegistrations - declaration + //==================================================================== + typedef ::cppu::WeakAggImplHelper1 < XDatabaseRegistrations + > DatabaseRegistrations_Base; + class DatabaseRegistrations :public ::cppu::BaseMutex + ,public DatabaseRegistrations_Base + { + public: + DatabaseRegistrations( const ::comphelper::ComponentContext& _rxContext ); + + protected: + ~DatabaseRegistrations(); + + public: + virtual ::sal_Bool SAL_CALL hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getRegistrationNames() throw (RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException); + virtual void SAL_CALL registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException); + virtual void SAL_CALL revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException); + virtual void SAL_CALL changeDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException); + virtual ::sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException); + virtual void SAL_CALL addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& Listener ) throw (RuntimeException); + virtual void SAL_CALL removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& Listener ) throw (RuntimeException); + + private: + ::utl::OConfigurationNode + impl_checkValidName_throw( const ::rtl::OUString& _rName, const bool _bMustExist ); + + void impl_checkValidLocation_throw( const ::rtl::OUString& _rLocation ); + + /** retrieves the configuration node whose "Name" sub node has the given value + + Since we separated the name of the registration node from the "Name" value of the registration, we cannot + simply do a "getByName" (equivalent) when we want to retrieve the node for a given registration name. + Instead, we must search all nodes. + + If _bMustExist is <TRUE/>, and a node with the given display name does not exist, then a NoSuchElementException + is thrown. + + If _bMustExist is <FALSE/>, and a node with the given name already exists, then a ElementExistException is + thrown. + + In either case, if no exception is thrown, then a valid node is returned: If the node existed and was allowed + to exist, it is returned, if the node did not yet exist, and was required to not exist, a new node is created. + However, in this case the root node is not yet committed. + */ + ::utl::OConfigurationNode + impl_getNodeForName_throw( const ::rtl::OUString& _rName, const bool _bMustExist ); + + ::utl::OConfigurationNode + impl_getNodeForName_nothrow( const ::rtl::OUString& _rName ); + + private: + ::comphelper::ComponentContext m_aContext; + ::utl::OConfigurationTreeRoot m_aConfigurationRoot; + ::cppu::OInterfaceContainerHelper m_aRegistrationListeners; + }; + + //==================================================================== + //= DatabaseRegistrations - implementation + //==================================================================== + //-------------------------------------------------------------------- + DatabaseRegistrations::DatabaseRegistrations( const ::comphelper::ComponentContext& _rxContext ) + :m_aContext( _rxContext ) + ,m_aConfigurationRoot() + ,m_aRegistrationListeners( m_aMutex ) + { + m_aConfigurationRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory( + m_aContext.getLegacyServiceFactory(), getConfigurationRootPath(), -1, ::utl::OConfigurationTreeRoot::CM_UPDATABLE ); + } + + //-------------------------------------------------------------------- + DatabaseRegistrations::~DatabaseRegistrations() + { + } + + //-------------------------------------------------------------------- + ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_nothrow( const ::rtl::OUString& _rName ) + { + Sequence< ::rtl::OUString > aNames( m_aConfigurationRoot.getNodeNames() ); + for ( const ::rtl::OUString* pName = aNames.getConstArray(); + pName != aNames.getConstArray() + aNames.getLength(); + ++pName + ) + { + ::utl::OConfigurationNode aNodeForName = m_aConfigurationRoot.openNode( *pName ); + + ::rtl::OUString sTestName; + OSL_VERIFY( aNodeForName.getNodeValue( getNameNodeName() ) >>= sTestName ); + if ( sTestName == _rName ) + return aNodeForName; + } + return ::utl::OConfigurationNode(); + } + + //-------------------------------------------------------------------- + ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_throw( const ::rtl::OUString& _rName, const bool _bMustExist ) + { + ::utl::OConfigurationNode aNodeForName( impl_getNodeForName_nothrow( _rName ) ); + + if ( aNodeForName.isValid() ) + { + if ( !_bMustExist ) + throw ElementExistException( _rName, *this ); + + return aNodeForName; + } + + if ( _bMustExist ) + throw NoSuchElementException( _rName, *this ); + + ::rtl::OUString sNewNodeName; + { + ::rtl::OUStringBuffer aNewNodeName; + aNewNodeName.appendAscii( "org.openoffice." ); + aNewNodeName.append( _rName ); + + // make unique + ::rtl::OUStringBuffer aReset( aNewNodeName ); + sNewNodeName = aNewNodeName.makeStringAndClear(); + sal_Int32 i=2; + while ( m_aConfigurationRoot.hasByName( sNewNodeName ) ) + { + aNewNodeName = aReset; + aNewNodeName.appendAscii( " " ); + aNewNodeName.append( i ); + sNewNodeName = aNewNodeName.makeStringAndClear(); + } + } + + ::utl::OConfigurationNode aNewNode( m_aConfigurationRoot.createNode( sNewNodeName ) ); + aNewNode.setNodeValue( getNameNodeName(), makeAny( _rName ) ); + return aNewNode; + } + + //-------------------------------------------------------------------- + ::utl::OConfigurationNode DatabaseRegistrations::impl_checkValidName_throw( const ::rtl::OUString& _rName, const bool _bMustExist ) + { + if ( !m_aConfigurationRoot.isValid() ) + throw RuntimeException( ::rtl::OUString(), *this ); + + if ( !_rName.getLength() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + + return impl_getNodeForName_throw( _rName, _bMustExist ); + } + + //-------------------------------------------------------------------- + void DatabaseRegistrations::impl_checkValidLocation_throw( const ::rtl::OUString& _rLocation ) + { + if ( !_rLocation.getLength() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 2 ); + + INetURLObject aURL( _rLocation ); + if ( aURL.GetProtocol() == INET_PROT_NOT_VALID ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 2 ); + } + + //-------------------------------------------------------------------- + ::sal_Bool SAL_CALL DatabaseRegistrations::hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + ::utl::OConfigurationNode aNodeForName = impl_getNodeForName_nothrow( _Name ); + return aNodeForName.isValid(); + } + + //------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL DatabaseRegistrations::getRegistrationNames() throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_aConfigurationRoot.isValid() ) + throw RuntimeException( ::rtl::OUString(), *this ); + + Sequence< ::rtl::OUString > aProgrammaticNames( m_aConfigurationRoot.getNodeNames() ); + Sequence< ::rtl::OUString > aDisplayNames( aProgrammaticNames.getLength() ); + ::rtl::OUString* pDisplayName = aDisplayNames.getArray(); + + for ( const ::rtl::OUString* pName = aProgrammaticNames.getConstArray(); + pName != aProgrammaticNames.getConstArray() + aProgrammaticNames.getLength(); + ++pName, ++pDisplayName + ) + { + ::utl::OConfigurationNode aRegistrationNode = m_aConfigurationRoot.openNode( *pName ); + OSL_VERIFY( aRegistrationNode.getNodeValue( getNameNodeName() ) >>= *pDisplayName ); + + } + + return aDisplayNames; + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL DatabaseRegistrations::getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + + ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw( _Name, true ); + + ::rtl::OUString sLocation; + OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation ); + sLocation = SvtPathOptions().SubstituteVariable( sLocation ); + + return sLocation; + } + + //-------------------------------------------------------------------- + void SAL_CALL DatabaseRegistrations::registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + // check + impl_checkValidLocation_throw( _Location ); + ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, false ); + + // register + aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( _Location ) ); + m_aConfigurationRoot.commit(); + + // notify + DatabaseRegistrationEvent aEvent( *this, _Name, ::rtl::OUString(), _Location ); + aGuard.clear(); + m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::registeredDatabaseLocation, aEvent ); + } + + //-------------------------------------------------------------------- + void SAL_CALL DatabaseRegistrations::revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + // check + ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw( _Name, true ); + + // obtain properties for notification + ::rtl::OUString sLocation; + OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation ); + + // revoke + if ( aNodeForName.isReadonly() + || !m_aConfigurationRoot.removeNode( aNodeForName.getLocalName() ) + ) + throw IllegalAccessException( ::rtl::OUString(), *this ); + + m_aConfigurationRoot.commit(); + + // notify + DatabaseRegistrationEvent aEvent( *this, _Name, sLocation, ::rtl::OUString() ); + aGuard.clear(); + m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::revokedDatabaseLocation, aEvent ); + } + + //-------------------------------------------------------------------- + void SAL_CALL DatabaseRegistrations::changeDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + // check + impl_checkValidLocation_throw( _NewLocation ); + ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, true ); + + if ( aDataSourceRegistration.isReadonly() ) + throw IllegalAccessException( ::rtl::OUString(), *this ); + + // obtain properties for notification + ::rtl::OUString sOldLocation; + OSL_VERIFY( aDataSourceRegistration.getNodeValue( getLocationNodeName() ) >>= sOldLocation ); + + // change + aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( _NewLocation ) ); + m_aConfigurationRoot.commit(); + + // notify + DatabaseRegistrationEvent aEvent( *this, _Name, sOldLocation, _NewLocation ); + aGuard.clear(); + m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::changedDatabaseLocation, aEvent ); + } + + //-------------------------------------------------------------------- + ::sal_Bool SAL_CALL DatabaseRegistrations::isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, true ); + return aDataSourceRegistration.isReadonly(); + } + + //-------------------------------------------------------------------- + void SAL_CALL DatabaseRegistrations::addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException) + { + if ( _Listener.is() ) + m_aRegistrationListeners.addInterface( _Listener ); + } + + //-------------------------------------------------------------------- + void SAL_CALL DatabaseRegistrations::removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException) + { + if ( _Listener.is() ) + m_aRegistrationListeners.removeInterface( _Listener ); + } + + //==================================================================== + //= DatabaseRegistrations - factory + //==================================================================== + Reference< XAggregation > createDataSourceRegistrations( const ::comphelper::ComponentContext& _rxContext ) + { + return new DatabaseRegistrations( _rxContext ); + } + +//........................................................................ +} // namespace dbaccess +//........................................................................ diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.hxx b/dbaccess/source/core/dataaccess/databaseregistrations.hxx new file mode 100644 index 000000000..0c9f39f50 --- /dev/null +++ b/dbaccess/source/core/dataaccess/databaseregistrations.hxx @@ -0,0 +1,50 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef OOO_DATASOURCEREGISTRATIONS_HXX +#define OOO_DATASOURCEREGISTRATIONS_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/uno/XAggregation.hpp> +/** === end UNO includes === **/ + +namespace comphelper +{ + class ComponentContext; +} + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > + createDataSourceRegistrations( const ::comphelper::ComponentContext& _rxContext ); + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // OOO_DATASOURCEREGISTRATIONS_HXX diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index cbf30c87d..81137ff64 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -199,8 +199,6 @@ void SAL_CALL FlushNotificationAdapter::flushed( const EventObject& rEvent ) thr //-------------------------------------------------------------------- void SAL_CALL FlushNotificationAdapter::disposing( const EventObject& Source ) throw (RuntimeException) { - DBG_ASSERT( Source.Source == m_aBroadcaster.get(), "FlushNotificationAdapter::disposing: where did this come from?" ); - Reference< XFlushListener > xListener( m_aListener ); if ( xListener.is() ) xListener->disposing( Source ); @@ -561,21 +559,22 @@ extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource() //-------------------------------------------------------------------------- ODatabaseSource::ODatabaseSource(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl) :ModelDependentComponent( _pImpl ) - ,OSubComponent( getMutex(), Reference< XInterface >() ) - ,OPropertySetHelper(OComponentHelper::rBHelper) + ,ODatabaseSource_Base( getMutex() ) + ,OPropertySetHelper( ODatabaseSource_Base::rBHelper ) ,m_aBookmarks( *this, getMutex() ) ,m_aFlushListeners( getMutex() ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::ODatabaseSource" ); // some kind of default DBG_CTOR(ODatabaseSource,NULL); + OSL_TRACE( "DS: ctor: %p: %p", this, m_pImpl.get() ); } //-------------------------------------------------------------------------- ODatabaseSource::~ODatabaseSource() { + OSL_TRACE( "DS: dtor: %p: %p", this, m_pImpl.get() ); DBG_DTOR(ODatabaseSource,NULL); - if ( !OComponentHelper::rBHelper.bInDispose && !OComponentHelper::rBHelper.bDisposed ) + if ( !ODatabaseSource_Base::rBHelper.bInDispose && !ODatabaseSource_Base::rBHelper.bDisposed ) { acquire(); dispose(); @@ -603,11 +602,8 @@ Sequence< Type > ODatabaseSource::getTypes() throw (RuntimeException) ::getCppuType( (const Reference< XMultiPropertySet > *)0 )); return ::comphelper::concatSequences( - ::comphelper::concatSequences( - OSubComponent::getTypes(), - aPropertyHelperTypes.getTypes() - ), - ODatabaseSource_Base::getTypes() + ODatabaseSource_Base::getTypes(), + aPropertyHelperTypes.getTypes() ); } @@ -633,39 +629,26 @@ Sequence< sal_Int8 > ODatabaseSource::getImplementationId() throw (RuntimeExcept Any ODatabaseSource::queryInterface( const Type & rType ) throw (RuntimeException) { //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::queryInterface" ); - Any aIface = OSubComponent::queryInterface( rType ); - if (!aIface.hasValue()) - { - aIface = ODatabaseSource_Base::queryInterface( rType ); - if ( !aIface.hasValue() ) - { - aIface = ::cppu::queryInterface( - rType, - static_cast< XPropertySet* >( this ), - static_cast< XFastPropertySet* >( this ), - static_cast< XMultiPropertySet* >( this )); - } - } + Any aIface = ODatabaseSource_Base::queryInterface( rType ); + if ( !aIface.hasValue() ) + aIface = ::cppu::OPropertySetHelper::queryInterface( rType ); return aIface; } //-------------------------------------------------------------------------- void ODatabaseSource::acquire() throw () { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::acquire" ); - OSubComponent::acquire(); + ODatabaseSource_Base::acquire(); } //-------------------------------------------------------------------------- void ODatabaseSource::release() throw () { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::release" ); - OSubComponent::release(); + ODatabaseSource_Base::release(); } // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseSource::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::disposing" ); if ( m_pImpl.is() ) m_pImpl->disposing(Source); } @@ -719,8 +702,8 @@ sal_Bool ODatabaseSource::supportsService( const ::rtl::OUString& _rServiceName //------------------------------------------------------------------------------ void ODatabaseSource::disposing() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::disposing" ); - OSubComponent::disposing(); + OSL_TRACE( "DS: disp: %p, %p", this, m_pImpl.get() ); + ODatabaseSource_Base::WeakComponentImplHelperBase::disposing(); OPropertySetHelper::disposing(); EventObject aDisposeEvent(static_cast<XWeak*>(this)); @@ -799,8 +782,6 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const ::rtl::O m_pImpl->getDefaultDataSourceSettings() ); - impl_insertJavaDriverClassPath_nothrow(aDriverInfo); - if ( m_pImpl->isEmbeddedDatabase() ) { sal_Int32 nCount = aDriverInfo.getLength(); @@ -1502,29 +1483,6 @@ Reference< XInterface > ODatabaseSource::getThis() const return *const_cast< ODatabaseSource* >( this ); } // ----------------------------------------------------------------------------- -void ODatabaseSource::impl_insertJavaDriverClassPath_nothrow(Sequence< PropertyValue >& _rDriverInfo) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::impl_insertJavaDriverClassPath_nothrow" ); - Reference< XPropertySet > xPropertySet( m_pImpl->m_xSettings, UNO_QUERY_THROW ); - ::rtl::OUString sJavaDriverClass; - xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))) >>= sJavaDriverClass; - if ( sJavaDriverClass.getLength() ) - { - static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths")); - ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory( - m_pImpl->m_aContext.getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); - if ( aNamesRoot.isValid() && aNamesRoot.hasByName( sJavaDriverClass ) ) - { - ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( sJavaDriverClass ); - ::rtl::OUString sURL; - OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL ); - - ::comphelper::NamedValueCollection aDriverSettings( _rDriverInfo ); - aDriverSettings.put( "JavaDriverClassPath", sURL ); - aDriverSettings >>= _rDriverInfo; - } - } -} //........................................................................ } // namespace dbaccess //........................................................................ diff --git a/dbaccess/source/core/dataaccess/datasource.hxx b/dbaccess/source/core/dataaccess/datasource.hxx index 7ba295f04..e6fb11576 100644 --- a/dbaccess/source/core/dataaccess/datasource.hxx +++ b/dbaccess/source/core/dataaccess/datasource.hxx @@ -70,11 +70,8 @@ #ifndef _CPPUHELPER_WEAKREF_HXX_ #include <cppuhelper/weakref.hxx> #endif -#ifndef _CPPUHELPER_IMPLBASE11_HXX_ -#include <cppuhelper/implbase11.hxx> -#endif -#ifndef _CPPUHELPER_IMPLBASE12_HXX_ -#include <cppuhelper/implbase12.hxx> +#ifndef _CPPUHELPER_COMPBASE11_HXX_ +#include <cppuhelper/compbase11.hxx> #endif #ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONLISTENER_HPP_ #include <com/sun/star/embed/XTransactionListener.hpp> @@ -142,32 +139,31 @@ class OChildCommitListen_Impl; //============================================================ //= ODatabaseSource //============================================================ -typedef ::cppu::ImplHelper11 < ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::sdbc::XDataSource - , ::com::sun::star::sdb::XBookmarksSupplier - , ::com::sun::star::sdb::XQueryDefinitionsSupplier - , ::com::sun::star::sdb::XCompletedConnection - , ::com::sun::star::container::XContainerListener - , ::com::sun::star::sdbc::XIsolatedConnection - , ::com::sun::star::sdbcx::XTablesSupplier - , ::com::sun::star::util::XFlushable - , ::com::sun::star::util::XFlushListener - , ::com::sun::star::sdb::XDocumentDataSource - > ODatabaseSource_Base; +typedef ::cppu::WeakComponentImplHelper11 < ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::sdbc::XDataSource + , ::com::sun::star::sdb::XBookmarksSupplier + , ::com::sun::star::sdb::XQueryDefinitionsSupplier + , ::com::sun::star::sdb::XCompletedConnection + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::sdbc::XIsolatedConnection + , ::com::sun::star::sdbcx::XTablesSupplier + , ::com::sun::star::util::XFlushable + , ::com::sun::star::util::XFlushListener + , ::com::sun::star::sdb::XDocumentDataSource + > ODatabaseSource_Base; class ODatabaseSource :public ModelDependentComponent // must be first - ,public OSubComponent + ,public ODatabaseSource_Base ,public ::cppu::OPropertySetHelper ,public ::comphelper::OPropertyArrayUsageHelper < ODatabaseSource > - ,public ODatabaseSource_Base { friend class ODatabaseContext; friend class OConnection; friend class OSharedConnectionManager; private: - + using ODatabaseSource_Base::rBHelper; OBookmarkContainer m_aBookmarks; ::cppu::OInterfaceContainerHelper m_aFlushListeners; @@ -299,8 +295,6 @@ private: void clearConnections(); - void impl_insertJavaDriverClassPath_nothrow(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverInfo); - protected: using ::cppu::OPropertySetHelper::getFastPropertyValue; }; diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx index 808178015..87de5935d 100644 --- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx +++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx @@ -727,23 +727,16 @@ void ODefinitionContainer::addObjectListener(const Reference< XContent >& _xNewO { xProp->addPropertyChangeListener(PROPERTY_NAME, this); xProp->addVetoableChangeListener(PROPERTY_NAME, this); - //::rtl::OUString sTitle(RTL_CONSTASCII_USTRINGPARAM( "Title" )); - //xProp->addPropertyChangeListener(sTitle, this); - //xProp->addVetoableChangeListener(sTitle, this); - } // if ( xProp.is() ) + } } // ----------------------------------------------------------------------------- void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xNewObject) { - OSL_ENSURE(_xNewObject.is(),"ODefinitionContainer::addObjectListener: Object is null!"); Reference<XPropertySet> xProp(_xNewObject,UNO_QUERY); if ( xProp.is() ) { xProp->removePropertyChangeListener(PROPERTY_NAME, this); xProp->removeVetoableChangeListener(PROPERTY_NAME, this); - //::rtl::OUString sTitle(RTL_CONSTASCII_USTRINGPARAM( "Title" )); - //xProp->removePropertyChangeListener(sTitle, this); - //xProp->removeVetoableChangeListener(sTitle, this); } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 8a587ac25..fe1d6f8e3 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -88,6 +88,7 @@ #include <vcl/svapp.hxx> #include <vos/mutex.hxx> +#include <comphelper/namedvaluecollection.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -212,61 +213,33 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments if ( ServiceSpecifier == SERVICE_SDB_DOCUMENTDEFINITION ) { MutexGuard aGuard(m_aMutex); - ::rtl::OUString sName,sPersistentName,sURL; + + ::rtl::OUString sName, sPersistentName, sURL, sMediaType; Reference< XCommandProcessor > xCopyFrom; - Reference<XConnection> xConnection; - Sequence<sal_Int8> aClassID; + Reference< XConnection > xConnection; + Sequence< sal_Int8 > aClassID; sal_Bool bAsTemplate = sal_False; - const Any* pBegin = _aArguments.getConstArray(); - const Any* pEnd = pBegin + _aArguments.getLength(); - PropertyValue aValue; - for(;pBegin != pEnd;++pBegin) + ::comphelper::NamedValueCollection aArgs( _aArguments ); + sName = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_NAME, sName ); + sPersistentName = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_PERSISTENT_NAME, sPersistentName ); + xCopyFrom = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_EMBEDDEDOBJECT, xCopyFrom ); + sURL = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_URL, sURL ); + xConnection = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection ); + bAsTemplate = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_AS_TEMPLATE, bAsTemplate ); + sMediaType = aArgs.getOrDefault( (::rtl::OUString)INFO_MEDIATYPE, sMediaType ); + + if ( aArgs.has( "ClassID" ) ) { - *pBegin >>= aValue; - if ( aValue.Name.equalsAscii(PROPERTY_NAME) ) - { - aValue.Value >>= sName; - } - else if ( aValue.Name.equalsAscii(PROPERTY_PERSISTENT_NAME) ) - { - aValue.Value >>= sPersistentName; - } - else if ( aValue.Name.equalsAscii(PROPERTY_EMBEDDEDOBJECT) ) - { - xCopyFrom.set(aValue.Value,UNO_QUERY); - } - else if ( aValue.Name.equalsAscii(PROPERTY_URL) ) - { - aValue.Value >>= sURL; - } - else if ( aValue.Name.equalsAscii(PROPERTY_ACTIVE_CONNECTION) ) - { - xConnection.set(aValue.Value,UNO_QUERY); - } - else if ( aValue.Name.equalsAscii("ClassID") ) - { - if (! ( aValue.Value >>= aClassID ) ) - { - // Extended for usage also with a string - ::rtl::OUString suValue; - aValue.Value >>= suValue; - aClassID = ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( suValue ); - - } - rtl::OUString suClassID = ::comphelper::MimeConfigurationHelper::GetStringClassIDRepresentation(aClassID); - volatile int dummy = 0; - (void)dummy; - (void)suClassID; - } - else if ( aValue.Name.equalsAscii(PROPERTY_AS_TEMPLATE) ) + Any aClassIDValue = aArgs.get( "ClassID" ); + // class IDs might be passed as byte sequence ... + if ( !( aClassIDValue >>= aClassID ) ) { - aValue.Value >>= bAsTemplate; + // ... or as string + ::rtl::OUString sClassID; + aClassIDValue >>= sClassID; + aClassID = ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( sClassID ); } - else - { - // DBG_ASSERT("unknown property exception"); - } } const ODefinitionContainer_Impl& rDefinitions( getDefinitions() ); @@ -282,6 +255,7 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments if ( xElements.is() ) sPersistentName = ::dbtools::createUniqueName(xElements,sPersistentName); + const bool bNeedClassID = ( aClassID.getLength() == 0 ) && ( 0 == sURL.getLength() ); if ( xCopyFrom.is() ) { Sequence<Any> aIni(2); @@ -295,10 +269,16 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments Reference<XPropertySet> xProp(xCopyFrom,UNO_QUERY); if ( xProp.is() && xProp->getPropertySetInfo().is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_AS_TEMPLATE) ) xProp->getPropertyValue(PROPERTY_AS_TEMPLATE) >>= bAsTemplate; - } - if ( ( aClassID.getLength() == 0 ) && ( 0 == sURL.getLength() ) ) - ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID ); + // if we do not have an own class ID, see if we can determine one from the copy we just created + if ( bNeedClassID ) + ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID ); + } + else + { + if ( bNeedClassID && sMediaType.getLength() ) + ODocumentDefinition::GetDocumentServiceFromMediaType( sMediaType, m_aContext, aClassID ); + } } ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName ); @@ -730,7 +710,7 @@ void SAL_CALL ODocumentContainer::revert( ) throw (::com::sun::star::io::IOExce Reference< XStorage> ODocumentContainer::getContainerStorage() const { return m_pImpl->m_pDataSource - ? m_pImpl->m_pDataSource->getStorage( ODatabaseModelImpl::getObjectContainerStorageName( m_bFormsContainer ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) ) + ? m_pImpl->m_pDataSource->getStorage( m_bFormsContainer ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) : Reference< XStorage>(); } diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index b72a620ad..7cf73f865 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -422,7 +422,7 @@ namespace dbaccess //================================================================== typedef ::cppu::WeakImplHelper1 < css::lang::XEventListener > LifetimeCoupler_Base; - /** helper class which couples the lifetime of a component to the lifetim + /** helper class which couples the lifetime of a component to the lifetime of another component Instances of this class are constructed with two components. The first is @@ -617,13 +617,12 @@ void SAL_CALL ODocumentDefinition::disposing() ::osl::MutexGuard aGuard(m_aMutex); closeObject(); ::comphelper::disposeComponent(m_xListener); - if ( m_bRemoveListener && m_xDesktop.is() ) + if ( m_bRemoveListener ) { Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY); if ( xCloseable.is() ) xCloseable->removeCloseListener(this); } - m_xDesktop = NULL; } // ----------------------------------------------------------------------------- IMPLEMENT_TYPEPROVIDER3(ODocumentDefinition,OContentHelper,OPropertyStateContainer,ODocumentDefinition_Base); @@ -690,17 +689,15 @@ namespace } // ----------------------------------------------------------------------------- -void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const Reference< XFrame >& _rxFrame ) +void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const ::comphelper::ComponentContext& _rContxt, const Reference< XFrame >& _rxFrame ) { - if ( !m_xDesktop.is() ) - m_xDesktop.set( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); - - Reference< XFrames > xFrames( m_xDesktop->getFrames(), UNO_QUERY_THROW ); + Reference< XFramesSupplier > xDesktop( _rContxt.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); + Reference< XFrames > xFrames( xDesktop->getFrames(), UNO_QUERY_THROW ); xFrames->remove( _rxFrame ); } // ----------------------------------------------------------------------------- -void ODocumentDefinition::impl_onActivateEmbeddedObject() +void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow() { try { @@ -712,26 +709,23 @@ void ODocumentDefinition::impl_onActivateEmbeddedObject() if ( !m_xListener.is() ) // it's the first time the embedded object has been activated // create an OEmbedObjectHolder - m_xListener = new OEmbedObjectHolder(m_xEmbeddedObject,this); + m_xListener = new OEmbedObjectHolder( m_xEmbeddedObject, this ); - Reference< XFrame > xFrame( xController->getFrame() ); - if ( xFrame.is() ) - { - // raise the window to top (especially necessary if this is not the first activation) - Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW ); - xTopWindow->toFront(); + // raise the window to top (especially necessary if this is not the first activation) + Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW ); + Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW ); + xTopWindow->toFront(); - // remove the frame from the desktop's frame collection because we need full control of it. - impl_removeFrameFromDesktop_throw( xFrame ); - } + // remove the frame from the desktop's frame collection because we need full control of it. + impl_removeFrameFromDesktop_throw( m_aContext, xFrame ); // ensure that we ourself are kept alive as long as the embedded object's frame is // opened LifetimeCoupler::couple( *this, Reference< XComponent >( xFrame, UNO_QUERY_THROW ) ); // init the edit view - if ( m_bOpenInDesign ) - impl_initObjectEditView( xController ); + if ( m_bForm && m_bOpenInDesign ) + impl_initFormEditView( xController ); } catch( const RuntimeException& ) { @@ -833,12 +827,8 @@ namespace } // ----------------------------------------------------------------------------- -void ODocumentDefinition::impl_initObjectEditView( const Reference< XController >& _rxController ) +void ODocumentDefinition::impl_initFormEditView( const Reference< XController >& _rxController ) { - if ( !m_bForm ) - // currently, only forms need to be initialized - return; - try { Reference< XViewSettingsSupplier > xSettingsSupplier( _rxController, UNO_QUERY_THROW ); @@ -872,10 +862,10 @@ void ODocumentDefinition::impl_initObjectEditView( const Reference< XController } // ----------------------------------------------------------------------------- -void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, const bool _bActivate, - const Reference< XCommandEnvironment >& _rxEnvironment, Any& _out_rComponent, ::osl::ClearableMutexGuard & _aGuard ) +Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, const bool _bActivate, + const Reference< XCommandEnvironment >& _rxEnvironment ) { - OExecuteImpl aExecuteGuard(m_bInExecute); + OExecuteImpl aExecuteGuard( m_bInExecute ); Reference< XConnection > xConnection; sal_Int32 nOpenMode = OpenMode::DOCUMENT; @@ -885,7 +875,9 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con // for the document, default to the interaction handler as used for loading the DB doc // This might be overwritten below, when examining _rOpenArgument. ::comphelper::NamedValueCollection aDBDocArgs( m_pImpl->m_pDataSource->getResource() ); - aDocumentArgs.put( "InteractionHandler", aDBDocArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + Reference< XInteractionHandler > xHandler( aDBDocArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + if ( xHandler.is() ) + aDocumentArgs.put( "InteractionHandler", xHandler ); ::boost::optional< sal_Int16 > aDocumentMacroMode; @@ -999,7 +991,7 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con OSL_ENSURE( m_pImpl->m_aProps.sPersistentName.getLength(), "ODocumentDefinition::onCommandOpenSomething: no persistent name - cannot load!" ); if ( !m_pImpl->m_aProps.sPersistentName.getLength() ) - return; + return Any(); // embedded objects themself do not support the hidden flag. We implement support for // it by changing the STATE to RUNNING only, instead of ACTIVE. @@ -1009,7 +1001,7 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), aDocumentArgs.getPropertyValues(), false, !m_bOpenInDesign ); OSL_ENSURE( m_xEmbeddedObject.is(), "ODocumentDefinition::onCommandOpenSomething: what's this?" ); if ( !m_xEmbeddedObject.is() ) - return; + return Any(); Reference< XModel > xModel( getComponent(), UNO_QUERY ); Reference< report::XReportDefinition > xReportDefinition(xModel,UNO_QUERY); @@ -1035,158 +1027,169 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con xReportEngine->setReportDefinition(xReportDefinition); xReportEngine->setActiveConnection(m_xLastKnownConnection); if ( bOpenHidden ) - _out_rComponent <<= xReportEngine->createDocumentModel( ); - else - _out_rComponent <<= xReportEngine->createDocumentAlive(NULL); - return; + return makeAny( xReportEngine->createDocumentModel() ); + return makeAny( xReportEngine->createDocumentAlive( NULL ) ); } if ( _bActivate && !bOpenHidden ) { m_xEmbeddedObject->changeState( EmbedStates::ACTIVE ); - impl_onActivateEmbeddedObject(); + ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow(); } - // LLA: Alle fillReportData() calls prfen, sollte es welche geben, die danach noch viel machen - // LLA: sollten wir einen _aGuard Pointer bergeben, sonst erstmal als Referenz - fillReportData(_aGuard); - _out_rComponent <<= xModel; + if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign ) + ODocumentDefinition::fillReportData( m_aContext, getComponent(), xConnection ); + + return makeAny( xModel ); } // ----------------------------------------------------------------------------- Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException) { Any aRet; - ::osl::ClearableMutexGuard aGuard(m_aMutex); - if ( !m_bInExecute ) - { - sal_Bool bOpen = aCommand.Name.equalsAscii( "open" ); - sal_Bool bOpenInDesign = aCommand.Name.equalsAscii( "openDesign" ); - sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" ); - if ( bOpen || bOpenInDesign || bOpenForMail ) - { - bool bActivateObject = true; - if ( bOpenForMail ) - { - OSL_ENSURE( false, "ODocumentDefinition::execute: 'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" ); - bActivateObject = false; - } - - // if the object is already opened, do nothing - // #i89509# / 2008-05-22 / frank.schoenheit@sun.com - if ( m_xEmbeddedObject.is() ) - { - sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState(); - bool bIsActive = ( nCurrentState == EmbedStates::ACTIVE ); - - // exception: new-style reports always create a new document when "open" is executed - Reference< report::XReportDefinition > xReportDefinition( getComponent(), UNO_QUERY ); - bool bIsAliveNewStyleReport = ( xReportDefinition.is() && ( bOpen || bOpenForMail ) ); - - if ( bIsActive && !bIsAliveNewStyleReport ) - { - impl_onActivateEmbeddedObject(); - return makeAny( getComponent() ); - } - } - - // m_bOpenInDesign = bOpenInDesign; - // onCommandOpenSomething( aCommand.Argument, !bOpenForMail, Environment, aRet, aGuard ); - m_bOpenInDesign = bOpenInDesign || bOpenForMail; - onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment, aRet, aGuard ); - } - else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) ) + sal_Bool bOpen = aCommand.Name.equalsAscii( "open" ); + sal_Bool bOpenInDesign = aCommand.Name.equalsAscii( "openDesign" ); + sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" ); + if ( bOpen || bOpenInDesign || bOpenForMail ) + { + // opening the document involves a lot of VCL code, which is not thread-safe, but needs the SolarMutex locked. + // Unfortunately, the DocumentDefinition, as well as the EmbeddedObject implementation, calls into VCL-dependent + // components *without* releasing the own mutex, which is a guaranteed recipe for deadlocks. + // We have control over this implementation here, and in modifying it to release the own mutex before calling into + // the VCL-dependent components is not too difficult (was there, seen it). + // However, we do /not/ have control over the EmbeddedObject implementation, and from a first look, it seems as + // making it release the own mutex before calling SolarMutex-code is ... difficult, at least. + // So, to be on the same side, we lock the SolarMutex here. Yes, it sucks. + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::ClearableMutexGuard aGuard(m_aMutex); + if ( m_bInExecute ) + return aRet; + + bool bActivateObject = true; + if ( bOpenForMail ) { - Sequence<Any> aIni; - aCommand.Argument >>= aIni; - if ( aIni.getLength() != 2 ) - { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( - rtl::OUString(), - static_cast< cppu::OWeakObject * >( this ), - -1 ) ), - Environment ); - // Unreachable - } - Reference< XStorage> xDest(aIni[0],UNO_QUERY); - ::rtl::OUString sPersistentName; - aIni[1] >>= sPersistentName; - Reference< XStorage> xStorage = getContainerStorage(); - // ----------------------------------------------------------------------------- - xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xDest,sPersistentName); - /*loadEmbeddedObject( true ); - Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY); - if ( xPersist.is() ) - { - xPersist->storeToEntry(xStorage,sPersistentName,Sequence<PropertyValue>(),Sequence<PropertyValue>()); - xPersist->storeOwn(); - m_xEmbeddedObject->changeState(EmbedStates::LOADED); - } - else - throw CommandAbortedException();*/ - } - else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "preview" ) ) ) - { - onCommandPreview(aRet); + OSL_ENSURE( false, "ODocumentDefinition::execute: 'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" ); + bActivateObject = false; } - else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ) ) + + // if the object is already opened, do nothing + // #i89509# / 2008-05-22 / frank.schoenheit@sun.com + if ( m_xEmbeddedObject.is() ) { - Sequence<Any> aIni; - aCommand.Argument >>= aIni; - if ( aIni.getLength() > 0 && aIni.getLength() < 2 ) + sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState(); + bool bIsActive = ( nCurrentState == EmbedStates::ACTIVE ); + + // exception: new-style reports always create a new document when "open" is executed + Reference< report::XReportDefinition > xReportDefinition( getComponent(), UNO_QUERY ); + bool bIsAliveNewStyleReport = ( xReportDefinition.is() && ( bOpen || bOpenForMail ) ); + + if ( bIsActive && !bIsAliveNewStyleReport ) { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( - rtl::OUString(), - static_cast< cppu::OWeakObject * >( this ), - -1 ) ), - Environment ); - // Unreachable + ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow(); + return makeAny( getComponent() ); } - ::rtl::OUString sURL; - aIni[0] >>= sURL; - onCommandInsert( sURL, Environment ); } - else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) // compatibility - || aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getDocumentInfo" ) ) - ) - { - onCommandGetDocumentProperties( aRet ); - } - else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) ) - { - ////////////////////////////////////////////////////////////////// - // delete - ////////////////////////////////////////////////////////////////// - closeObject(); - Reference< XStorage> xStorage = getContainerStorage(); - if ( xStorage.is() ) - xStorage->removeElement(m_pImpl->m_aProps.sPersistentName); - dispose(); + m_bOpenInDesign = bOpenInDesign || bOpenForMail; + return onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment ); + } - } - else if ( ( aCommand.Name.compareToAscii( "storeOwn" ) == 0 ) // compatibility - || ( aCommand.Name.compareToAscii( "store" ) == 0 ) - ) + ::osl::ClearableMutexGuard aGuard(m_aMutex); + if ( m_bInExecute ) + return aRet; + + if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) ) + { + Sequence<Any> aIni; + aCommand.Argument >>= aIni; + if ( aIni.getLength() != 2 ) { - impl_store_throw(); + OSL_ENSURE( sal_False, "Wrong argument type!" ); + ucbhelper::cancelCommandExecution( + makeAny( IllegalArgumentException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } - else if ( ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // compatibility - || ( aCommand.Name.compareToAscii( "close" ) == 0 ) - ) + Reference< XStorage> xDest(aIni[0],UNO_QUERY); + ::rtl::OUString sPersistentName; + aIni[1] >>= sPersistentName; + Reference< XStorage> xStorage = getContainerStorage(); + // ----------------------------------------------------------------------------- + xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xDest,sPersistentName); + /*loadEmbeddedObject( true ); + Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY); + if ( xPersist.is() ) { - aRet <<= impl_close_throw(); + xPersist->storeToEntry(xStorage,sPersistentName,Sequence<PropertyValue>(),Sequence<PropertyValue>()); + xPersist->storeOwn(); + m_xEmbeddedObject->changeState(EmbedStates::LOADED); } else + throw CommandAbortedException();*/ + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "preview" ) ) ) + { + onCommandPreview(aRet); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ) ) + { + Sequence<Any> aIni; + aCommand.Argument >>= aIni; + if ( !aIni.getLength() ) { - aRet = OContentHelper::execute(aCommand,CommandId,Environment); + OSL_ENSURE( sal_False, "Wrong argument count!" ); + ucbhelper::cancelCommandExecution( + makeAny( IllegalArgumentException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable } + ::rtl::OUString sURL; + aIni[0] >>= sURL; + onCommandInsert( sURL, Environment ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) // compatibility + || aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getDocumentInfo" ) ) + ) + { + onCommandGetDocumentProperties( aRet ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) ) + { + ////////////////////////////////////////////////////////////////// + // delete + ////////////////////////////////////////////////////////////////// + closeObject(); + Reference< XStorage> xStorage = getContainerStorage(); + if ( xStorage.is() ) + xStorage->removeElement(m_pImpl->m_aProps.sPersistentName); + + dispose(); + } + else if ( ( aCommand.Name.compareToAscii( "storeOwn" ) == 0 ) // compatibility + || ( aCommand.Name.compareToAscii( "store" ) == 0 ) + ) + { + impl_store_throw(); + } + else if ( ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // compatibility + || ( aCommand.Name.compareToAscii( "close" ) == 0 ) + ) + { + aRet <<= impl_close_throw(); + } + else + { + aRet = OContentHelper::execute(aCommand,CommandId,Environment); + } + return aRet; } // ----------------------------------------------------------------------------- @@ -1607,9 +1610,8 @@ Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XC xParentFrame = lcl_getDatabaseDocumentFrame( *m_pImpl->m_pDataSource ); if ( !xParentFrame.is() ) { // i87957 we need a parent frame - if ( !m_xDesktop.is() ) - m_xDesktop.set( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); - xParentFrame.set(m_xDesktop,uno::UNO_QUERY); + Reference< XComponentLoader > xDesktop( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); + xParentFrame.set( xDesktop, UNO_QUERY ); if ( xParentFrame.is() ) { Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY); @@ -1918,10 +1920,8 @@ Reference< XComponent > ODocumentDefinition::impl_openUI_nolck_throw( bool _bFor { // no XDatabaseDocumentUI -> just execute the respective command m_bOpenInDesign = _bForEditing; - Any aComponent; - onCommandOpenSomething( Any(), true, NULL, aComponent, aGuard ); - Reference< XComponent > xComponent; - OSL_VERIFY( aComponent >>= xComponent ); + Reference< XComponent > xComponent( onCommandOpenSomething( Any(), true, NULL ), UNO_QUERY ); + OSL_ENSURE( xComponent.is(), "ODocumentDefinition::impl_openUI_nolck_throw: opening the thingie failed." ); return xComponent; } @@ -2052,7 +2052,7 @@ void SAL_CALL ODocumentDefinition::rename( const ::rtl::OUString& _rNewName ) th Reference< XStorage> ODocumentDefinition::getContainerStorage() const { return m_pImpl->m_pDataSource - ? m_pImpl->m_pDataSource->getStorage( ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) ) + ? m_pImpl->m_pDataSource->getStorage( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) : Reference< XStorage>(); } // ----------------------------------------------------------------------------- @@ -2122,26 +2122,29 @@ bool ODocumentDefinition::prepareClose() return true; } // ----------------------------------------------------------------------------- -void ODocumentDefinition::fillReportData(::osl::ClearableMutexGuard & _aGuard) +void ODocumentDefinition::fillReportData( const ::comphelper::ComponentContext& _rContext, + const Reference< util::XCloseable >& _rxComponent, + const Reference< XConnection >& _rxActiveConnection ) { - if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign ) // open a report in alive mode, so we need to fill it - { - Sequence<Any> aArgs(2); - PropertyValue aValue; - aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TextDocument")); - aValue.Value <<= getComponent(); - aArgs[0] <<= aValue; - aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")); - aValue.Value <<= m_xLastKnownConnection; - aArgs[1] <<= aValue; - - Reference< XJobExecutor > xExecuteable( m_aContext.createComponentWithArguments( "com.sun.star.wizards.report.CallReportWizard", aArgs ), UNO_QUERY ); - if ( xExecuteable.is() ) - { - _aGuard.clear(); - xExecuteable->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fill"))); + Sequence< Any > aArgs(2); + PropertyValue aValue; + aValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextDocument" ) ); + aValue.Value <<= _rxComponent; + aArgs[0] <<= aValue; + aValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ); + aValue.Value <<= _rxActiveConnection; + aArgs[1] <<= aValue; + + try + { + Reference< XJobExecutor > xExecuteable( + _rContext.createComponentWithArguments( "com.sun.star.wizards.report.CallReportWizard", aArgs ), UNO_QUERY_THROW ); + xExecuteable->trigger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "fill" ) ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } -} } // ----------------------------------------------------------------------------- void ODocumentDefinition::updateDocumentTitle() diff --git a/dbaccess/source/core/dataaccess/documentdefinition.hxx b/dbaccess/source/core/dataaccess/documentdefinition.hxx index de02023f0..4335d5e36 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.hxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.hxx @@ -92,7 +92,6 @@ class ODocumentDefinition { ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject> m_xEmbeddedObject; ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStateChangeListener > m_xListener; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier > m_xDesktop; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xLastKnownConnection; OInterceptor* m_pInterceptor; @@ -163,9 +162,17 @@ public: sal_Bool saveAs(); void closeObject(); sal_Bool isModified(); - void fillReportData(::osl::ClearableMutexGuard & _aGuard); inline sal_Bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; } + static void fillReportData( + const ::comphelper::ComponentContext& _rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& _rxComponent, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActiveConnection + ); + + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& + getConnection() const { return m_xLastKnownConnection; } + /** prepares closing the document component The method suspends the controller associated with the document, and saves the document @@ -192,12 +199,10 @@ public: private: /** does necessary initializations after our embedded object has been switched to ACTIVE - @param _bOpenedInDesignMode - determines whether the embedded object has been opened for designing it or for data display */ - void impl_onActivateEmbeddedObject(); + void impl_onActivateEmbeddedObject_nothrow(); - /** initializes a newly created view/controller which is displaying our embedded object + /** initializes a newly created view/controller of a form which is displaying our embedded object Has only to be called if the respective embedded object has been loaded for design (and not for data entry) @@ -205,12 +210,15 @@ private: @param _rxController the controller which belongs to the XModel of our (active) embedded object */ - void impl_initObjectEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController ); + static void impl_initFormEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController ); /** removes the given frame from the desktop's frame collection @raises ::com::sun::star::uno::RuntimeException */ - void impl_removeFrameFromDesktop_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame ); + static void impl_removeFrameFromDesktop_throw( + const ::comphelper::ComponentContext& _rContxt, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame + ); /** opens the UI for this sub document */ @@ -310,10 +318,12 @@ private: void onCommandGetDocumentProperties( ::com::sun::star::uno::Any& _rProps ); void onCommandInsert( const ::rtl::OUString& _sURL, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw( ::com::sun::star::uno::Exception ); void onCommandPreview( ::com::sun::star::uno::Any& _rImage ); - void onCommandOpenSomething( const ::com::sun::star::uno::Any& _rArgument, const bool _bActivate, - const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment, - ::com::sun::star::uno::Any& _out_rComponent, - ::osl::ClearableMutexGuard & _aClearableGuard); + ::com::sun::star::uno::Any + onCommandOpenSomething( + const ::com::sun::star::uno::Any& _rArgument, + const bool _bActivate, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment + ); }; //........................................................................ diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx index 50e407f25..37abdef73 100644 --- a/dbaccess/source/core/dataaccess/intercept.cxx +++ b/dbaccess/source/core/dataaccess/intercept.cxx @@ -31,28 +31,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _COM_SUN_STAR_EMBED_EMBEDSTATES_HPP_ +#include "intercept.hxx" +#include "dbastrings.hrc" + #include <com/sun/star/embed/EmbedStates.hpp> -#endif -#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTBROADCASTER_HPP_ #include <com/sun/star/document/XEventBroadcaster.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_ #include <com/sun/star/util/XModifiable.hpp> -#endif -#ifndef _CPPUHELPER_WEAK_HXX_ #include <cppuhelper/weak.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ + #include <comphelper/types.hxx> -#endif -#ifndef DBA_INTERCEPT_HXX -#include "intercept.hxx" -#endif -#include "dbastrings.hrc" -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif +#include <tools/diagnose_ex.h> namespace dbaccess @@ -140,66 +129,78 @@ struct DispatchHelper //XDispatch void SAL_CALL OInterceptor::dispatch( const URL& _URL,const Sequence<PropertyValue >& Arguments ) throw (RuntimeException) { - osl::ClearableMutexGuard aClearableGuard(m_aMutex); - if( m_pContentHolder ) + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_pContentHolder ) + return; + + if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_SAVE ] ) { - if( _URL.Complete == m_aInterceptedURL[DISPATCH_SAVE] ) - { - m_pContentHolder->save(sal_False); - } - else if( _URL.Complete == m_aInterceptedURL[DISPATCH_RELOAD] ) + m_pContentHolder->save( sal_False ); + return; + } + + if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_RELOAD ] ) + { + ODocumentDefinition::fillReportData( + m_pContentHolder->getContext(), + m_pContentHolder->getComponent(), + m_pContentHolder->getConnection() + ); + return; + } + + if( _URL.Complete == m_aInterceptedURL[ DISPATCH_SAVEAS ] ) + { + if ( m_pContentHolder->isNewReport() ) { - m_pContentHolder->fillReportData(aClearableGuard); - // IMPORTANT: m_aMutex is cleared! + m_pContentHolder->saveAs(); } - else if( _URL.Complete == m_aInterceptedURL[DISPATCH_SAVEAS] ) + else if ( m_xSlaveDispatchProvider.is() ) { - if ( m_pContentHolder->isNewReport() ) - { - m_pContentHolder->saveAs(); - } - else if ( m_xSlaveDispatchProvider.is() ) - { - Sequence< PropertyValue > aNewArgs = Arguments; - sal_Int32 nInd = 0; + Sequence< PropertyValue > aNewArgs = Arguments; + sal_Int32 nInd = 0; - while( nInd < aNewArgs.getLength() ) - { - if ( aNewArgs[nInd].Name.equalsAscii( "SaveTo" ) ) - { - aNewArgs[nInd].Value <<= sal_True; - break; - } - nInd++; - } - - if ( nInd == aNewArgs.getLength() ) + while( nInd < aNewArgs.getLength() ) + { + if ( aNewArgs[nInd].Name.equalsAscii( "SaveTo" ) ) { - aNewArgs.realloc( nInd + 1 ); - aNewArgs[nInd].Name = ::rtl::OUString::createFromAscii( "SaveTo" ); aNewArgs[nInd].Value <<= sal_True; + break; } + nInd++; + } - Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch( - _URL, ::rtl::OUString::createFromAscii( "_self" ), 0 ); - if ( xDispatch.is() ) - xDispatch->dispatch( _URL, aNewArgs ); + if ( nInd == aNewArgs.getLength() ) + { + aNewArgs.realloc( nInd + 1 ); + aNewArgs[nInd].Name = ::rtl::OUString::createFromAscii( "SaveTo" ); + aNewArgs[nInd].Value <<= sal_True; } + + Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch( + _URL, ::rtl::OUString::createFromAscii( "_self" ), 0 ); + if ( xDispatch.is() ) + xDispatch->dispatch( _URL, aNewArgs ); } - else if ( _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEDOC] - || _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEWIN] - || _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEFRAME]) - { - DispatchHelper* pHelper = new DispatchHelper; - pHelper->aArguments = Arguments; - pHelper->aURL = _URL; - Application::PostUserEvent(LINK(this, OInterceptor, OnDispatch),reinterpret_cast<void*>(pHelper) ); - } + return; + } + + if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEDOC ] + || _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEWIN ] + || _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEFRAME ] + ) + { + DispatchHelper* pHelper = new DispatchHelper; + pHelper->aArguments = Arguments; + pHelper->aURL = _URL; + Application::PostUserEvent( LINK( this, OInterceptor, OnDispatch ), reinterpret_cast< void* >( pHelper ) ); + return; } } -IMPL_LINK( OInterceptor, OnDispatch, void*, _nId) + +IMPL_LINK( OInterceptor, OnDispatch, void*, _pDispatcher ) { - ::std::auto_ptr<DispatchHelper> pHelper(reinterpret_cast<DispatchHelper*>(_nId)); + ::std::auto_ptr<DispatchHelper> pHelper( reinterpret_cast< DispatchHelper* >( _pDispatcher ) ); try { if ( m_pContentHolder && m_pContentHolder->prepareClose() && m_xSlaveDispatchProvider.is() ) @@ -217,10 +218,11 @@ IMPL_LINK( OInterceptor, OnDispatch, void*, _nId) } } } - catch(const Exception&) + catch ( const Exception& ) { - OSL_ENSURE(sal_False, "caught an exception while starting the table wizard!"); + DBG_UNHANDLED_EXCEPTION(); } + return 0L; } diff --git a/dbaccess/source/core/dataaccess/makefile.mk b/dbaccess/source/core/dataaccess/makefile.mk index 580d62c08..aff531b3a 100644 --- a/dbaccess/source/core/dataaccess/makefile.mk +++ b/dbaccess/source/core/dataaccess/makefile.mk @@ -56,6 +56,7 @@ SLOFILES= \ $(SLO)$/databasecontext.obj \ $(SLO)$/connection.obj \ $(SLO)$/datasource.obj \ + $(SLO)$/databaseregistrations.obj \ $(SLO)$/intercept.obj \ $(SLO)$/myucp_datasupplier.obj \ $(SLO)$/myucp_resultset.obj \ diff --git a/dbaccess/source/core/inc/ContainerMediator.hxx b/dbaccess/source/core/inc/ContainerMediator.hxx index 625b56b84..e77f092f5 100644 --- a/dbaccess/source/core/inc/ContainerMediator.hxx +++ b/dbaccess/source/core/inc/ContainerMediator.hxx @@ -112,23 +112,12 @@ namespace dbaccess */ void impl_cleanup_nothrow(); - /** retrieves the settings object to initialize a container element - - Normally, this object will simply retrieve the object with the given name from our settings - container. Hiowever, for columns, there's a fallback in case this settings object does - not yet exist: Then, we check if the given destination object refers to a table column, via its - TableName and RealName property. If so, this table column is used as initialization object. - - @param _rName - the name of the destination object in its container - @param _rxDestination - the destination object to initialize + /** initializes the properties of the given object from its counterpart in our settings container */ - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - impl_getSettingsForInitialization_nothrow( + void impl_initSettings_nothrow( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDestination - ) const; + ); }; //........................................................................ } // namespace dbaccess diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx index e1657169c..caab3e6bd 100644 --- a/dbaccess/source/core/inc/ContentHelper.hxx +++ b/dbaccess/source/core/inc/ContentHelper.hxx @@ -236,6 +236,8 @@ namespace dbaccess getPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties ); + const ::comphelper::ComponentContext& getContext() const { return m_aContext; } + inline TContentPtr getImpl() const { return m_pImpl; } protected: diff --git a/dbaccess/source/core/inc/PropertyForward.hxx b/dbaccess/source/core/inc/PropertyForward.hxx index 0ca98fec6..746648c4e 100644 --- a/dbaccess/source/core/inc/PropertyForward.hxx +++ b/dbaccess/source/core/inc/PropertyForward.hxx @@ -55,24 +55,31 @@ namespace dbaccess { //........................................................................ + + // =================================================================== + // = OPropertyForward + // =================================================================== typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener > OPropertyForward_Base; - class OPropertyForward : public ::comphelper::OBaseMutex + class OPropertyForward :public ::comphelper::OBaseMutex ,public OPropertyForward_Base { - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xSource; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xDest; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> m_xDestInfo; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xDestContainer; - ::rtl::OUString m_sName; - sal_Bool m_bInInsert; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSource; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDest; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xDestInfo; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDestContainer; + ::rtl::OUString m_sName; + sal_Bool m_bInInsert; + protected: virtual ~OPropertyForward(); + public: - OPropertyForward(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSource - ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xDestContainer - ,const ::rtl::OUString& _sName - ,const ::std::vector< ::rtl::OUString>& _aPropertyList = ::std::vector< ::rtl::OUString>()); + OPropertyForward( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSource, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xDestContainer, + const ::rtl::OUString& _sName, + const ::std::vector< ::rtl::OUString >& _aPropertyList + ); // ::com::sun::star::beans::XPropertyChangeListener virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); @@ -80,10 +87,11 @@ namespace dbaccess // ::com::sun::star::lang::XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); - inline void setName(const ::rtl::OUString& _sName) { m_sName = _sName; } - void setDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest); - inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getDefinition() const { return m_xDest;} + inline void setName( const ::rtl::OUString& _sName ) { m_sName = _sName; } + void setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDest); + inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDefinition() const { return m_xDest; } }; + //........................................................................ } // namespace dbaccess //........................................................................ diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx index c42b7b7d0..5d81a92c0 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/compbase2.hxx> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/propshlp.hxx> +#include <osl/diagnose.h> + +#include <hash_map> namespace dbaccess { @@ -124,23 +72,25 @@ namespace dbaccess //************************************************************ // OColumn //************************************************************ - typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel > OColumnBase; + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::container::XNamed + > OColumnBase; //------------------------------------------------------------ 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; protected: + // <properties> ::rtl::OUString m_sName; + // </properties> protected: - OColumn(); + OColumn( const bool _bNameIsReadOnly ); public: virtual ~OColumn(); @@ -157,27 +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(); - // cppu::OComponentHelper virtual void SAL_CALL disposing(void); @@ -190,57 +119,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; - }; - - //************************************************************ - // OColumnSettings - //************************************************************ - class OColumnSettings - { - // <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 - ::com::sun::star::uno::Any m_aAlignment; // sal_Int32 (::com::sun::star::awt::TextAlign) or void - ::com::sun::star::uno::Any m_aHelpText; // the description of the column which is visible in the helptext of the column - ::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> - - // Setting of values - public: - OColumnSettings(); - 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; - - // 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(); - - public: - - /** check if the persistent settings have their default value - */ - sal_Bool isDefaulted() const; + // 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 new file mode 100644 index 000000000..bbb7fac8f --- /dev/null +++ b/dbaccess/source/core/inc/columnsettings.hxx @@ -0,0 +1,108 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef COLUMNSETTINGS_HXX +#define COLUMNSETTINGS_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/XPropertySet.hpp> +/** === end UNO includes === **/ + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + // 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> + ::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 + ::com::sun::star::uno::Any m_aAlignment; // sal_Int32 (::com::sun::star::awt::TextAlign) or void + ::com::sun::star::uno::Any m_aHelpText; // the description of the column which is visible in the helptext of the column + ::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> + + protected: + virtual ~OColumnSettings(); + + public: + OColumnSettings(); + + protected: + void registerProperties( IPropertyContainer& _rPropertyContainer ); + + /** determines whether the property with the given handle is handled by the class + */ + static bool isColumnSettingProperty( const sal_Int32 _nPropertyHandle ); + static bool isDefaulted( const sal_Int32 _nPropertyHandle, const ::com::sun::star::uno::Any& _rPropertyValue ); + + public: + /** check if the persistent settings have their default value + */ + static bool hasDefaultSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn ); + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // COLUMNSETTINGS_HXX diff --git a/dbaccess/source/core/inc/core_resource.hrc b/dbaccess/source/core/inc/core_resource.hrc index 39814c63b..2196932f0 100644 --- a/dbaccess/source/core/inc/core_resource.hrc +++ b/dbaccess/source/core/inc/core_resource.hrc @@ -32,12 +32,11 @@ #define _DBA_CORE_RESOURCE_HRC_ #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif //------------------------------------------------------------------------------ #define RID_CORE_STRINGS_START RID_DBACCESS_START -#define RID_CORE_OTHER_START RID_DBACCESS_START //------------------------------------------------------------------------------ //- String-IDs @@ -89,6 +88,7 @@ #define RID_STR_NAME_NOT_FOUND ( RID_CORE_STRINGS_START + 45 ) #define RID_STR_QUERY_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 46 ) #define RID_STR_ERROR_WHILE_SAVING ( RID_CORE_STRINGS_START + 47 ) +#define RID_NO_SUCH_DATA_SOURCE ( RID_CORE_STRINGS_START + 48 ) #endif // _DBA_CORE_RESOURCE_HRC_ diff --git a/dbaccess/source/core/inc/core_resource.hxx b/dbaccess/source/core/inc/core_resource.hxx index 96dbd174e..fe15efeb1 100644 --- a/dbaccess/source/core/inc/core_resource.hxx +++ b/dbaccess/source/core/inc/core_resource.hxx @@ -110,8 +110,6 @@ namespace dbaccess const sal_Char* _pPlaceholderAscii2, const ::rtl::OUString& _rReplace2 ); - - static ResMgr* getResManager(); }; //========================================================================= diff --git a/dbaccess/source/core/inc/datasettings.hxx b/dbaccess/source/core/inc/datasettings.hxx index ff75269dd..9ca769d64 100644 --- a/dbaccess/source/core/inc/datasettings.hxx +++ b/dbaccess/source/core/inc/datasettings.hxx @@ -81,6 +81,7 @@ public: protected: ODataSettings_Base(); ODataSettings_Base(const ODataSettings_Base& _rSource); + ~ODataSettings_Base(); }; //========================================================================== //= ODataSettings - a base class which implements the property handling diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx index 19515c07d..4fb24d477 100644 --- a/dbaccess/source/core/inc/definitioncolumn.hxx +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -30,36 +30,26 @@ #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_ #define _DBACORE_DEFINITIONCOLUMN_HXX_ -#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include "apitools.hxx" +#include "column.hxx" +#include "columnsettings.hxx" + #include <com/sun/star/sdbc/DataType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ -#include "apitools.hxx" -#endif -#ifndef _DBA_COREAPI_COLUMN_HXX_ -#include "column.hxx" -#endif -#ifndef COMPHELPER_IDPROPERTYARRAYUSAGEHELPER_HXX + #include <comphelper/IdPropArrayHelper.hxx> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> -#endif -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ #include <cppuhelper/implbase1.hxx> -#endif namespace dbaccess { typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild; + // ========================================================================= + //= OTableColumnDescriptor + // ========================================================================= /** * provides the properties for description. A descriptor could be used to create a new table column. */ @@ -68,7 +58,9 @@ namespace dbaccess ,public ::comphelper::OPropertyArrayUsageHelper < OTableColumnDescriptor > ,public TXChild { - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; + const bool m_bActAsDescriptor; + protected: // <properties> rtl::OUString m_aTypeName; @@ -79,24 +71,32 @@ namespace dbaccess sal_Int32 m_nPrecision; sal_Int32 m_nScale; sal_Int32 m_nIsNullable; - sal_Bool m_bAutoIncrement : 1; - sal_Bool m_bRowVersion : 1; - sal_Bool m_bCurrency : 1; + sal_Bool m_bAutoIncrement; + 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_bActAsDescriptor( _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(); + } 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); @@ -104,67 +104,100 @@ 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); - - protected: - using OColumn::getFastPropertyValue; + private: + void impl_registerProperties(); }; - /** - * describes a column of an existing table. The informations for the column are - * retrieved in a generic way using the meta data of a connection. + // ========================================================================= + // = OTableColumn + // ========================================================================= + class OTableColumn; + typedef ::comphelper::OPropertyArrayUsageHelper < OTableColumn > OTableColumn_PBase; + /** describes a column of a table */ - class OTableColumn : public OTableColumnDescriptor, - public ::comphelper::OPropertyArrayUsageHelper < OTableColumn > + class OTableColumn :public OTableColumnDescriptor + ,public OTableColumn_PBase { - friend class ODBTable; - protected: virtual ~OTableColumn(); + public: OTableColumn(const ::rtl::OUString& _rName); - OTableColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn); - // com::sun::star::lang::XTypeProvider + // XTypeProvider virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); - // ::com::sun::star::lang::XServiceInfo + // 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); - // ::comphelper::OPropertyArrayUsageHelper + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + }; + + // ========================================================================= + // = OQueryColumn + // ========================================================================= + class OQueryColumn; + typedef ::comphelper::OPropertyArrayUsageHelper< OQueryColumn > OQueryColumn_PBase; + /** a column of a Query, with additional information obtained from parsing the query statement + */ + class OQueryColumn :public OTableColumnDescriptor + ,public OQueryColumn_PBase + { + // <properties> + ::rtl::OUString m_sCatalogName; + ::rtl::OUString m_sSchemaName; + ::rtl::OUString m_sTableName; + ::rtl::OUString m_sRealName; + // </properties> + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn; + + protected: + ~OQueryColumn(); + + public: + OQueryColumn( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection + ); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + + // *Property* 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; + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + impl_determineOriginalTableColumn( + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection + ); + + using ::cppu::OPropertySetHelper::getFastPropertyValue; }; + // ========================================================================= + // = OColumnWrapper + // ========================================================================= /** * 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! @@ -174,7 +207,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: @@ -195,24 +228,30 @@ 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; }; + // ========================================================================= + // = OTableColumnDescriptorWrapper + // ========================================================================= /** * 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); @@ -243,26 +282,26 @@ namespace dbaccess 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); - - protected: using OColumnWrapper::getFastPropertyValue; }; + // ========================================================================= + // = OTableColumnWrapper + // ========================================================================= /** * 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); @@ -275,76 +314,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_ diff --git a/dbaccess/source/core/inc/querycontainer.hxx b/dbaccess/source/core/inc/querycontainer.hxx index 1e56c4420..bdcda1607 100644 --- a/dbaccess/source/core/inc/querycontainer.hxx +++ b/dbaccess/source/core/inc/querycontainer.hxx @@ -180,7 +180,7 @@ namespace dbaccess ); DECLARE_XINTERFACE( ) - // ::com::sun::star::lang::XServiceInfo + DECLARE_XTYPEPROVIDER( ) DECLARE_SERVICE_INFO(); // ::com::sun::star::container::XContainerListener diff --git a/dbaccess/source/core/inc/sdbcoretools.hxx b/dbaccess/source/core/inc/sdbcoretools.hxx index 037bd864d..8c21c0de9 100644 --- a/dbaccess/source/core/inc/sdbcoretools.hxx +++ b/dbaccess/source/core/inc/sdbcoretools.hxx @@ -31,12 +31,13 @@ #ifndef DBACORE_SDBCORETOOLS_HXX #define DBACORE_SDBCORETOOLS_HXX -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ #include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif + +namespace comphelper +{ + class ComponentContext; +} //......................................................................... namespace dbaccess @@ -71,6 +72,11 @@ namespace dbaccess ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue ); + // ----------------------------------------------------------------------------- + /** retrieves a to-be-displayed string for a given caught exception; + */ + ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const ::com::sun::star::uno::Any& _rError ); + //......................................................................... } // namespace dbaccess //......................................................................... diff --git a/dbaccess/source/core/misc/ContainerMediator.cxx b/dbaccess/source/core/misc/ContainerMediator.cxx index d0841ab67..29e85d0b4 100644 --- a/dbaccess/source/core/misc/ContainerMediator.cxx +++ b/dbaccess/source/core/misc/ContainerMediator.cxx @@ -128,7 +128,7 @@ void OContainerMediator::impl_cleanup_nothrow() xContainer = m_xContainer; if ( xContainer.is() ) xContainer->removeContainerListener( this ); - m_xContainer.clear();//WeakReference< XContainer >(); + m_xContainer.clear(); m_aForwardList.clear(); } @@ -214,115 +214,69 @@ void SAL_CALL OContainerMediator::disposing( const EventObject& /*Source*/ ) thr { ::osl::MutexGuard aGuard(m_aMutex); -// Reference< XContainer > xContainer = m_xContainer; -// if ( Source.Source == xContainer || Source.Source == m_xSettings ) - // this can only be one of them :-) So no check needed here impl_cleanup_nothrow(); } // ----------------------------------------------------------------------------- -Reference< XPropertySet > OContainerMediator::impl_getSettingsForInitialization_nothrow( const ::rtl::OUString& _rName, - const Reference< XPropertySet >& _rxDestination ) const +void OContainerMediator::impl_initSettings_nothrow( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDestination ) { - Reference< XPropertySet > xSettings; try { if ( m_xSettings.is() && m_xSettings->hasByName( _rName ) ) - OSL_VERIFY( m_xSettings->getByName( _rName ) >>= xSettings ); - else if ( m_eType == eColumns ) { - do // artifial loop for easier flow control - { - - Reference< XConnection > xConnection( m_aConnection ); - if ( !xConnection.is() ) - break; - - Reference< XPropertySetInfo > xPSI( _rxDestination->getPropertySetInfo(), UNO_QUERY_THROW ); - if ( !xPSI->hasPropertyByName( PROPERTY_TABLENAME ) - || !xPSI->hasPropertyByName( PROPERTY_REALNAME ) - ) - break; - - // determine the composed table name, plus the column name, as indicated by the - // respective properties at the destination object - ::rtl::OUString sCatalog, sSchema, sTable, sColumn; - if ( xPSI->hasPropertyByName( PROPERTY_CATALOGNAME ) ) - { - OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog ); - } - if ( xPSI->hasPropertyByName( PROPERTY_SCHEMANAME ) ) - { - OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema ); - } - OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_TABLENAME ) >>= sTable ); - OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_REALNAME ) >>= sColumn ); - - ::rtl::OUString sComposedTableName = ::dbtools::composeTableName( - xConnection->getMetaData(), sCatalog, sSchema, sTable, sal_False, ::dbtools::eComplete ); - - // retrieve the table in question - Reference< XTablesSupplier > xSuppTables( xConnection, UNO_QUERY_THROW ); - Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW ); - if ( !xTables->hasByName( sComposedTableName ) ) - break; - - Reference< XColumnsSupplier > xSuppCols( xTables->getByName( sComposedTableName ), UNO_QUERY_THROW ); - Reference< XNameAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW ); - if ( !xColumns->hasByName( sColumn ) ) - break; - - xSettings.set( xColumns->getByName( sColumn ), UNO_QUERY ); - - } - while ( false ); + Reference< XPropertySet > xSettings( m_xSettings->getByName( _rName ), UNO_QUERY_THROW ); + ::comphelper::copyProperties( xSettings, _rxDestination ); } } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return xSettings; } // ----------------------------------------------------------------------------- -void OContainerMediator::notifyElementCreated(const ::rtl::OUString& _sName,const Reference<XPropertySet>& _xDest) +void OContainerMediator::notifyElementCreated( const ::rtl::OUString& _sName, const Reference< XPropertySet >& _xDest ) { - PropertyForwardList::iterator aFind = m_aForwardList.find(_sName); - if ( (aFind == m_aForwardList.end() || !aFind->second->getDefinition().is() )&& m_xSettings.is() ) - { - ::std::vector< ::rtl::OUString> aPropertyList; + if ( !m_xSettings.is() ) + return; - try - { - // initially copy from the settings object (if existent) to the newly created object - Reference< XPropertySet > xSetting( impl_getSettingsForInitialization_nothrow( _sName, _xDest ) ); - if ( xSetting.is() ) - ::comphelper::copyProperties( xSetting, _xDest ); + PropertyForwardList::iterator aFind = m_aForwardList.find( _sName ); + if ( aFind != m_aForwardList.end() + && aFind->second->getDefinition().is() + ) + { + OSL_ENSURE( false, "OContainerMediator::notifyElementCreated: is this really a valid case?" ); + return; + } - // collect the to-be-monitored properties - Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_QUERY_THROW ); - Sequence< Property > aProperties( xPSI->getProperties() ); - const Property* property = aProperties.getConstArray(); - const Property* propertyEnd = aProperties.getConstArray() + aProperties.getLength(); - for ( ; property != propertyEnd; ++property ) - { - if ( ( property->Attributes & PropertyAttribute::READONLY ) != 0 ) - continue; - if ( ( property->Attributes & PropertyAttribute::BOUND ) == 0 ) - continue; + ::std::vector< ::rtl::OUString > aPropertyList; + try + { + // initially copy from the settings object (if existent) to the newly created object + impl_initSettings_nothrow( _sName, _xDest ); - aPropertyList.push_back( property->Name ); - } - } - catch( const Exception& ) + // collect the to-be-monitored properties + Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_QUERY_THROW ); + Sequence< Property > aProperties( xPSI->getProperties() ); + const Property* property = aProperties.getConstArray(); + const Property* propertyEnd = aProperties.getConstArray() + aProperties.getLength(); + for ( ; property != propertyEnd; ++property ) { - DBG_UNHANDLED_EXCEPTION(); + if ( ( property->Attributes & PropertyAttribute::READONLY ) != 0 ) + continue; + if ( ( property->Attributes & PropertyAttribute::BOUND ) == 0 ) + continue; + + aPropertyList.push_back( property->Name ); } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } - ::rtl::Reference< OPropertyForward > pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) ); - m_aForwardList[_sName] = pForward; - } // if ( aFind == m_aForwardList.end() && m_xSettings.is() ) + ::rtl::Reference< OPropertyForward > pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) ); + m_aForwardList[ _sName ] = pForward; } // ----------------------------------------------------------------------------- //........................................................................ diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 46d7f9293..351c75e9a 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -584,7 +584,8 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat { xChartData->setData(uno::Sequence< uno::Sequence<double> >()); xChartData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >()); - m_xInternal->deleteSequence(0); + if ( m_xInternal->hasDataByRangeRepresentation(::rtl::OUString::valueOf(sal_Int32(0))) ) + m_xInternal->deleteSequence(0); } uno::Sequence< ::rtl::OUString > aColumns; diff --git a/dbaccess/source/core/misc/PropertyForward.cxx b/dbaccess/source/core/misc/PropertyForward.cxx index 697519295..d145aa983 100644 --- a/dbaccess/source/core/misc/PropertyForward.cxx +++ b/dbaccess/source/core/misc/PropertyForward.cxx @@ -30,140 +30,146 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBA_PROPERTYSETFORWARD_HXX + #include "PropertyForward.hxx" -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ -#include <com/sun/star/beans/PropertyValue.hpp> -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ -#include <comphelper/property.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ + +#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ #include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _TOOLS_DEBUG_HXX + +#include <comphelper/property.hxx> #include <tools/debug.hxx> -#endif +#include <tools/diagnose_ex.h> //........................................................................ namespace dbaccess { //........................................................................ + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::sdbcx; + using namespace ::com::sun::star::lang; -DBG_NAME(OPropertyForward) -OPropertyForward::OPropertyForward(const Reference< XPropertySet>& _xSource - ,const Reference< XNameAccess>& _xDestContainer - ,const ::rtl::OUString& _sName - ,const ::std::vector< ::rtl::OUString>& _aPropertyList) - : m_xSource(_xSource) - , m_xDestContainer(_xDestContainer) - , m_sName(_sName) - , m_bInInsert(sal_False) -{ - DBG_CTOR(OPropertyForward,NULL); - OSL_ENSURE(_xDestContainer.is(),"OPropertyForward::OPropertyForward: destination should be valid!"); - OSL_ENSURE(m_xSource.is(),"OPropertyForward::OPropertyForward: source must be valid!"); - osl_incrementInterlockedCount(&m_refCount); - try + DBG_NAME(OPropertyForward) + + //------------------------------------------------------------------------ + OPropertyForward::OPropertyForward( const Reference< XPropertySet>& _xSource, const Reference< XNameAccess>& _xDestContainer, + const ::rtl::OUString& _sName, const ::std::vector< ::rtl::OUString>& _aPropertyList ) + :m_xSource( _xSource, UNO_SET_THROW ) + ,m_xDestContainer( _xDestContainer, UNO_SET_THROW ) + ,m_sName( _sName ) + ,m_bInInsert( sal_False ) { - if ( _aPropertyList.empty() ) - _xSource->addPropertyChangeListener(::rtl::OUString(), this); - else + DBG_CTOR(OPropertyForward,NULL); + + osl_incrementInterlockedCount(&m_refCount); + try { - ::std::vector< ::rtl::OUString>::const_iterator aIter = _aPropertyList.begin(); - ::std::vector< ::rtl::OUString>::const_iterator aEnd = _aPropertyList.end(); - for (; aIter != aEnd ; ++aIter ) - _xSource->addPropertyChangeListener(*aIter, this); + if ( _aPropertyList.empty() ) + _xSource->addPropertyChangeListener( ::rtl::OUString(), this ); + else + { + ::std::vector< ::rtl::OUString >::const_iterator aIter = _aPropertyList.begin(); + ::std::vector< ::rtl::OUString >::const_iterator aEnd = _aPropertyList.end(); + for (; aIter != aEnd ; ++aIter ) + _xSource->addPropertyChangeListener( *aIter, this ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } + osl_decrementInterlockedCount( &m_refCount ); } - catch(Exception&) + + // ----------------------------------------------------------------------------- + OPropertyForward::~OPropertyForward() { - OSL_ENSURE(sal_False, "OPropertyForward::OPropertyForward: caught an exception!"); + DBG_DTOR(OPropertyForward,NULL); } - osl_decrementInterlockedCount(&m_refCount); -} -// ----------------------------------------------------------------------------- -OPropertyForward::~OPropertyForward() -{ - DBG_DTOR(OPropertyForward,NULL); -} -// ----------------------------------------------------------------------------- -void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(m_aMutex); - if ( m_xDestContainer.is() ) + + // ----------------------------------------------------------------------------- + void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException) { - if ( m_xDestContainer->hasByName(m_sName) ) - { - m_xDest.set(m_xDestContainer->getByName(m_sName),UNO_QUERY); - } - else + ::osl::MutexGuard aGuard( m_aMutex ); + + if ( !m_xDestContainer.is() ) + throw DisposedException( ::rtl::OUString(), *this ); + + try { - Reference<XDataDescriptorFactory> xFactory(m_xDestContainer,UNO_QUERY); - if ( xFactory.is() ) + if ( !m_xDest.is() ) { - m_xDest = xFactory->createDataDescriptor(); - if ( m_xDest.is() ) + if ( m_xDestContainer->hasByName( m_sName ) ) + { + m_xDest.set( m_xDestContainer->getByName( m_sName ), UNO_QUERY_THROW ); + } + else { - ::comphelper::copyProperties(m_xSource,m_xDest); + Reference< XDataDescriptorFactory > xFactory( m_xDestContainer, UNO_QUERY_THROW ); + m_xDest.set( xFactory->createDataDescriptor(), UNO_SET_THROW ); + + ::comphelper::copyProperties( m_xSource, m_xDest ); + m_bInInsert = sal_True; - Reference<XAppend> xAppend(m_xDestContainer,UNO_QUERY); - if ( xAppend.is() ) - xAppend->appendByDescriptor(m_xDest); + Reference< XAppend > xAppend( m_xDestContainer, UNO_QUERY_THROW ); + xAppend->appendByDescriptor( m_xDest ); m_bInInsert = sal_False; } + + m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW ); + } + + if ( m_xDestInfo->hasPropertyByName( evt.PropertyName ) ) + { + m_xDest->setPropertyValue( evt.PropertyName, evt.NewValue ); } } - if ( m_xDest.is() ) - m_xDestInfo = m_xDest->getPropertySetInfo(); - } - - if ( m_xDestInfo.is() && m_xDestInfo->hasPropertyByName(evt.PropertyName) ) - { - m_xDest->setPropertyValue(evt.PropertyName,evt.NewValue); + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } -} -// ----------------------------------------------------------------------------- -void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard(m_aMutex); - if ( m_xSource.is() ) + + // ----------------------------------------------------------------------------- + void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException) { - m_xSource->removePropertyChangeListener(::rtl::OUString(), this); + ::osl::MutexGuard aGuard(m_aMutex); + + if ( !m_xSource.is() ) + throw DisposedException( ::rtl::OUString(), *this ); + + m_xSource->removePropertyChangeListener( ::rtl::OUString(), this ); m_xSource = NULL; + m_xDestContainer = NULL; + m_xDestInfo = NULL; + m_xDest = NULL; } - m_xDestContainer = NULL; - m_xDestInfo = NULL; - m_xDest = NULL; -} -// ----------------------------------------------------------------------------- -void OPropertyForward::setDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest) -{ - ::osl::MutexGuard aGuard(m_aMutex); - if ( !m_bInInsert ) + + // ----------------------------------------------------------------------------- + void OPropertyForward::setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest ) { - OSL_ENSURE( !m_xDest.is(),"Definition object is already set!"); + ::osl::MutexGuard aGuard( m_aMutex ); + if ( m_bInInsert ) + return; - m_xDest = _xDest; - if ( m_xDest.is() ) + OSL_ENSURE( !m_xDest.is(), "OPropertyForward::setDefinition: definition object is already set!" ); + try { - m_xDestInfo = m_xDest->getPropertySetInfo(); - ::comphelper::copyProperties(m_xDest,m_xSource); + m_xDest.set( _xDest, UNO_SET_THROW ); + m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW ); + ::comphelper::copyProperties( m_xDest, m_xSource ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } -} + //........................................................................ } // namespace dbaccess //........................................................................ diff --git a/dbaccess/source/core/misc/apitools.cxx b/dbaccess/source/core/misc/apitools.cxx index bb4b45315..be95d9305 100644 --- a/dbaccess/source/core/misc/apitools.cxx +++ b/dbaccess/source/core/misc/apitools.cxx @@ -101,11 +101,14 @@ void OSubComponent::release() throw ( ) Reference< XInterface > x( xDelegator ); if (! x.is()) { - if (osl_decrementInterlockedCount( &m_refCount ) == 0 && m_refCount == 0 ) + if (osl_decrementInterlockedCount( &m_refCount ) == 0 ) { - OSL_ENSURE( m_refCount == 0, "OSubComponent::release: why the hell is this false!" ); if (! rBHelper.bDisposed) { + // *before* again incrementing our ref count, ensure that our weak connection point + // will not create references to us anymore (via XAdapter::queryAdapted) + disposeWeakConnectionPoint(); + Reference< XInterface > xHoldAlive( *this ); // remember the parent Reference< XInterface > xParent; @@ -115,13 +118,13 @@ void OSubComponent::release() throw ( ) m_xParent = NULL; } - OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count!" ); + OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (before dispose)!" ); // First dispose dispose(); // only the alive ref holds the object - OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count!" ); + OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (after dispose)!" ); // release the parent in the ~ if (xParent.is()) diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index f97527ae0..94b3d5d4a 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -185,7 +185,7 @@ String ODsnTypeCollection::getMediaType(const ::rtl::OUString& _sURL) const // ----------------------------------------------------------------------------- String ODsnTypeCollection::getDatasourcePrefixFromMediaType(const ::rtl::OUString& _sMediaType,const ::rtl::OUString& _sExtension) { - String sURL; + String sURL, sFallbackURL; const uno::Sequence< ::rtl::OUString > aURLs = m_aDriverConfig.getURLs(); const ::rtl::OUString* pIter = aURLs.getConstArray(); const ::rtl::OUString* pEnd = pIter + aURLs.getLength(); @@ -195,13 +195,19 @@ String ODsnTypeCollection::getDatasourcePrefixFromMediaType(const ::rtl::OUStrin if ( aFeatures.getOrDefault("MediaType",::rtl::OUString()) == _sMediaType ) { const ::rtl::OUString sFileExtension = aFeatures.getOrDefault("Extension",::rtl::OUString()); - if ( (sFileExtension.getLength() && _sExtension == sFileExtension ) || !sFileExtension.getLength() || !_sExtension.getLength() ) + if ( _sExtension == sFileExtension ) { sURL = *pIter; break; } + if ( !sFileExtension.getLength() && _sExtension.getLength() ) + sFallbackURL = *pIter; } } // for(;pIter != pEnd;++pIter ) + + if ( !sURL.Len() && sFallbackURL.Len() ) + sURL = sFallbackURL; + sURL.EraseTrailingChars('*'); return sURL; } @@ -299,12 +305,6 @@ Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( const ::rtl::O return aProperties.getPropertyValues(); } -// ----------------------------------------------------------------------------- -String ODsnTypeCollection::getTypeExtension(const ::rtl::OUString& _sURL) const -{ - const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL); - return aFeatures.getOrDefault("Extension",::rtl::OUString()); -} //------------------------------------------------------------------------- bool ODsnTypeCollection::isEmbeddedDatabase( const ::rtl::OUString& _sURL ) const { diff --git a/dbaccess/source/core/misc/sdbcoretools.cxx b/dbaccess/source/core/misc/sdbcoretools.cxx index fbf8e0996..c4b938868 100644 --- a/dbaccess/source/core/misc/sdbcoretools.cxx +++ b/dbaccess/source/core/misc/sdbcoretools.cxx @@ -31,30 +31,24 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBACORE_SDBCORETOOLS_HXX #include "sdbcoretools.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include "dbastrings.hrc" + +/** === begin UNO includes === **/ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include <com/sun/star/beans/PropertyValue.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_ #include <com/sun/star/util/XModifiable.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ #include <com/sun/star/sdb/XDocumentDataSource.hpp> -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC -#include "dbastrings.hrc" -#endif +#include <com/sun/star/task/XInteractionRequestStringResolver.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/interaction.hxx> +#include <rtl/ref.hxx> +#include <rtl/ustrbuf.hxx> //......................................................................... namespace dbaccess @@ -67,6 +61,7 @@ namespace dbaccess using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::task; using namespace ::com::sun::star::container; // ========================================================================= @@ -130,6 +125,45 @@ namespace dbaccess } // ----------------------------------------------------------------------------- + ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const Any& _rError ) + { + ::rtl::OUString sDisplayMessage; + + try + { + Reference< XInteractionRequestStringResolver > xStringResolver; + if ( _rContext.createComponent( "com.sun.star.task.InteractionRequestStringResolver", xStringResolver ) ) + { + ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rError ) ); + ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove ); + pRequest->addContinuation( pApprove.get() ); + Optional< ::rtl::OUString > aMessage = xStringResolver->getStringFromInformationalRequest( pRequest.get() ); + if ( aMessage.IsPresent ) + sDisplayMessage = aMessage.Value; + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( !sDisplayMessage.getLength() ) + { + Exception aExcept; + _rError >>= aExcept; + + ::rtl::OUStringBuffer aBuffer; + aBuffer.append( _rError.getValueTypeName() ); + aBuffer.appendAscii( ":\n" ); + aBuffer.append( aExcept.Message ); + + sDisplayMessage = aBuffer.makeStringAndClear(); + } + + return sDisplayMessage; + } + +// ----------------------------------------------------------------------------- //......................................................................... } // namespace dbaccess //......................................................................... diff --git a/dbaccess/source/core/resource/core_resource.cxx b/dbaccess/source/core/resource/core_resource.cxx index 0cbbd0f07..63030f75f 100644 --- a/dbaccess/source/core/resource/core_resource.cxx +++ b/dbaccess/source/core/resource/core_resource.cxx @@ -42,7 +42,7 @@ //--------------------------------------------------- #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif //......................................................................... @@ -116,12 +116,6 @@ namespace dbaccess m_pImpl = NULL; } } - ResMgr* ResourceManager::getResManager() - { - ensureImplExists(); - return m_pImpl; - } - //......................................................................... } //......................................................................... diff --git a/dbaccess/source/core/resource/strings.src b/dbaccess/source/core/resource/strings.src index 2d14b2784..0b6951116 100644 --- a/dbaccess/source/core/resource/strings.src +++ b/dbaccess/source/core/resource/strings.src @@ -243,7 +243,12 @@ String RID_STR_NAME_NOT_FOUND String RID_STR_ERROR_WHILE_SAVING { - Text [ en-US ] = "Could not save the document:\n\n$except$:\n$message$"; + Text [ en-US ] = "Could not save the document to $location$:\n$message$"; +}; + +String RID_NO_SUCH_DATA_SOURCE +{ + Text [ en-US ] = "Error accessing data source '$name$':\n$error$"; }; //------------------------------------------------------------------------- diff --git a/dbaccess/source/ext/adabas/Acomponentmodule.cxx b/dbaccess/source/ext/adabas/Acomponentmodule.cxx index 0a54c86c5..5990d390a 100644 --- a/dbaccess/source/ext/adabas/Acomponentmodule.cxx +++ b/dbaccess/source/ext/adabas/Acomponentmodule.cxx @@ -37,7 +37,7 @@ #include <tools/resmgr.hxx> #endif #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> diff --git a/dbaccess/source/ext/adabas/AdabasNewDb.cxx b/dbaccess/source/ext/adabas/AdabasNewDb.cxx index 4152e50ed..9dba4d1ef 100644 --- a/dbaccess/source/ext/adabas/AdabasNewDb.cxx +++ b/dbaccess/source/ext/adabas/AdabasNewDb.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 @@ -75,7 +75,7 @@ #include <vcl/waitobj.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> @@ -136,7 +136,7 @@ namespace adabasui ODatabaseCreator(const Reference<XCreateCatalog>& _rxCreateCatalog ,Window* _pErrorWindow ,const Reference< XMultiServiceFactory >& _xORB - ,const Sequence< PropertyValue>& _rValues) + ,const Sequence< PropertyValue>& _rValues) : m_aValues(_rValues) , m_xCreateCatalog(_rxCreateCatalog) , m_xORB(_xORB) @@ -144,7 +144,7 @@ namespace adabasui {} void setTerminateHandler(const Link& _aTerminateHandler) { m_aTerminateHandler = _aTerminateHandler; } - + protected: /// Working method which should be overridden. @@ -330,7 +330,7 @@ OAdabasNewDbDlg::OAdabasNewDbDlg( Window* pParent, sal_Bool bError = fillEnvironmentVariable(s_sWork,m_sDbWork); if ( bError || !m_sDbWork.Len() ) bError = fillEnvironmentVariable(s_sRoot,m_sDbWork); - + bError = fillEnvironmentVariable(s_sConfig,m_sDbConfig); if ( bError || !m_sDbConfig.Len() ) bError = fillEnvironmentVariable(s_sRoot,m_sDbConfig); @@ -514,7 +514,7 @@ IMPL_LINK( OAdabasNewDbDlg, ImplOKHdl, OKButton*, /*EMPTYARG*/ ) else bOk = TRUE; - + if (!bOk) { ErrorBox(this, WB_OK, aErrorMessage).Execute(); @@ -561,7 +561,7 @@ IMPL_LINK( OAdabasNewDbDlg, ImplOKHdl, OKButton*, /*EMPTYARG*/ ) m_aCreatorWait = ::std::auto_ptr<WaitObject>(new WaitObject(this)); m_aCreatorThread = ::std::auto_ptr<ODatabaseCreator>(new ODatabaseCreator(m_xCreateCatalog,this,m_xORB,aCreateArgs)); m_aCreatorThread->setTerminateHandler(LINK(this,OAdabasNewDbDlg,TerminateHdl)); - m_aCreatorThread->create(); + m_aCreatorThread->create(); return TRUE; } @@ -636,7 +636,7 @@ IMPL_LINK( OAdabasNewDbDlg, ButtonClickHdl, Button *, pButton ) { WinBits nBits(WB_3DLOOK|WB_STDMODAL|WB_SAVEAS); ::sfx2::FileDialogHelper aFileDlg( static_cast<sal_uInt32>(nBits) ); // new FileDialog( this, nBits ); - + String aPath; if(pButton == &m_PB_SYSDEVSPACE) aPath = m_SYSDEV_File; @@ -794,7 +794,7 @@ sal_Bool OAdabasNewDbDlg::fillEnvironmentVariable(const ::rtl::OUString& _sVaria _rsValue = sTemp; rtl_uString_release(pDbVar); pDbVar = NULL; - + // ensure dir exists osl::FileBase::RC rc = osl::Directory::createPath(_rsValue); if(rc != osl::FileBase::E_None && rc != osl::FileBase::E_EXIST) diff --git a/dbaccess/source/ext/adabas/adabasui_resource.hrc b/dbaccess/source/ext/adabas/adabasui_resource.hrc index 74e77cb4d..411d530aa 100644 --- a/dbaccess/source/ext/adabas/adabasui_resource.hrc +++ b/dbaccess/source/ext/adabas/adabasui_resource.hrc @@ -32,7 +32,7 @@ #define _ADABASUI_RESOURCE_HRC_ #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif #define RID_DIALOG_START RID_DB_EXTENSIONS_START diff --git a/dbaccess/source/ext/macromigration/dbmm_global.hrc b/dbaccess/source/ext/macromigration/dbmm_global.hrc index 7bc71199c..ba5a0d351 100644 --- a/dbaccess/source/ext/macromigration/dbmm_global.hrc +++ b/dbaccess/source/ext/macromigration/dbmm_global.hrc @@ -31,7 +31,7 @@ #ifndef DBACCESS_DBMM_GLOBAL_HRC #define DBACCESS_DBMM_GLOBAL_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> //===================================================================== //= bases diff --git a/dbaccess/source/ext/macromigration/docinteraction.cxx b/dbaccess/source/ext/macromigration/docinteraction.cxx index 19d1f682f..4805a1fc5 100644 --- a/dbaccess/source/ext/macromigration/docinteraction.cxx +++ b/dbaccess/source/ext/macromigration/docinteraction.cxx @@ -89,18 +89,6 @@ namespace dbmm //= InteractionHandler //==================================================================== //-------------------------------------------------------------------- - InteractionHandler::InteractionHandler( const ::comphelper::ComponentContext& _rContext ) - :m_pData( new InteractionHandler_Data( _rContext ) ) - { - } - - //-------------------------------------------------------------------- - InteractionHandler::InteractionHandler( const Reference< XInteractionHandler >& _rxHandler ) - :m_pData( new InteractionHandler_Data( _rxHandler ) ) - { - } - - //-------------------------------------------------------------------- InteractionHandler::InteractionHandler( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) :m_pData( new InteractionHandler_Data( _rContext ) ) { diff --git a/dbaccess/source/ext/macromigration/docinteraction.hxx b/dbaccess/source/ext/macromigration/docinteraction.hxx index 298e06c71..68f0b28ac 100644 --- a/dbaccess/source/ext/macromigration/docinteraction.hxx +++ b/dbaccess/source/ext/macromigration/docinteraction.hxx @@ -57,15 +57,6 @@ namespace dbmm { public: /** creates an interaction handler by instantiating a css.task.InteractionHandler - component at the given component context. - */ - InteractionHandler( const ::comphelper::ComponentContext& _rContext ); - - /** creates an InteractionHandler instance, using the given existing UNO handler. - */ - InteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler ); - - /** creates an interaction handler by instantiating a css.task.InteractionHandler component at the given component context, or using the given document's interaction handler, if one is specified in the document's media descriptor. */ diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx index a7432cb71..28a714cb5 100644 --- a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx @@ -56,7 +56,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/implbase1.hxx> #include <rtl/ref.hxx> -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #include <tools/diagnose_ex.h> #include <ucbhelper/content.hxx> #include <ucbhelper/contentbroker.hxx> diff --git a/dbaccess/source/ext/macromigration/progressmixer.cxx b/dbaccess/source/ext/macromigration/progressmixer.cxx index 0dfdee019..771fe129e 100644 --- a/dbaccess/source/ext/macromigration/progressmixer.cxx +++ b/dbaccess/source/ext/macromigration/progressmixer.cxx @@ -108,12 +108,13 @@ namespace dbmm //-------------------------------------------------------------------- namespace { +#if OSL_DEBUG_LEVEL > 0 //---------------------------------------------------------------- bool lcl_isRunning( const ProgressMixer_Data& _rData ) { return _rData.pCurrentPhase != _rData.aPhases.end(); } - +#endif //---------------------------------------------------------------- void lcl_ensureInitialized( ProgressMixer_Data& _rData ) { diff --git a/dbaccess/source/filter/migration/cfgimport.cxx b/dbaccess/source/filter/migration/cfgimport.cxx index 213a2af29..b134ab697 100644 --- a/dbaccess/source/filter/migration/cfgimport.cxx +++ b/dbaccess/source/filter/migration/cfgimport.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 @@ -79,7 +79,7 @@ #include <tools/urlobj.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ #include <com/sun/star/frame/XComponentLoader.hpp> @@ -603,7 +603,7 @@ void OCfgImport::createDataSource(const ::rtl::OUString& _sName) Reference<XOfficeDatabaseDocument> xOfficeDoc(m_xModel,UNO_QUERY); if ( xOfficeDoc.is() ) m_xCurrentDS.set(xOfficeDoc->getDataSource(),UNO_QUERY); - + INetURLObject aURL(rsWorkPath,INetURLObject::WAS_ENCODED); aURL.insertName(_sName,false,INetURLObject::LAST_SEGMENT,true,INetURLObject::ENCODE_ALL); @@ -1237,22 +1237,22 @@ void SAL_CALL OCfgImport::endProperty() } // ----------------------------------------------------------------------------- -void SAL_CALL OCfgImport::addProperty( +void SAL_CALL OCfgImport::addProperty( const rtl::OUString& /*aName*/, sal_Int16 /*aAttributes*/, const Type& /*aType*/ ) - throw( + throw( MalformedDataException, WrappedTargetException ) { } // ----------------------------------------------------------------------------- -void SAL_CALL OCfgImport::addPropertyWithValue( +void SAL_CALL OCfgImport::addPropertyWithValue( const rtl::OUString& /*aName*/, sal_Int16 /*aAttributes*/, - const Any& /*aValue*/ ) - throw( + const Any& /*aValue*/ ) + throw( MalformedDataException, WrappedTargetException ) { diff --git a/dbaccess/source/filter/xml/dbloader2.cxx b/dbaccess/source/filter/xml/dbloader2.cxx index 4d3aa9c19..30105438f 100644 --- a/dbaccess/source/filter/xml/dbloader2.cxx +++ b/dbaccess/source/filter/xml/dbloader2.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 @@ -75,7 +75,7 @@ #include <cppuhelper/implbase2.hxx> #include <osl/file.hxx> #include <sfx2/docfile.hxx> -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <tools/diagnose_ex.h> @@ -439,7 +439,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: sal_Bool bSuccess = sal_True; - // If there's no interaction handler in the media descriptor, put one. + // If there's no interaction handler in the media descriptor, put one. // By definition, loading via loadComponentFromURL (and thus via the content loader here) // is allowed to raise UI. To not burden every place inside the document with creating // a default handler, we simply ensure there is one. @@ -490,7 +490,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: if ( bCreateNew && xModel.is() ) { if ( bNewAndInteractive ) - { + { bSuccess = impl_executeNewDatabaseWizard( xModel, bStartTableWizard ); } else diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index 68cd26f44..16d745ce7 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.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 @@ -30,15 +30,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" - + #ifndef DBA_XMLEXPORT_HXX #include "xmlExport.hxx" #endif -#ifndef DBA_XMLAUTOSTYLE_HXX +#ifndef DBA_XMLAUTOSTYLE_HXX #include "xmlAutoStyle.hxx" #endif #ifndef _FLT_REGHELPER_HXX_ -#include "flt_reghelper.hxx" +#include "flt_reghelper.hxx" #endif #ifndef _XMLOFF_PROGRESSBARHELPER_HXX #include <xmloff/ProgressBarHelper.hxx> @@ -103,8 +103,8 @@ #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ #include <com/sun/star/awt/FontDescriptor.hpp> #endif -#include <svtools/filenotation.hxx> -#include <svtools/pathoptions.hxx> +#include <svl/filenotation.hxx> +#include <unotools/pathoptions.hxx> #include <tools/diagnose_ex.h> #include <connectivity/DriversConfig.hxx> @@ -134,17 +134,17 @@ namespace dbaxml }; } // ----------------------------------------------------------------------------- -extern "C" void SAL_CALL createRegistryInfo_ODBFilterExport( ) +extern "C" void SAL_CALL createRegistryInfo_ODBFilterExport( ) { static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBExport > aAutoRegistration; } //-------------------------------------------------------------------------- -extern "C" void SAL_CALL createRegistryInfo_OSettingsExport( ) +extern "C" void SAL_CALL createRegistryInfo_OSettingsExport( ) { static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBExportHelper > aAutoRegistration; } //-------------------------------------------------------------------------- -extern "C" void SAL_CALL createRegistryInfo_OFullExport( ) +extern "C" void SAL_CALL createRegistryInfo_OFullExport( ) { static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBFullExportHelper > aAutoRegistration; } @@ -174,7 +174,7 @@ namespace dbaxml return aSupported; } - + //--------------------------------------------------------------------- Reference< XInterface > SAL_CALL ODBFullExportHelper::Create(const Reference< XMultiServiceFactory >& _rxORB) { @@ -192,7 +192,7 @@ namespace dbaxml aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExportFilter"); return aSupported; } - + //--------------------------------------------------------------------- ::rtl::OUString lcl_implGetPropertyXMLType(const Type& _rType) { @@ -263,7 +263,7 @@ ODBExport::ODBExport(const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 _GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG ); _GetNamespaceMap().Add( GetXMLToken(XML_NP_DB), GetXMLToken(XML_N_DB_OASIS), XML_NAMESPACE_DB ); - + if( (nExportFlag & (EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS) ) != 0 ) _GetNamespaceMap().Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO ); @@ -320,7 +320,7 @@ ODBExport::ODBExport(const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 } // ----------------------------------------------------------------------------- IMPLEMENT_SERVICE_INFO1_STATIC( ODBExport, "com.sun.star.comp.sdb.DBExportFilter", "com.sun.star.document.ExportFilter") -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- void ODBExport::exportDataSource() { try @@ -452,7 +452,7 @@ void ODBExport::exportDataSource() // special handlings if ( pProperties->Name == PROPERTY_BOOLEANCOMPARISONMODE ) { - sal_Int32 nValue = 0; + sal_Int32 nValue = 0; aValue >>= nValue; if ( sValue.equalsAscii("0") ) sValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("equal-integer")); @@ -542,7 +542,7 @@ void ODBExport::exportDataSource() // ----------------------------------------------------------------------------- void ODBExport::exportApplicationConnectionSettings(const TSettingsMap& _aSettings) { - const ::xmloff::token::XMLTokenEnum pSettings[] = { + const ::xmloff::token::XMLTokenEnum pSettings[] = { XML_IS_TABLE_NAME_LENGTH_LIMITED ,XML_ENABLE_SQL92_CHECK ,XML_APPEND_TABLE_ALIAS_NAME @@ -578,7 +578,7 @@ void ODBExport::exportApplicationConnectionSettings(const TSettingsMap& _aSettin // ----------------------------------------------------------------------------- void ODBExport::exportDriverSettings(const TSettingsMap& _aSettings) { - const ::xmloff::token::XMLTokenEnum pSettings[] = { + const ::xmloff::token::XMLTokenEnum pSettings[] = { XML_SHOW_DELETED ,XML_SYSTEM_DRIVER_SETTINGS ,XML_BASE_DN @@ -716,9 +716,9 @@ void ODBExport::exportConnectionData() SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, sal_True, sal_True); } } - + } - + exportLogin(); } // ----------------------------------------------------------------------------- @@ -739,7 +739,7 @@ void ODBExport::exportDataSourceSettings() aSimpleType = ::comphelper::getSequenceElementType( aIter->Value.getValueType() ); else aSimpleType = aIter->Type; - + AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_IS_LIST,bIsSequence ? XML_TRUE : XML_FALSE ); AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, aIter->Name ); @@ -751,7 +751,7 @@ void ODBExport::exportDataSourceSettings() if ( aSeq.getLength() ) sTypeName = lcl_implGetPropertyXMLType(aSeq[0].getValueType()); } - + AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, sTypeName ); SvXMLElementExport aDataSourceSetting( *this, XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING, sal_True, sal_True ); @@ -812,7 +812,7 @@ void ODBExport::exportCharSet() if ( m_sCharSet.getLength() ) { AddAttribute(XML_NAMESPACE_DB, XML_ENCODING,m_sCharSet); - + SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_FONT_CHARSET, sal_True, sal_True); } } @@ -822,7 +822,7 @@ void ODBExport::exportDelimiter() if ( m_aDelimiter.get() && m_aDelimiter->bUsed ) { AddAttribute(XML_NAMESPACE_DB, XML_FIELD,m_aDelimiter->sField); - AddAttribute(XML_NAMESPACE_DB, XML_STRING,m_aDelimiter->sText); + AddAttribute(XML_NAMESPACE_DB, XML_STRING,m_aDelimiter->sText); AddAttribute(XML_NAMESPACE_DB, XML_DECIMAL,m_aDelimiter->sDecimal); AddAttribute(XML_NAMESPACE_DB, XML_THOUSAND,m_aDelimiter->sThousand); SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DELIMITER, sal_True, sal_True); @@ -834,7 +834,7 @@ void ODBExport::exportAutoIncrement() if ( m_aAutoIncrement.get() ) { AddAttribute(XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,m_aAutoIncrement->second); - AddAttribute(XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT,m_aAutoIncrement->first); + AddAttribute(XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT,m_aAutoIncrement->first); SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_AUTO_INCREMENT, sal_True, sal_True); } } @@ -905,7 +905,7 @@ void ODBExport::exportCollection(const Reference< XNameAccess >& _xCollection else if ( xProp.is() ) _aMemFunc(this,xProp.get()); } - } + } } // ----------------------------------------------------------------------------- void ODBExport::exportComponent(XPropertySet* _xProp) @@ -933,7 +933,7 @@ void ODBExport::exportQuery(XPropertySet* _xProp) if ( getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYFILTER)) ) AddAttribute(XML_NAMESPACE_DB, XML_APPLY_FILTER,XML_TRUE); - if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER) + if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER) && getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYORDER)) ) AddAttribute(XML_NAMESPACE_DB, XML_APPLY_ORDER,XML_TRUE); @@ -960,7 +960,7 @@ void ODBExport::exportTable(XPropertySet* _xProp) if ( getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYFILTER)) ) AddAttribute(XML_NAMESPACE_DB, XML_APPLY_FILTER,XML_TRUE); - if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER) + if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER) && getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYORDER)) ) AddAttribute(XML_NAMESPACE_DB, XML_APPLY_ORDER,XML_TRUE); @@ -970,7 +970,7 @@ void ODBExport::exportTable(XPropertySet* _xProp) Reference<XColumnsSupplier> xCol(_xProp,UNO_QUERY); exportColumns(xCol); exportFilter(_xProp,PROPERTY_FILTER,XML_FILTER_STATEMENT); - exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT); + exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT); } // ----------------------------------------------------------------------------- void ODBExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt) @@ -1049,7 +1049,7 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) exportStyleName(aFind->second.get(),*pAtt); AddAttributeList(xAtt); SvXMLElementExport aColumn(*this,XML_NAMESPACE_DB, XML_COLUMN, sal_True, sal_True); - + } return; } @@ -1068,7 +1068,7 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) exportStyleName(xProp.get(),*pAtt); sal_Bool bHidden = getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN)); - + ::rtl::OUString sValue; xProp->getPropertyValue(PROPERTY_HELPTEXT) >>= sValue; Any aColumnDefault; @@ -1079,7 +1079,7 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); if ( bHidden ) AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE); - + if ( sValue.getLength() ) AddAttribute(XML_NAMESPACE_DB, XML_HELP_MESSAGE,sValue); @@ -1144,7 +1144,7 @@ void ODBExport::exportQueries(sal_Bool _bExportContext) Reference< XNameAccess > xCollection = xSup->getQueryDefinitions(); if ( xCollection.is() && xCollection->hasElements() ) { - ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc; + ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc; if ( _bExportContext ) pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportQuery) ); else @@ -1163,7 +1163,7 @@ void ODBExport::exportTables(sal_Bool _bExportContext) Reference< XNameAccess > xCollection = xSup->getTables(); if ( xCollection.is() && xCollection->hasElements() ) { - ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc; + ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc; if ( _bExportContext ) pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportTable) ); else @@ -1225,7 +1225,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) } m_aCurrentPropertyStates.clear(); } - else + else { // here I know I have a column TExportPropMapperPair pExportHelper[] = { TExportPropMapperPair(m_xColumnExportHelper,TEnumMapperPair(&m_aAutoStyleNames,XML_STYLE_FAMILY_TABLE_COLUMN )) @@ -1260,7 +1260,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) } ++aItr; } // while ( aItr != aEnd ) - + } // if ( !aPropStates.empty() ) if ( XML_STYLE_FAMILY_TABLE_CELL == pExportHelper[i].second.second ) ::std::copy( m_aCurrentPropertyStates.begin(), m_aCurrentPropertyStates.end(), ::std::back_inserter( aPropStates )); @@ -1359,7 +1359,7 @@ void ODBExport::GetViewSettings(Sequence<PropertyValue>& aProps) } } } - + } // ----------------------------------------------------------------------------- void ODBExport::GetConfigurationSettings(Sequence<PropertyValue>& aProps) @@ -1432,7 +1432,7 @@ UniReference < XMLPropertySetMapper > ODBExport::GetCellStylesPropertySetMapper( { if ( !m_xCellStylesPropertySetMapper.is() ) { - m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper(); + m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper(); } return m_xCellStylesPropertySetMapper; } @@ -1441,7 +1441,7 @@ UniReference < XMLPropertySetMapper > ODBExport::GetColumnStylesPropertySetMappe { if ( !m_xColumnStylesPropertySetMapper.is() ) { - m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper(); + m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper(); } return m_xColumnStylesPropertySetMapper; } diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx index ab348bcc2..edfb331d5 100644 --- a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.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 @@ -58,8 +58,8 @@ #include <tools/diagnose_ex.h> #endif #include <comphelper/sequence.hxx> -#include <svtools/filenotation.hxx> -#include <svtools/pathoptions.hxx> +#include <svl/filenotation.hxx> +#include <unotools/pathoptions.hxx> #include "dsntypes.hxx" namespace dbaxml { @@ -102,7 +102,11 @@ OXMLFileBasedDatabase::OXMLFileBasedDatabase( ODBFilter& rImport, rtl::OUString sFileName = aPathOptions.SubstituteVariable(sValue); if ( sValue == sFileName ) { - sLocation = ::svt::OFileNotation(rImport.GetAbsoluteReference(sValue)).get( ::svt::OFileNotation::N_SYSTEM ); + const sal_Int32 nFileNameLength = sFileName.getLength(); + if ( ( nFileNameLength > 0 ) && ( sFileName.getStr()[ nFileNameLength - 1 ] == '/' ) ) + sFileName = sFileName.copy( 0, nFileNameLength - 1 ); + + sLocation = ::svt::OFileNotation( rImport.GetAbsoluteReference( sFileName ) ).get( ::svt::OFileNotation::N_SYSTEM ); } if ( sLocation.getLength() == 0 ) diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 6eed831a1..c56d70a9e 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.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 @@ -41,10 +41,10 @@ #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> #endif #ifndef DBA_XMLFILTER_HXX -#include "xmlfilter.hxx" +#include "xmlfilter.hxx" #endif #ifndef _FLT_REGHELPER_HXX_ -#include "flt_reghelper.hxx" +#include "flt_reghelper.hxx" #endif #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> @@ -124,7 +124,7 @@ #include <vos/mutex.hxx> #endif #include <svtools/sfxecode.hxx> -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/helper/vclunohelper.hxx> #endif @@ -140,7 +140,7 @@ using namespace ::com::sun::star; -extern "C" void SAL_CALL createRegistryInfo_ODBFilter( ) +extern "C" void SAL_CALL createRegistryInfo_ODBFilter( ) { static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBFilter > aAutoRegistration; } @@ -153,7 +153,7 @@ namespace dbaxml { public: typedef enum { E_JAVA, E_CALC } StartType; - FastLoader(uno::Reference< lang::XMultiServiceFactory > const & _xFactory,StartType _eType) + FastLoader(uno::Reference< lang::XMultiServiceFactory > const & _xFactory,StartType _eType) :m_xFactory(_xFactory) ,m_eWhat(_eType) {} @@ -203,7 +203,7 @@ namespace dbaxml sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE; uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag); xFrameLoad.set( xFrame,uno::UNO_QUERY); - + if ( xFrameLoad.is() ) { uno::Sequence < beans::PropertyValue > aArgs( 3); @@ -380,7 +380,7 @@ sal_Int32 ReadThroughComponent( { uno::Reference< io::XStream > xDocStream; sal_Bool bEncrypted = sal_False; - + try { // open stream (and set parser input) @@ -389,7 +389,7 @@ sal_Int32 ReadThroughComponent( { // stream name not found! Then try the compatibility name. // if no stream can be opened, return immediatly with OK signal - + // do we even have an alternative name? if ( NULL == pCompatibilityStreamName ) return 0; @@ -439,7 +439,7 @@ sal_Int32 ReadThroughComponent( // ------------- DBG_NAME(ODBFilter) -ODBFilter::ODBFilter( const uno::Reference< XMultiServiceFactory >& _rxMSF ) +ODBFilter::ODBFilter( const uno::Reference< XMultiServiceFactory >& _rxMSF ) :SvXMLImport(_rxMSF) ,m_bNewFormat(false) { @@ -466,7 +466,7 @@ ODBFilter::~ODBFilter() throw() // ----------------------------------------------------------------------------- IMPLEMENT_SERVICE_INFO1_STATIC( ODBFilter, "com.sun.star.comp.sdb.DBFilter", "com.sun.star.document.ImportFilter") // ----------------------------------------------------------------------------- -sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescriptor ) +sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException) { uno::Reference< ::com::sun::star::awt::XWindow > xWindow; @@ -489,7 +489,7 @@ sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescripto if ( pFocusWindow ) pFocusWindow->LeaveWait(); } - + return bRet; } @@ -507,7 +507,7 @@ sal_Bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) OSL_ENSURE( sFileName.getLength(), "ODBFilter::implImport: no URL given!" ); sal_Bool bRet = ( sFileName.getLength() != 0 ); - if ( bRet ) + if ( bRet ) { uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY); @@ -556,7 +556,7 @@ sal_Bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) bRet = nRet == 0; - if ( bRet ) + if ( bRet ) { uno::Reference< XModifiable > xModi(GetModel(),UNO_QUERY); if ( xModi.is() ) @@ -670,12 +670,12 @@ void ODBFilter::fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap) pIter->Value >>= aValue; _rMap.insert(TPropertyNameMap::value_type(pIter->Name,aValue)); } - + } // ----------------------------------------------------------------------------- const SvXMLTokenMap& ODBFilter::GetDocElemTokenMap() const { - if ( !m_pDocElemTokenMap.get() ) + if ( !m_pDocElemTokenMap.get() ) { static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= { @@ -697,7 +697,7 @@ const SvXMLTokenMap& ODBFilter::GetDocElemTokenMap() const // ----------------------------------------------------------------------------- const SvXMLTokenMap& ODBFilter::GetDatabaseElemTokenMap() const { - if ( !m_pDatabaseElemTokenMap.get() ) + if ( !m_pDatabaseElemTokenMap.get() ) { static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= { @@ -721,21 +721,21 @@ const SvXMLTokenMap& ODBFilter::GetDataSourceElemTokenMap() const { static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]= { - { XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, XML_TOK_CONNECTION_RESOURCE}, - { XML_NAMESPACE_DB, XML_SUPPRESS_VERSION_COLUMNS, XML_TOK_SUPPRESS_VERSION_COLUMNS}, - { XML_NAMESPACE_DB, XML_JAVA_DRIVER_CLASS, XML_TOK_JAVA_DRIVER_CLASS}, - { XML_NAMESPACE_DB, XML_EXTENSION, XML_TOK_EXTENSION}, - { XML_NAMESPACE_DB, XML_IS_FIRST_ROW_HEADER_LINE, XML_TOK_IS_FIRST_ROW_HEADER_LINE}, - { XML_NAMESPACE_DB, XML_SHOW_DELETED, XML_TOK_SHOW_DELETED}, - { XML_NAMESPACE_DB, XML_IS_TABLE_NAME_LENGTH_LIMITED, XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED}, - { XML_NAMESPACE_DB, XML_SYSTEM_DRIVER_SETTINGS, XML_TOK_SYSTEM_DRIVER_SETTINGS}, - { XML_NAMESPACE_DB, XML_ENABLE_SQL92_CHECK, XML_TOK_ENABLE_SQL92_CHECK}, - { XML_NAMESPACE_DB, XML_APPEND_TABLE_ALIAS_NAME, XML_TOK_APPEND_TABLE_ALIAS_NAME}, - { XML_NAMESPACE_DB, XML_PARAMETER_NAME_SUBSTITUTION, XML_TOK_PARAMETER_NAME_SUBSTITUTION}, - { XML_NAMESPACE_DB, XML_IGNORE_DRIVER_PRIVILEGES, XML_TOK_IGNORE_DRIVER_PRIVILEGES}, - { XML_NAMESPACE_DB, XML_BOOLEAN_COMPARISON_MODE, XML_TOK_BOOLEAN_COMPARISON_MODE}, - { XML_NAMESPACE_DB, XML_USE_CATALOG, XML_TOK_USE_CATALOG}, - { XML_NAMESPACE_DB, XML_BASE_DN, XML_TOK_BASE_DN}, + { XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, XML_TOK_CONNECTION_RESOURCE}, + { XML_NAMESPACE_DB, XML_SUPPRESS_VERSION_COLUMNS, XML_TOK_SUPPRESS_VERSION_COLUMNS}, + { XML_NAMESPACE_DB, XML_JAVA_DRIVER_CLASS, XML_TOK_JAVA_DRIVER_CLASS}, + { XML_NAMESPACE_DB, XML_EXTENSION, XML_TOK_EXTENSION}, + { XML_NAMESPACE_DB, XML_IS_FIRST_ROW_HEADER_LINE, XML_TOK_IS_FIRST_ROW_HEADER_LINE}, + { XML_NAMESPACE_DB, XML_SHOW_DELETED, XML_TOK_SHOW_DELETED}, + { XML_NAMESPACE_DB, XML_IS_TABLE_NAME_LENGTH_LIMITED, XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED}, + { XML_NAMESPACE_DB, XML_SYSTEM_DRIVER_SETTINGS, XML_TOK_SYSTEM_DRIVER_SETTINGS}, + { XML_NAMESPACE_DB, XML_ENABLE_SQL92_CHECK, XML_TOK_ENABLE_SQL92_CHECK}, + { XML_NAMESPACE_DB, XML_APPEND_TABLE_ALIAS_NAME, XML_TOK_APPEND_TABLE_ALIAS_NAME}, + { XML_NAMESPACE_DB, XML_PARAMETER_NAME_SUBSTITUTION, XML_TOK_PARAMETER_NAME_SUBSTITUTION}, + { XML_NAMESPACE_DB, XML_IGNORE_DRIVER_PRIVILEGES, XML_TOK_IGNORE_DRIVER_PRIVILEGES}, + { XML_NAMESPACE_DB, XML_BOOLEAN_COMPARISON_MODE, XML_TOK_BOOLEAN_COMPARISON_MODE}, + { XML_NAMESPACE_DB, XML_USE_CATALOG, XML_TOK_USE_CATALOG}, + { XML_NAMESPACE_DB, XML_BASE_DN, XML_TOK_BASE_DN}, { XML_NAMESPACE_DB, XML_MAX_ROW_COUNT, XML_TOK_MAX_ROW_COUNT}, { XML_NAMESPACE_DB, XML_LOGIN, XML_TOK_LOGIN}, { XML_NAMESPACE_DB, XML_TABLE_FILTER, XML_TOK_TABLE_FILTER}, @@ -758,7 +758,7 @@ const SvXMLTokenMap& ODBFilter::GetDataSourceElemTokenMap() const { XML_NAMESPACE_DB, XML_DRIVER_SETTINGS, XML_TOK_DRIVER_SETTINGS}, { XML_NAMESPACE_DB, XML_JAVA_CLASSPATH, XML_TOK_JAVA_CLASSPATH}, { XML_NAMESPACE_DB, XML_CHARACTER_SET, XML_TOK_CHARACTER_SET}, - { XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS,XML_TOK_APPLICATION_CONNECTION_SETTINGS}, + { XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS,XML_TOK_APPLICATION_CONNECTION_SETTINGS}, XML_TOKEN_MAP_END }; m_pDataSourceElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); @@ -816,7 +816,7 @@ const SvXMLTokenMap& ODBFilter::GetDataSourceInfoElemTokenMap() const { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, XML_TOK_DATA_SOURCE_SETTING_TYPE}, { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, XML_TOK_DATA_SOURCE_SETTING_NAME}, { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET}, - { XML_NAMESPACE_DB, XML_ENCODING, XML_TOK_ENCODING}, + { XML_NAMESPACE_DB, XML_ENCODING, XML_TOK_ENCODING}, XML_TOKEN_MAP_END }; m_pDataSourceInfoElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); @@ -879,7 +879,7 @@ const SvXMLTokenMap& ODBFilter::GetQueryElemTokenMap() const { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_STYLE_NAME}, { XML_NAMESPACE_DB, XML_APPLY_FILTER, XML_TOK_APPLY_FILTER}, { XML_NAMESPACE_DB, XML_APPLY_ORDER, XML_TOK_APPLY_ORDER}, - { XML_NAMESPACE_DB, XML_COLUMNS, XML_TOK_COLUMNS}, + { XML_NAMESPACE_DB, XML_COLUMNS, XML_TOK_COLUMNS}, XML_TOKEN_MAP_END }; m_pQueryElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap )); @@ -943,7 +943,7 @@ UniReference < XMLPropertySetMapper > ODBFilter::GetColumnStylesPropertySetMappe { if ( !m_xColumnStylesPropertySetMapper.is() ) { - m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper(); + m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper(); } return m_xColumnStylesPropertySetMapper; } @@ -952,7 +952,7 @@ UniReference < XMLPropertySetMapper > ODBFilter::GetCellStylesPropertySetMapper( { if ( !m_xCellStylesPropertySetMapper.is() ) { - m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper(); + m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper(); } return m_xCellStylesPropertySetMapper; } diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx index 8963b6749..3d2a091c3 100644 --- a/dbaccess/source/inc/dsntypes.hxx +++ b/dbaccess/source/inc/dsntypes.hxx @@ -139,9 +139,6 @@ public: /// get the datasource type display name from a DSN string String getTypeDisplayName(const ::rtl::OUString& _sURL) const; - /// returns the extension of the user defined type - String getTypeExtension(const ::rtl::OUString& _sURL) const; - /// on a given string, cut the type prefix and return the result String cutPrefix(const ::rtl::OUString& _sURL) const; diff --git a/dbaccess/source/sdbtools/inc/sdbt_resource.hrc b/dbaccess/source/sdbtools/inc/sdbt_resource.hrc index 1fafdcd3b..8cc2f3e63 100644 --- a/dbaccess/source/sdbtools/inc/sdbt_resource.hrc +++ b/dbaccess/source/sdbtools/inc/sdbt_resource.hrc @@ -32,7 +32,7 @@ #define DBACCESS_SDBT_RESOURCE_HRC #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif //------------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 2af08e0d0..42eeedc7b 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.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 @@ -87,7 +87,7 @@ #include <tools/diagnose_ex.h> #endif #ifndef SVTOOLS_URIHELPER_HXX -#include <svtools/urihelper.hxx> +#include <svl/urihelper.hxx> #endif #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> @@ -135,10 +135,10 @@ #include <vcl/menu.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef INCLUDED_SVTOOLS_INTERNALOPTIONS_HXX -#include <svtools/internaloptions.hxx> +#include <unotools/internaloptions.hxx> #endif #ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> @@ -178,7 +178,7 @@ #include <sfx2/mailmodelapi.hxx> #endif #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #endif #ifndef _SVTREEBOX_HXX #include <svtools/svtreebx.hxx> @@ -219,10 +219,10 @@ #include <sfx2/QuerySaveDocument.hxx> #endif #ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX -#include <svtools/historyoptions.hxx> +#include <unotools/historyoptions.hxx> #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> @@ -1621,7 +1621,7 @@ void OApplicationController::describeSupportedFeatures() implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL, CommandGroup::APPLICATION ); // this one should not appear under Tools->Customize->Keyboard - implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection", + implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection", SID_APP_NEW_REPORT_PRE_SEL,CommandGroup::INTERNAL ); implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT, CommandGroup::INTERNAL); implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT, CommandGroup::INTERNAL); diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx index b4bed6193..5b6fc6c4b 100644 --- a/dbaccess/source/ui/app/AppController.hxx +++ b/dbaccess/source/ui/app/AppController.hxx @@ -295,15 +295,6 @@ namespace dbaui /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>. sal_Bool isTableFormat() const; - /** copies a table which was constructed by tags like HTML or RTF - @param _rDesc - The Drop descriptor - @param _bCheck - If set to <TRUE/> than the controller checks only if a copy is possible. - */ - sal_Bool copyTagTable( OTableCopyHelper::DropDescriptor& _rDesc - , sal_Bool _bCheck); - /** fills the vector with all supported formats @param _eType The type for which we need the formats diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx index 74c628be3..edd68410d 100644 --- a/dbaccess/source/ui/app/AppControllerDnD.cxx +++ b/dbaccess/source/ui/app/AppControllerDnD.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 @@ -204,7 +204,7 @@ #include <sfx2/filedlghelper.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef _SFX_DOCFILT_HACK_HXX #include <sfx2/docfilt.hxx> @@ -835,7 +835,7 @@ sal_Bool OApplicationController::paste( ElementType _eType,const ::svx::ODataAcc if ( xSrcNameAccess.is() && xDstNameAccess.is() && xSrcNameAccess->hasElements() && xAppend.is() ) { Reference<XPropertySet> xDstProp(xFac->createDataDescriptor()); - + Sequence< ::rtl::OUString> aSeq = xSrcNameAccess->getElementNames(); const ::rtl::OUString* pIter = aSeq.getConstArray(); const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); @@ -902,18 +902,6 @@ sal_Bool OApplicationController::isTableFormat() const return m_aTableCopyHelper.isTableFormat(getViewClipboard()); } // ----------------------------------------------------------------------------- -sal_Bool OApplicationController::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, sal_Bool _bCheck) -{ - // first get the dest connection - ::osl::MutexGuard aGuard( getMutex() ); - - SharedConnection xConnection( ensureConnection() ); - if ( !xConnection.is() ) - return sal_False; - - return m_aTableCopyHelper.copyTagTable( _rDesc, _bCheck, xConnection ); -} -// ----------------------------------------------------------------------------- IMPL_LINK( OApplicationController, OnAsyncDrop, void*, /*NOTINTERESTEDIN*/ ) { m_nAsyncDrop = 0; diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index ff9bd2516..7e08e4016 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -545,7 +545,7 @@ void OApplicationController::previewChanged( sal_Int32 _nMode ) // // String sTitle = String(ModuleRes(STR_APP_TITLE)); // sName = sName + sTitle; -//#ifndef PRODUCT +//#ifdef DBG_UTIL // ::rtl::OUString aDefault; // sName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" [")); // sName += utl::Bootstrap::getBuildIdData( aDefault ); diff --git a/dbaccess/source/ui/app/AppView.cxx b/dbaccess/source/ui/app/AppView.cxx index 01fa100b4..c4e56e0a8 100644 --- a/dbaccess/source/ui/app/AppView.cxx +++ b/dbaccess/source/ui/app/AppView.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 @@ -44,8 +44,8 @@ #endif #ifndef _DBA_DBACCESS_HELPID_HRC_ #include "dbaccess_helpid.hrc" -#endif -#ifndef _SV_TOOLBOX_HXX +#endif +#ifndef _SV_TOOLBOX_HXX #include <vcl/toolbox.hxx> #endif #ifndef _UTL_CONFIGMGR_HXX_ @@ -70,7 +70,7 @@ #include <com/sun/star/sdb/XQueriesSupplier.hpp> #endif #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #endif #ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" @@ -105,8 +105,8 @@ #ifndef DBACCESS_UI_BROWSER_ID_HXX #include "browserids.hxx" #endif -#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> #endif #include "IApplicationController.hxx" @@ -145,8 +145,8 @@ OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePrev m_pPanel->setChildWindow(pSwap); m_pPanel->SetUniqueId(UID_APP_DATABASE_VIEW); - m_pPanel->Show(); - + m_pPanel->Show(); + m_pDetailView = new OApplicationDetailView(*this,_ePreviewMode); m_pDetailView->Show(); @@ -200,7 +200,7 @@ void OAppBorderWindow::Resize() nX = ::std::max(m_pPanel->GetWidthPixel() ,nX); m_pPanel->SetPosSizePixel(Point(0,0),Size(nX,nOutputHeight)); } - + if ( m_pDetailView ) m_pDetailView->SetPosSizePixel(Point(nX + aFLSize.Width(),0),Size(nOutputWidth - nX - aFLSize.Width(),nOutputHeight)); } @@ -239,7 +239,7 @@ void OAppBorderWindow::ImplInitSettings() if( true ) SetBackground( rStyleSettings.GetDialogColor() ); - + /*SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) ); SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() ); SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );*/ @@ -288,7 +288,7 @@ OApplicationView::OApplicationView( Window* pParent m_pWin = new OAppBorderWindow(this,_ePreviewMode); m_pWin->SetUniqueId(UID_APP_VIEW_BORDER_WIN); - m_pWin->Show(); + m_pWin->Show(); ImplInitSettings(); } @@ -330,7 +330,7 @@ void OApplicationView::DataChanged( const DataChangedEvent& rDCEvt ) ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) { - ImplInitSettings(); + ImplInitSettings(); Invalidate(); } } @@ -377,7 +377,7 @@ long OApplicationView::PreNotify( NotifyEvent& rNEvt ) } break; } - + return ODataView::PreNotify(rNEvt); } // ----------------------------------------------------------------------------- @@ -410,21 +410,21 @@ sal_Bool OApplicationView::isPasteAllowed() void OApplicationView::copy() { IClipboardTest* pTest = getActiveChild(); - if ( pTest ) + if ( pTest ) pTest->copy(); } // ----------------------------------------------------------------------------- void OApplicationView::cut() { IClipboardTest* pTest = getActiveChild(); - if ( pTest ) + if ( pTest ) pTest->cut(); } // ----------------------------------------------------------------------------- void OApplicationView::paste() { IClipboardTest* pTest = getActiveChild(); - if ( pTest ) + if ( pTest ) pTest->paste(); } // ----------------------------------------------------------------------------- @@ -597,7 +597,7 @@ void OApplicationView::showPreview( const ::rtl::OUString& _sDataSourceName, try { Reference<XNameAccess> xNameAccess; - if ( _bTable ) + if ( _bTable ) { Reference<XTablesSupplier> xSup(_xConnection,UNO_QUERY); if ( xSup.is() ) diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx index 8541879c6..f5ce0cf18 100644 --- a/dbaccess/source/ui/app/subcomponentmanager.cxx +++ b/dbaccess/source/ui/app/subcomponentmanager.cxx @@ -125,8 +125,9 @@ namespace dbaui xModel.set( _rxComponent, UNO_QUERY ); if ( xModel.is() ) { - xController.set( xModel->getCurrentController(), UNO_SET_THROW ); - xFrame.set( xController->getFrame(), UNO_SET_THROW ); + xController.set( xModel->getCurrentController() ); + if ( xController.is() ) + xFrame.set( xController->getFrame(), UNO_SET_THROW ); } else { @@ -468,13 +469,15 @@ namespace dbaui // put into map SubComponentAccessor aKey( _rName, _nComponentType, _eOpenMode ); SubComponentDescriptor aElement( _rxComponent ); + ENSURE_OR_THROW( aElement.xModel.is() || aElement.xController.is(), "illegal component" ); m_pData->m_aComponents.insert( SubComponentMap::value_type( aKey, aElement ) ) ; // add as listener - aElement.xController->addEventListener( this ); + if ( aElement.xController.is() ) + aElement.xController->addEventListener( this ); if ( aElement.xModel.is() ) aElement.xModel->addEventListener( this ); diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 147d55a8d..d8427d6ae 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -32,187 +32,72 @@ #include "precompiled_dbaccess.hxx" -#ifndef _SBA_BWRCTRLR_HXX + +#include "browserids.hxx" #include "brwctrlr.hxx" -#endif -#ifndef _SBX_BRWVIEW_HXX #include "brwview.hxx" -#endif -#ifndef _OSL_MUTEX_HXX_ //autogen wg. MutexGuard -#include <osl/mutex.hxx> -#endif -#ifndef _SFXAPP_HXX //autogen wg. SFX_APP -#include <sfx2/app.hxx> -#endif -#ifndef _COM_SUN_STAR_UNO_TYPECLASS_HPP_ -#include <com/sun/star/uno/TypeClass.hpp> -#endif -#ifndef _DBAUI_SQLMESSAGE_HXX_ +#include "dbu_brw.hrc" +#include "dbustrings.hrc" +#include "queryfilter.hxx" +#include "queryorder.hxx" #include "sqlmessage.hxx" -#endif -#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_ -#include <com/sun/star/form/XFormController.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ -#include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_ -#include <com/sun/star/sdbc/XRowSetListener.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ -#include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ -#include <com/sun/star/sdbcx/XRowLocate.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ -#include <com/sun/star/sdbc/XResultSetUpdate.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XSQLERRORBROADCASTER_HPP_ -#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ -#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ -#include <com/sun/star/form/XLoadable.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ -#include <com/sun/star/sdb/SQLContext.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ + +/** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/form/FormButtonType.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XCHANGELISTENER_HPP_ -#include <com/sun/star/form/XChangeListener.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_FORMSUBMITENCODING_HPP_ #include <com/sun/star/form/FormSubmitEncoding.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_FORMSUBMITMETHOD_HPP_ #include <com/sun/star/form/FormSubmitMethod.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XSUBMITLISTENER_HPP_ -#include <com/sun/star/form/XSubmitListener.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XRESET_HPP_ -#include <com/sun/star/form/XReset.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XSUBMIT_HPP_ -#include <com/sun/star/form/XSubmit.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XAPPROVEACTIONBROADCASTER_HPP_ #include <com/sun/star/form/XApproveActionBroadcaster.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XCHANGEBROADCASTER_HPP_ +#include <com/sun/star/form/XBoundControl.hpp> #include <com/sun/star/form/XChangeBroadcaster.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XRESETLISTENER_HPP_ -#include <com/sun/star/form/XResetListener.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ -#include <com/sun/star/util/XCancellable.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XDATABASEPARAMETERBROADCASTER_HPP_ +#include <com/sun/star/form/XChangeListener.hpp> #include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XBOUNDCONTROL_HPP_ -#include <com/sun/star/form/XBoundControl.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ -#include <com/sun/star/container/XNamed.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ +#include <com/sun/star/form/XLoadable.hpp> +#include <com/sun/star/form/XReset.hpp> +#include <com/sun/star/form/XResetListener.hpp> +#include <com/sun/star/form/XSubmit.hpp> +#include <com/sun/star/form/XSubmitListener.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> +#include <com/sun/star/sdb/ParametersRequest.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> +#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#include <com/sun/star/sdbc/XRowSetListener.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> #include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ -#include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _CPPUHELPER_EXC_HLP_HXX_ -#include <cppuhelper/exc_hlp.hxx> -#endif -#ifndef _SV_MSGBOX_HXX //autogen -#include <vcl/msgbox.hxx> -#endif -#ifndef _FMSEARCH_HXX -#include <svx/fmsearch.hxx> -#endif -#ifndef _SV_WAITOBJ_HXX -#include <vcl/waitobj.hxx> -#endif -#ifndef _TOOLS_COLOR_HXX -#include <tools/color.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H -#include <tools/diagnose_ex.h> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ -#include <comphelper/sequence.hxx> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _CPPUHELPER_IMPLBASE2_HXX_ -#include <cppuhelper/implbase2.hxx> -#endif -#ifndef _DBU_BRW_HRC_ -#include "dbu_brw.hrc" -#endif -#ifndef _SFX_HRC -#include <sfx2/sfx.hrc> -#endif -#ifndef DBACCESS_UI_BROWSER_ID_HXX -#include "browserids.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC -#include "dbustrings.hrc" -#endif -#ifndef _COMPHELPER_INTERACTION_HXX_ +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/uno/TypeClass.hpp> +#include <com/sun/star/util/XCancellable.hpp> +/** === end UNO includes === **/ + +#include <comphelper/enumhelper.hxx> +#include <comphelper/extract.hxx> #include <comphelper/interaction.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <comphelper/sequence.hxx> #include <connectivity/dbexception.hxx> -#endif -#ifndef CONNECTIVITY_SQLERROR_HXX +#include <connectivity/dbtools.hxx> #include <connectivity/sqlerror.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_ -#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ -#include <com/sun/star/sdb/ParametersRequest.hpp> -#endif -#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ -#include <com/sun/star/task/XInteractionHandler.hpp> -#endif -#ifndef INCLUDED_COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP -#include <com/sun/star/sdbc/XWarningsSupplier.hpp> -#endif -#ifndef INCLUDED_COM_SUN_STAR_SDB_ERRORCONDITION_HPP -#include <com/sun/star/sdb/ErrorCondition.hpp> -#endif -#ifndef DBAUI_QUERYFILTER_HXX -#include "queryfilter.hxx" -#endif -#ifndef DBAUI_QUERYORDER_HXX -#include "queryorder.hxx" -#endif +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <osl/mutex.hxx> #include <rtl/logfile.hxx> - -#include <svx/svxdlg.hxx> //CHINA001 -//#include <svx/fmresids.hrc> //CHINA001 +#include <sfx2/app.hxx> +#include <sfx2/sfx.hrc> +#include <svx/fmsearch.hxx> +#include <svx/svxdlg.hxx> +#include <tools/color.hxx> +#include <tools/diagnose_ex.h> +#include <vcl/msgbox.hxx> +#include <vcl/waitobj.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; @@ -280,12 +165,12 @@ void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyVal //============================================================================== -// a helper class implementing a ::com::sun::star::form::XFormController, will be aggregated by SbaXDataBrowserController -// (we can't derive from ::com::sun::star::form::XFormController as it's base class is ::com::sun::star::awt::XTabController and the ::com::sun::star::awt::XTabController::getModel collides -// with the ::com::sun::star::frame::XController::getModel implemented in our base class SbaXDataBrowserController) +// a helper class implementing a runtime::XFormController, will be aggregated by SbaXDataBrowserController +// (we can't derive from XFormController as it's base class is XTabController and the XTabController::getModel collides +// with the XController::getModel implemented in our base class SbaXDataBrowserController) class SbaXDataBrowserController::FormControllerImpl - : public ::cppu::WeakAggImplHelper2< ::com::sun::star::form::XFormController, - ::com::sun::star::frame::XFrameActionListener> + : public ::cppu::WeakAggImplHelper2< ::com::sun::star::form::runtime::XFormController, + ::com::sun::star::frame::XFrameActionListener > { friend class SbaXDataBrowserController; ::cppu::OInterfaceContainerHelper m_aActivateListeners; @@ -294,12 +179,68 @@ class SbaXDataBrowserController::FormControllerImpl public: FormControllerImpl(SbaXDataBrowserController* pOwner); - // ::com::sun::star::form::XFormController + // XFormController + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( ::com::sun::star::uno::RuntimeException ); - - // ::com::sun::star::awt::XTabController + virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException); + + // XChild, base of XFormController + 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); + + // XComponent, base of XFormController + virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XIndexAccess, base of XFormController + virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess, base of XIndexAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess, base of XElementAccess + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw (::com::sun::star::uno::RuntimeException); + + // XModifyBroadcaster, base of XFormController + virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XConfirmDeleteBroadcaster, base of XFormController + virtual void SAL_CALL addConfirmDeleteListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeConfirmDeleteListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XSQLErrorBroadcaster, base of XFormController + virtual void SAL_CALL addSQLErrorListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeSQLErrorListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + + // XRowSetApproveBroadcaster, base of XFormController + virtual void SAL_CALL addRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + + // XDatabaseParameterBroadcaster2, base of XFormController + virtual void SAL_CALL addDatabaseParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeDatabaseParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XDatabaseParameterBroadcaster, base of XDatabaseParameterBroadcaster2 + virtual void SAL_CALL addParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XModeSelector, base of XFormController + virtual void SAL_CALL setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getMode( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::uno::RuntimeException); + + // XTabController, base of XFormController virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel > & Model) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel > SAL_CALL getModel(void) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > & _Container) throw( ::com::sun::star::uno::RuntimeException ); @@ -310,10 +251,10 @@ public: virtual void SAL_CALL activateFirst(void) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL activateLast(void) throw( ::com::sun::star::uno::RuntimeException ); - // ::com::sun::star::frame::XFrameActionListener + // XFrameActionListener virtual void SAL_CALL frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - // ::com::sun::star::lang::XEventListener + // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); protected: @@ -340,6 +281,13 @@ SbaXDataBrowserController::FormControllerImpl::~FormControllerImpl() } //------------------------------------------------------------------ +Reference< runtime::XFormOperations > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getFormOperations() throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::getFormOperations: not supported!" ); + return NULL; +} + +//------------------------------------------------------------------ Reference< ::com::sun::star::awt::XControl > SbaXDataBrowserController::FormControllerImpl::getCurrentControl(void) throw( RuntimeException ) { return m_pOwner->getBrowserView() ? m_pOwner->getBrowserView()->getGridControl() : Reference< ::com::sun::star::awt::XControl > (); @@ -358,6 +306,202 @@ void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeActivateListe } //------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addChildController( const Reference< runtime::XFormController >& /*_ChildController*/ ) throw( RuntimeException, IllegalArgumentException ) +{ + // not supported + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); +} + +//------------------------------------------------------------------ +Reference< runtime::XFormControllerContext > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getContext() throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::getContext: no support!!" ); + return NULL; +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setContext( const Reference< runtime::XFormControllerContext >& /*_context*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::setContext: no support!!" ); +} + +//------------------------------------------------------------------ +Reference< XInteractionHandler > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getInteractionHandler() throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::getInteractionHandler: no support!!" ); + return NULL; +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setInteractionHandler( const Reference< XInteractionHandler >& /*_interactionHandler*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::setInteractionHandler: no support!!" ); +} + +//------------------------------------------------------------------ +Reference< XInterface > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getParent( ) throw (RuntimeException) +{ + // don't have any parent form controllers + return NULL; +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setParent( const Reference< XInterface >& /*Parent*/ ) throw (NoSupportException, RuntimeException) +{ + throw NoSupportException( ::rtl::OUString(), *this ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::dispose( ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::dispose: no, you do *not* want to do this!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addEventListener: no support!!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeEventListener: no support!!" ); +} + +//------------------------------------------------------------------ +::sal_Int32 SAL_CALL SbaXDataBrowserController::FormControllerImpl::getCount( ) throw (RuntimeException) +{ + // no sub controllers, never + return 0; +} + +//------------------------------------------------------------------ +Any SAL_CALL SbaXDataBrowserController::FormControllerImpl::getByIndex( ::sal_Int32 /*Index*/ ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException) +{ + // no sub controllers, never + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); +} + +//------------------------------------------------------------------ +Type SAL_CALL SbaXDataBrowserController::FormControllerImpl::getElementType( ) throw (RuntimeException) +{ + return ::cppu::UnoType< runtime::XFormController >::get(); +} + +//------------------------------------------------------------------ +::sal_Bool SAL_CALL SbaXDataBrowserController::FormControllerImpl::hasElements( ) throw (RuntimeException) +{ + // no sub controllers, never + return false; +} + +//------------------------------------------------------------------ +Reference< XEnumeration > SAL_CALL SbaXDataBrowserController::FormControllerImpl::createEnumeration( ) throw (RuntimeException) +{ + return new ::comphelper::OEnumerationByIndex( this ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addModifyListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeModifyListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::addParameterListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "SbaXDataBrowserController::FormControllerImpl::removeParameterListener: no support!" ); +} + +//------------------------------------------------------------------ +void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setMode( const ::rtl::OUString& _rMode ) throw (NoSupportException, RuntimeException) +{ + if ( !supportsMode( _rMode ) ) + throw NoSupportException(); +} + +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL SbaXDataBrowserController::FormControllerImpl::getMode( ) throw (RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); +} + +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getSupportedModes( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aModes(1); + aModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); + return aModes; +} + +//------------------------------------------------------------------ +::sal_Bool SAL_CALL SbaXDataBrowserController::FormControllerImpl::supportsMode( const ::rtl::OUString& aMode ) throw (RuntimeException) +{ + return aMode.compareToAscii( "DataMode" ) == 0; +} + +//------------------------------------------------------------------ void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setModel(const Reference< ::com::sun::star::awt::XTabControllerModel > & /*Model*/) throw( RuntimeException ) { OSL_ENSURE(sal_False, "SbaXDataBrowserController::FormControllerImpl::setModel : invalid call, can't change my model !"); @@ -465,19 +609,12 @@ Sequence< sal_Int8 > SAL_CALL SbaXDataBrowserController::getImplementationId( ) //------------------------------------------------------------------ Any SAL_CALL SbaXDataBrowserController::queryInterface(const Type& _rType) throw (RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::queryInterface" ); // check for our additional interfaces Any aRet = SbaXDataBrowserController_Base::queryInterface(_rType); - // check for the base controllers interfaces + // check for our aggregate (implementing the XFormController) if (!aRet.hasValue()) - { - // check for our aggregate (implementing the XFormController) - if (!aRet.hasValue()) - { - aRet = m_xFormControllerImpl->queryAggregation(_rType); - } - } + aRet = m_xFormControllerImpl->queryAggregation(_rType); // no more to offer return aRet; @@ -1206,16 +1343,6 @@ sal_Bool SbaXDataBrowserController::suspend(sal_Bool /*bSuspend*/) throw( Runtim // ----------------------------------------------------------------------- void SbaXDataBrowserController::disposing() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposing" ); - // and dispose the aggregate - if (m_xFormControllerImpl.is()) - { - Reference< XComponent > xAggComp; - m_xFormControllerImpl->queryAggregation(::getCppuType(&xAggComp)) >>= xAggComp; - if (xAggComp.is()) - xAggComp->dispose(); - } - // the base class SbaXDataBrowserController_Base::OGenericUnoController::disposing(); @@ -1368,7 +1495,10 @@ void SbaXDataBrowserController::errorOccured(const ::com::sun::star::sdb::SQLErr m_aCurrentError = aInfo; } else + { + m_aCurrentError = aInfo; m_aAsyncDisplayError.Call(); + } } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx index 4448d5b63..1174a1308 100644 --- a/dbaccess/source/ui/browser/dbloader.cxx +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -324,7 +324,16 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: } catch(const Exception&) { - DBG_UNHANDLED_EXCEPTION(); + // Does this need to be shown to the user? + bSuccess = false; + try + { + ::comphelper::disposeComponent( xController ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } @@ -342,7 +351,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const :: } else if ( rListener.is() ) - rListener->loadCancelled( this ); + rListener->loadCancelled( this ); } // ----------------------------------------------------------------------- diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx index 2b2dc7937..7bba5b4dd 100644 --- a/dbaccess/source/ui/browser/exsrcbrw.cxx +++ b/dbaccess/source/ui/browser/exsrcbrw.cxx @@ -43,9 +43,6 @@ #ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_ #include <com/sun/star/form/XGridColumnFactory.hpp> #endif -#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_ -#include <com/sun/star/form/XFormController.hpp> -#endif #ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ #include <com/sun/star/form/XLoadable.hpp> #endif diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 4bed7fcf6..9eb25d7d8 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.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 @@ -105,13 +105,13 @@ #include <tools/urlobj.hxx> #endif #ifndef SVTOOLS_URIHELPER_HXX -#include <svtools/urihelper.hxx> +#include <svl/urihelper.hxx> #endif #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_ #include "datasourceconnector.hxx" #endif #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #endif #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -282,6 +282,7 @@ OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFacto } } +#ifdef WNT // ----------------------------------------------------------------------------- OGenericUnoController::OGenericUnoController() :OGenericUnoController_Base( getMutex() ) @@ -302,6 +303,7 @@ OGenericUnoController::OGenericUnoController() // we simply abort here. abort(); } +#endif // ----------------------------------------------------------------------------- OGenericUnoController::~OGenericUnoController() @@ -453,7 +455,7 @@ void OGenericUnoController::disposing(const EventObject& Source) throw( RuntimeE //------------------------------------------------------------------------ void OGenericUnoController::modified(const EventObject& aEvent) throw( RuntimeException ) { - ::osl::MutexGuard aGuard( getMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); if ( !isDataSourceReadOnly() ) { Reference<XModifiable> xModi(aEvent.Source,UNO_QUERY); @@ -481,7 +483,7 @@ Reference< XWindow > SAL_CALL OGenericUnoController::getComponentWindow() throw void OGenericUnoController::attachFrame( const Reference< XFrame >& _rxFrame ) throw( RuntimeException ) { vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard( getMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); stopFrameListening( m_aCurrentFrame.getFrame() ); Reference< XFrame > xFrame = m_aCurrentFrame.attachFrame( _rxFrame ); @@ -730,7 +732,7 @@ void OGenericUnoController::InvalidateAll_Impl() { // --------------------------------- // invalidate all aupported features - + for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin(); aIter != m_aSupportedFeatures.end(); ++aIter @@ -923,7 +925,7 @@ void OGenericUnoController::disposing() Dispatch aStatusListener = m_arrStatusListener; Dispatch::iterator aEnd = aStatusListener.end(); for (Dispatch::iterator aIter = aStatusListener.begin(); aIter != aEnd; ++aIter) - { + { aIter->xListener->disposing(aDisposeEvent); } m_arrStatusListener.clear(); @@ -1376,7 +1378,7 @@ void OGenericUnoController::openHelpAgent(rtl::OUString const& _suHelpStringURL } URL aURL; aURL.Complete = suURL; - + openHelpAgent( aURL ); } @@ -1439,10 +1441,10 @@ Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw() { Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY ); Reference< XController > xThis(static_cast< XController* >(this), UNO_QUERY_THROW); - + ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_xServiceFactory); m_xTitleHelper.set( static_cast< ::cppu::OWeakObject* >(pHelper), UNO_QUERY_THROW); - + pHelper->setOwner (xThis ); pHelper->connectWithUntitledNumbers (xUntitledProvider); } @@ -1471,7 +1473,7 @@ void SAL_CALL OGenericUnoController::setTitle(const ::rtl::OUString& sTitle) m_bExternalTitle = sal_True; impl_getTitleHelper_throw()->setTitle (sTitle); } - + //============================================================================= // XTitleChangeBroadcaster void SAL_CALL OGenericUnoController::addTitleChangeListener(const Reference< XTitleChangeListener >& xListener) @@ -1589,14 +1591,14 @@ bool OGenericUnoController::interceptUserInput( const NotifyEvent& _rEvent ) sal_Bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const { FeatureState aState = GetState( _nCommandId ); - + return aState.bChecked && (sal_Bool)*aState.bChecked; } // ----------------------------------------------------------------------------- sal_Bool OGenericUnoController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const { OSL_ENSURE( _rCompleteCommandURL.getLength(), "OGenericUnoController::isCommandEnabled: Empty command url!" ); - + sal_Bool bIsEnabled = sal_False; SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCompleteCommandURL ); if ( aIter != m_aSupportedFeatures.end() ) diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 832f90f98..37932621c 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -121,7 +121,7 @@ #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _SVX_ALGITEM_HXX //autogen @@ -137,19 +137,19 @@ #endif #ifndef _NUMUNO_HXX -#include <svtools/numuno.hxx> +#include <svl/numuno.hxx> #endif #ifndef _SFXITEMPOOL_HXX //autogen wg. SfxItemInfo -#include <svtools/itempool.hxx> +#include <svl/itempool.hxx> #endif #ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif #ifndef _SFXRNGITEM_HXX -#include <svtools/rngitem.hxx> +#include <svl/rngitem.hxx> #endif #ifndef _SV_WAITOBJ_HXX @@ -160,7 +160,7 @@ #endif #ifndef _ZFORLIST_HXX -#include <svtools/zforlist.hxx> +#include <svl/zforlist.hxx> #endif #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ #include <cppuhelper/queryinterface.hxx> @@ -985,13 +985,13 @@ void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu) rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, aNewItems.GetHelpId(ID_BROWSER_ROWHEIGHT)); rMenu.InsertSeparator(nPos++); } // if (!IsReadOnlyDB()) -
- if ( GetSelectRowCount() > 0 )
- {
- rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++);
- rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY));
-
- rMenu.InsertSeparator(nPos++);
+ + if ( GetSelectRowCount() > 0 ) + { + rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++); + rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY)); + + rMenu.InsertSeparator(nPos++); } } @@ -1428,20 +1428,20 @@ void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos) } // ----------------------------------------------------------------------- -void SbaGridControl::CopySelectedRowsToClipboard()
-{
- DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" );
- implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true );
-}
-
-// -----------------------------------------------------------------------
-void SbaGridControl::DoRowDrag( sal_Int16 nRowPos )
-{
- implTransferSelectedRows( nRowPos, false );
-}
-
-// -----------------------------------------------------------------------
-void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag )
+void SbaGridControl::CopySelectedRowsToClipboard() +{ + DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" ); + implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true ); +} + +// ----------------------------------------------------------------------- +void SbaGridControl::DoRowDrag( sal_Int16 nRowPos ) +{ + implTransferSelectedRows( nRowPos, false ); +} + +// ----------------------------------------------------------------------- +void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag ) { Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY); DBG_ASSERT(xDataSource.is(), "SbaGridControl::implTransferSelectedRows : invalid data source !"); @@ -1478,8 +1478,8 @@ void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfC ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone, getServiceManager()); Reference< XTransferable > xEnsureDelete = pTransfer; - if ( _bTrueIfClipboardFalseIfDrag )
- pTransfer->CopyToClipboard( this );
+ if ( _bTrueIfClipboardFalseIfDrag ) + pTransfer->CopyToClipboard( this ); else pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK); } diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index f7046122b..5f5fca83f 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.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 @@ -77,6 +77,7 @@ #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdb/XBookmarksSupplier.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> #include <com/sun/star/sdb/XParametersSupplier.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> @@ -109,14 +110,15 @@ #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <connectivity/dbexception.hxx> +#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/implbase2.hxx> #include <cppuhelper/typeprovider.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> #include <sot/storage.hxx> -#include <svtools/filenotation.hxx> -#include <svtools/intitem.hxx> -#include <svtools/moduleoptions.hxx> +#include <svl/filenotation.hxx> +#include <svl/intitem.hxx> +#include <unotools/moduleoptions.hxx> #include <svtools/svlbitm.hxx> #include <svtools/svtreebx.hxx> #include <svx/algitem.hxx> @@ -197,25 +199,21 @@ void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, const :: //------------------------------------------------------------------------- ::rtl::OUString SAL_CALL SbaTableQueryBrowser::getImplementationName() throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImplementationName" ); return getImplementationName_Static(); } //------------------------------------------------------------------------- ::comphelper::StringSequence SAL_CALL SbaTableQueryBrowser::getSupportedServiceNames() throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getSupportedServiceNames" ); return getSupportedServiceNames_Static(); } // ------------------------------------------------------------------------- ::rtl::OUString SbaTableQueryBrowser::getImplementationName_Static() throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImplementationName_Static" ); return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ODatasourceBrowser"); } //------------------------------------------------------------------------- ::comphelper::StringSequence SbaTableQueryBrowser::getSupportedServiceNames_Static() throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getSupportedServiceNames_Static" ); ::comphelper::StringSequence aSupported(1); aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.DataSourceBrowser"); return aSupported; @@ -223,7 +221,6 @@ void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, const :: //------------------------------------------------------------------------- Reference< XInterface > SAL_CALL SbaTableQueryBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::Create" ); ::vos::OGuard aGuard(Application::GetSolarMutex()); return *(new SbaTableQueryBrowser(_rxFactory)); } @@ -246,7 +243,6 @@ SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory ,m_bInSuspend(sal_False) ,m_bEnableBrowser(sal_True) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::SbaTableQueryBrowser" ); DBG_CTOR(SbaTableQueryBrowser,NULL); } @@ -266,7 +262,6 @@ SbaTableQueryBrowser::~SbaTableQueryBrowser() //------------------------------------------------------------------------------ Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) throw (RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::queryInterface" ); if ( _rType.equals( XScriptInvocationContext::static_type() ) ) { OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::queryInterface: did not initialize this, yet!" ); @@ -284,7 +279,6 @@ Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) throw (Run //------------------------------------------------------------------------------ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getTypes" ); Sequence< Type > aTypes( ::comphelper::concatSequences( SbaXDataBrowserController::getTypes(), SbaTableQueryBrowser_Base::getTypes() @@ -308,7 +302,6 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) throw (RuntimeExcep //------------------------------------------------------------------------------ Sequence< sal_Int8 > SAL_CALL SbaTableQueryBrowser::getImplementationId( ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImplementationId" ); static ::cppu::OImplementationId * pId = 0; if (! pId) { @@ -325,7 +318,6 @@ Sequence< sal_Int8 > SAL_CALL SbaTableQueryBrowser::getImplementationId( ) thro //------------------------------------------------------------------------------ void SAL_CALL SbaTableQueryBrowser::disposing() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::disposing" ); ::vos::OGuard aGuard(Application::GetSolarMutex()); // doin' a lot of VCL stuff here -> lock the SolarMutex @@ -350,9 +342,15 @@ void SAL_CALL SbaTableQueryBrowser::disposing() implRemoveStatusListeners(); // remove the container listener from the database context - Reference< XContainer > xDatasourceContainer(m_xDatabaseContext, UNO_QUERY); - if (xDatasourceContainer.is()) - xDatasourceContainer->removeContainerListener(this); + try + { + Reference< XDatabaseRegistrations > xDatabaseRegistrations( m_xDatabaseContext, UNO_QUERY_THROW ); + xDatabaseRegistrations->removeDatabaseRegistrationsListener( this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // check out from all the objects we are listening // the frame @@ -364,23 +362,17 @@ void SAL_CALL SbaTableQueryBrowser::disposing() //------------------------------------------------------------------------------ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::Construct" ); - if (!SbaXDataBrowserController::Construct(pParent)) + if ( !SbaXDataBrowserController::Construct( pParent ) ) return sal_False; try { - Reference< XContainer > xDatasourceContainer(m_xDatabaseContext, UNO_QUERY); - if (xDatasourceContainer.is()) - xDatasourceContainer->addContainerListener(this); - else { - DBG_ERROR("SbaTableQueryBrowser::Construct: the DatabaseContext should allow us to be a listener!"); - } + Reference< XDatabaseRegistrations > xDatabaseRegistrations( m_xDatabaseContext, UNO_QUERY_THROW ); + xDatabaseRegistrations->addDatabaseRegistrationsListener( this ); // the collator for the string compares - m_xCollator = Reference< XCollator >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.Collator")), UNO_QUERY); - if (m_xCollator.is()) - m_xCollator->loadDefaultCollator(Application::GetSettings().GetLocale(), 0); + m_xCollator = Reference< XCollator >( getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ), UNO_QUERY_THROW ); + m_xCollator->loadDefaultCollator( Application::GetSettings().GetLocale(), 0 ); } catch(Exception&) { @@ -433,7 +425,6 @@ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent) // ------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::InitializeForm" ); if(!m_pCurrentlyDisplayed) return sal_True; @@ -490,7 +481,6 @@ sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star: //------------------------------------------------------------------------------ void SbaTableQueryBrowser::initializePreviewMode() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::initializePreviewMode" ); if ( getBrowserView() && getBrowserView()->getVclControl() ) { getBrowserView()->getVclControl()->AlwaysEnableInput( FALSE ); @@ -509,7 +499,6 @@ void SbaTableQueryBrowser::initializePreviewMode() //------------------------------------------------------------------------------ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & xGrid) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::InitializeGridModel" ); try { Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(xGrid, UNO_QUERY); @@ -633,6 +622,7 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: break; case DataType::LONGVARCHAR: + case DataType::CLOB: aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), makeAny( (sal_Bool)sal_True ) ) ); // NO break! case DataType::BINARY: @@ -750,7 +740,6 @@ Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const // ----------------------------------------------------------------------- void SbaTableQueryBrowser::transferChangedControlProperty(const ::rtl::OUString& _rProperty, const Any& _rNewValue) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::transferChangedControlProperty" ); if(m_pCurrentlyDisplayed) { DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); @@ -764,7 +753,6 @@ void SbaTableQueryBrowser::transferChangedControlProperty(const ::rtl::OUString& // ----------------------------------------------------------------------- void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::propertyChange" ); SbaXDataBrowserController::propertyChange(evt); try @@ -873,7 +861,6 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) throw( // ----------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::suspend" ); vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::MutexGuard aGuard( getMutex() ); if ( getView() && getView()->IsInModalMode() ) @@ -898,7 +885,6 @@ sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeExceptio // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEvent ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::statusChanged" ); // search the external dispatcher causing this call Reference< XDispatch > xSource(_rEvent.Source, UNO_QUERY); ExternalFeaturesMap::iterator aLoop; @@ -953,7 +939,6 @@ void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEv // ------------------------------------------------------------------------- void SbaTableQueryBrowser::checkDocumentDataSource() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::checkDocumentDataSource" ); SvLBoxEntry* pDataSourceEntry = NULL; SvLBoxEntry* pContainerEntry = NULL; SvLBoxEntry* pObjectEntry = getObjectEntry( m_aDocumentDataSource, &pDataSourceEntry, &pContainerEntry, sal_False ); @@ -991,7 +976,6 @@ void SbaTableQueryBrowser::checkDocumentDataSource() // ------------------------------------------------------------------------- void SbaTableQueryBrowser::extractDescriptorProps(const ::svx::ODataAccessDescriptor& _rDescriptor, ::rtl::OUString& _rDataSource, ::rtl::OUString& _rCommand, sal_Int32& _rCommandType, sal_Bool& _rEscapeProcessing) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::extractDescriptorProps" ); _rDataSource = _rDescriptor.getDataSource(); if ( _rDescriptor.has(daCommand) ) _rDescriptor[daCommand] >>= _rCommand; @@ -1043,7 +1027,6 @@ namespace // ------------------------------------------------------------------------- String SbaTableQueryBrowser::getDataSourceAcessor( SvLBoxEntry* _pDataSourceEntry ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getDataSourceAcessor" ); DBG_ASSERT( _pDataSourceEntry, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry!" ); DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pDataSourceEntry->GetUserData() ); @@ -1057,7 +1040,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS SvLBoxEntry** _ppDataSourceEntry, SvLBoxEntry** _ppContainerEntry, sal_Bool _bExpandAncestors, const SharedConnection& _rxConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getObjectEntry" ); if (_ppDataSourceEntry) *_ppDataSourceEntry = NULL; if (_ppContainerEntry) @@ -1080,9 +1062,7 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS { // special case, the data source is a URL // add new entries to the list box model - Image a, b, c; // not interested in reusing them - String e, f; - implAddDatasource( _rDataSource, a, e, b, f, c, _rxConnection ); + implAddDatasource( _rDataSource, _rxConnection ); pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, NULL, &aFilter ); DBG_ASSERT( pDataSource, "SbaTableQueryBrowser::getObjectEntry: hmm - did not find it again!" ); } @@ -1132,7 +1112,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::svx::ODataAccessDescri SvLBoxEntry** _ppDataSourceEntry, SvLBoxEntry** _ppContainerEntry, sal_Bool _bExpandAncestors) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getObjectEntry" ); // extract the props from the descriptor ::rtl::OUString sDataSource; ::rtl::OUString sCommand; @@ -1146,7 +1125,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::svx::ODataAccessDescri // ------------------------------------------------------------------------- void SbaTableQueryBrowser::connectExternalDispatches() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::connectExternalDispatches" ); Reference< XDispatchProvider > xProvider( getFrame(), UNO_QUERY ); DBG_ASSERT(xProvider.is(), "SbaTableQueryBrowser::connectExternalDispatches: no DispatchProvider !"); if (xProvider.is()) @@ -1213,7 +1191,6 @@ void SbaTableQueryBrowser::connectExternalDispatches() // ------------------------------------------------------------------------- void SbaTableQueryBrowser::implCheckExternalSlot( sal_uInt16 _nId ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implCheckExternalSlot" ); if ( !m_xMainToolbar.is() ) return; @@ -1236,7 +1213,6 @@ void SbaTableQueryBrowser::implCheckExternalSlot( sal_uInt16 _nId ) // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::disposing( const EventObject& _rSource ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::disposing" ); // our frame ? Reference< ::com::sun::star::frame::XFrame > xSourceFrame(_rSource.Source, UNO_QUERY); if (m_xCurrentFrameParent.is() && (xSourceFrame == m_xCurrentFrameParent)) @@ -1299,7 +1275,6 @@ void SAL_CALL SbaTableQueryBrowser::disposing( const EventObject& _rSource ) thr // ------------------------------------------------------------------------- void SbaTableQueryBrowser::implRemoveStatusListeners() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implRemoveStatusListeners" ); // clear all old dispatches for ( ExternalFeaturesMap::const_iterator aLoop = m_aExternalFeatures.begin(); aLoop != m_aExternalFeatures.end(); @@ -1324,7 +1299,6 @@ void SbaTableQueryBrowser::implRemoveStatusListeners() // ------------------------------------------------------------------------- sal_Bool SAL_CALL SbaTableQueryBrowser::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::select" ); ::vos::OGuard aGuard(Application::GetSolarMutex()); // doin' a lot of VCL stuff here -> lock the SolarMutex @@ -1354,7 +1328,6 @@ sal_Bool SAL_CALL SbaTableQueryBrowser::select( const Any& _rSelection ) throw ( // ------------------------------------------------------------------------- Any SAL_CALL SbaTableQueryBrowser::getSelection( ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getSelection" ); Any aReturn; try @@ -1382,21 +1355,18 @@ Any SAL_CALL SbaTableQueryBrowser::getSelection( ) throw (RuntimeException) // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::addSelectionChangeListener" ); m_aSelectionListeners.addInterface(_rxListener); } // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::removeSelectionChangeListener" ); m_aSelectionListeners.removeInterface(_rxListener); } // ------------------------------------------------------------------------- void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & _xFrame) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::attachFrame" ); implRemoveStatusListeners(); if (m_xCurrentFrameParent.is()) @@ -1410,7 +1380,7 @@ void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame: m_xCurrentFrameParent = xCurrentFrame->findFrame(::rtl::OUString::createFromAscii("_parent"),FrameSearchFlag::PARENT); if ( m_xCurrentFrameParent.is() ) m_xCurrentFrameParent->addFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this); - + // obtain our toolbox try { @@ -1441,7 +1411,6 @@ void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame: // ------------------------------------------------------------------------- void SbaTableQueryBrowser::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::addModelListeners" ); SbaXDataBrowserController::addModelListeners(_xGridControlModel); Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY); if (xSourceSet.is()) @@ -1459,7 +1428,6 @@ void SbaTableQueryBrowser::addModelListeners(const Reference< ::com::sun::star:: // ------------------------------------------------------------------------- void SbaTableQueryBrowser::removeModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::removeModelListeners" ); SbaXDataBrowserController::removeModelListeners(_xGridControlModel); Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY); if (xSourceSet.is()) @@ -1475,7 +1443,6 @@ void SbaTableQueryBrowser::removeModelListeners(const Reference< ::com::sun::sta // ------------------------------------------------------------------------- void SbaTableQueryBrowser::RowChanged() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::RowChanged" ); if(getBrowserView()) { SbaGridControl* pControl = getBrowserView()->getVclControl(); @@ -1488,7 +1455,6 @@ void SbaTableQueryBrowser::RowChanged() // ------------------------------------------------------------------------- void SbaTableQueryBrowser::ColumnChanged() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ColumnChanged" ); if(getBrowserView()) { SbaGridControl* pControl = getBrowserView()->getVclControl(); @@ -1500,7 +1466,6 @@ void SbaTableQueryBrowser::ColumnChanged() //------------------------------------------------------------------------------ void SbaTableQueryBrowser::AddColumnListener(const Reference< XPropertySet > & xCol) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::AddColumnListener" ); SbaXDataBrowserController::AddColumnListener(xCol); SafeAddPropertyListener(xCol, PROPERTY_WIDTH, static_cast<XPropertyChangeListener*>(this)); SafeAddPropertyListener(xCol, PROPERTY_HIDDEN, static_cast<XPropertyChangeListener*>(this)); @@ -1511,7 +1476,6 @@ void SbaTableQueryBrowser::AddColumnListener(const Reference< XPropertySet > & x //------------------------------------------------------------------------------ void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet > & xCol) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::RemoveColumnListener" ); SbaXDataBrowserController::RemoveColumnListener(xCol); SafeRemovePropertyListener(xCol, PROPERTY_WIDTH, static_cast<XPropertyChangeListener*>(this)); SafeRemovePropertyListener(xCol, PROPERTY_HIDDEN, static_cast<XPropertyChangeListener*>(this)); @@ -1522,7 +1486,6 @@ void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet > //------------------------------------------------------------------------------ void SbaTableQueryBrowser::criticalFail() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::criticalFail" ); SbaXDataBrowserController::criticalFail(); unloadAndCleanup( sal_False ); } @@ -1530,7 +1493,6 @@ void SbaTableQueryBrowser::criticalFail() //------------------------------------------------------------------------------ void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::LoadFinished" ); SbaXDataBrowserController::LoadFinished(_bWasSynch); m_sQueryCommand = ::rtl::OUString(); @@ -1552,7 +1514,6 @@ void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch) //------------------------------------------------------------------------------ sal_Bool SbaTableQueryBrowser::getExternalSlotState( sal_uInt16 _nId ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getExternalSlotState" ); sal_Bool bEnabled = sal_False; ExternalFeaturesMap::const_iterator aPos = m_aExternalFeatures.find( _nId ); if ( ( m_aExternalFeatures.end() != aPos ) && aPos->second.xDispatcher.is() ) @@ -1563,7 +1524,6 @@ sal_Bool SbaTableQueryBrowser::getExternalSlotState( sal_uInt16 _nId ) const //------------------------------------------------------------------------------ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::GetState" ); FeatureState aReturn; // (disabled automatically) @@ -1744,7 +1704,7 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const aReturn.bEnabled = m_aCurrentFrame.isActive(); break; } // if ( getBrowserView()->getVclControl()->GetSelectRowCount() ) - else + else aReturn.bEnabled = pControl->canCopyCellText(pControl->GetCurRow(), pControl->GetCurColumnId()); break; } @@ -1765,7 +1725,6 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const //------------------------------------------------------------------------------ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue >& aArgs) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::Execute" ); switch (nId) { default: @@ -1951,12 +1910,20 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue break; } } + +// ------------------------------------------------------------------------- +void SbaTableQueryBrowser::implAddDatasource( const String& _rDataSourceName, const SharedConnection& _rxConnection ) +{ + Image a, b, c; + String d, e; + implAddDatasource( _rDataSourceName, a, d, b, e, c, _rxConnection ); +} + // ------------------------------------------------------------------------- void SbaTableQueryBrowser::implAddDatasource(const String& _rDbName, Image& _rDbImage, String& _rQueryName, Image& _rQueryImage, String& _rTableName, Image& _rTableImage, const SharedConnection& _rxConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implAddDatasource" ); vos::OGuard aGuard( Application::GetSolarMutex() ); // initialize the names/images if necessary if (!_rQueryName.Len()) @@ -2010,7 +1977,6 @@ void SbaTableQueryBrowser::implAddDatasource(const String& _rDbName, Image& _rDb // ------------------------------------------------------------------------- void SbaTableQueryBrowser::initializeTreeModel() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::initializeTreeModel" ); if (m_xDatabaseContext.is()) { Image aDBImage, aQueriesImage, aTablesImage; @@ -2029,7 +1995,6 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName SvLBoxEntry* _pParent, EntryType _eEntryType) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::populateTree" ); DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pParent->GetUserData()); if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables pData->xContainer = _xNameAccess; @@ -2060,7 +2025,6 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName //------------------------------------------------------------------------------ void SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implAppendEntry" ); ::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( _pParent ) ); Image aImage, aImageHC; @@ -2077,7 +2041,6 @@ void SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& //------------------------------------------------------------------------------ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::OnExpandEntry" ); if (_pParent->HasChilds()) // nothing to to ... return 1L; @@ -2180,7 +2143,6 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent) //------------------------------------------------------------------------------ sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ensureEntryObject" ); DBG_ASSERT(_pEntry, "SbaTableQueryBrowser::ensureEntryObject: invalid argument!"); if (!_pEntry) return sal_False; @@ -2240,7 +2202,6 @@ sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry ) //------------------------------------------------------------------------------ sal_Bool SbaTableQueryBrowser::implSelect(const ::svx::ODataAccessDescriptor& _rDescriptor,sal_Bool _bSelectDirect) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implSelect(_rDescriptor,_bSelectDirect)" ); // extract the props ::rtl::OUString sDataSource; ::rtl::OUString sCommand; @@ -2256,7 +2217,6 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::svx::ODataAccessDescriptor& _r sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rCommand, const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing, const SharedConnection& _rxConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implLoadAnything" ); Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY); if(xProp.is()) { @@ -2274,8 +2234,6 @@ sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSou xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, ::cppu::bool2any(_bEscapeProcessing)); if ( m_bPreview ) { - // this be undone by the grid control in DbGridControl::RecalcRows - // xProp->setPropertyValue(PROPERTY_FETCHSIZE, makeAny(sal_Int32(20))); xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, makeAny(FetchDirection::FORWARD)); } @@ -2310,21 +2268,24 @@ sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSou InvalidateAll(); return bSuccess; } - catch(SQLException& e) + catch( const SQLException& e ) { - showError(SQLExceptionInfo(e)); + Any aException( ::cppu::getCaughtException() ); + showError( SQLExceptionInfo( aException ) ); } - catch(WrappedTargetException& e) + catch( const WrappedTargetException& e ) { SQLException aSql; - if(e.TargetException >>= aSql) - showError(SQLExceptionInfo(aSql)); + if ( e.TargetException.isExtractableTo( ::cppu::UnoType< SQLException >::get() ) ) + showError( SQLExceptionInfo( e.TargetException ) ); else - OSL_ENSURE(sal_False, "SbaTableQueryBrowser::implLoadAnything: something strange happended!"); + { + DBG_UNHANDLED_EXCEPTION(); + } } catch(Exception&) { - OSL_ENSURE(sal_False, "SbaTableQueryBrowser::implLoadAnything: something strange happended!"); + DBG_UNHANDLED_EXCEPTION(); } } @@ -2338,7 +2299,6 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::rtl::OUString& _rDataSourceNam const SharedConnection& _rxConnection ,sal_Bool _bSelectDirect) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implSelect(_rDataSourceName,_rCommand,...)" ); if (_rDataSourceName.getLength() && _rCommand.getLength() && (-1 != _nCommandType)) { SvLBoxEntry* pDataSource = NULL; @@ -2387,7 +2347,6 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectionChange, void*, /*NOINTERESTEDIN*/) //------------------------------------------------------------------------------ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implSelect(_pEntry)" ); if ( !_pEntry ) return false; @@ -2581,7 +2540,6 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) // ----------------------------------------------------------------------------- SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& _rxNameAccess) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getEntryFromContainer" ); DBTreeListBox& rListBox = m_pTreeView->getListBox(); SvLBoxEntry* pContainer = NULL; SvLBoxEntry* pDSLoop = rListBox.FirstChild(NULL); @@ -2606,7 +2564,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAc // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::elementInserted" ); vos::OGuard aSolarGuard( Application::GetSolarMutex() ); Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY); @@ -2638,24 +2595,12 @@ void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEve } implAppendEntry( pEntry, ::comphelper::getString( _rEvent.Accessor ), pNewData, pNewData->eType ); } - else if (xNames.get() == m_xDatabaseContext.get()) - { // a new datasource has been added to the context - // the name of the new ds - ::rtl::OUString sNewDS; - _rEvent.Accessor >>= sNewDS; - - // add new entries to the list box model - Image a, b, c; // not interested in reusing them - String e, f; - implAddDatasource( sNewDS, a, e, b, f, c, SharedConnection() ); - } else SbaXDataBrowserController::elementInserted(_rEvent); } // ------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const String& _sName,SvLBoxEntry* _pContainer) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::isCurrentlyDisplayedChanged" ); return m_pCurrentlyDisplayed && getEntryType(m_pCurrentlyDisplayed) == getChildType(_pContainer) && m_pTreeView->getListBox().GetParent(m_pCurrentlyDisplayed) == _pContainer @@ -2664,7 +2609,6 @@ sal_Bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const String& _sName, // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::elementRemoved" ); ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY); @@ -2711,62 +2655,6 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven // maybe the object which is part of the document data source has been removed checkDocumentDataSource(); } - else if (xNames.get() == m_xDatabaseContext.get()) - { // a datasource has been removed from the context - - // the name - ::rtl::OUString sNewDS; - _rEvent.Accessor >>= sNewDS; - String sNewDatasource = sNewDS; - - // get the top-level representing the removed data source - SvLBoxEntry* pDSLoop = m_pTreeView->getListBox().FirstChild(NULL); - while (pDSLoop) - { - if (m_pTreeView->getListBox().GetEntryText(pDSLoop) == sNewDatasource) - break; - - pDSLoop = m_pTreeView->getListBox().NextSibling(pDSLoop); - } - - if (pDSLoop) - { - if (isSelected(pDSLoop)) - { // a table or query belonging to the deleted data source is currently beeing displayed. - OSL_ENSURE(m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) == pDSLoop, "SbaTableQueryBrowser::elementRemoved: inconsistence (1)!"); - unloadAndCleanup( sal_True ); - } - else - OSL_ENSURE( - (NULL == m_pCurrentlyDisplayed) - || (m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) != pDSLoop), "SbaTableQueryBrowser::elementRemoved: inconsistence (2)!"); - - // look for user data to delete - SvTreeEntryList* pList = m_pTreeModel->GetChildList(pDSLoop); - if(pList) - { - SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>(pList->First()); - while (pEntryLoop) - { - DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData()); - pEntryLoop->SetUserData(NULL); - delete pData; - pEntryLoop = static_cast<SvLBoxEntry*>(pList->Next()); - } - } - // remove the entry. This should remove all children, too. - DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pDSLoop->GetUserData()); - pDSLoop->SetUserData(NULL); - delete pData; - m_pTreeModel->Remove(pDSLoop); - } - else { - DBG_ERROR("SbaTableQueryBrowser::elementRemoved: unknown datasource name!"); - } - - // maybe the object which is part of the document data source has been removed - checkDocumentDataSource(); - } else SbaXDataBrowserController::elementRemoved(_rEvent); } @@ -2774,7 +2662,6 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::elementReplaced" ); ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY); @@ -2847,7 +2734,6 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve // ------------------------------------------------------------------------- void SbaTableQueryBrowser::impl_releaseConnection( SharedConnection& _rxConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::impl_releaseConnection" ); // remove as event listener Reference< XComponent > xComponent( _rxConnection, UNO_QUERY ); if ( xComponent.is() ) @@ -2876,7 +2762,6 @@ void SbaTableQueryBrowser::impl_releaseConnection( SharedConnection& _rxConnecti // ------------------------------------------------------------------------- void SbaTableQueryBrowser::disposeConnection( SvLBoxEntry* _pDSEntry ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::disposeConnection" ); DBG_ASSERT( _pDSEntry, "SbaTableQueryBrowser::disposeConnection: invalid entry (NULL)!" ); DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::disposeConnection: invalid entry (not top-level)!" ); @@ -2891,7 +2776,6 @@ void SbaTableQueryBrowser::disposeConnection( SvLBoxEntry* _pDSEntry ) // ------------------------------------------------------------------------- void SbaTableQueryBrowser::closeConnection(SvLBoxEntry* _pDSEntry,sal_Bool _bDisposeConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::closeConnection" ); DBG_ASSERT(_pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (NULL)!"); DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!"); @@ -2928,7 +2812,6 @@ void SbaTableQueryBrowser::closeConnection(SvLBoxEntry* _pDSEntry,sal_Bool _bDis // ------------------------------------------------------------------------- void SbaTableQueryBrowser::unloadAndCleanup( sal_Bool _bDisposeConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::unloadAndCleanup" ); if (!m_pCurrentlyDisplayed) // nothing to do return; @@ -3016,7 +2899,6 @@ namespace // ------------------------------------------------------------------------- void SbaTableQueryBrowser::impl_initialize() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::impl_initialize" ); ::vos::OGuard aGuard(Application::GetSolarMutex()); // doin' a lot of VCL stuff here -> lock the SolarMutex @@ -3150,12 +3032,7 @@ void SbaTableQueryBrowser::impl_initialize() } } - Image aDBImage, aQueriesImage, aTablesImage; - String sQueriesName, sTablesName; - - implAddDatasource( sInitialDataSourceName, - aDBImage, sQueriesName, aQueriesImage, sTablesName, aTablesImage, xConnection - ); + implAddDatasource( sInitialDataSourceName, xConnection ); m_pTreeView->getListBox().Expand( m_pTreeView->getListBox().First() ); } else @@ -3196,14 +3073,12 @@ void SbaTableQueryBrowser::impl_initialize() // ------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::haveExplorer() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::haveExplorer" ); return m_pTreeView && m_pTreeView->IsVisible(); } // ------------------------------------------------------------------------- void SbaTableQueryBrowser::hideExplorer() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::hideExplorer" ); if (!haveExplorer()) return; if (!getBrowserView()) @@ -3219,7 +3094,6 @@ void SbaTableQueryBrowser::hideExplorer() // ------------------------------------------------------------------------- void SbaTableQueryBrowser::showExplorer() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::showExplorer" ); if (haveExplorer()) return; @@ -3236,7 +3110,6 @@ void SbaTableQueryBrowser::showExplorer() // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ensureConnection" ); SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(_pAnyEntry); DBTreeListUserData* pDSData = pDSEntry @@ -3249,7 +3122,6 @@ sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedC // ----------------------------------------------------------------------------- ::std::auto_ptr< ImageProvider > SbaTableQueryBrowser::getImageProviderFor( SvLBoxEntry* _pAnyEntry ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImageProviderFor" ); ::std::auto_ptr< ImageProvider > pImageProvider( new ImageProvider ); SharedConnection xConnection; if ( getExistentConnectionFor( _pAnyEntry, xConnection ) ) @@ -3260,7 +3132,6 @@ sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedC // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::getExistentConnectionFor( SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getExistentConnectionFor" ); SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent( _pAnyEntry ); DBTreeListUserData* pDSData = pDSEntry @@ -3275,7 +3146,6 @@ sal_Bool SbaTableQueryBrowser::getExistentConnectionFor( SvLBoxEntry* _pAnyEntry // ----------------------------------------------------------------------------- bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::impl_isDataSourceEntry" ); return m_pTreeModel->GetRootLevelParent( _pEntry ) == _pEntry; } #endif @@ -3283,7 +3153,6 @@ bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::ensureConnection( SvLBoxEntry* _pDSEntry, void* pDSData, SharedConnection& _rConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ensureConnection" ); DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::ensureConnection: this entry does not denote a data source!" ); if(_pDSEntry) { @@ -3386,7 +3255,6 @@ IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData*, _pSortDa // ----------------------------------------------------------------------------- void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implAdministrate" ); OSL_PRECOND( _pApplyTo, "SbaTableQueryBrowser::implAdministrate: illegal entry!" ); if ( !_pApplyTo ) return; @@ -3444,7 +3312,6 @@ void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo ) // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::requestQuickHelp" ); const DBTreeListUserData* pData = static_cast< const DBTreeListUserData* >( _pEntry->GetUserData() ); if ( ( pData->eType == etDatasource ) && pData->sAccessor.Len() ) { @@ -3457,7 +3324,6 @@ sal_Bool SbaTableQueryBrowser::requestQuickHelp( const SvLBoxEntry* _pEntry, Str // ----------------------------------------------------------------------------- PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getContextMenu" ); OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl, "SbaTableQueryBrowser::getContextMenu: where does this come from?" ); if ( &m_pTreeView->getListBox() != &_rControl ) @@ -3469,21 +3335,18 @@ PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const // ----------------------------------------------------------------------------- IController& SbaTableQueryBrowser::getCommandController() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getCommandController" ); return *this; } // ----------------------------------------------------------------------------- ::cppu::OInterfaceContainerHelper* SbaTableQueryBrowser::getContextMenuInterceptors() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getContextMenuInterceptors" ); return &m_aContextMenuInterceptors; } // ----------------------------------------------------------------------------- Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getCurrentSelection" ); OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl, "SbaTableQueryBrowser::getCurrentSelection: where does this come from?" ); @@ -3525,7 +3388,6 @@ Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand, sal_Bool& _bEscapeProcessing ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implGetQuerySignature" ); _rCommand = ::rtl::OUString(); _bEscapeProcessing = sal_False; @@ -3574,7 +3436,6 @@ sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand //------------------------------------------------------------------------------ void SbaTableQueryBrowser::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::frameAction" ); if (aEvent.Frame == m_xCurrentFrameParent) { if(aEvent.Action == FrameAction_COMPONENT_DETACHING) @@ -3589,7 +3450,6 @@ void SbaTableQueryBrowser::frameAction(const ::com::sun::star::frame::FrameActio // ----------------------------------------------------------------------------- void SbaTableQueryBrowser::clearGridColumns(const Reference< XNameContainer >& _xColContainer) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::clearGridColumns" ); // first we have to clear the grid Sequence< ::rtl::OUString > aNames = _xColContainer->getElementNames(); const ::rtl::OUString* pIter = aNames.getConstArray(); @@ -3605,7 +3465,6 @@ void SbaTableQueryBrowser::clearGridColumns(const Reference< XNameContainer >& _ // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::isHiContrast() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::isHiContrast" ); sal_Bool bRet = sal_False; if ( m_pTreeView ) bRet = m_pTreeView->getListBox().GetSettings().GetStyleSettings().GetHighContrastMode(); @@ -3614,7 +3473,6 @@ sal_Bool SbaTableQueryBrowser::isHiContrast() const // ----------------------------------------------------------------------------- void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::loadMenu" ); if ( m_bShowMenu ) { OGenericUnoController::loadMenu(_xFrame); @@ -3636,7 +3494,6 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame) // ----------------------------------------------------------------------------- ::rtl::OUString SbaTableQueryBrowser::getPrivateTitle() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getPrivateTitle" ); ::rtl::OUString sTitle; if ( m_pCurrentlyDisplayed ) { @@ -3661,7 +3518,6 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame) // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::preReloadForm() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::preReloadForm" ); sal_Bool bIni = sal_False; if ( !m_pCurrentlyDisplayed ) { @@ -3690,7 +3546,6 @@ sal_Bool SbaTableQueryBrowser::preReloadForm() // ----------------------------------------------------------------------------- void SbaTableQueryBrowser::postReloadForm() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::postReloadForm" ); InitializeGridModel(getFormComponent()); LoadFinished(sal_True); //updateTitle(); @@ -3699,7 +3554,6 @@ void SbaTableQueryBrowser::postReloadForm() //------------------------------------------------------------------------------ Reference< XEmbeddedScripts > SAL_CALL SbaTableQueryBrowser::getScriptContainer() throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getScriptContainer" ); // update our database document Reference< XModel > xDocument; try @@ -3726,7 +3580,6 @@ Reference< XEmbeddedScripts > SAL_CALL SbaTableQueryBrowser::getScriptContainer( //------------------------------------------------------------------------------ void SAL_CALL SbaTableQueryBrowser::registerContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::registerContextMenuInterceptor" ); if ( _Interceptor.is() ) m_aContextMenuInterceptors.addInterface( _Interceptor ); } @@ -3734,10 +3587,90 @@ void SAL_CALL SbaTableQueryBrowser::registerContextMenuInterceptor( const Refere //------------------------------------------------------------------------------ void SAL_CALL SbaTableQueryBrowser::releaseContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::releaseContextMenuInterceptor" ); - m_aContextMenuInterceptors.removeInterface( _Interceptor ); + if ( _Interceptor.is() ) + m_aContextMenuInterceptors.removeInterface( _Interceptor ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL SbaTableQueryBrowser::registeredDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + implAddDatasource( _Event.Name, SharedConnection() ); +} + +//------------------------------------------------------------------------------ +void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const String& _rDataSourceName ) +{ + // get the top-level representing the removed data source + SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().FirstChild( NULL ); + while ( pDataSourceEntry ) + { + if ( m_pTreeView->getListBox().GetEntryText( pDataSourceEntry ) == _rDataSourceName ) + break; + + pDataSourceEntry = m_pTreeView->getListBox().NextSibling( pDataSourceEntry ); + } + + OSL_ENSURE( pDataSourceEntry, "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: do not know this data source!" ); + if ( !pDataSourceEntry ) + return; + + if ( isSelected( pDataSourceEntry ) ) + { // a table or query belonging to the deleted data source is currently beeing displayed. + OSL_ENSURE( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) == pDataSourceEntry, + "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (1)!" ); + unloadAndCleanup( sal_True ); + } + else + OSL_ENSURE( + ( NULL == m_pCurrentlyDisplayed ) + || ( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) != pDataSourceEntry ), + "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (2)!"); + + // delete any user data of the child entries of the to-be-removed entry + SvTreeEntryList* pList = m_pTreeModel->GetChildList( pDataSourceEntry ); + if ( pList ) + { + SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>( pList->First() ); + while ( pEntryLoop ) + { + DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pEntryLoop->GetUserData() ); + pEntryLoop->SetUserData( NULL ); + delete pData; + pEntryLoop = static_cast< SvLBoxEntry* >( pList->Next() ); + } + } + + // remove the entry + DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() ); + pDataSourceEntry->SetUserData( NULL ); + delete pData; + m_pTreeModel->Remove( pDataSourceEntry ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL SbaTableQueryBrowser::revokedDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + impl_cleanupDataSourceEntry( _Event.Name ); + + // maybe the object which is part of the document data source has been removed + checkDocumentDataSource(); } +//------------------------------------------------------------------------------ +void SAL_CALL SbaTableQueryBrowser::changedDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + // in case the data source was expanded, and connected, we need to clean it up + // for simplicity, just do as if the data source were completely removed and re-added + impl_cleanupDataSourceEntry( _Event.Name ); + implAddDatasource( _Event.Name, SharedConnection() ); +} + + // ......................................................................... } // namespace dbaui // ......................................................................... diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx index 05f541ca8..c1c640b7e 100644 --- a/dbaccess/source/ui/control/ColumnControlWindow.cxx +++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx @@ -37,7 +37,7 @@ #include "FieldControls.hxx" #endif #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #endif #ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index cdad2f612..9504628af 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -53,12 +53,12 @@ #include <svx/numfmtsh.hxx> #include <svx/svxids.hrc> #include <svx/algitem.hxx> -#include <svtools/itempool.hxx> -#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svtools/zforlist.hxx> -#include <svtools/zforlist.hxx> -#include <svtools/rngitem.hxx> -#include <svtools/intitem.hxx> -#include <svtools/numuno.hxx> +#include <svl/itempool.hxx> +#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svl/zforlist.hxx> +#include <svl/zforlist.hxx> +#include <svl/rngitem.hxx> +#include <svl/intitem.hxx> +#include <svl/numuno.hxx> #include <svtools/transfer.hxx> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/util/NumberFormat.hpp> @@ -1375,6 +1375,14 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) ActivateAggregate( tpFormat ); break; case DataType::BIT: + if ( pFieldType->aCreateParams.getLength() ) + { + DeactivateAggregate( tpFormat ); + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpBoolDefault ); + break; + } + // run through case DataType::BOOLEAN: DeactivateAggregate( tpTextLen ); DeactivateAggregate( tpFormat ); @@ -1473,7 +1481,9 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) if( pBoolDefault ) { // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen - String sDef = BoolStringUI(::comphelper::getString(pFieldDescr->GetControlDefault())); + ::rtl::OUString sValue; + pFieldDescr->GetControlDefault() >>= sValue; + String sDef = BoolStringUI(sValue); // sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() ) @@ -1667,8 +1677,7 @@ void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) ::rtl::OUString sDefault; if (pDefault) { - if ( pDefault->GetSavedValue() != pDefault->GetText() ) - sDefault = pDefault->GetText(); + sDefault = pDefault->GetText(); } else if (pBoolDefault) { diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx index 3b1feb4e0..07f6e7679 100644 --- a/dbaccess/source/ui/control/charsetlistbox.cxx +++ b/dbaccess/source/ui/control/charsetlistbox.cxx @@ -36,8 +36,8 @@ /** === begin UNO includes === **/ /** === end UNO includes === **/ -#include <svtools/itemset.hxx> -#include <svtools/stritem.hxx> +#include <svl/itemset.hxx> +#include <svl/stritem.hxx> //........................................................................ namespace dbaui diff --git a/dbaccess/source/ui/control/listviewitems.cxx b/dbaccess/source/ui/control/listviewitems.cxx index 9541f8779..6c42d8b52 100644 --- a/dbaccess/source/ui/control/listviewitems.cxx +++ b/dbaccess/source/ui/control/listviewitems.cxx @@ -45,7 +45,9 @@ namespace dbaui //------------------------------------------------------------------------ void OBoldListboxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* _pViewData) { - SvLBoxString::InitViewData(pView,pEntry, _pViewData); + SvLBoxString::InitViewData( pView, pEntry, _pViewData ); + if ( !m_bEmphasized ) + return; if (!_pViewData) _pViewData = pView->GetViewDataItem( pEntry, this ); pView->Push(PUSH_ALL); diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx index ef071b028..136f51ffd 100644 --- a/dbaccess/source/ui/control/opendoccontrols.cxx +++ b/dbaccess/source/ui/control/opendoccontrols.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 @@ -72,7 +72,7 @@ #include <vcl/help.hxx> #endif #ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX -#include <svtools/historyoptions.hxx> +#include <unotools/historyoptions.hxx> #endif #ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_ #include <comphelper/sequenceashashmap.hxx> @@ -81,7 +81,7 @@ #include <tools/urlobj.hxx> #endif #ifndef SVTOOLS_FILENOTATION_HXX -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif //........................................................................ @@ -190,7 +190,7 @@ namespace dbaui Sequence<Reference< XGraphic> > xIconList( xImageManager->getImages( 0, aCommandList ) ); if ( !xIconList.hasElements() ) break; - + aIcon = Graphic( xIconList[0] ).GetBitmapEx(); } while ( false ); @@ -210,13 +210,6 @@ namespace dbaui //= OpenButton //==================================================================== //-------------------------------------------------------------------- - OpenDocumentButton::OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, WinBits _nStyle ) - :PushButton( _pParent, _nStyle ) - { - impl_init( _pAsciiModuleName ); - } - - //-------------------------------------------------------------------- OpenDocumentButton::OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId ) :PushButton( _pParent, _rResId ) { @@ -247,13 +240,6 @@ namespace dbaui //= OpenDocumentListBox //==================================================================== //-------------------------------------------------------------------- - OpenDocumentListBox::OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, WinBits _nStyle ) - :ListBox( _pParent, _nStyle ) - { - impl_init( _pAsciiModuleName ); - } - - //-------------------------------------------------------------------- OpenDocumentListBox::OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId ) :ListBox( _pParent, _rResId ) { diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx index bca065c12..499dcacfe 100644 --- a/dbaccess/source/ui/control/sqledit.cxx +++ b/dbaccess/source/ui/control/sqledit.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 @@ -40,7 +40,7 @@ #include "undosqledit.hxx" #include "QueryDesignView.hxx" -#include <svtools/smplhint.hxx> +#include <svl/smplhint.hxx> ////////////////////////////////////////////////////////////////////////// // OSqlEdit @@ -67,8 +67,8 @@ OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) : ImplSetFont(); // listen for change of Font and Color Settings - StartListening(m_SourceViewConfig); - StartListening(m_ColorConfig); + m_SourceViewConfig.AddListener( this ); + m_ColorConfig.AddListener(this); //#i97044# EnableFocusSelectionHide( FALSE ); @@ -79,9 +79,9 @@ OSqlEdit::~OSqlEdit() { DBG_DTOR(OSqlEdit,NULL); if (m_timerUndoActionCreation.IsActive()) - m_timerUndoActionCreation.Stop(); - EndListening(m_SourceViewConfig); - EndListening(m_ColorConfig); + m_timerUndoActionCreation.Stop(); + m_SourceViewConfig.RemoveListener(this); + m_ColorConfig.RemoveListener(this); } //------------------------------------------------------------------------------ void OSqlEdit::KeyInput( const KeyEvent& rKEvt ) @@ -163,7 +163,7 @@ IMPL_LINK(OSqlEdit, ModifyHdl, void*, /*EMPTYTAG*/) m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_SBA_QRY_EXECUTE); m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_CUT); m_pView->getContainerWindow()->getDesignView()->getController().InvalidateFeature(SID_COPY); - + m_lnkTextModifyHdl.Call(NULL); return 0; } @@ -180,13 +180,13 @@ void OSqlEdit::SetText(const String& rNewText) MultiLineEditSyntaxHighlight::SetText(rNewText); m_strOrigText =rNewText; -} +} // ----------------------------------------------------------------------------- void OSqlEdit::stopTimer() { m_bStopTimer = sal_True; if (m_timerInvalidate.IsActive()) - m_timerInvalidate.Stop(); + m_timerInvalidate.Stop(); } // ----------------------------------------------------------------------------- void OSqlEdit::startTimer() @@ -196,11 +196,11 @@ void OSqlEdit::startTimer() m_timerInvalidate.Start(); } -void OSqlEdit::Notify( SfxBroadcaster& rBC, const SfxHint& /*rHint*/ ) +void OSqlEdit::ConfigurationChanged( utl::ConfigurationBroadcaster* pOption, sal_uInt32 ) { - if (&rBC == &m_SourceViewConfig) - ImplSetFont(); - else if (&rBC == &m_ColorConfig) + if ( pOption == &m_SourceViewConfig ) + ImplSetFont(); + else if ( pOption == &m_ColorConfig ) MultiLineEditSyntaxHighlight::UpdateData(); } diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx index a7e19d70c..dd5820fb4 100644 --- a/dbaccess/source/ui/control/toolboxcontroller.cxx +++ b/dbaccess/source/ui/control/toolboxcontroller.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 @@ -73,7 +73,7 @@ #include <svtools/miscopt.hxx> #endif #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #endif #ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> @@ -192,7 +192,7 @@ namespace dbaui break; } } - + // check if paste special is allowed, when not don't add DROPDOWN pToolBox->SetItemBits(m_nToolBoxId,pToolBox->GetItemBits(m_nToolBoxId) | TIB_DROPDOWN); } @@ -201,7 +201,7 @@ namespace dbaui void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard(m_aMutex); TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete ); if ( aFind != m_aStates.end() ) { @@ -242,7 +242,7 @@ namespace dbaui Reference<XUIConfigurationManager> xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument"))); Reference<XImageManager> xImageMgr(xUIConfigMgr->getImageManager(),UNO_QUERY); - + short nImageType = hasBigImages() ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT; if ( bHighContrast ) nImageType |= ImageType::COLOR_HIGHCONTRAST; @@ -257,7 +257,7 @@ namespace dbaui USHORT nItemId = pMenu->GetItemId(nPos); aSeq[0] = pMenu->GetItemCommand(nItemId); Sequence< Reference<XGraphic> > aImages = xImageMgr->getImages(nImageType,aSeq); - + Image aImage(aImages[0]); pMenu->SetItemImage(nItemId,aImage); TCommandState::iterator aFind = m_aStates.find( aSeq[0] ); @@ -283,7 +283,7 @@ namespace dbaui { // execute the menu vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard(m_aMutex); ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent())); ::std::auto_ptr<PopupMenu> pMenu = getMenu(); @@ -302,7 +302,7 @@ namespace dbaui Reference<XDispatch> xDispatch = m_aListenerMap.find(m_aCommandURL)->second; if ( xDispatch.is() ) - { + { URL aUrl; Sequence < PropertyValue > aArgs; aUrl.Complete = m_aCommandURL; @@ -310,7 +310,7 @@ namespace dbaui if ( getURLTransformer().is() ) getURLTransformer()->parseStrict(aUrl); xDispatch->dispatch(aUrl,aArgs); - + } } return Reference< ::com::sun::star::awt::XWindow >(); diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx index d1a713523..af88f4c5e 100644 --- a/dbaccess/source/ui/dlg/CollectionView.cxx +++ b/dbaccess/source/ui/dlg/CollectionView.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 @@ -106,9 +106,9 @@ #include <com/sun/star/awt/XWindow.hpp> #endif #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX -#include <svtools/viewoptions.hxx> +#include <unotools/viewoptions.hxx> #endif -#ifndef _OSL_THREAD_H_ +#ifndef _OSL_THREAD_H_ #include <osl/thread.h> #endif #ifndef _DBHELPER_DBEXCEPTION_HXX_ @@ -135,7 +135,7 @@ DBG_NAME(OCollectionView) OCollectionView::OCollectionView( Window * pParent ,const Reference< XContent>& _xContent ,const ::rtl::OUString& _sDefaultName - ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) + ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) : ModalDialog( pParent, ModuleRes(DLG_COLLECTION_VIEW)) , m_aFTCurrentPath( this, ModuleRes( FT_EXPLORERFILE_CURRENTPATH ) ) , m_aNewFolder( this, ModuleRes( BTN_EXPLORERFILE_NEWFOLDER ) ) @@ -152,7 +152,7 @@ OCollectionView::OCollectionView( Window * pParent , m_xORB(_xORB) , m_bCreateForm(sal_True) { - DBG_CTOR(OCollectionView,NULL); + DBG_CTOR(OCollectionView,NULL); FreeResource(); OSL_ENSURE(m_xContent.is(),"No valid content!"); @@ -178,7 +178,7 @@ OCollectionView::OCollectionView( Window * pParent // ----------------------------------------------------------------------------- OCollectionView::~OCollectionView( ) { - DBG_DTOR(OCollectionView,NULL); + DBG_DTOR(OCollectionView,NULL); } // ----------------------------------------------------------------------------- Reference< XContent> OCollectionView::getSelectedFolder() const @@ -205,7 +205,7 @@ IMPL_LINK( OCollectionView, Save_Click, PushButton*, EMPTYARG ) { xNameAccess.set(xChild->getParent(),UNO_QUERY); if ( xNameAccess.is() ) - { + { m_xContent.set(xNameAccess,UNO_QUERY); xChild.set(m_xContent,UNO_QUERY); } @@ -239,8 +239,8 @@ IMPL_LINK( OCollectionView, Save_Click, PushButton*, EMPTYARG ) ::com::sun::star::ucb::IOErrorCode eError = IOErrorCode_NOT_EXISTING_PATH; ::rtl::OUString sTemp; InteractiveAugmentedIOException aException(sTemp,Reference<XInterface>(),eClass,eError,aValues); - - + + Reference<XInitialization> xIni(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler"))),UNO_QUERY); if ( xIni.is() ) { @@ -255,10 +255,10 @@ IMPL_LINK( OCollectionView, Save_Click, PushButton*, EMPTYARG ) OInteractionApprove* pApprove = new OInteractionApprove; pRequest->addContinuation(pApprove); - Reference< XInteractionHandler > xHandler(xIni,UNO_QUERY); + Reference< XInteractionHandler > xHandler(xIni,UNO_QUERY); xHandler->handle(xRequest); } - return 0; + return 0; } } } @@ -375,7 +375,7 @@ void OCollectionView::initCurrentPath() sPath = sCID.copy(s_sFormsCID.getLength()); else if ( !m_bCreateForm && sCID.getLength() != s_sReportsCID.getLength() ) sPath = sCID.copy(s_sReportsCID.getLength()); - + m_aFTCurrentPath.SetText(sPath); Reference<XChild> xChild(m_xContent,UNO_QUERY); bEnable = xChild.is() && Reference<XNameAccess>(xChild->getParent(),UNO_QUERY).is(); diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index cdc8566f6..d7d3b5b15 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.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 @@ -44,26 +44,26 @@ #ifndef _DBU_MISC_HRC_ #include "dbu_misc.hrc" #endif -#ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> #endif #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #endif #ifndef _SFX_FCONTNR_HXX #include <sfx2/fcontnr.hxx> #endif -#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> #endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> #endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> #endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> #endif #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" @@ -74,13 +74,13 @@ #ifndef _DBAUI_LOCALRESACCESS_HXX_ #include "localresaccess.hxx" #endif -#ifndef _OSL_PROCESS_H_ +#ifndef _OSL_PROCESS_H_ #include <osl/process.h> #endif #ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> #endif -#ifndef _FILEDLGHELPER_HXX +#ifndef _FILEDLGHELPER_HXX #include <sfx2/filedlghelper.hxx> #endif #ifndef _DBAUI_DBADMIN_HXX_ @@ -89,7 +89,7 @@ #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> #endif -#ifndef _VCL_STDTEXT_HXX +#ifndef _VCL_STDTEXT_HXX #include <vcl/stdtext.hxx> #endif #ifndef _DBAUI_SQLMESSAGE_HXX_ @@ -102,12 +102,12 @@ #include "dsselect.hxx" #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" #endif -#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> #endif #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ @@ -126,10 +126,10 @@ #ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" #endif -#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX #include <unotools/localfilehelper.hxx> #endif -#ifndef _UNOTOOLS_UCBHELPER_HXX +#ifndef _UNOTOOLS_UCBHELPER_HXX #include <unotools/ucbhelper.hxx> #endif #ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX @@ -141,7 +141,7 @@ #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ #include <connectivity/CommonTools.hxx> #endif -#ifndef _URLOBJ_HXX +#ifndef _URLOBJ_HXX #include <tools/urlobj.hxx> #endif #ifndef TOOLS_DIAGNOSE_EX_H @@ -155,7 +155,7 @@ #endif #ifdef _ADO_DATALINK_BROWSE_ -#if defined( WNT ) +#if defined( WNT ) #include <tools/prewin.h> #include <windows.h> #include <tools/postwin.h> @@ -213,7 +213,7 @@ DBG_NAME(OConnectionHelper) OConnectionHelper::~OConnectionHelper() { - + DBG_DTOR(OConnectionHelper,NULL); } @@ -244,7 +244,7 @@ DBG_NAME(OConnectionHelper) m_aConnectionURL.ClearModifyFlag(); } - OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); } // ----------------------------------------------------------------------- @@ -331,7 +331,7 @@ DBG_NAME(OConnectionHelper) { const ::rtl::OUString sExt(RTL_CONSTASCII_USTRINGPARAM("*.mdb")); String sFilterName(ModuleRes (STR_MSACCESS_FILTERNAME)); - ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); + ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); aFileDlg.AddFilter(sFilterName,sExt); aFileDlg.SetCurrentFilter(sFilterName); askForFileName(aFileDlg); @@ -341,7 +341,7 @@ DBG_NAME(OConnectionHelper) { const ::rtl::OUString sAccdb(RTL_CONSTASCII_USTRINGPARAM("*.accdb")); String sFilterName2(ModuleRes (STR_MSACCESS_2007_FILTERNAME)); - ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); + ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); aFileDlg.AddFilter(sFilterName2,sAccdb); aFileDlg.SetCurrentFilter(sFilterName2); askForFileName(aFileDlg); @@ -367,7 +367,7 @@ DBG_NAME(OConnectionHelper) rtl_uString_release(pDbVar); pDbVar = NULL; } - + sEnvVarName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBCONFIG")); if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar) { @@ -389,7 +389,7 @@ DBG_NAME(OConnectionHelper) rtl_uString_release(pDbVar); pDbVar = NULL; } - + sal_Bool bOldFashion = sAdabasConfigDir.getLength() && sAdabasWorkDir.getLength(); if(!bOldFashion) // we have a normal adabas installation @@ -400,7 +400,7 @@ DBG_NAME(OConnectionHelper) if(sAdabasConfigDir.getLength() && sAdabasWorkDir.getLength() && sRootDir.getLength()) { - + aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir); if(!aInstalledDBs.size() && bOldFashion) @@ -471,12 +471,12 @@ DBG_NAME(OConnectionHelper) Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); OSL_ENSURE( xFactory.is(), "can't get service factory" ); - + Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) ); OSL_ENSURE( xInstance.is(), "failed to create instance" ); Reference<XMozillaBootstrap> xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY); OSL_ENSURE( xMozillaBootstrap.is(), "failed to create instance" ); - + if (xMozillaBootstrap.is()) { // collect all Mozilla Profiles @@ -484,7 +484,7 @@ DBG_NAME(OConnectionHelper) xMozillaBootstrap->getProfileList( profileType, list ); const ::rtl::OUString * pArray = list.getConstArray(); - + sal_Int32 count = list.getLength(); StringBag aProfiles; @@ -552,7 +552,7 @@ DBG_NAME(OConnectionHelper) if ( sFileURLEncoded.Len() ) { OFileNotation aFileNotation(sFileURLEncoded); - // set this decoded URL as text + // set this decoded URL as text sURL += String(aFileNotation.get(OFileNotation::N_SYSTEM)); } } @@ -801,7 +801,7 @@ DBG_NAME(OConnectionHelper) bExists = bIsFile? aCheckExistence.isDocument(): aCheckExistence.isFolder(); eExists = bExists? PATH_EXIST: PATH_NOT_EXIST; } - catch(const Exception&) + catch(const Exception&) { eExists = ( pHandler && pHandler->isDoesNotExist() ) ? PATH_NOT_EXIST: (bIsFile ? PATH_NOT_EXIST : PATH_NOT_KNOWN); } @@ -975,7 +975,7 @@ DBG_NAME(OConnectionHelper) setURLNoPrefix(sURL); m_aConnectionURL.SaveValueNoPrefix(); return sal_True; - } + } //------------------------------------------------------------------------- void OConnectionHelper::askForFileName(::sfx2::FileDialogHelper& _aFileOpen) { diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx index 0fd8ebc13..93ef5a588 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.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 @@ -43,23 +43,23 @@ #ifndef DBACCESS_DSMETA_HXX #include "dsmeta.hxx" #endif -#ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> #endif -#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <unotools/pathoptions.hxx> #endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> #endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> #endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> #endif #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include <svtools/moduleoptions.hxx> +#include <unotools/moduleoptions.hxx> #endif #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" @@ -70,13 +70,13 @@ #ifndef _DBAUI_LOCALRESACCESS_HXX_ #include "localresaccess.hxx" #endif -#ifndef _OSL_PROCESS_H_ +#ifndef _OSL_PROCESS_H_ #include <osl/process.h> #endif #ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> #endif -#ifndef _FILEDLGHELPER_HXX +#ifndef _FILEDLGHELPER_HXX #include <sfx2/filedlghelper.hxx> #endif #ifndef _DBAUI_DBADMIN_HXX_ @@ -85,7 +85,7 @@ #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> #endif -#ifndef _VCL_STDTEXT_HXX +#ifndef _VCL_STDTEXT_HXX #include <vcl/stdtext.hxx> #endif #ifndef _DBAUI_SQLMESSAGE_HXX_ @@ -98,12 +98,12 @@ #include "dsselect.hxx" #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" #endif -#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ +#ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_ #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> #endif #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ @@ -134,10 +134,10 @@ #ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" #endif -#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX #include <unotools/localfilehelper.hxx> #endif -#ifndef _UNOTOOLS_UCBHELPER_HXX +#ifndef _UNOTOOLS_UCBHELPER_HXX #include <unotools/ucbhelper.hxx> #endif #ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX @@ -149,7 +149,7 @@ #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ #include <connectivity/CommonTools.hxx> #endif -#ifndef _URLOBJ_HXX +#ifndef _URLOBJ_HXX #include <tools/urlobj.hxx> #endif #ifndef _SFX_DOCFILT_HACK_HXX @@ -161,7 +161,7 @@ #endif #ifdef _ADO_DATALINK_BROWSE_ -#if defined( WNT ) +#if defined( WNT ) #include <tools/prewin.h> #include <windows.h> #include <tools/postwin.h> @@ -197,7 +197,7 @@ namespace dbaui //======================================================================== //= OConnectionTabPage //======================================================================== - DBG_NAME(OConnectionTabPage) + DBG_NAME(OConnectionTabPage) OConnectionTabPage::OConnectionTabPage(Window* pParent, const SfxItemSet& _rCoreAttrs) :OConnectionHelper(pParent, ModuleRes(PAGE_CONNECTION), _rCoreAttrs) ,m_bUserGrabFocus(sal_True) @@ -212,7 +212,7 @@ namespace dbaui ,m_aTestJavaDriver(this, ModuleRes(PB_TESTDRIVERCLASS)) ,m_aTestConnection(this, ModuleRes(PB_TESTCONNECTION)) { - DBG_CTOR(OConnectionTabPage,NULL); + DBG_CTOR(OConnectionTabPage,NULL); m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPage, OnEditModified)); m_aJavaDriver.SetModifyHdl(getControlModifiedLink()); m_aJavaDriver.SetModifyHdl(LINK(this, OConnectionTabPage, OnEditModified)); @@ -228,7 +228,7 @@ namespace dbaui // ----------------------------------------------------------------------- OConnectionTabPage::~OConnectionTabPage() { - DBG_DTOR(OConnectionTabPage,NULL); + DBG_DTOR(OConnectionTabPage,NULL); } // ----------------------------------------------------------------------- @@ -377,7 +377,7 @@ namespace dbaui void OConnectionTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) { _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL1)); - + _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL2)); _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aJavaDriverLabel)); _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aTestJavaDriver)); diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx index f38e794ed..6f2d9f4bf 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.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 @@ -44,19 +44,19 @@ #include "dbu_dlg.hrc" #endif #ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #endif #ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" @@ -98,7 +98,7 @@ #include "dsselect.hxx" #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" @@ -229,7 +229,7 @@ namespace dbaui else m_aFT_HelpText.Hide(); - + if ( USHRT_MAX != _nHeaderResId ) SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderResId); @@ -256,7 +256,7 @@ namespace dbaui m_aFT_Connection.Hide(); m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified)); - + SetRoadmapStateValue(sal_False); } @@ -270,7 +270,7 @@ namespace dbaui void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) { m_eType = m_pAdminDialog->getDatasourceType(_rSet); - // special handling for oracle, this can only happen + // special handling for oracle, this can only happen // if the user enters the same url as used for Oracle and we are on the JDBC path //! TODO //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType ) @@ -288,7 +288,7 @@ namespace dbaui // ppTextControls[i]->SetText(sDisplayName); // } //} - + callModifiedHdl(); } // ----------------------------------------------------------------------- diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index 438c498d1..5a2d6ba1d 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.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 @@ -45,17 +45,17 @@ #ifndef _DBAUI_DBADMINSETUP_HRC_ #include "dbadminsetup.hrc" #endif -#ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> #endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> #endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> #endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> #endif #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" @@ -74,7 +74,7 @@ #include <vcl/mnemonic.hxx> #endif #ifndef _SVTOOLS_CJKOPTIONS_HXX -#include <svtools/cjkoptions.hxx> +#include <svl/cjkoptions.hxx> #endif #include <jvmaccess/virtualmachine.hxx> #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ @@ -100,7 +100,7 @@ #include <com/sun/star/sdbc/XDriverAccess.hpp> #include "dbustrings.hrc" #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #include <unotools/localfilehelper.hxx> @@ -109,7 +109,7 @@ #include "finteraction.hxx" #include <connectivity/CommonTools.hxx> #include "dbaccess_helpid.hrc" -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #include <svtools/roadmapwizard.hxx> #include "TextConnectionHelper.hxx" @@ -155,12 +155,12 @@ DBG_NAME(OTextConnectionPageSetup) OTextConnectionPageSetup::~OTextConnectionPageSetup() { DELETEZ(m_pTextConnectionHelper); - + DBG_DTOR(OTextConnectionPageSetup,NULL); - } + } IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/) - { + { SetRoadmapStateValue((m_pTextConnectionHelper->GetExtension().Len() > 0) && OConnectionTabPageSetup::checkTestConnection()); callModifiedHdl(); return sal_True; @@ -205,7 +205,7 @@ DBG_NAME(OTextConnectionPageSetup) return bChangedSomething; } - + sal_Bool OTextConnectionPageSetup::prepareLeave(){ return m_pTextConnectionHelper->prepareLeave(); } @@ -296,12 +296,12 @@ DBG_NAME(OTextConnectionPageSetup) SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True); SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True); - if ( bValid ) + if ( bValid ) { m_aETBaseDN.SetText(pBaseDN->GetValue()); m_aNFPortNumber.SetValue(pPortNumber->GetValue()); } - OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); + OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue); callModifiedHdl(); } @@ -350,7 +350,7 @@ DBG_NAME(OMySQLIntroPageSetup) // ----------------------------------------------------------------------- OMySQLIntroPageSetup::~OMySQLIntroPageSetup() { - + DBG_DTOR(OMySQLIntroPageSetup,NULL); } @@ -497,7 +497,7 @@ DBG_NAME(OMySQLIntroPageSetup) String sHelpText = String(ModuleRes(_nHelpTextResId)); m_aFTHelpText.SetText(sHelpText); //TODO this code snippet is redundant - SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderTextResId); + SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderTextResId); m_aETDatabasename.SetModifyHdl(getControlModifiedLink()); m_aETHostname.SetModifyHdl(getControlModifiedLink()); @@ -505,7 +505,7 @@ DBG_NAME(OMySQLIntroPageSetup) m_aETDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified)); m_aPBTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup,OnTestJavaClickHdl)); - + SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL; @@ -522,12 +522,12 @@ DBG_NAME(OMySQLIntroPageSetup) // ----------------------------------------------------------------------- OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, - PAGE_DBWIZARD_MYSQL_JDBC, + return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, + PAGE_DBWIZARD_MYSQL_JDBC, _rAttrSet, DSID_MYSQL_PORTNUMBER , STR_MYSQL_DEFAULT, - STR_MYSQLJDBC_HELPTEXT, + STR_MYSQLJDBC_HELPTEXT, STR_MYSQLJDBC_HEADERTEXT, STR_MYSQL_DRIVERCLASSTEXT) ); } @@ -535,12 +535,12 @@ DBG_NAME(OMySQLIntroPageSetup) // ----------------------------------------------------------------------- OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, - PAGE_DBWIZARD_ORACLE, - _rAttrSet, + return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent, + PAGE_DBWIZARD_ORACLE, + _rAttrSet, DSID_ORACLE_PORTNUMBER, - STR_ORACLE_DEFAULT, - STR_ORACLE_HELPTEXT, + STR_ORACLE_DEFAULT, + STR_ORACLE_HELPTEXT, STR_ORACLE_HEADERTEXT, STR_ORACLE_DRIVERCLASSTEXT) ); } @@ -639,7 +639,7 @@ DBG_NAME(OMySQLIntroPageSetup) aMsg.Execute(); return 0L; } - + // ----------------------------------------------------------------------- IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit) { @@ -793,7 +793,7 @@ DBG_NAME(OSpreadSheetConnectionPageSetup) // ----------------------------------------------------------------------- OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup() { - + DBG_DTOR(OSpreadSheetConnectionPageSetup,NULL); } @@ -853,7 +853,7 @@ DBG_NAME(OAuthentificationPageSetup) // ----------------------------------------------------------------------- OAuthentificationPageSetup::~OAuthentificationPageSetup() { - + DBG_DTOR(OAuthentificationPageSetup,NULL); } @@ -919,7 +919,7 @@ DBG_NAME(OFinalDBPageSetup) , m_aFTAdditionalSettings (this, ModuleRes(FT_ADDITIONALSETTINGS)) , m_aCBOpenAfterwards (this, ModuleRes(CB_OPENAFTERWARDS)) , m_aCBStartTableWizard (this, ModuleRes(CB_STARTTABLEWIZARD)) - , m_aFTFinalText (this, ModuleRes(FT_FINALTEXT)) + , m_aFTFinalText (this, ModuleRes(FT_FINALTEXT)) { DBG_CTOR(OFinalDBPageSetup,NULL); @@ -933,7 +933,7 @@ DBG_NAME(OFinalDBPageSetup) sal_Int32 nUnrelatedHeight = LogicToPixel( Size( 0, UNRELATED_CONTROLS ), MAP_APPFONT ).Height(); sal_Int32 nRelatedHeight = LogicToPixel( Size( 0, RELATED_CONTROLS ), MAP_APPFONT ).Height(); - ::std::pair<Window*,sal_Int32> pWindows[] = { + ::std::pair<Window*,sal_Int32> pWindows[] = { ::std::pair<Window*,sal_Int32>(&m_aFTFinalHelpText,nRelatedHeight) ,::std::pair<Window*,sal_Int32>(&m_aRBRegisterDataSource,nRelatedHeight) ,::std::pair<Window*,sal_Int32>(&m_aRBDontregisterDataSource,nUnrelatedHeight) @@ -952,14 +952,8 @@ DBG_NAME(OFinalDBPageSetup) aPos.X() = pWindows[i].first->GetPosPixel().X(); Size aSize = pWindows[i].first->GetSizePixel(); FixedText* pText = dynamic_cast<FixedText*>(pWindows[i].first); - CheckBox* pCheck = dynamic_cast<CheckBox*>(pWindows[i].first); - RadioButton* pRadio = dynamic_cast<RadioButton*>(pWindows[i].first); if ( pText ) aSize = pText->CalcMinimumSize(aSize.Width()); - else if ( pRadio ) - aSize = pRadio->CalcMinimumSize(aSize.Width()); - else if ( pCheck ) - aSize = pCheck->CalcMinimumSize(aSize.Width()); pWindows[i].first->SetPosSizePixel(aPos,aSize); aPos.Y() += aSize.Height() + pWindows[i].second; } @@ -969,17 +963,17 @@ DBG_NAME(OFinalDBPageSetup) // ----------------------------------------------------------------------- OFinalDBPageSetup::~OFinalDBPageSetup() { - + DBG_DTOR(OFinalDBPageSetup,NULL); } sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered() - { + { return m_aRBRegisterDataSource.IsChecked() && m_aRBRegisterDataSource.IsEnabled(); } sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened() - { + { return m_aCBOpenAfterwards.IsChecked() && m_aCBOpenAfterwards.IsEnabled(); } diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 061950b28..617f6f492 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -34,93 +34,41 @@ #include "DbAdminImpl.hxx" #include "dsmeta.hxx" -#ifndef _SFXPOOLITEM_HXX -#include <svtools/poolitem.hxx> -#endif -#ifndef _SFXITEMPOOL_HXX -#include <svtools/itempool.hxx> -#endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> -#endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> -#endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ -#include <comphelper/property.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ -#include <comphelper/sequence.hxx> -#endif -#ifndef _SVTOOLS_LOGINDLG_HXX_ -#include <svtools/logindlg.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#include <connectivity/DriversConfig.hxx> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ -#include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ -#include <com/sun/star/sdb/SQLContext.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ -#include <com/sun/star/sdbc/XDriverAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ -#include <com/sun/star/sdbc/XDriver.hpp> -#endif -#ifndef DBAUI_DRIVERSETTINGS_HXX #include "DriverSettings.hxx" -#endif -#ifndef _DBAUI_PROPERTYSETITEM_HXX_ -#include "propertysetitem.hxx" -#endif -#ifndef _DBAUI_DATASOURCEITEMS_HXX_ -#include "dsitems.hxx" -#endif -#ifndef DBAUI_ITEMSETHELPER_HXX #include "IItemSetHelper.hxx" -#endif -#ifndef _DBU_DLG_HRC_ +#include "UITools.hxx" #include "dbu_dlg.hrc" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef _VCL_STDTEXT_HXX -#include <vcl/stdtext.hxx> -#endif -#ifndef _SV_MSGBOX_HXX -#include <vcl/msgbox.hxx> -#endif -#ifndef _SV_WAITOBJ_HXX -#include <vcl/waitobj.hxx> -#endif -#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_ -#include <typelib/typedescription.hxx> -#endif - -#ifndef _OSL_FILE_HXX_ -#include <osl/file.hxx> -#endif -#ifndef _DBAUI_STRINGLISTITEM_HXX_ -#include "stringlistitem.hxx" -#endif -#ifndef _DBAUI_MODULE_DBU_HXX_ +#include "dsitems.hxx" +#include "dsnItem.hxx" #include "moduledbu.hxx" -#endif -#ifndef DBAUI_TOOLS_HXX -#include "UITools.hxx" -#endif -#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ +#include "optionalboolitem.hxx" +#include "propertysetitem.hxx" +#include "stringlistitem.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/frame/XStorable.hpp> -#endif -#include "dsnItem.hxx" +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdbc/XDriver.hpp> +#include <com/sun/star/sdbc/XDriverAccess.hpp> +/** === end UNO includes === **/ + +#include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> +#include <connectivity/DriversConfig.hxx> +#include <connectivity/dbexception.hxx> +#include <osl/file.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/itempool.hxx> +#include <svtools/logindlg.hxx> +#include <svl/poolitem.hxx> +#include <svl/stritem.hxx> +#include <typelib/typedescription.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/stdtext.hxx> +#include <vcl/waitobj.hxx> #include <algorithm> #include <functional> @@ -231,6 +179,7 @@ ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper(const Refer m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AS_BEFORE_CORRNAME, INFO_AS_BEFORE_CORRELATION_NAME ) ); m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHECK_REQUIRED_FIELDS, INFO_FORMS_CHECK_REQUIRED_FIELDS ) ); m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ESCAPE_DATETIME, INFO_ESCAPE_DATETIME ) ); + m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_PRIMARY_KEY_SUPPORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrimaryKeySupport" ) ) ) ); m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_PARAMETERNAMESUBST, INFO_PARAMETERNAMESUBST)); m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_IGNOREDRIVER_PRIV, INFO_IGNOREDRIVER_PRIV)); m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_BOOLEANCOMPARISON, PROPERTY_BOOLEANCOMPARISONMODE)); @@ -909,14 +858,36 @@ Any ODbDataSourceAdministrationHelper::implTranslateProperty(const SfxPoolItem* { // translate the SfxPoolItem Any aValue; - if (_pItem->ISA(SfxStringItem)) - aValue <<= ::rtl::OUString(PTR_CAST(SfxStringItem, _pItem)->GetValue().GetBuffer()); - else if (_pItem->ISA(SfxBoolItem)) - aValue <<= PTR_CAST(SfxBoolItem, _pItem)->GetValue(); - else if (_pItem->ISA(SfxInt32Item)) - aValue <<= PTR_CAST(SfxInt32Item, _pItem)->GetValue(); - else if (_pItem->ISA(OStringListItem)) - aValue <<= PTR_CAST(OStringListItem, _pItem)->getList(); + + const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, _pItem ); + const SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, _pItem ); + const OptionalBoolItem* pOptBoolItem = PTR_CAST( OptionalBoolItem, _pItem ); + const SfxInt32Item* pInt32Item = PTR_CAST( SfxInt32Item, _pItem ); + const OStringListItem* pStringListItem = PTR_CAST( OStringListItem, _pItem ); + + if ( pStringItem ) + { + aValue <<= ::rtl::OUString( pStringItem->GetValue().GetBuffer() ); + } + else if ( pBoolItem ) + { + aValue <<= pBoolItem->GetValue(); + } + else if ( pOptBoolItem ) + { + if ( !pOptBoolItem->HasValue() ) + aValue.clear(); + else + aValue <<= (sal_Bool)pOptBoolItem->GetValue(); + } + else if ( pInt32Item ) + { + aValue <<= pInt32Item->GetValue(); + } + else if ( pStringListItem ) + { + aValue <<= pStringListItem->getList(); + } else { DBG_ERROR("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported item type!"); @@ -957,15 +928,14 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty(const Reference< X //------------------------------------------------------------------------- void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet, sal_Int32 _nId, const Any& _rValue ) { - USHORT nId = (USHORT)_nId; - switch (_rValue.getValueType().getTypeClass()) + switch ( _rValue.getValueType().getTypeClass() ) { case TypeClass_STRING: - if ( implCheckItemType( _rSet, nId, SfxStringItem::StaticType() ) ) + if ( implCheckItemType( _rSet, _nId, SfxStringItem::StaticType() ) ) { ::rtl::OUString sValue; _rValue >>= sValue; - _rSet.Put(SfxStringItem(nId, sValue.getStr())); + _rSet.Put(SfxStringItem(_nId, sValue.getStr())); } else { DBG_ERROR( @@ -978,11 +948,24 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet break; case TypeClass_BOOLEAN: - if ( implCheckItemType( _rSet, nId, SfxBoolItem::StaticType() ) ) + if ( implCheckItemType( _rSet, _nId, SfxBoolItem::StaticType() ) ) { sal_Bool bVal = sal_False; _rValue >>= bVal; - _rSet.Put(SfxBoolItem(nId, bVal)); + _rSet.Put(SfxBoolItem(_nId, bVal)); + } + else if ( implCheckItemType( _rSet, _nId, OptionalBoolItem::StaticType() ) ) + { + OptionalBoolItem aItem( _nId ); + if ( _rValue.hasValue() ) + { + sal_Bool bValue = sal_False; + _rValue >>= bValue; + aItem.SetValue( bValue ); + } + else + aItem.ClearValue(); + _rSet.Put( aItem ); } else { DBG_ERROR( @@ -995,11 +978,11 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet break; case TypeClass_LONG: - if ( implCheckItemType( _rSet, nId, SfxInt32Item::StaticType() ) ) + if ( implCheckItemType( _rSet, _nId, SfxInt32Item::StaticType() ) ) { sal_Int32 nValue = 0; _rValue >>= nValue; - _rSet.Put( SfxInt32Item( nId, nValue ) ); + _rSet.Put( SfxInt32Item( _nId, nValue ) ); } else { DBG_ERROR( @@ -1012,7 +995,7 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet break; case TypeClass_SEQUENCE: - if ( implCheckItemType( _rSet, nId, OStringListItem::StaticType() ) ) + if ( implCheckItemType( _rSet, _nId, OStringListItem::StaticType() ) ) { // determine the element type TypeDescription aTD(_rValue.getValueType()); @@ -1027,7 +1010,7 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet { Sequence< ::rtl::OUString > aStringList; _rValue >>= aStringList; - _rSet.Put(OStringListItem(nId, aStringList)); + _rSet.Put(OStringListItem(_nId, aStringList)); } break; default: @@ -1045,7 +1028,7 @@ void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet break; case TypeClass_VOID: - _rSet.ClearItem(nId); + _rSet.ClearItem(_nId); break; default: diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx index a8517c86c..d01d02234 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.hxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx @@ -59,12 +59,12 @@ #include "dsntypes.hxx" #endif #ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ #include <com/sun/star/frame/XModel.hpp> #endif -#include <svtools/poolitem.hxx> +#include <svl/poolitem.hxx> class Window; //......................................................................... diff --git a/dbaccess/source/ui/dlg/DriverSettings.cxx b/dbaccess/source/ui/dlg/DriverSettings.cxx index cd0caca1d..98b28cbf4 100644 --- a/dbaccess/source/ui/dlg/DriverSettings.cxx +++ b/dbaccess/source/ui/dlg/DriverSettings.cxx @@ -32,13 +32,13 @@ #include "precompiled_dbaccess.hxx" #include "DriverSettings.hxx" -#include "dsitems.hxx" -#include "datasourceui.hxx" -#include <connectivity/DriversConfig.hxx> +#include "dsmeta.hxx" #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/NamedValue.hpp> +#include <connectivity/DriversConfig.hxx> + using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::NamedValue; @@ -47,34 +47,23 @@ void ODriversSettings::getSupportedIndirectSettings( const ::rtl::OUString& _sUR { // for a number of settings, we do not need to use hard-coded here, but can ask a // central DataSourceUI instance. - // TODO: isn't DataSourceUI obsolete, now that this is in the configuration? - DataSourceMetaData aMeta(_sURLPrefix); - DataSourceUI aDSUI( aMeta ); - const USHORT nGenericKnownSettings[] = + DataSourceMetaData aMeta( _sURLPrefix ); + const FeatureSet& rFeatures( aMeta.getFeatureSet() ); + for ( FeatureSet::const_iterator feature = rFeatures.begin(); + feature != rFeatures.end(); + ++feature + ) { - DSID_SQL92CHECK, - DSID_APPEND_TABLE_ALIAS, - DSID_AS_BEFORE_CORRNAME, - DSID_ENABLEOUTERJOIN, - DSID_IGNOREDRIVER_PRIV, - DSID_PARAMETERNAMESUBST, - DSID_SUPPRESSVERSIONCL, - DSID_CATALOG, - DSID_SCHEMA, - DSID_INDEXAPPENDIX, - DSID_CHECK_REQUIRED_FIELDS, - DSID_AUTORETRIEVEENABLED, - DSID_AUTOINCREMENTVALUE, - DSID_AUTORETRIEVEVALUE, - DSID_BOOLEANCOMPARISON, - DSID_ESCAPE_DATETIME, - 0 - }; - for ( const USHORT* pGenericKnowSetting = nGenericKnownSettings; *pGenericKnowSetting; ++pGenericKnowSetting ) - if ( aDSUI.hasSetting( *pGenericKnowSetting ) ) - _out_rDetailsIds.push_back( *pGenericKnowSetting ); + _out_rDetailsIds.push_back( *feature ); + } // the rest is configuration-based + // TODO: that's not really true: *everything* is configuration-based nowadays, even the FeatureSet obtained + // from the DataSourceMetaData has been initialized from the configuration. So in fact, we could consolidate + // the two blocks. + // The best approach would be to extend the FeatureSet to contain *all* known data source features, not only + // the ones from the "Advanced settings" UI. + ::connectivity::DriversConfig aDriverConfig(_xFactory); const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix); #if OSL_DEBUG_LEVEL > 0 @@ -117,7 +106,11 @@ void ODriversSettings::getSupportedIndirectSettings( const ::rtl::OUString& _sUR ,TProperties(0,::rtl::OUString()) }; // TODO: This mapping between IDs and property names already exists - in ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper. - // We should not duplicate it here. + // Another mapping (which is also duplicated in ODbDataSourceAdministrationHelper) exists in dsmeta.cxx. We should + // consolidate those three places into one. + // However, care has to be taken: We need to distinguish between "features" and "properties" of a data source (resp. driver). + // That is, a driver can support a certain property, but not allow to change it in the UI, which means it would + // not have the respective "feature". for ( TProperties* pProps = aProps; pProps->first; ++pProps ) { if ( aProperties.has(pProps->second) ) diff --git a/dbaccess/source/ui/dlg/DriverSettings.hxx b/dbaccess/source/ui/dlg/DriverSettings.hxx index 5a275ac54..031b2265e 100644 --- a/dbaccess/source/ui/dlg/DriverSettings.hxx +++ b/dbaccess/source/ui/dlg/DriverSettings.hxx @@ -33,7 +33,7 @@ #ifndef _DBAUI_DSNTYPES_HXX_ #include "dsntypes.hxx" #endif -#include <svtools/poolitem.hxx> +#include <svl/poolitem.hxx> #include <vector> class SfxTabPage; diff --git a/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx b/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx index 645793979..de4fecbcf 100644 --- a/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx +++ b/dbaccess/source/ui/dlg/ExtensionNotPresent.cxx @@ -44,7 +44,7 @@ /** === end UNO includes === **/ #include <connectivity/dbconversion.hxx> -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #include <svx/globlmn.hrc> #include <svx/svxids.hrc> #include <tools/debug.hxx> diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx index e933b0617..55322812b 100644 --- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/TextConnectionHelper.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 @@ -50,17 +50,17 @@ #include "AutoControls.hrc" #endif -#ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#ifndef _SFXITEMSET_HXX +#include <svl/itemset.hxx> #endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#ifndef _SFXSTRITEM_HXX +#include <svl/stritem.hxx> #endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#ifndef _SFXENUMITEM_HXX +#include <svl/eitem.hxx> #endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#ifndef _SFXINTITEM_HXX +#include <svl/intitem.hxx> #endif #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" @@ -81,7 +81,7 @@ #include <vcl/mnemonic.hxx> #endif #ifndef _SVTOOLS_CJKOPTIONS_HXX -#include <svtools/cjkoptions.hxx> +#include <svl/cjkoptions.hxx> #endif #include <jvmaccess/virtualmachine.hxx> #ifndef _DBAUI_ADASTAT_HXX_ @@ -109,7 +109,7 @@ #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX @@ -141,7 +141,7 @@ #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX @@ -194,7 +194,7 @@ DBG_NAME(OTextConnectionHelper) nCnt = m_aTextSeparatorList.GetTokenCount( '\t' ); for( i=0 ; i<nCnt ; i+=2 ) m_aTextSeparator.InsertEntry( m_aTextSeparatorList.GetToken( i, '\t' ) ); - m_aTextSeparator.InsertEntry(m_aTextNone); + m_aTextSeparator.InsertEntry(m_aTextNone); // set the modify handlers m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink()); @@ -306,7 +306,7 @@ DBG_NAME(OTextConnectionHelper) // ----------------------------------------------------------------------- OTextConnectionHelper::~OTextConnectionHelper() { - + DBG_DTOR(OTextConnectionHelper,NULL); } @@ -357,7 +357,7 @@ DBG_NAME(OTextConnectionHelper) _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel)); _rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet)); } - + // ----------------------------------------------------------------------- void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid) { @@ -491,9 +491,9 @@ DBG_NAME(OTextConnectionHelper) { rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) ); bChangedSomething = sal_True; - } + } } - + if ( ( m_nAvailableSections & TC_HEADER ) != 0 ) { if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) ) diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.cxx b/dbaccess/source/ui/dlg/UserAdminDlg.cxx index 642b431bc..daa0888b4 100644 --- a/dbaccess/source/ui/dlg/UserAdminDlg.cxx +++ b/dbaccess/source/ui/dlg/UserAdminDlg.cxx @@ -45,9 +45,9 @@ #include <comphelper/componentcontext.hxx> #include <connectivity/dbmetadata.hxx> #include <cppuhelper/exc_hlp.hxx> -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> -#include <svtools/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <tools/diagnose_ex.h> #include <vcl/msgbox.hxx> #include <vcl/stdtext.hxx> diff --git a/dbaccess/source/ui/dlg/admincontrols.cxx b/dbaccess/source/ui/dlg/admincontrols.cxx index 00feec0fa..d60467774 100755 --- a/dbaccess/source/ui/dlg/admincontrols.cxx +++ b/dbaccess/source/ui/dlg/admincontrols.cxx @@ -32,9 +32,9 @@ #include "dsitems.hxx" #include "moduledbu.hxx" -#include <svtools/eitem.hxx> -#include <svtools/stritem.hxx> -#include <svtools/intitem.hxx> +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> +#include <svl/intitem.hxx> //........................................................................ namespace dbaui diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx index d48e962bc..0807e8a6a 100644 --- a/dbaccess/source/ui/dlg/adminpages.cxx +++ b/dbaccess/source/ui/dlg/adminpages.cxx @@ -31,70 +31,31 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBAUI_ADMINPAGES_HXX_ #include "adminpages.hxx" -#endif -#ifndef _DBAUI_DBADMIN_HRC_ #include "dbadmin.hrc" -#endif -#ifndef _DBU_DLG_HRC_ +#include "dbadmin.hxx" #include "dbu_dlg.hrc" -#endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> -#endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> -#endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> -#endif -#ifndef _DBAUI_DATASOURCEITEMS_HXX_ -#include "dsitems.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef _DBAUI_DBADMIN_HXX_ -#include "dbadmin.hxx" -#endif -#ifndef _SV_MSGBOX_HXX -#include <vcl/msgbox.hxx> -#endif -#ifndef _DBAUI_SQLMESSAGE_HXX_ -#include "sqlmessage.hxx" -#endif -#ifndef _SV_ACCEL_HXX -#include <vcl/accel.hxx> -#endif -#include <algorithm> -#include <stdlib.h> -#ifndef _OSL_FILE_HXX_ -#include <osl/file.hxx> -#endif -#ifndef _DBAUI_DSSELECT_HXX_ +#include "dsitems.hxx" #include "dsselect.hxx" -#endif -#ifndef _DBAUI_ODBC_CONFIG_HXX_ -#include "odbcconfig.hxx" -#endif -#ifndef _DBAUI_LOCALRESACCESS_HXX_ #include "localresaccess.hxx" -#endif -#ifndef _SV_FIELD_HXX +#include "odbcconfig.hxx" +#include "optionalboolitem.hxx" +#include "sqlmessage.hxx" + +#include <osl/file.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <vcl/accel.hxx> +#include <vcl/button.hxx> +#include <vcl/edit.hxx> #include <vcl/field.hxx> -#endif -#ifndef _SV_LSTBOX_HXX #include <vcl/lstbox.hxx> -#endif -#ifndef _SV_EDIT_HXX -#include <vcl/edit.hxx> -#endif -#ifndef _SV_BUTTON_HXX -#include <vcl/button.hxx> -#endif - +#include <vcl/msgbox.hxx> +#include <algorithm> +#include <stdlib.h> //......................................................................... namespace dbaui @@ -256,7 +217,16 @@ namespace dbaui if ( _bRevertValue ) bValue = !bValue; - _rSet.Put( SfxBoolItem( _nID, bValue ) ); + if ( _pCheckBox->IsTriStateEnabled() ) + { + OptionalBoolItem aValue( _nID ); + if ( _pCheckBox->GetState() != STATE_DONTKNOW ) + aValue.SetValue( bValue ); + _rSet.Put( aValue ); + } + else + _rSet.Put( SfxBoolItem( _nID, bValue ) ); + _bChangedSomething = sal_True; } } diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx index 825e5f66b..988027669 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.cxx +++ b/dbaccess/source/ui/dlg/advancedsettings.cxx @@ -37,8 +37,7 @@ #include "dsitems.hxx" #include "DbAdminImpl.hxx" #include "DriverSettings.hxx" -#include "datasourceui.hxx" - +#include "optionalboolitem.hxx" #include "dbu_resource.hrc" #include "dbu_dlg.hrc" #include "dbadmin.hrc" @@ -47,9 +46,9 @@ /** === begin UNO includes === **/ /** === end UNO includes === **/ -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> -#include <svtools/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <vcl/msgbox.hxx> @@ -98,15 +97,16 @@ namespace dbaui ,m_pCheckRequiredFields( NULL ) ,m_pIgnoreCurrency(NULL) ,m_pEscapeDateTime(NULL) + ,m_pPrimaryKeySupport(NULL) ,m_pBooleanComparisonModeLabel( NULL ) ,m_pBooleanComparisonMode( NULL ) ,m_aControlDependencies() ,m_aBooleanSettings() - ,m_aSupported( _rDSMeta.getAdvancedSettingsSupport() ) + ,m_bHasBooleanComparisonMode( _rDSMeta.getFeatureSet().has( DSID_BOOLEANCOMPARISON ) ) { impl_initBooleanSettings(); - DataSourceUI aDSUI( _rDSMeta ); + const FeatureSet& rFeatures( _rDSMeta.getFeatureSet() ); // create all the check boxes for the boolean settings for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); setting != m_aBooleanSettings.end(); @@ -114,11 +114,16 @@ namespace dbaui ) { USHORT nItemId = setting->nItemId; - if ( aDSUI.hasSetting( nItemId ) ) + if ( rFeatures.has( nItemId ) ) { - USHORT nID = setting->nControlResId; - (*setting->ppControl) = new CheckBox( this, ModuleRes( nID ) ); + USHORT nResourceId = setting->nControlResId; + (*setting->ppControl) = new CheckBox( this, ModuleRes( nResourceId ) ); (*setting->ppControl)->SetClickHdl( getControlModifiedLink() ); + + // check whether this must be a tristate check box + const SfxPoolItem& rItem = _rCoreAttrs.Get( nItemId ); + if ( rItem.ISA( OptionalBoolItem ) ) + (*setting->ppControl)->EnableTriState( TRUE ); } } @@ -148,7 +153,7 @@ namespace dbaui } // create the controls for the boolean comparison mode - if ( m_aSupported.bBooleanComparisonMode ) + if ( m_bHasBooleanComparisonMode ) { m_pBooleanComparisonModeLabel = new FixedText( this, ModuleRes( FT_BOOLEANCOMPARISON ) ); m_pBooleanComparisonMode = new ListBox( this, ModuleRes( LB_BOOLEANCOMPARISON ) ); @@ -185,6 +190,7 @@ namespace dbaui DELETEZ( m_pCheckRequiredFields ); DELETEZ( m_pIgnoreCurrency ); DELETEZ( m_pEscapeDateTime ); + DELETEZ( m_pPrimaryKeySupport ); DELETEZ( m_pBooleanComparisonModeLabel ); DELETEZ( m_pBooleanComparisonMode ); } @@ -210,13 +216,12 @@ namespace dbaui { &m_pCheckRequiredFields, CB_CHECK_REQUIRED, DSID_CHECK_REQUIRED_FIELDS, false }, { &m_pIgnoreCurrency, CB_IGNORECURRENCY, DSID_IGNORECURRENCY, false }, { &m_pEscapeDateTime, CB_ESCAPE_DATETIME, DSID_ESCAPE_DATETIME, false }, + { &m_pPrimaryKeySupport, CB_PRIMARY_KEY_SUPPORT, DSID_PRIMARY_KEY_SUPPORT, false }, { NULL, 0, 0, false } }; for ( const BooleanSettingDesc* pCopy = aSettings; pCopy->nItemId != 0; ++pCopy ) { - USHORT nID = pCopy->nItemId; - (void) nID; m_aBooleanSettings.push_back( *pCopy ); } } @@ -224,7 +229,7 @@ namespace dbaui // ----------------------------------------------------------------------- void SpecialSettingsPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList ) { - if ( m_aSupported.bBooleanComparisonMode ) + if ( m_bHasBooleanComparisonMode ) { _rControlList.push_back( new ODisableWrapper< FixedText >( m_pBooleanComparisonModeLabel ) ); } @@ -244,7 +249,7 @@ namespace dbaui } } - if ( m_aSupported.bBooleanComparisonMode ) + if ( m_bHasBooleanComparisonMode ) _rControlList.push_back( new OSaveValueWrapper< ListBox >( m_pBooleanComparisonMode ) ); } @@ -270,16 +275,35 @@ namespace dbaui if ( !*setting->ppControl ) continue; - SFX_ITEMSET_GET( _rSet, pItem, SfxBoolItem, setting->nItemId, sal_True ); - bool bValue = pItem->GetValue(); - if ( setting->bInvertedDisplay ) - bValue = !bValue; + ::boost::optional< bool > aValue; - (*setting->ppControl)->Check( bValue ); + SFX_ITEMSET_GET( _rSet, pItem, SfxPoolItem, setting->nItemId, sal_True ); + if ( pItem->ISA( SfxBoolItem ) ) + { + aValue.reset( PTR_CAST( SfxBoolItem, pItem )->GetValue() ); + } + else if ( pItem->ISA( OptionalBoolItem ) ) + { + aValue = PTR_CAST( OptionalBoolItem, pItem )->GetFullValue(); + } + else + DBG_ERROR( "SpecialSettingsPage::implInitControls: unknown boolean item type!" ); + + if ( !aValue ) + { + (*setting->ppControl)->SetState( STATE_DONTKNOW ); + } + else + { + BOOL bValue = *aValue; + if ( setting->bInvertedDisplay ) + bValue = !bValue; + (*setting->ppControl)->Check( bValue ); + } } // the non-boolean items - if ( m_aSupported.bBooleanComparisonMode ) + if ( m_bHasBooleanComparisonMode ) { SFX_ITEMSET_GET( _rSet, pBooleanComparison, SfxInt32Item, DSID_BOOLEANCOMPARISON, sal_True ); m_pBooleanComparisonMode->SelectEntryPos( static_cast< USHORT >( pBooleanComparison->GetValue() ) ); @@ -305,7 +329,7 @@ namespace dbaui } // the non-boolean items - if ( m_aSupported.bBooleanComparisonMode ) + if ( m_bHasBooleanComparisonMode ) { if ( m_pBooleanComparisonMode->GetSelectEntryPos() != m_pBooleanComparisonMode->GetSavedValue() ) { @@ -420,14 +444,14 @@ namespace dbaui const ::rtl::OUString eType = m_pImpl->getDatasourceType(*_pItems); DataSourceMetaData aMeta( eType ); - const AdvancedSettingsSupport& rAdvancedSupport( aMeta.getAdvancedSettingsSupport() ); + const FeatureSet& rFeatures( aMeta.getFeatureSet() ); // auto-generated values? - if ( rAdvancedSupport.bGeneratedValues ) + if ( rFeatures.supportsGeneratedValues() ) AddTabPage( PAGE_GENERATED_VALUES, String( ModuleRes( STR_GENERATED_VALUE ) ), ODriversSettings::CreateGeneratedValuesPage, NULL ); // any "special settings"? - if ( rAdvancedSupport.supportsAnySpecialSetting() ) + if ( rFeatures.supportsAnySpecialSetting() ) AddTabPage( PAGE_ADVANCED_SETTINGS_SPECIAL, String( ModuleRes( STR_DS_BEHAVIOUR ) ), ODriversSettings::CreateSpecialSettingsPage, NULL ); // remove the reset button - it's meaning is much too ambiguous in this dialog @@ -446,8 +470,8 @@ namespace dbaui bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL ) { DataSourceMetaData aMeta( _sURL ); - const AdvancedSettingsSupport& rSupport( aMeta.getAdvancedSettingsSupport() ); - if ( rSupport.bGeneratedValues || rSupport.supportsAnySpecialSetting() ) + const FeatureSet& rFeatures( aMeta.getFeatureSet() ); + if ( rFeatures.supportsGeneratedValues() || rFeatures.supportsAnySpecialSetting() ) return true; return false; } diff --git a/dbaccess/source/ui/dlg/advancedsettings.hrc b/dbaccess/source/ui/dlg/advancedsettings.hrc index 2ef8ad881..714fc3c4e 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.hrc +++ b/dbaccess/source/ui/dlg/advancedsettings.hrc @@ -31,7 +31,7 @@ #ifndef DBAUI_ADVANCEDSETTINGS_HRC #define DBAUI_ADVANCEDSETTINGS_HRC -#define ADVANCED_CHECKBOX_OPTIONS 14 +#define ADVANCED_CHECKBOX_OPTIONS 15 #define ADVANCED_LISTBOX_OPTIONS 1 #define ADVANCED_PAGE_X 200 @@ -40,7 +40,7 @@ /* label */ FIXEDTEXT_HEIGHT + RELATED_CONTROLS + \ /* check boxes */ ( ADVANCED_CHECKBOX_OPTIONS * ( CHECKBOX_HEIGHT + RELATED_CONTROLS ) ) + \ /* list boxes */ ( ADVANCED_LISTBOX_OPTIONS * ( LISTBOX_HEIGHT + RELATED_CONTROLS ) ) + \ - /* bottom space */ START_Y - RELATED_CONTROLS + /* bottom space */ START_Y #define STR_GENERATED_VALUE 1 @@ -64,6 +64,7 @@ #define CB_CHECK_REQUIRED 13 #define CB_IGNORECURRENCY 14 #define CB_ESCAPE_DATETIME 15 +#define CB_PRIMARY_KEY_SUPPORT 16 #define ET_AUTOINCREMENTVALUE 1 #define ET_RETRIEVE_AUTO 2 diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx index 955dbc2e0..3bed8dbc7 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.hxx +++ b/dbaccess/source/ui/dlg/advancedsettings.hxx @@ -74,6 +74,7 @@ namespace dbaui CheckBox* m_pCheckRequiredFields; CheckBox* m_pIgnoreCurrency; CheckBox* m_pEscapeDateTime; + CheckBox* m_pPrimaryKeySupport; FixedText* m_pBooleanComparisonModeLabel; ListBox* m_pBooleanComparisonMode; @@ -83,8 +84,7 @@ namespace dbaui BooleanSettingDescs m_aBooleanSettings; - AdvancedSettingsSupport - m_aSupported; + bool m_bHasBooleanComparisonMode; public: virtual BOOL FillItemSet ( SfxItemSet& _rCoreAttrs ); diff --git a/dbaccess/source/ui/dlg/advancedsettings.src b/dbaccess/source/ui/dlg/advancedsettings.src index 13ed94809..956a367f7 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.src +++ b/dbaccess/source/ui/dlg/advancedsettings.src @@ -206,7 +206,18 @@ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \ TabStop = TRUE ; \ HelpId = HID_DSADMIN_ESCAPE_DATETIME; \ - Text [ en-US ] = "Use ODBC conformant date/time literals"; \ + Text [ en-US ] = "Use ODBC conformant date/time literals"; \ + }; + + +#define AUTO_PRIMARY_KEY_SUPPORT(AUTO_Y) \ + CheckBox CB_PRIMARY_KEY_SUPPORT \ + { \ + Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \ + Size = MAP_APPFONT ( ADVANCED_PAGE_X - 12 , CHECKBOX_HEIGHT ) ; \ + TabStop = TRUE ; \ + HelpId = HID_DSADMIN_PRIMARY_KEY_SUPPORT; \ + Text [ en-US ] = "Supports primary keys"; \ }; @@ -321,8 +332,9 @@ TabPage PAGE_ADVANCED_SETTINGS_SPECIAL AUTO_DOSLINEENDS( 11*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 10*CHECKBOX_HEIGHT + RELATED_CONTROLS ) AUTO_CHECKREQUIRED( 12*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 11*CHECKBOX_HEIGHT + RELATED_CONTROLS ) AUTO_IGNORECURRENCY( 13*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 12*CHECKBOX_HEIGHT + RELATED_CONTROLS ) - AUTO_ESCAPE_DATETIME( 14*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS ) - AUTO_BOOLEANCOMPARISON( 15*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 13*CHECKBOX_HEIGHT + RELATED_CONTROLS + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 ) + AUTO_ESCAPE_DATETIME( 14*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_PRIMARY_KEY_SUPPORT( 15*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 15*CHECKBOX_HEIGHT + RELATED_CONTROLS ) + AUTO_BOOLEANCOMPARISON( 16*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 ) }; //------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/dlg/datasourceui.cxx b/dbaccess/source/ui/dlg/datasourceui.cxx deleted file mode 100644 index 0225f845b..000000000 --- a/dbaccess/source/ui/dlg/datasourceui.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************* - * - * 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 - * - * $RCSfile: datasourceui.cxx,v $ - * $Revision: 1.5.68.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "datasourceui.hxx" -#include "dsmeta.hxx" -#include "dsitems.hxx" - -/** === begin UNO includes === **/ -/** === end UNO includes === **/ - -//........................................................................ -namespace dbaui -{ -//........................................................................ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - /** === end UNO using === **/ - - //==================================================================== - //= DataSourceUI - //==================================================================== - //-------------------------------------------------------------------- - DataSourceUI::DataSourceUI( const DataSourceMetaData& _rDSMeta ) - :m_aDSMeta( _rDSMeta ) - { - } - - //-------------------------------------------------------------------- - DataSourceUI::~DataSourceUI() - { - } - - //-------------------------------------------------------------------- - bool DataSourceUI::hasSetting( const USHORT _nItemId ) const - { - const AdvancedSettingsSupport& rAdvancedSupport( m_aDSMeta.getAdvancedSettingsSupport() ); - - switch ( _nItemId ) - { - case DSID_SQL92CHECK: return rAdvancedSupport.bUseSQL92NamingConstraints; - case DSID_APPEND_TABLE_ALIAS: return rAdvancedSupport.bAppendTableAliasInSelect; - case DSID_AS_BEFORE_CORRNAME: return rAdvancedSupport.bUseKeywordAsBeforeAlias; - case DSID_ENABLEOUTERJOIN: return rAdvancedSupport.bUseBracketedOuterJoinSyntax; - case DSID_IGNOREDRIVER_PRIV: return rAdvancedSupport.bIgnoreDriverPrivileges; - case DSID_PARAMETERNAMESUBST: return rAdvancedSupport.bParameterNameSubstitution; - case DSID_SUPPRESSVERSIONCL: return rAdvancedSupport.bDisplayVersionColumns; - case DSID_CATALOG: return rAdvancedSupport.bUseCatalogInSelect; - case DSID_SCHEMA: return rAdvancedSupport.bUseSchemaInSelect; - case DSID_INDEXAPPENDIX: return rAdvancedSupport.bUseIndexDirectionKeyword; - case DSID_DOSLINEENDS: return rAdvancedSupport.bUseDOSLineEnds; - case DSID_BOOLEANCOMPARISON: return rAdvancedSupport.bBooleanComparisonMode; - case DSID_CHECK_REQUIRED_FIELDS:return rAdvancedSupport.bFormsCheckRequiredFields; - case DSID_AUTORETRIEVEENABLED: return rAdvancedSupport.bGeneratedValues; - case DSID_AUTOINCREMENTVALUE: return rAdvancedSupport.bGeneratedValues; - case DSID_AUTORETRIEVEVALUE: return rAdvancedSupport.bGeneratedValues; - case DSID_IGNORECURRENCY: return rAdvancedSupport.bIgnoreCurrency; - case DSID_ESCAPE_DATETIME: return rAdvancedSupport.bEscapeDateTime; - } - - OSL_ENSURE( false, "DataSourceUI::hasSetting: this item id is currently not supported!" ); - // Support for *all* items is a medium-term goal only. - return false; - } - -//........................................................................ -} // namespace dbaui -//........................................................................ diff --git a/dbaccess/source/ui/dlg/datasourceui.hxx b/dbaccess/source/ui/dlg/datasourceui.hxx deleted file mode 100644 index b18e3e725..000000000 --- a/dbaccess/source/ui/dlg/datasourceui.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************* - * - * 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 - * - * $RCSfile: datasourceui.hxx,v $ - * $Revision: 1.3.68.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef DBACCESS_DATASOURCEUI_HXX -#define DBACCESS_DATASOURCEUI_HXX - -#include "dsntypes.hxx" -#include "dsmeta.hxx" - -/** === begin UNO includes === **/ -/** === end UNO includes === **/ - -#include <boost/shared_ptr.hpp> - -//........................................................................ -namespace dbaui -{ -//........................................................................ - - //==================================================================== - //= DataSourceUI - //==================================================================== - /** encapsulates information about available UI features of a data source type - */ - class DataSourceUI - { - public: - DataSourceUI( const DataSourceMetaData& _rDSMeta ); - ~DataSourceUI(); - - /** returns whether the data source's UI contains the specified setting - - Note that at the moment, not all items are supported by this method. In particular, use - it for the following only - <ul><li>All items which refer to advanced settings (see AdvancedSettingsSupport)</li> - </ul> - - A complete support of *all* items is a medium-term goal. - - @param _nItemId - the UI's item ID for the setting in question. See dsitems.hxx. - */ - bool hasSetting( const USHORT _nItemId ) const; - - private: - DataSourceMetaData m_aDSMeta; - }; - -//........................................................................ -} // namespace dbaui -//........................................................................ - -#endif // DBACCESS_DATASOURCEUI_HXX diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index 937e8b4cf..29a02c53f 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -31,58 +31,26 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#include "dsnItem.hxx" -#ifndef _DBAUI_DBADMIN_HXX_ -#include "dbadmin.hxx" -#endif -#ifndef _DBAUI_DBADMIN_HRC_ +#include "ConnectionPage.hxx" +#include "DbAdminImpl.hxx" +#include "DriverSettings.hxx" +#include "adminpages.hxx" #include "dbadmin.hrc" -#endif -#ifndef _DBU_DLG_HRC_ +#include "dbadmin.hxx" #include "dbu_dlg.hrc" -#endif -#ifndef _DBAUI_DATASOURCEITEMS_HXX_ -#include "dsitems.hxx" -#endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> -#endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> -#endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> -#endif -#ifndef _SV_MSGBOX_HXX -#include <vcl/msgbox.hxx> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef _DBAUI_ADMINPAGES_HXX_ -#include "adminpages.hxx" -#endif -#ifndef _DBAUI_LOCALRESACCESS_HXX_ +#include "dsitems.hxx" +#include "dsnItem.hxx" #include "localresaccess.hxx" -#endif -#ifndef _DBAUI_STRINGLISTITEM_HXX_ -#include "stringlistitem.hxx" -#endif -#ifndef _DBAUI_PROPERTYSETITEM_HXX_ +#include "optionalboolitem.hxx" #include "propertysetitem.hxx" -#endif -#ifndef _UNOTOOLS_CONFIGNODE_HXX_ +#include "stringlistitem.hxx" + +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <unotools/confignode.hxx> -#endif -#ifndef DBAUI_CONNECTIONPAGE_HXX -#include "ConnectionPage.hxx" -#endif -#ifndef DBAUI_DRIVERSETTINGS_HXX -#include "DriverSettings.hxx" -#endif -#ifndef _DBAUI_DBADMINIMPL_HXX_ -#include "DbAdminImpl.hxx" -#endif +#include <vcl/msgbox.hxx> //......................................................................... namespace dbaui @@ -153,16 +121,6 @@ void ODbAdminDialog::PageCreated(USHORT _nId, SfxTabPage& _rPage) SfxTabDialog::PageCreated(_nId, _rPage); } -// ----------------------------------------------------------------------------- -void ODbAdminDialog::removeDetailPages() -{ - // remove all current detail pages - while (m_aCurrentDetailPages.size()) - { - RemoveTabPage((USHORT)m_aCurrentDetailPages.top()); - m_aCurrentDetailPages.pop(); - } -} // ----------------------------------------------------------------------------- void ODbAdminDialog::addDetailPage(USHORT _nPageId, USHORT _nTextId, CreateTabPage _pCreateFunc) @@ -449,8 +407,9 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp *pCounter++ = new SfxBoolItem(DSID_CHECK_REQUIRED_FIELDS, sal_True); *pCounter++ = new SfxBoolItem(DSID_IGNORECURRENCY, sal_False); *pCounter++ = new SfxStringItem(DSID_CONN_SOCKET, String()); - *pCounter++ = new SfxBoolItem(DSID_ESCAPE_DATETIME, sal_True); // must be the same as in ModelImpl.cxx + *pCounter++ = new SfxBoolItem(DSID_ESCAPE_DATETIME, sal_True); *pCounter++ = new SfxStringItem(DSID_NAMED_PIPE, String()); + *pCounter++ = new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT ); // create the pool static SfxItemInfo __READONLY_DATA aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1] = @@ -510,7 +469,8 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp {0,0}, {0,0}, {0,0}, - {0,0}, /* for Escape DateTime*/ + {0,0}, + {0,0}, {0,0}, {0,0} }; diff --git a/dbaccess/source/ui/dlg/dbadminsetup.src b/dbaccess/source/ui/dlg/dbadminsetup.src index 7bc1d861a..d20553c9c 100644 --- a/dbaccess/source/ui/dlg/dbadminsetup.src +++ b/dbaccess/source/ui/dlg/dbadminsetup.src @@ -315,7 +315,7 @@ TabPage PAGE_DBWIZARD_FINAL { Pos = MAP_APPFONT (START_X , 100 ) ; Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 8 ) ; - Text[ en-US ] = "~After the database file has been saved, what do you want to do?" ; + Text[ en-US ] = "After the database file has been saved, what do you want to do?" ; }; CheckBox CB_OPENAFTERWARDS diff --git a/dbaccess/source/ui/dlg/dbfindex.cxx b/dbaccess/source/ui/dlg/dbfindex.cxx index 1e591d7c2..64f49e10f 100644 --- a/dbaccess/source/ui/dlg/dbfindex.cxx +++ b/dbaccess/source/ui/dlg/dbfindex.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 @@ -60,13 +60,13 @@ #include <tools/urlobj.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef _UCBHELPER_CONTENT_HXX #include <ucbhelper/content.hxx> #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index faa752820..2ba3bdfad 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -45,13 +45,13 @@ #endif #include "dsnItem.hxx" #ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #endif #ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 22cb00e2d..1c7f2a587 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.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 @@ -40,16 +40,16 @@ #include "dsnItem.hxx" #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #endif #ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> @@ -156,7 +156,7 @@ #ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ #include <com/sun/star/frame/XDesktop.hpp> #endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ +#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ #include <com/sun/star/sdbc/XDriverAccess.hpp> #endif #ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_ @@ -169,7 +169,7 @@ /** === end UNO includes === **/ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #include <comphelper/interaction.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -313,7 +313,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent m_pCollection->fillPageIds(sURLPrefix,aPath); aPath.push_back(PAGE_DBSETUPWIZARD_AUTHENTIFICATION); aPath.push_back(PAGE_DBSETUPWIZARD_FINAL); - + declareAuthDepPath(sURLPrefix,i,aPath); } @@ -587,7 +587,7 @@ Reference< XDriver > ODbTypeWizDialogSetup::getDriver() { if (m_pMySQLIntroPage != NULL) { - switch( m_pMySQLIntroPage->getMySQLMode() ) + switch( m_pMySQLIntroPage->getMySQLMode() ) { case OMySQLIntroPageSetup::VIA_JDBC: return ::dbaccess::DST_MYSQL_JDBC; @@ -609,7 +609,7 @@ Reference< XDriver > ODbTypeWizDialogSetup::getDriver() ::rtl::OUString sRet = m_pImpl->getDatasourceType(_rSet); if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() ) { - switch( m_pMySQLIntroPage->getMySQLMode() ) + switch( m_pMySQLIntroPage->getMySQLMode() ) { case OMySQLIntroPageSetup::VIA_JDBC: sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); @@ -859,7 +859,7 @@ namespace Reference < XInteractionRequest > xRequest( pRequest ); OInteractionAbort* pAbort = new OInteractionAbort; pRequest->addContinuation( pAbort ); - + return _rxHandler->handleInteractionRequest( xRequest ); } } @@ -1190,7 +1190,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() { throw TerminationVetoException(); } - + // ............................................................................. void SAL_CALL AsyncLoader::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException) { diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx index 24183ab37..76f1b31ea 100644 --- a/dbaccess/source/ui/dlg/detailpages.cxx +++ b/dbaccess/source/ui/dlg/detailpages.cxx @@ -46,16 +46,16 @@ #include "dbadmin.hrc" #ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif #ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #endif #ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> @@ -64,7 +64,7 @@ #include <vcl/mnemonic.hxx> #endif #ifndef _SVTOOLS_CJKOPTIONS_HXX -#include <svtools/cjkoptions.hxx> +#include <svl/cjkoptions.hxx> #endif #include <jvmaccess/virtualmachine.hxx> #ifndef DBAUI_ADABASPAGE_HRC diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx index 0e18cfc23..795cf352f 100644 --- a/dbaccess/source/ui/dlg/directsql.cxx +++ b/dbaccess/source/ui/dlg/directsql.cxx @@ -171,13 +171,6 @@ DBG_NAME(DirectSQLDialog) } //-------------------------------------------------------------------- - void DirectSQLDialog::addHistoryEntry(const String& _rStatement) - { - CHECK_INVARIANTS("DirectSQLDialog::addHistoryEntry"); - implAddToStatementHistory(_rStatement); - } - - //-------------------------------------------------------------------- sal_Int32 DirectSQLDialog::getHistorySize() const { CHECK_INVARIANTS("DirectSQLDialog::getHistorySize"); diff --git a/dbaccess/source/ui/dlg/dlgattr.cxx b/dbaccess/source/ui/dlg/dlgattr.cxx index b1d7f41bb..e882d293e 100644 --- a/dbaccess/source/ui/dlg/dlgattr.cxx +++ b/dbaccess/source/ui/dlg/dlgattr.cxx @@ -66,16 +66,16 @@ #include "dbu_dlg.hrc" #endif #ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif #define _ZFORLIST_DECLARE_TABLE #ifndef _ZFORLIST_HXX -#include <svtools/zforlist.hxx> +#include <svl/zforlist.hxx> #endif #include <svx/svxids.hrc> //CHINA001 #include <svx/flagsdef.hxx> //CHINA001 #ifndef _SFXINTITEM_HXX //CHINA001 -#include <svtools/intitem.hxx> //CHINA001 +#include <svl/intitem.hxx> //CHINA001 #endif //CHINA001 #ifndef _DBAUI_MODULE_DBU_HXX_ #include "moduledbu.hxx" diff --git a/dbaccess/source/ui/dlg/dsnItem.hxx b/dbaccess/source/ui/dlg/dsnItem.hxx index 80ed787ea..ebfd36090 100644 --- a/dbaccess/source/ui/dlg/dsnItem.hxx +++ b/dbaccess/source/ui/dlg/dsnItem.hxx @@ -32,7 +32,7 @@ #ifndef _DBAUI_DSNITEM_HXX_ #define _DBAUI_DSNITEM_HXX_ -#include <svtools/poolitem.hxx> +#include <svl/poolitem.hxx> //......................................................................... namespace dbaccess diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx index 5d2ec3627..f6a1eb043 100644 --- a/dbaccess/source/ui/dlg/dsselect.cxx +++ b/dbaccess/source/ui/dlg/dsselect.cxx @@ -84,16 +84,16 @@ #include "dsitems.hxx" #endif #ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #endif #ifndef _SFXITEMSET_HXX -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif //......................................................................... diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 48bbf77fb..f37efae73 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -44,7 +44,7 @@ #include <vcl/stdtext.hxx> #include "localresaccess.hxx" #include <vcl/msgbox.hxx> -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #include <vcl/waitobj.hxx> #include <com/sun/star/sdbc/XDriverAccess.hpp> #include <com/sun/star/beans/PropertyValue.hpp> diff --git a/dbaccess/source/ui/dlg/makefile.mk b/dbaccess/source/ui/dlg/makefile.mk index ca2098778..2ec59f3d7 100644 --- a/dbaccess/source/ui/dlg/makefile.mk +++ b/dbaccess/source/ui/dlg/makefile.mk @@ -124,13 +124,13 @@ EXCEPTIONSFILES= \ $(SLO)$/DriverSettings.obj \ $(SLO)$/odbcconfig.obj \ $(SLO)$/advancedsettings.obj \ - $(SLO)$/datasourceui.obj \ $(SLO)$/textconnectionsettings.obj SLOFILES= \ $(EXCEPTIONSFILES) \ $(SLO)$/dlgsize.obj \ - $(SLO)$/dlgattr.obj + $(SLO)$/dlgattr.obj \ + $(SLO)$/optionalboolitem.obj .IF "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"=="" DISABLE_ADO=TRUE diff --git a/dbaccess/source/ui/dlg/optionalboolitem.cxx b/dbaccess/source/ui/dlg/optionalboolitem.cxx new file mode 100644 index 000000000..19087a740 --- /dev/null +++ b/dbaccess/source/ui/dlg/optionalboolitem.cxx @@ -0,0 +1,75 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "optionalboolitem.hxx" + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= OptionalBoolItem + //==================================================================== + TYPEINIT1( OptionalBoolItem, SfxPoolItem ); + //-------------------------------------------------------------------- + OptionalBoolItem::OptionalBoolItem( sal_Int16 _nWhich ) + :SfxPoolItem( _nWhich ) + ,m_aValue() + { + } + + //-------------------------------------------------------------------- + OptionalBoolItem::OptionalBoolItem( const OptionalBoolItem& _rSource ) + :SfxPoolItem( _rSource ) + ,m_aValue( _rSource.m_aValue ) + { + } + + //-------------------------------------------------------------------- + int OptionalBoolItem::operator==( const SfxPoolItem& _rItem ) const + { + const OptionalBoolItem* pCompare = PTR_CAST( OptionalBoolItem, &_rItem ); + if ( !pCompare ) + return 0; + + if ( m_aValue == pCompare->m_aValue ) + return 1; + + return 0; + } + + //-------------------------------------------------------------------- + SfxPoolItem* OptionalBoolItem::Clone( SfxItemPool* /*_pPool*/ ) const + { + return new OptionalBoolItem( *this ); + } + +//........................................................................ +} // namespace dbaui +//........................................................................ diff --git a/dbaccess/source/ui/dlg/optionalboolitem.hxx b/dbaccess/source/ui/dlg/optionalboolitem.hxx new file mode 100644 index 000000000..19ff87d53 --- /dev/null +++ b/dbaccess/source/ui/dlg/optionalboolitem.hxx @@ -0,0 +1,66 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef DBACCESS_OPTIONALBOOLITEM_HXX +#define DBACCESS_OPTIONALBOOLITEM_HXX + +#include <svl/poolitem.hxx> + +#include <boost/optional.hpp> + +//........................................................................ +namespace dbaui +{ +//........................................................................ + + //==================================================================== + //= OptionalBoolItem + //==================================================================== + class OptionalBoolItem : public SfxPoolItem + { + ::boost::optional< bool > m_aValue; + + public: + TYPEINFO(); + OptionalBoolItem( sal_Int16 nWhich ); + OptionalBoolItem( const OptionalBoolItem& _rSource ); + + virtual int operator==( const SfxPoolItem& _rItem ) const; + virtual SfxPoolItem* Clone( SfxItemPool* _pPool = NULL ) const; + + bool HasValue() const { return !!m_aValue; } + void ClearValue() { m_aValue.reset(); } + bool GetValue() const { return *m_aValue; } + void SetValue( const bool _bValue ) { m_aValue.reset( _bValue ); } + + const ::boost::optional< bool >& + GetFullValue() const { return m_aValue; } + }; + +//........................................................................ +} // namespace dbaui +//........................................................................ + +#endif // DBACCESS_OPTIONALBOOLITEM_HXX diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx index 906f8a334..b68ca3a64 100644 --- a/dbaccess/source/ui/dlg/paramdialog.cxx +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -72,7 +72,7 @@ #include "localresaccess.hxx" #endif #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #endif #define EF_VISITED 0x0001 diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx index 02883dfce..032d8009c 100644 --- a/dbaccess/source/ui/dlg/tablespage.cxx +++ b/dbaccess/source/ui/dlg/tablespage.cxx @@ -62,10 +62,10 @@ #include "stringlistitem.hxx" #endif #ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #endif #ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #endif #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" diff --git a/dbaccess/source/ui/inc/GeneralUndo.hxx b/dbaccess/source/ui/inc/GeneralUndo.hxx index 715b3ecdc..44a8caba0 100644 --- a/dbaccess/source/ui/inc/GeneralUndo.hxx +++ b/dbaccess/source/ui/inc/GeneralUndo.hxx @@ -31,7 +31,7 @@ #define DBAUI_GENERALUNDO_HXX #ifndef _UNDO_HXX -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #endif #ifndef _DBAUI_MODULE_DBU_HXX_ #include "moduledbu.hxx" diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx index 66bf1b259..a273542db 100644 --- a/dbaccess/source/ui/inc/TypeInfo.hxx +++ b/dbaccess/source/ui/inc/TypeInfo.hxx @@ -83,6 +83,7 @@ const sal_uInt16 TYPE_BLOB = 27; const sal_uInt16 TYPE_CLOB = 28; const sal_uInt16 TYPE_REF = 29; const sal_uInt16 TYPE_OTHER = 30; +const sal_uInt16 TYPE_BIT = 31; class OTypeInfo { diff --git a/dbaccess/source/ui/inc/brwctrlr.hxx b/dbaccess/source/ui/inc/brwctrlr.hxx index 0b3da2498..f91dd9a42 100644 --- a/dbaccess/source/ui/inc/brwctrlr.hxx +++ b/dbaccess/source/ui/inc/brwctrlr.hxx @@ -56,7 +56,7 @@ #include <svtools/transfer.hxx> #include <osl/mutex.hxx> #include <vos/thread.hxx> -#include <svtools/cancel.hxx> +#include <svl/cancel.hxx> #include <cppuhelper/implbase9.hxx> #include <svtools/cliplistener.hxx> diff --git a/dbaccess/source/ui/inc/databaseobjectview.hxx b/dbaccess/source/ui/inc/databaseobjectview.hxx index 0e64160e6..675e751ae 100644 --- a/dbaccess/source/ui/inc/databaseobjectview.hxx +++ b/dbaccess/source/ui/inc/databaseobjectview.hxx @@ -280,18 +280,6 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame ); }; - //====================================================================== - //= ReportDesigner - //====================================================================== - class ReportDesigner : public DatabaseObjectView - { - public: - ReportDesigner( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame - ); - }; // ......................................................................... } // namespace dbaui // ......................................................................... diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx index 3dcd68f5c..fa04f32d3 100644 --- a/dbaccess/source/ui/inc/dbadmin.hxx +++ b/dbaccess/source/ui/inc/dbadmin.hxx @@ -114,8 +114,6 @@ public: protected: // adds a new detail page and remove all the old ones void addDetailPage(USHORT _nPageId,USHORT _nTextId,CreateTabPage pCreateFunc); - // removes all detail pages - void removeDetailPages(); virtual void PageCreated(USHORT _nId, SfxTabPage& _rPage); virtual short Ok(); diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc index de4492e9f..86e4a489a 100644 --- a/dbaccess/source/ui/inc/dbu_resource.hrc +++ b/dbaccess/source/ui/inc/dbu_resource.hrc @@ -32,7 +32,7 @@ #define _DBU_RESOURCE_HRC_ #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif #define RID_DIALOG_START RID_DBACCESS_START diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx index 752a5ec2a..7eed79487 100644 --- a/dbaccess/source/ui/inc/directsql.hxx +++ b/dbaccess/source/ui/inc/directsql.hxx @@ -108,9 +108,6 @@ namespace dbaui const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn); ~DirectSQLDialog(); - /// add an history entry - void addHistoryEntry(const String& _rStatement); - /// number of history entries sal_Int32 getHistorySize() const; diff --git a/dbaccess/source/ui/dlg/dsitems.hxx b/dbaccess/source/ui/inc/dsitems.hxx index 97ed22ba4..b53d4dc1a 100644 --- a/dbaccess/source/ui/dlg/dsitems.hxx +++ b/dbaccess/source/ui/inc/dsitems.hxx @@ -31,6 +31,8 @@ #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #define _DBAUI_DATASOURCEITEMS_HXX_ +typedef sal_Int32 ItemID; + //======================================================================== //= item ids for the data source administration dialog @@ -92,6 +94,7 @@ #define DSID_CONN_SOCKET 56 #define DSID_ESCAPE_DATETIME 57 #define DSID_NAMED_PIPE 58 +#define DSID_PRIMARY_KEY_SUPPORT 59 // don't forget to adjust DSID_LAST_ITEM_ID below! @@ -99,7 +102,7 @@ //= item range. Adjust this if you introduce new items above #define DSID_FIRST_ITEM_ID DSID_NAME -#define DSID_LAST_ITEM_ID DSID_NAMED_PIPE +#define DSID_LAST_ITEM_ID DSID_PRIMARY_KEY_SUPPORT #endif // _DBAUI_DATASOURCEITEMS_HXX_ diff --git a/dbaccess/source/ui/inc/dsmeta.hxx b/dbaccess/source/ui/inc/dsmeta.hxx index 874e09427..1c646231b 100644 --- a/dbaccess/source/ui/inc/dsmeta.hxx +++ b/dbaccess/source/ui/inc/dsmeta.hxx @@ -32,6 +32,7 @@ #define DBACCESS_DSMETA_HXX #include "dsntypes.hxx" +#include "dsitems.hxx" /** === begin UNO includes === **/ /** === end UNO includes === **/ @@ -56,7 +57,7 @@ namespace dbaui //==================================================================== //= DataSourceMetaData //==================================================================== - struct AdvancedSettingsSupport; + class FeatureSet; class DataSourceMetaData_Impl; /** encapsulates meta data for a data source @@ -74,11 +75,9 @@ namespace dbaui ~DataSourceMetaData(); /// returns a struct describing this data source type's support for our known advanced settings - const AdvancedSettingsSupport& getAdvancedSettingsSupport() const; + const FeatureSet& getFeatureSet() const; /// determines whether or not the data source requires authentication - AuthenticationMode getAuthentication() const; - static AuthenticationMode getAuthentication( const ::rtl::OUString& _sURL ); private: @@ -86,77 +85,56 @@ namespace dbaui }; //==================================================================== - //= AdvancedSettingsSupport + //= FeatureSet //==================================================================== - /// struct taking flags for the supported advanced settings - struct AdvancedSettingsSupport + /** can be used to ask for (UI) support for certain advanced features + */ + class FeatureSet { - // auto-generated values - bool bGeneratedValues; - // various settings as found on the "Special Settings" page in the UI - bool bUseSQL92NamingConstraints; - bool bAppendTableAliasInSelect; - bool bUseKeywordAsBeforeAlias; - bool bUseBracketedOuterJoinSyntax; - bool bIgnoreDriverPrivileges; - bool bParameterNameSubstitution; - bool bDisplayVersionColumns; - bool bUseCatalogInSelect; - bool bUseSchemaInSelect; - bool bUseIndexDirectionKeyword; - bool bUseDOSLineEnds; - bool bBooleanComparisonMode; - bool bFormsCheckRequiredFields; - bool bIgnoreCurrency; - bool bEscapeDateTime; - - // Note: If you extend this list, you need to adjust the ctor (of course) - // and (maybe) the implementation of supportsAnySpecialSetting - - AdvancedSettingsSupport() - :bGeneratedValues ( true ) - ,bUseSQL92NamingConstraints ( true ) - ,bAppendTableAliasInSelect ( true ) - ,bUseKeywordAsBeforeAlias ( true ) - ,bUseBracketedOuterJoinSyntax ( true ) - ,bIgnoreDriverPrivileges ( true ) - ,bParameterNameSubstitution ( true ) - ,bDisplayVersionColumns ( true ) - ,bUseCatalogInSelect ( true ) - ,bUseSchemaInSelect ( true ) - ,bUseIndexDirectionKeyword ( true ) - ,bUseDOSLineEnds ( true ) - ,bBooleanComparisonMode ( true ) - ,bFormsCheckRequiredFields ( true ) - ,bIgnoreCurrency ( false ) - ,bEscapeDateTime ( false ) - { - } - - /** determines whether there is support for any of the settings found on the "Special Settings" - UI - */ - inline bool supportsAnySpecialSetting() const; + public: + typedef ::std::set< ItemID >::const_iterator const_iterator; + + public: + inline FeatureSet() { } + + inline void put( const ItemID _id ) { m_aContent.insert( _id ); } + inline bool has( const ItemID _id ) const { return m_aContent.find( _id ) != m_aContent.end(); } + + inline bool supportsAnySpecialSetting() const; + inline bool supportsGeneratedValues() const; + + inline const_iterator begin() const { return m_aContent.begin(); } + inline const_iterator end() const { return m_aContent.end(); } + + private: + ::std::set< ItemID > m_aContent; }; //-------------------------------------------------------------------- - inline bool AdvancedSettingsSupport::supportsAnySpecialSetting() const + inline bool FeatureSet::supportsGeneratedValues() const + { + return has( DSID_AUTORETRIEVEENABLED ); + } + + //-------------------------------------------------------------------- + inline bool FeatureSet::supportsAnySpecialSetting() const { - return ( bUseSQL92NamingConstraints == true ) - || ( bAppendTableAliasInSelect == true ) - || ( bUseKeywordAsBeforeAlias == true ) - || ( bUseBracketedOuterJoinSyntax == true ) - || ( bIgnoreDriverPrivileges == true ) - || ( bParameterNameSubstitution == true ) - || ( bDisplayVersionColumns == true ) - || ( bUseCatalogInSelect == true ) - || ( bUseSchemaInSelect == true ) - || ( bUseIndexDirectionKeyword == true ) - || ( bUseDOSLineEnds == true ) - || ( bBooleanComparisonMode == true ) - || ( bFormsCheckRequiredFields == true ) - || ( bIgnoreCurrency == true ) - || ( bEscapeDateTime == true ) + return has( DSID_SQL92CHECK ) + || has( DSID_APPEND_TABLE_ALIAS ) + || has( DSID_AS_BEFORE_CORRNAME ) + || has( DSID_ENABLEOUTERJOIN ) + || has( DSID_IGNOREDRIVER_PRIV ) + || has( DSID_PARAMETERNAMESUBST ) + || has( DSID_SUPPRESSVERSIONCL ) + || has( DSID_CATALOG ) + || has( DSID_SCHEMA ) + || has( DSID_INDEXAPPENDIX ) + || has( DSID_DOSLINEENDS ) + || has( DSID_BOOLEANCOMPARISON ) + || has( DSID_CHECK_REQUIRED_FIELDS ) + || has( DSID_IGNORECURRENCY ) + || has( DSID_ESCAPE_DATETIME ) + || has( DSID_PRIMARY_KEY_SUPPORT ) ; } diff --git a/dbaccess/source/ui/inc/exsrcbrw.hxx b/dbaccess/source/ui/inc/exsrcbrw.hxx index 092c4d05b..6a5e46369 100644 --- a/dbaccess/source/ui/inc/exsrcbrw.hxx +++ b/dbaccess/source/ui/inc/exsrcbrw.hxx @@ -31,18 +31,11 @@ #ifndef _SBA_EXTCTRLR_HXX #define _SBA_EXTCTRLR_HXX -#ifndef _SBA_BWRCTRLR_HXX #include "brwctrlr.hxx" -#endif -#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_ -#include <com/sun/star/form/XFormController.hpp> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ + #include <comphelper/uno3.hxx> -#endif -#ifndef _CPPUHELPER_IMPLBASE2_HXX_ #include <cppuhelper/implbase2.hxx> -#endif + //============================================================================== //= SbaExternalSourceBrowser //============================================================================== diff --git a/dbaccess/source/ui/inc/indexdialog.hxx b/dbaccess/source/ui/inc/indexdialog.hxx index c79b24ba1..8e247d6a6 100644 --- a/dbaccess/source/ui/inc/indexdialog.hxx +++ b/dbaccess/source/ui/inc/indexdialog.hxx @@ -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 @@ -34,13 +34,13 @@ #ifndef _SV_DIALOG_HXX #include <vcl/dialog.hxx> #endif -#ifndef _SV_FIXED_HXX +#ifndef _SV_FIXED_HXX #include <vcl/fixed.hxx> #endif -#ifndef _SV_LSTBOX_HXX +#ifndef _SV_LSTBOX_HXX #include <vcl/lstbox.hxx> #endif -#ifndef _SV_BUTTON_HXX +#ifndef _SV_BUTTON_HXX #include <vcl/button.hxx> #endif #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ @@ -55,14 +55,14 @@ #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ #include <com/sun/star/uno/Sequence.hxx> #endif -#ifndef _SV_TOOLBOX_HXX +#ifndef _SV_TOOLBOX_HXX #include <vcl/toolbox.hxx> #endif -#ifndef _SVTREEBOX_HXX +#ifndef _SVTREEBOX_HXX #include <svtools/svtreebx.hxx> #endif #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX -#include <svtools/viewoptions.hxx> +#include <unotools/viewoptions.hxx> #endif #ifndef _DBAUI_INDEXES_HXX_ #include "indexes.hxx" diff --git a/dbaccess/source/ui/inc/opendoccontrols.hxx b/dbaccess/source/ui/inc/opendoccontrols.hxx index facf13834..f677153d6 100644 --- a/dbaccess/source/ui/inc/opendoccontrols.hxx +++ b/dbaccess/source/ui/inc/opendoccontrols.hxx @@ -61,7 +61,6 @@ namespace dbaui ::rtl::OUString m_sModule; public: - OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, WinBits _nStyle = 0 ); OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId ); protected: @@ -81,7 +80,6 @@ namespace dbaui MapIndexToStringPair m_aURLs; public: - OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, WinBits _nStyle = WB_BORDER ); OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId ); String GetSelectedDocumentURL() const; diff --git a/dbaccess/source/ui/inc/propertysetitem.hxx b/dbaccess/source/ui/inc/propertysetitem.hxx index 57e104740..84af1d2cb 100644 --- a/dbaccess/source/ui/inc/propertysetitem.hxx +++ b/dbaccess/source/ui/inc/propertysetitem.hxx @@ -32,7 +32,7 @@ #define _DBAUI_PROPERTYSETITEM_HXX_ #ifndef _SFXPOOLITEM_HXX -#include <svtools/poolitem.hxx> +#include <svl/poolitem.hxx> #endif #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx index e77d8106d..d75ecfac8 100644 --- a/dbaccess/source/ui/inc/querycontroller.hxx +++ b/dbaccess/source/ui/inc/querycontroller.hxx @@ -54,7 +54,7 @@ #include <connectivity/sqliterator.hxx> #include <connectivity/sqlnode.hxx> #include <connectivity/sqlparse.hxx> -#include <svtools/undo.hxx> +#include <svl/undo.hxx> class VCLXWindow; namespace dbaui diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx index b062c1357..4438d15d1 100644 --- a/dbaccess/source/ui/inc/sqledit.hxx +++ b/dbaccess/source/ui/inc/sqledit.hxx @@ -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,14 +31,14 @@ #define DBAUI_SQLEDIT_HXX #include <svtools/editsyntaxhighlighter.hxx> -#include <svtools/lstner.hxx> +#include <svl/lstner.hxx> #include <svtools/colorcfg.hxx> -#include <svtools/sourceviewconfig.hxx> +#include <unotools/sourceviewconfig.hxx> namespace dbaui { class OQueryTextView; - class OSqlEdit : public MultiLineEditSyntaxHighlight, SfxListener + class OSqlEdit : public MultiLineEditSyntaxHighlight, utl::ConfigurationListener { private: Timer m_timerInvalidate; @@ -48,13 +48,13 @@ namespace dbaui OQueryTextView* m_pView; BOOL m_bAccelAction; // Wird bei Cut, Copy, Paste gesetzt BOOL m_bStopTimer; - svt::SourceViewConfig m_SourceViewConfig; + utl::SourceViewConfig m_SourceViewConfig; svtools::ColorConfig m_ColorConfig; DECL_LINK(OnUndoActionTimer, void*); DECL_LINK(OnInvalidateTimer, void*); - private: + private: void ImplSetFont(); protected: @@ -82,7 +82,7 @@ namespace dbaui void stopTimer(); void startTimer(); - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ); using MultiLineEditSyntaxHighlight::Notify; }; } diff --git a/dbaccess/source/ui/inc/stringlistitem.hxx b/dbaccess/source/ui/inc/stringlistitem.hxx index b17fb3b27..eac15b847 100644 --- a/dbaccess/source/ui/inc/stringlistitem.hxx +++ b/dbaccess/source/ui/inc/stringlistitem.hxx @@ -32,7 +32,7 @@ #define _DBAUI_STRINGLISTITEM_HXX_ #ifndef _SFXPOOLITEM_HXX -#include <svtools/poolitem.hxx> +#include <svl/poolitem.hxx> #endif #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index 0e0ee7f1c..5ae86c6f0 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -70,8 +70,11 @@ #ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECTCONTAINER_HPP_ #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> #endif -#ifndef _CPPUHELPER_IMPLBASE4_HXX_ -#include <cppuhelper/implbase4.hxx> +#ifndef _COM_SUN_STAR_SDB_DATABASEOBJECTCONTAINER_HPP_ +#include <com/sun/star/sdb/XDatabaseRegistrationsListener.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include <cppuhelper/implbase5.hxx> #endif #ifndef _DBACCESS_UI_CALLBACKS_HXX_ #include "callbacks.hxx" @@ -113,10 +116,11 @@ namespace dbaui class ImageProvider; // ===================================================================== - typedef ::cppu::ImplHelper4 < ::com::sun::star::frame::XStatusListener + typedef ::cppu::ImplHelper5 < ::com::sun::star::frame::XStatusListener , ::com::sun::star::view::XSelectionSupplier , ::com::sun::star::document::XScriptInvocationContext , ::com::sun::star::ui::XContextMenuInterception + , ::com::sun::star::sdb::XDatabaseRegistrationsListener > SbaTableQueryBrowser_Base; class SbaTableQueryBrowser :public SbaXDataBrowserController @@ -256,6 +260,11 @@ namespace dbaui virtual void SAL_CALL registerContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); + // XDatabaseRegistrationsListener + virtual void SAL_CALL registeredDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL revokedDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL changedDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + protected: // SbaXDataBrowserController overridables virtual sal_Bool InitializeForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & xForm); @@ -339,6 +348,11 @@ namespace dbaui const SharedConnection& _rxConnection ); + void implAddDatasource( const String& _rDataSourceName, const SharedConnection& _rxConnection ); + + /// removes (and cleans up) the entry for the given data source + void impl_cleanupDataSourceEntry( const String& _rDataSourceName ); + /// clears the tree list box void clearTreeModel(); diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index 8f559e2a4..bd83952e2 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -50,7 +50,7 @@ #include "dbu_misc.hrc" #include <connectivity/dbconversion.hxx> #include <sfx2/sfxhtml.hxx> -#include <svtools/numuno.hxx> +#include <svl/numuno.hxx> #include <connectivity/dbtools.hxx> #include <comphelper/extract.hxx> #include "TypeInfo.hxx" @@ -65,8 +65,8 @@ #include "WCopyTable.hxx" #include "WExtendPages.hxx" #include "WCPage.hxx" -#include <svtools/syslocale.hxx> -#include <svtools/zforlist.hxx> +#include <unotools/syslocale.hxx> +#include <svl/zforlist.hxx> #include <connectivity/dbexception.hxx> #include <connectivity/FValue.hxx> #include <com/sun/star/sdbc/SQLWarning.hpp> diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx index 1bf5f4d9d..cd5ee5ca5 100644 --- a/dbaccess/source/ui/misc/HtmlReader.cxx +++ b/dbaccess/source/ui/misc/HtmlReader.cxx @@ -63,7 +63,7 @@ #include "QEnumTypes.hxx" #include "WCPage.hxx" #include <tools/inetmime.hxx> -#include <svtools/inettype.hxx> +#include <svl/inettype.hxx> #include <rtl/tencinfo.h> #include "UITools.hxx" #include <vcl/svapp.hxx> diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx index 9e27554d9..74bd146bc 100644 --- a/dbaccess/source/ui/misc/RowSetDrop.cxx +++ b/dbaccess/source/ui/misc/RowSetDrop.cxx @@ -237,6 +237,12 @@ sal_Bool ORowSetImportExport::insertNewRow() case DataType::VARBINARY: aValue <<= m_xRow->getBytes(*aIter); break; + case DataType::BLOB: + aValue <<= m_xRow->getBlob(*aIter); + break; + case DataType::CLOB: + aValue <<= m_xRow->getClob(*aIter); + break; default: OSL_ENSURE(0,"Unknown type"); } diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx index c2536ea72..7dcf57338 100644 --- a/dbaccess/source/ui/misc/TokenWriter.cxx +++ b/dbaccess/source/ui/misc/TokenWriter.cxx @@ -55,7 +55,7 @@ #include <tools/color.hxx> #include <svtools/htmlout.hxx> #include <sfx2/frmhtmlw.hxx> -#include <svtools/numuno.hxx> +#include <svl/numuno.hxx> #include <vcl/svapp.hxx> #include "UITools.hxx" #include <toolkit/helper/vclunohelper.hxx> @@ -63,7 +63,7 @@ #include <svtools/rtfout.hxx> #include <svx/htmlcfg.hxx> #include <connectivity/formattedcolumnvalue.hxx> -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #include <comphelper/componentcontext.hxx> #include <rtl/logfile.hxx> diff --git a/dbaccess/source/ui/misc/ToolBoxHelper.cxx b/dbaccess/source/ui/misc/ToolBoxHelper.cxx index be7a105ae..db1b72181 100644 --- a/dbaccess/source/ui/misc/ToolBoxHelper.cxx +++ b/dbaccess/source/ui/misc/ToolBoxHelper.cxx @@ -61,13 +61,13 @@ namespace dbaui DBG_CTOR(OToolBoxHelper,NULL); OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical"); - SvtMiscOptions().AddListener( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); + SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) ); } // ----------------------------------------------------------------------------- OToolBoxHelper::~OToolBoxHelper() { - SvtMiscOptions().RemoveListener( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); + SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) ); DBG_DTOR(OToolBoxHelper,NULL); } diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index ee136d8d5..28d9efe1a 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.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 @@ -198,7 +198,7 @@ #define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO #ifndef _SFXITEMPOOL_HXX -#include <svtools/itempool.hxx> +#include <svl/itempool.hxx> #endif #ifndef _STRING_HXX #include <tools/string.hxx> @@ -207,16 +207,16 @@ #include "dbaccess_helpid.hrc" #endif #ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #endif #ifndef DBACCESS_SBA_GRID_HRC #include "sbagrid.hrc" #endif #ifndef _SFXRNGITEM_HXX -#include <svtools/rngitem.hxx> +#include <svl/rngitem.hxx> #endif #ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #endif #ifndef _SVX_ALGITEM_HXX #include <svx/algitem.hxx> @@ -229,7 +229,7 @@ #include <svx/numinf.hxx> #endif #ifndef _ZFORLIST_HXX -#include <svtools/zforlist.hxx> +#include <svl/zforlist.hxx> #endif #ifndef DBAUI_SBATTRDLG_HXX #include "dlgattr.hxx" @@ -283,13 +283,13 @@ #include <tools/diagnose_ex.h> #endif #ifndef _NUMUNO_HXX -#include <svtools/numuno.hxx> +#include <svl/numuno.hxx> #endif #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef _SVT_FILEVIEW_HXX #include <svtools/fileview.hxx> @@ -803,6 +803,12 @@ void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxCon aName = _rsTypeNames.GetToken(TYPE_DATETIME); break; case DataType::BIT: + if ( pInfo->aCreateParams.getLength() ) + { + aName = _rsTypeNames.GetToken(TYPE_BIT); + break; + } + // run through case DataType::BOOLEAN: aName = _rsTypeNames.GetToken(TYPE_BOOL); break; @@ -1155,7 +1161,7 @@ sal_Bool callColumnFormatDialog(Window* _pParent, if (_bHasFormat) { // if the col is bound to a text field we have to disallow all non-text formats - if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType)) + if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType)) { bText = sal_True; pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True)); @@ -1622,6 +1628,10 @@ TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rType if ( pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) ) break; break; + case DataType::LONGVARCHAR: + if ( pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) ) + break; + break; default: ; } // switch(_nDataType) diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 79ac5958e..9196fc9f0 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -63,6 +63,7 @@ #include <comphelper/extract.hxx> #include <comphelper/types.hxx> #include <connectivity/dbtools.hxx> +#include <connectivity/dbmetadata.hxx> #include <rtl/logfile.hxx> #include <rtl/ustrbuf.hxx> @@ -632,6 +633,22 @@ OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rD if ( !lcl_sameConnection_throw( _xSourceConnection, m_xDestConnection ) ) bAllowViews = false; + if ( m_bInterConnectionCopy ) + { + Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData(); + ::rtl::OUString sCatalog; + ::rtl::OUString sSchema; + ::rtl::OUString sTable; + ::dbtools::qualifiedNameComponents( xSrcMeta, + m_sName, + sCatalog, + sSchema, + sTable, + ::dbtools::eInDataManipulation); + + m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,sal_False,::dbtools::eInTableDefinitions); + } + OCopyTable* pPage1( new OCopyTable( this ) ); pPage1->disallowUseHeaderLine(); if ( !bAllowViews ) @@ -1381,23 +1398,12 @@ Reference< XPropertySet > OCopyTableWizard::createTable() // ----------------------------------------------------------------------------- bool OCopyTableWizard::supportsPrimaryKey( const Reference< XConnection >& _rxConnection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::supportsPrimaryKey" ); OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsPrimaryKey: invalid connection!" ); + if ( !_rxConnection.is() ) + return false; - bool bSupports( false ); - if ( _rxConnection.is() ) - { - try - { - Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_QUERY_THROW ); - bSupports = xMetaData->supportsCoreSQLGrammar(); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - return bSupports; + ::dbtools::DatabaseMetaData aMetaData( _rxConnection ); + return aMetaData.supportsPrimaryKeys(); } // ----------------------------------------------------------------------------- @@ -1591,6 +1597,10 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool& if ( supportsType(DataType::LONGVARCHAR,nDefaultType) ) break; break; + case DataType::LONGVARCHAR: + if ( supportsType(DataType::CLOB,nDefaultType) ) + break; + break; default: nDefaultType = DataType::VARCHAR; } diff --git a/dbaccess/source/ui/misc/controllerframe.cxx b/dbaccess/source/ui/misc/controllerframe.cxx index b7ccf472a..3b937896a 100644 --- a/dbaccess/source/ui/misc/controllerframe.cxx +++ b/dbaccess/source/ui/misc/controllerframe.cxx @@ -44,6 +44,8 @@ #include <rtl/ref.hxx> #include <sfx2/objsh.hxx> #include <tools/diagnose_ex.h> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/window.hxx> //........................................................................ namespace dbaui @@ -77,6 +79,7 @@ namespace dbaui using ::com::sun::star::lang::DisposedException; using ::com::sun::star::lang::EventObject; using ::com::sun::star::document::XDocumentEventBroadcaster; + using ::com::sun::star::awt::XWindow; /** === end UNO using === **/ //==================================================================== @@ -125,7 +128,7 @@ namespace dbaui ,m_xDocEventBroadcaster() ,m_pListener() ,m_bActive( false ) - ,m_bLivesInTopWindow( false ) + ,m_bIsTopLevelDocumentWindow( false ) { } @@ -134,7 +137,7 @@ namespace dbaui Reference< XDocumentEventBroadcaster > m_xDocEventBroadcaster; ::rtl::Reference< FrameWindowActivationListener > m_pListener; bool m_bActive; - bool m_bLivesInTopWindow; + bool m_bIsTopLevelDocumentWindow; }; //==================================================================== @@ -208,7 +211,7 @@ namespace dbaui if ( !xCompController.is() ) return; - if ( _rData.m_bActive && _rData.m_bLivesInTopWindow ) + if ( _rData.m_bActive && _rData.m_bIsTopLevelDocumentWindow ) { // set the "current component" at the SfxObjectShell Reference< XModel > xModel( xCompController->getModel() ); @@ -288,9 +291,21 @@ namespace dbaui void ( SAL_CALL XTopWindow::*pListenerAction )( const Reference< XTopWindowListener >& ) = _bRegister ? &XTopWindow::addTopWindowListener : &XTopWindow::removeTopWindowListener; - Reference< XTopWindow > xFrameContainer( m_pData->m_xFrame->getContainerWindow(), UNO_QUERY ); + const Reference< XWindow > xContainerWindow( m_pData->m_xFrame->getContainerWindow(), UNO_SET_THROW ); if ( _bRegister ) - m_pData->m_bLivesInTopWindow = xFrameContainer.is(); + { + const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + ENSURE_OR_THROW( pContainerWindow, "no Window implementation for the frame's container window!" ); + + /*const Window* pContainerParentWindow = pContainerWindow->GetParent(); + if ( pContainerParentWindow && ( pContainerParentWindow->GetType() == WINDOW_BORDERWINDOW ) ) + pContainerParentWindow = pContainerParentWindow->GetParent(); + m_pData->m_bIsTopLevelDocumentWindow = ( pContainerParentWindow == NULL );*/ + + m_pData->m_bIsTopLevelDocumentWindow = ( pContainerWindow->GetExtendedStyle() & WB_EXT_DOCUMENT ) != 0; + } + + const Reference< XTopWindow > xFrameContainer( xContainerWindow, UNO_QUERY ); if ( xFrameContainer.is() ) (xFrameContainer.get()->*pListenerAction)( this ); } diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx index ca9b3d28b..10b7e5604 100644 --- a/dbaccess/source/ui/misc/databaseobjectview.cxx +++ b/dbaccess/source/ui/misc/databaseobjectview.cxx @@ -31,66 +31,30 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX #include "databaseobjectview.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef DBACCESS_ASYNCMODALDIALOG_HXX #include "asyncmodaldialog.hxx" -#endif /** === begin UNO includes === **/ -#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ #include <com/sun/star/lang/XSingleServiceFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ #include <com/sun/star/frame/XDispatchProvider.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ #include <com/sun/star/frame/XFrame.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAMES_HPP_ #include <com/sun/star/frame/XFrames.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include <com/sun/star/frame/FrameSearchFlag.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_APPLICATION_XTABLEUIPROVIDER_HPP_ #include <com/sun/star/sdb/application/XTableUIProvider.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ #include <com/sun/star/beans/NamedValue.hpp> -#endif -#ifndef _COM_SUN_STAR_AWT_RECTANGLE_HPP_ #include <com/sun/star/awt/Rectangle.hpp> -#endif /** === end UNO includes === **/ -#ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> -#endif -#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX #include <comphelper/namedvaluecollection.hxx> -#endif - -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif - -#ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H +#include <toolkit/helper/vclunohelper.hxx> #include <tools/diagnose_ex.h> -#endif +#include <vcl/window.hxx> // ......................................................................... namespace dbaui @@ -183,6 +147,15 @@ namespace dbaui lArgs[nArg++] <<= aProp; m_xFrameLoader.set(xFact->createInstanceWithArguments(lArgs), UNO_QUERY_THROW); + + // everything we load can be considered a "top level document", so set the respective bit at the window. + // This, amongst other things, triggers that the component in this task participates in the + // "ThisComponent"-game for the global application Basic. + const Reference< XFrame > xFrame( m_xFrameLoader, UNO_QUERY_THROW ); + const Reference< XWindow > xFrameWindow( xFrame->getContainerWindow(), UNO_SET_THROW ); + Window* pContainerWindow = VCLUnoHelper::GetWindow( xFrameWindow ); + ENSURE_OR_THROW( pContainerWindow, "no implementation access to the frame's container window!" ); + pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT ); } Reference< XComponentLoader > xFrameLoader( m_xFrameLoader, UNO_QUERY_THROW ); @@ -405,16 +378,6 @@ namespace dbaui :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast< ::rtl::OUString >( URL_COMPONENT_RELATIONDESIGN ) ) { } - //====================================================================== - //= ReportDesigner - //====================================================================== - //---------------------------------------------------------------------- - ReportDesigner::ReportDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication , const Reference< XFrame >& _rxParentFrame) - :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame,static_cast< ::rtl::OUString >( URL_COMPONENT_REPORTDESIGN ) ) - { - } - - // ......................................................................... } // namespace dbaui // ......................................................................... diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx index 3612bb0da..963e97f36 100644 --- a/dbaccess/source/ui/misc/datasourceconnector.cxx +++ b/dbaccess/source/ui/misc/datasourceconnector.cxx @@ -86,7 +86,7 @@ #include <vcl/button.hxx> #endif #ifndef SVTOOLS_FILENOTATION_HXX -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> diff --git a/dbaccess/source/ui/misc/documentcontroller.cxx b/dbaccess/source/ui/misc/documentcontroller.cxx index 34132b99c..f844eff3c 100644 --- a/dbaccess/source/ui/misc/documentcontroller.cxx +++ b/dbaccess/source/ui/misc/documentcontroller.cxx @@ -58,16 +58,6 @@ namespace dbaui } //-------------------------------------------------------------------- - ModelControllerConnector::ModelControllerConnector( const Reference< XModel >& _rxModel, const Reference< XController >& _rxController ) - :m_xModel( _rxModel ) - ,m_xController( _rxController ) - { - DBG_CTOR( ModelControllerConnector, NULL ); - DBG_ASSERT( _rxModel.is() && m_xController.is(), "ModelControllerConnector::ModelControllerConnector: invalid model or controller!" ); - impl_connect(); - } - - //-------------------------------------------------------------------- ModelControllerConnector::ModelControllerConnector( const ModelControllerConnector& _rSource ) { DBG_CTOR( ModelControllerConnector, NULL ); diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx index 847bc8799..657a37f9c 100644 --- a/dbaccess/source/ui/misc/dsmeta.cxx +++ b/dbaccess/source/ui/misc/dsmeta.cxx @@ -47,32 +47,6 @@ namespace dbaui using namespace ::com::sun::star; /** === end UNO using === **/ - struct InitAdvanced : public AdvancedSettingsSupport - { - enum Special { All, AllButIgnoreCurrency, None }; - - InitAdvanced( Special _eType ) - :AdvancedSettingsSupport() - { - bGeneratedValues = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseSQL92NamingConstraints = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bAppendTableAliasInSelect = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseKeywordAsBeforeAlias = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseBracketedOuterJoinSyntax = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bIgnoreDriverPrivileges = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bParameterNameSubstitution = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bDisplayVersionColumns = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseCatalogInSelect = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseSchemaInSelect = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseIndexDirectionKeyword = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bUseDOSLineEnds = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bBooleanComparisonMode = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bFormsCheckRequiredFields = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - bIgnoreCurrency = ( _eType == All ); - bEscapeDateTime = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); - } - }; - struct FeatureSupport { // authentication mode of the data source @@ -89,98 +63,75 @@ namespace dbaui } }; + struct FeatureMapping + { + /// one of the items from dsitems.hxx + ItemID nItemID; + const sal_Char* pAsciiFeatureName; + }; + //==================================================================== //= global tables //==================================================================== //-------------------------------------------------------------------- - static const AdvancedSettingsSupport& getAdvancedSettingsSupport( const ::rtl::OUString& _sURL ) + static const FeatureMapping* lcl_getFeatureMappings() { - DECLARE_STL_USTRINGACCESS_MAP( AdvancedSettingsSupport, AdvancedSupport); - static AdvancedSupport s_aSupport; - if ( s_aSupport.empty() ) + static const FeatureMapping s_aMappings[] = { + { DSID_AUTORETRIEVEENABLED, "GeneratedValues" }, + { DSID_AUTOINCREMENTVALUE, "GeneratedValues" }, + { DSID_AUTORETRIEVEVALUE, "GeneratedValues" }, + { DSID_SQL92CHECK, "UseSQL92NamingConstraints" }, + { DSID_APPEND_TABLE_ALIAS, "AppendTableAliasInSelect" }, + { DSID_AS_BEFORE_CORRNAME, "UseKeywordAsBeforeAlias" }, + { DSID_ENABLEOUTERJOIN, "UseBracketedOuterJoinSyntax" }, + { DSID_IGNOREDRIVER_PRIV, "IgnoreDriverPrivileges" }, + { DSID_PARAMETERNAMESUBST, "ParameterNameSubstitution" }, + { DSID_SUPPRESSVERSIONCL, "DisplayVersionColumns" }, + { DSID_CATALOG, "UseCatalogInSelect" }, + { DSID_SCHEMA, "UseSchemaInSelect" }, + { DSID_INDEXAPPENDIX, "UseIndexDirectionKeyword" }, + { DSID_DOSLINEENDS, "UseDOSLineEnds" }, + { DSID_BOOLEANCOMPARISON, "BooleanComparisonMode" }, + { DSID_CHECK_REQUIRED_FIELDS, "FormsCheckRequiredFields" }, + { DSID_IGNORECURRENCY, "IgnoreCurrency" }, + { DSID_ESCAPE_DATETIME, "EscapeDateTime" }, + { DSID_PRIMARY_KEY_SUPPORT, "PrimaryKeySupport" }, + { 0, NULL } + }; + return s_aMappings; + } + + //-------------------------------------------------------------------- + static const FeatureSet& lcl_getFeatureSet( const ::rtl::OUString _rURL ) + { + typedef ::std::map< ::rtl::OUString, FeatureSet, ::comphelper::UStringLess > FeatureSets; + static FeatureSets s_aFeatureSets; + if ( s_aFeatureSets.empty() ) { - ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessServiceFactory()); - const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs(); - const ::rtl::OUString* pIter = aURLs.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aURLs.getLength(); - for(;pIter != pEnd;++pIter) + ::connectivity::DriversConfig aDriverConfig( ::comphelper::getProcessServiceFactory() ); + const uno::Sequence< ::rtl::OUString > aPatterns = aDriverConfig.getURLs(); + for ( const ::rtl::OUString* pattern = aPatterns.getConstArray(); + pattern != aPatterns.getConstArray() + aPatterns.getLength(); + ++pattern + ) { - InitAdvanced aInit(InitAdvanced::None); - const uno::Sequence< beans::NamedValue> aProperties = aDriverConfig.getFeatures(*pIter).getNamedValues(); - const beans::NamedValue* pPropertiesIter = aProperties.getConstArray(); - const beans::NamedValue* pPropertiesEnd = pPropertiesIter + aProperties.getLength(); - for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter) + FeatureSet aCurrentSet; + const ::comphelper::NamedValueCollection aCurrentFeatures( aDriverConfig.getFeatures( *pattern ).getNamedValues() ); + + const FeatureMapping* pFeatureMapping = lcl_getFeatureMappings(); + while ( pFeatureMapping->pAsciiFeatureName ) { - if ( pPropertiesIter->Name.equalsAscii("GeneratedValues") ) - { - pPropertiesIter->Value >>= aInit.bGeneratedValues; - } - else if ( pPropertiesIter->Name.equalsAscii("UseSQL92NamingConstraints") ) - { - pPropertiesIter->Value >>= aInit.bUseSQL92NamingConstraints; - } - else if ( pPropertiesIter->Name.equalsAscii("AppendTableAliasInSelect") ) - { - pPropertiesIter->Value >>= aInit.bAppendTableAliasInSelect; - } - else if ( pPropertiesIter->Name.equalsAscii("UseKeywordAsBeforeAlias") ) - { - pPropertiesIter->Value >>= aInit.bUseKeywordAsBeforeAlias; - } - else if ( pPropertiesIter->Name.equalsAscii("UseBracketedOuterJoinSyntax") ) - { - pPropertiesIter->Value >>= aInit.bUseBracketedOuterJoinSyntax; - } - else if ( pPropertiesIter->Name.equalsAscii("IgnoreDriverPrivileges") ) - { - pPropertiesIter->Value >>= aInit.bIgnoreDriverPrivileges; - } - else if ( pPropertiesIter->Name.equalsAscii("ParameterNameSubstitution") ) - { - pPropertiesIter->Value >>= aInit.bParameterNameSubstitution; - } - else if ( pPropertiesIter->Name.equalsAscii("DisplayVersionColumns") ) - { - pPropertiesIter->Value >>= aInit.bDisplayVersionColumns; - } - else if ( pPropertiesIter->Name.equalsAscii("UseCatalogInSelect") ) - { - pPropertiesIter->Value >>= aInit.bUseCatalogInSelect; - } - else if ( pPropertiesIter->Name.equalsAscii("UseSchemaInSelect") ) - { - pPropertiesIter->Value >>= aInit.bUseSchemaInSelect; - } - else if ( pPropertiesIter->Name.equalsAscii("UseIndexDirectionKeyword") ) - { - pPropertiesIter->Value >>= aInit.bUseIndexDirectionKeyword; - } - else if ( pPropertiesIter->Name.equalsAscii("UseDOSLineEnds") ) - { - pPropertiesIter->Value >>= aInit.bUseDOSLineEnds; - } - else if ( pPropertiesIter->Name.equalsAscii("BooleanComparisonMode") ) - { - pPropertiesIter->Value >>= aInit.bBooleanComparisonMode; - } - else if ( pPropertiesIter->Name.equalsAscii("FormsCheckRequiredFields") ) - { - pPropertiesIter->Value >>= aInit.bFormsCheckRequiredFields; - } - else if ( pPropertiesIter->Name.equalsAscii("IgnoreCurrency") ) - { - pPropertiesIter->Value >>= aInit.bIgnoreCurrency; - } - else if ( pPropertiesIter->Name.equalsAscii("EscapeDateTime") ) - { - pPropertiesIter->Value >>= aInit.bEscapeDateTime; - } - } // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter) - s_aSupport.insert(AdvancedSupport::value_type(*pIter,aInit)); + if ( aCurrentFeatures.has( pFeatureMapping->pAsciiFeatureName ) ) + aCurrentSet.put( pFeatureMapping->nItemID ); + ++pFeatureMapping; + } + + s_aFeatureSets[ *pattern ] = aCurrentSet; } - } // if ( s_aSupport.empty() ) - OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!"); - return s_aSupport[ _sURL ]; + } + + OSL_ENSURE( s_aFeatureSets.find( _rURL ) != s_aFeatureSets.end(), "invalid URL/pattern!" ); + return s_aFeatureSets[ _rURL ]; } //-------------------------------------------------------------------- @@ -208,8 +159,8 @@ namespace dbaui aInit = AuthPwd; } s_aSupport.insert(Supported::value_type(*pIter,aInit)); - } // for(;pIter != pEnd;++pIter) - } // if ( s_aSupport.empty() ) + } + } OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!"); return s_aSupport[ _sURL ].eAuthentication; } @@ -249,15 +200,9 @@ namespace dbaui } //-------------------------------------------------------------------- - const AdvancedSettingsSupport& DataSourceMetaData::getAdvancedSettingsSupport() const - { - return ::dbaui::getAdvancedSettingsSupport( m_pImpl->getType() ); - } - - //-------------------------------------------------------------------- - AuthenticationMode DataSourceMetaData::getAuthentication() const + const FeatureSet& DataSourceMetaData::getFeatureSet() const { - return getAuthenticationMode( m_pImpl->getType() ); + return lcl_getFeatureSet( m_pImpl->getType() ); } //-------------------------------------------------------------------- diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx index 5906492a8..7877c0bd8 100644 --- a/dbaccess/source/ui/misc/linkeddocuments.cxx +++ b/dbaccess/source/ui/misc/linkeddocuments.cxx @@ -92,7 +92,7 @@ #include "dbu_misc.hrc" #endif #ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svtools/filenotation.hxx> +#include <svl/filenotation.hxx> #endif #ifndef DBACCESS_UI_BROWSER_ID_HXX #include "browserids.hxx" @@ -279,10 +279,11 @@ namespace dbaui { ::svx::ODataAccessDescriptor aDesc; aDesc.setDataSource(m_sDataSourceName); - if ( _nCommandType != -1 ) + if ( _rObjectName.getLength() && ( _nCommandType != -1 ) ) + { aDesc[::svx::daCommandType] <<= _nCommandType; - if ( _rObjectName.getLength() ) aDesc[::svx::daCommand] <<= _rObjectName; + } if ( m_xConnection.is() ) aDesc[::svx::daConnection] <<= m_xConnection; @@ -349,7 +350,7 @@ namespace dbaui //------------------------------------------------------------------ Reference< XComponent > OLinkedDocumentsAccess::newDocument( sal_Int32 _nNewFormId, Reference< XComponent >& _xDefinition, const sal_Int32 _nCommandType, const ::rtl::OUString& _sObjectName ) { - OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid document container!"); + OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::newDocument: invalid document container!"); // determine the URL to use for the new document Sequence<sal_Int8> aClassId; switch (_nNewFormId) @@ -372,7 +373,7 @@ namespace dbaui case SID_DB_FORM_NEW_PILOT: default: - OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newForm: pleas use newFormWithPilot!"); + OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newDocument: please use newFormWithPilot!"); return Reference< XComponent >(); } diff --git a/dbaccess/source/ui/misc/moduledbu.cxx b/dbaccess/source/ui/misc/moduledbu.cxx index 3f5e51976..5713171d0 100644 --- a/dbaccess/source/ui/misc/moduledbu.cxx +++ b/dbaccess/source/ui/misc/moduledbu.cxx @@ -39,7 +39,7 @@ #include <tools/resmgr.hxx> #endif #ifndef _SOLAR_HRC -#include <svtools/solar.hrc> +#include <svl/solar.hrc> #endif #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> diff --git a/dbaccess/source/ui/misc/propertystorage.cxx b/dbaccess/source/ui/misc/propertystorage.cxx index 6c2a48580..126460ab7 100644 --- a/dbaccess/source/ui/misc/propertystorage.cxx +++ b/dbaccess/source/ui/misc/propertystorage.cxx @@ -36,9 +36,9 @@ /** === begin UNO includes === **/ /** === end UNO includes === **/ -#include <svtools/itemset.hxx> -#include <svtools/stritem.hxx> -#include <svtools/eitem.hxx> +#include <svl/itemset.hxx> +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> #include <memory> diff --git a/dbaccess/source/ui/querydesign/JoinDesignView.cxx b/dbaccess/source/ui/querydesign/JoinDesignView.cxx index fab7b3d25..2b289081a 100644 --- a/dbaccess/source/ui/querydesign/JoinDesignView.cxx +++ b/dbaccess/source/ui/querydesign/JoinDesignView.cxx @@ -40,7 +40,7 @@ #include "JoinController.hxx" #endif #ifndef _UNDO_HXX -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #endif #ifndef DBAUI_QYDLGTAB_HXX #include "adtabdlg.hxx" diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 948a3d0d4..0fc5c6067 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -70,7 +70,7 @@ #include "browserids.hxx" #endif #ifndef _URLBMK_HXX -#include <svtools/urlbmk.hxx> +#include <svl/urlbmk.hxx> #endif #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 2c926e9af..33c8c725e 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -49,7 +49,7 @@ #include <vcl/split.hxx> #endif #ifndef _UNDO_HXX -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #endif #ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> @@ -133,7 +133,7 @@ #include "sqlmessage.hxx" #endif #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #endif using namespace ::dbaui; @@ -330,86 +330,6 @@ namespace return eErrorCode; } - //------------------------------------------------------------------------------ - ::rtl::OUString QuoteField( const OQueryDesignView* _pView,const ::rtl::OUString& rValue, sal_Int32 aType ) - { - ::rtl::OUString rNewValue; - switch (rValue.toChar()) - { - case '?': - if (rValue.getLength() != 1) - break; - case '\'': // ::rtl::OUString Quotierung oder Datum - //case '#': // Datumsquotierung // jetengine - case ':': // Parameter - case '[': // Parameter - return rValue; - } - - Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection(); - Reference< XDatabaseMetaData > xMetaData; - if(xConnection.is()) - xMetaData = xConnection->getMetaData(); - ::rtl::OUString aQuote; - try - { - if(xMetaData.is()) - aQuote = xMetaData->getIdentifierQuoteString(); - - switch( aType ) - { - case DataType::DATE: - case DataType::TIME: - case DataType::TIMESTAMP: - if (rValue.toChar() != '{') // nur quoten, wenn kein Access Datum - rNewValue = ::dbtools::quoteName(aQuote,rValue); - else - rNewValue = rValue; - break; - case DataType::CHAR: - case DataType::VARCHAR: - case DataType::LONGVARCHAR: - rNewValue = ::dbtools::quoteName(aQuote,rValue); - break; - case DataType::DECIMAL: - case DataType::NUMERIC: - case DataType::TINYINT: - case DataType::SMALLINT: - case DataType::INTEGER: - case DataType::BIGINT: - case DataType::REAL: - case DataType::DOUBLE: - case DataType::BINARY: - case DataType::VARBINARY: - case DataType::LONGVARBINARY: - rNewValue = rValue; - break; - case DataType::BIT: - case DataType::BOOLEAN: - { - if(xMetaData.is()) - { - ::comphelper::UStringMixEqual bCase(xMetaData->supportsMixedCaseQuotedIdentifiers()); - if (bCase(rValue, String(ModuleRes(STR_QUERY_TRUE)))) - rNewValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRUE")); - else if (bCase(rValue, String(ModuleRes(STR_QUERY_FALSE)))) - rNewValue = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FALSE")); - else - rNewValue = rValue; - } - } - break; - default: - DBG_ERROR( "QuoteField: illegal type" ); - break; - } - } - catch(SQLException&) - { - DBG_ERROR( "QuoteField: Exception" ); - } - return rNewValue; - } // ----------------------------------------------------------------------------- /** FillDragInfo fills the field description out of the table @@ -1385,6 +1305,9 @@ namespace // first extract the inner joins conditions GetInnerJoinCriteria(_pView,pNodeTmp); + // now simplify again, join are checked in ComparisonPredicate + ::connectivity::OSQLParseNode::absorptions(pNodeTmp); + pNodeTmp = pNode->getChild(1); // it could happen that pCondition is not more valid eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pNodeTmp, rLevel); @@ -1395,7 +1318,7 @@ namespace SqlParseError GetANDCriteria( OQueryDesignView* _pView, OSelectionBrowseBox* _pSelectionBrw, const ::connectivity::OSQLParseNode * pCondition, - const sal_uInt16 nLevel, + sal_uInt16& nLevel, sal_Bool bHaving, bool bAddOrOnOneLine); //------------------------------------------------------------------------------ @@ -1432,7 +1355,11 @@ namespace if ( SQL_ISRULE(pChild,search_condition) ) eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pChild,nLevel,bHaving,bAddOrOnOneLine); else - eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, bAddOrOnOneLine ? nLevel : nLevel++,bHaving, i == 0 ? false : bAddOrOnOneLine); + { + eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, nLevel,bHaving, i == 0 ? false : bAddOrOnOneLine); + if ( !bAddOrOnOneLine) + nLevel++; + } } } else @@ -1466,7 +1393,7 @@ namespace SqlParseError GetANDCriteria( OQueryDesignView* _pView, OSelectionBrowseBox* _pSelectionBrw, const ::connectivity::OSQLParseNode * pCondition, - const sal_uInt16 nLevel, + sal_uInt16& nLevel, sal_Bool bHaving, bool bAddOrOnOneLine) { @@ -1480,10 +1407,18 @@ namespace // Runde Klammern if (SQL_ISRULE(pCondition,boolean_primary)) { - sal_uInt16 nLevel2 = nLevel; // check if we have to put the or criteria on one line. - bool bMustAddOrOnOneLine = CheckOrCriteria(pCondition->getChild(1),NULL); - eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1), nLevel2,bHaving,bMustAddOrOnOneLine ); + const ::connectivity::OSQLParseNode* pSearchCondition = pCondition->getChild(1); + bool bMustAddOrOnOneLine = CheckOrCriteria(pSearchCondition,NULL); + if ( SQL_ISRULE( pSearchCondition, search_condition) ) // we have a or + { + _pSelectionBrw->DuplicateConditionLevel( nLevel); + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(0), nLevel,bHaving,bMustAddOrOnOneLine ); + ++nLevel; + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(2), nLevel,bHaving,bMustAddOrOnOneLine ); + } + else + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition, nLevel,bHaving,bMustAddOrOnOneLine ); } // Das erste Element ist (wieder) eine AND-Verknuepfung else if ( SQL_ISRULE(pCondition,boolean_term) ) @@ -1579,10 +1514,32 @@ namespace _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine); } } + else + { + // Funktions-Bedingung parsen + ::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1); + Reference< XConnection> xConnection = rController.getConnection(); + Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + // the international doesn't matter I have a string + ::rtl::OUString sName; + pCondition->getChild(0)->parseNodeToPredicateStr(sName, + xConnection, + rController.getNumberFormatter(), + aLocale, + static_cast<sal_Char>(sDecimal.toChar()), + &rController.getParser().getContext()); + + OTableFieldDescRef aDragLeft = new OTableFieldDesc(); + aDragLeft->SetField(sName); + aDragLeft->SetFunctionType(FKT_OTHER); + + if ( bHaving ) + aDragLeft->SetGroupBy(sal_True); + _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine); + } } else if( SQL_ISRULEOR2(pCondition,existence_test,unique_test) ) { - // Funktions-Bedingung parsen ::rtl::OUString aCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,0); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index c1f8f1649..3d59903e3 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -1207,6 +1207,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: if(aText.GetChar(0) != '\'' || aText.GetChar(aText.Len() -1) != '\'') { aText.SearchAndReplaceAll(String::CreateFromAscii("'"),String::CreateFromAscii("''")); @@ -1836,6 +1837,32 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt } } //------------------------------------------------------------------------------ +void OSelectionBrowseBox::DuplicateConditionLevel( const sal_uInt16 nLevel) +{ + DBG_CHKTHIS(OSelectionBrowseBox,NULL); + const sal_uInt16 nNewLevel = nLevel +1; + OTableFields& rFields = getFields(); + OTableFields::iterator aIter = rFields.begin(); + OTableFields::iterator aEnd = rFields.end(); + for(;aIter != aEnd;++aIter) + { + OTableFieldDescRef pEntry = *aIter; + + ::rtl::OUString sValue = pEntry->GetCriteria(nLevel); + if ( sValue.getLength() ) + { + pEntry->SetCriteria( nNewLevel, sValue); + if ( nNewLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1) ) + { + RowInserted( GetRowCount()-1, 1, TRUE ); + m_bVisibleRow.push_back(sal_True); + ++m_nVisibleCount; + } + m_bVisibleRow[BROW_CRIT1_ROW + nNewLevel] = sal_True; + } // if (!pEntry->GetCriteria(nLevel).getLength() ) + } // for(;aIter != getFields().end();++aIter) +} +//------------------------------------------------------------------------------ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const String& rValue, const sal_uInt16 nLevel,bool _bAddOrOnOneLine ) { Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection(); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx index fcc9a5320..ff73a8c10 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx @@ -132,6 +132,7 @@ namespace dbaui const String& rValue, const sal_uInt16 nLevel, bool _bAddOrOnOneLine ); + void DuplicateConditionLevel( const sal_uInt16 nLevel); void AddOrder(const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos); void ClearAll(); OTableFieldDescRef AppendNewCol( sal_uInt16 nCnt=1 ); diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx index 7905aa56f..c88eae53a 100644 --- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx +++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx @@ -229,16 +229,17 @@ namespace dbaui Reference < XFrame > xBeamerFrame( m_pViewSwitch->getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")),UNO_QUERY ); m_xBeamer.set( xBeamerFrame ); + OSL_ENSURE(m_xBeamer.is(),"No frame created!"); + m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) ); // notify layout manager to not create internal toolbars Reference < XPropertySet > xPropSet( xBeamerFrame, UNO_QUERY ); try { const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )); - Reference < XPropertySet > xLMPropSet; + Reference < XPropertySet > xLMPropSet(xPropSet->getPropertyValue( aLayoutManager ),UNO_QUERY); - Any a = xPropSet->getPropertyValue( aLayoutManager ); - if ( a >>= xLMPropSet ) + if ( xLMPropSet.is() ) { const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" )); xLMPropSet->setPropertyValue( aAutomaticToolbars, Any( sal_False )); @@ -248,8 +249,6 @@ namespace dbaui { } - OSL_ENSURE(m_xBeamer.is(),"No frame created!"); - m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) ); m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW); // append our frame diff --git a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx index 7fabf5deb..5c02ef4c9 100644 --- a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx @@ -40,7 +40,7 @@ #include "RelationController.hxx" #endif #ifndef _UNDO_HXX -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #endif #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index fd47db6d2..aade6a93f 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -78,7 +78,7 @@ #include <connectivity/dbexception.hxx> #include "RTableWindow.hxx" #include "JAccess.hxx" -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #include <com/sun/star/accessibility/AccessibleEventId.hpp> using namespace dbaui; diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 8540b4b8d..e78cc2303 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -239,8 +239,19 @@ void OFieldDescription::FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bF if ( bForce ) { sal_Int32 nPrec = DEFAULT_OTHER_PRECSION; - if ( GetPrecision() ) - nPrec = GetPrecision(); + switch ( _pType->nType ) + { + case DataType::BIT: + case DataType::BLOB: + case DataType::CLOB: + nPrec = _pType->nPrecision; + break; + default: + if ( GetPrecision() ) + nPrec = GetPrecision(); + break; + } + if ( _pType->nPrecision ) SetPrecision(::std::min<sal_Int32>(nPrec ? nPrec : DEFAULT_NUMERIC_PRECSION,_pType->nPrecision)); if ( _pType->nMaximumScale ) diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 53022b5ad..bcdd42a38 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -1534,19 +1534,8 @@ sal_Bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ ) return sal_False; OTableController& rController = GetView()->getController(); - try - { - Reference<XConnection> xCon = rController.getConnection(); - - Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>(); - if(!xMetaData.is() || !xMetaData->supportsCoreSQLGrammar()) - return sal_False; // no primary keys allowed - - } - catch(SQLException&) - { - OSL_ASSERT(!"supportsCoreSQLGrammar"); - } + if ( !rController.getSdbMetaData().supportsPrimaryKeys() ) + return sal_False; Reference<XPropertySet> xTable = rController.getTable(); ////////////////////////////////////////////////////////////// diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index f236eb112..f0e0f7c13 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -30,143 +30,62 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBUI_TABLECONTROLLER_HXX -#include "TableController.hxx" -#endif -#ifndef _DBAU_REGHELPER_HXX_ +#include "FieldDescriptions.hxx" +#include "TEditControl.hxx" +#include "TableController.hxx" +#include "TableDesignView.hxx" +#include "TableRow.hxx" +#include "TypeInfo.hxx" +#include "UITools.hxx" +#include "browserids.hxx" #include "dbu_reghelper.hxx" -#endif -#ifndef _STRING_HXX -#include <tools/string.hxx> -#endif -#include <tools/diagnose_ex.h> -#ifndef _SFXSIDS_HRC -#include <sfx2/sfxsids.hrc> -#endif -#ifndef _DBU_TBL_HRC_ #include "dbu_tbl.hrc" -#endif -#ifndef DBACCESS_UI_BROWSER_ID_HXX -#include "browserids.hxx" -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX #include "defaultobjectnamecheck.hxx" -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef DBAUI_DLGSAVE_HXX #include "dlgsave.hxx" -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include "dsmeta.hxx" +#include "indexdialog.hxx" +#include "sqlmessage.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ -#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ -#include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ -#include <com/sun/star/sdbcx/XDrop.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ -#include <com/sun/star/sdbcx/XAlterTable.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ -#include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/XTitleChangeListener.hpp> +#include <com/sun/star/frame/XUntitledNumbers.hpp> +#include <com/sun/star/io/XActiveDataSink.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/SQLContext.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ -#include <com/sun/star/sdbc/SQLWarning.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#include <com/sun/star/sdbcx/XAlterTable.hpp> +#include <com/sun/star/sdbcx/XAppend.hpp> +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#include <com/sun/star/sdbcx/XDrop.hpp> #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> -#endif -#include <com/sun/star/frame/XTitleChangeListener.hpp> -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _COM_SUN_STAR_UI_XEXECUTABLEDIALOG_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#endif -#include <com/sun/star/frame/XUntitledNumbers.hpp> -#ifndef _COMPHELPER_STREAMSECTION_HXX_ +/** === end UNO includes === **/ + +#include <comphelper/extract.hxx> #include <comphelper/streamsection.hxx> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ -#include <com/sun/star/io/XActiveDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_ -#include <com/sun/star/io/XActiveDataSink.hpp> -#endif -#ifndef DBAUI_TABLEDESIGNVIEW_HXX -#include "TableDesignView.hxx" -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ -#include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef DBAUI_FIELDDESCRIPTIONS_HXX -#include "FieldDescriptions.hxx" -#endif -#ifndef DBAUI_TABLEROW_HXX -#include "TableRow.hxx" -#endif -#ifndef DBAUI_TYPEINFO_HXX -#include "TypeInfo.hxx" -#endif -#ifndef DBAUI_TABLEEDITORCONTROL_HXX -#include "TEditControl.hxx" -#endif -#ifndef _DBAUI_SQLMESSAGE_HXX_ -#include "sqlmessage.hxx" -#endif -#ifndef _SV_MSGBOX_HXX +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> +#include <connectivity/dbmetadata.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <sfx2/sfxsids.hrc> +#include <tools/diagnose_ex.h> +#include <tools/string.hxx> #include <vcl/msgbox.hxx> -#endif -#ifndef _DBAUI_INDEXDIALOG_HXX_ -#include "indexdialog.hxx" -#endif -#ifndef DBAUI_TOOLS_HXX -#include "UITools.hxx" -#endif -#ifndef DBAUI_TOOLS_HXX -#include "UITools.hxx" -#endif -#include <boost/mem_fn.hpp> -#ifndef _CPPUHELPER_EXC_HLP_HXX_ -#include <cppuhelper/exc_hlp.hxx> -#endif -#include "dsmeta.hxx" +#include <boost/mem_fn.hpp> #include <boost/bind.hpp> + #include <algorithm> #include <functional> @@ -1089,7 +1008,8 @@ sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star:: { sal_Bool bOk = sal_True; sal_Bool bFoundPKey = sal_False; - Reference< XDatabaseMetaData> xMetaData = getMetaData( ); + Reference< XDatabaseMetaData > xMetaData = getMetaData( ); + DatabaseMetaData aMetaData( getConnection() ); ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True); ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin(); @@ -1115,39 +1035,38 @@ sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star:: } } } - if(!bFoundPKey) + if ( _bNew && !bFoundPKey && aMetaData.supportsPrimaryKeys() ) { - if(_bNew && xMetaData.is() && xMetaData->supportsCoreSQLGrammar()) - { - String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD)); - String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY)); - OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); + String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD)); + String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY)); + OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); - INT16 nReturn = aBox.Execute(); + switch ( aBox.Execute() ) + { + case RET_YES: + { + ::boost::shared_ptr<OTableRow> pNewRow(new OTableRow()); + TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo); + if ( !pTypeInfo.get() ) + break; - if (nReturn == RET_YES) - { - ::boost::shared_ptr<OTableRow> pNewRow(new OTableRow()); - TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo); - - if ( pTypeInfo.get() ) - { - pNewRow->SetFieldType( pTypeInfo ); - OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr(); + pNewRow->SetFieldType( pTypeInfo ); + OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr(); - pActFieldDescr->SetAutoIncrement(sal_False); // #95927# pTypeInfo->bAutoIncrement - pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); + pActFieldDescr->SetAutoIncrement(sal_False); // #95927# pTypeInfo->bAutoIncrement + pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); - pActFieldDescr->SetName( createUniqueName(::rtl::OUString::createFromAscii("ID") )); - pActFieldDescr->SetPrimaryKey( sal_True ); - m_vRowList.insert(m_vRowList.begin(),pNewRow); + pActFieldDescr->SetName( createUniqueName(::rtl::OUString::createFromAscii("ID") )); + pActFieldDescr->SetPrimaryKey( sal_True ); + m_vRowList.insert(m_vRowList.begin(),pNewRow); - static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->Invalidate(); - static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->RowInserted(0); - } // if ( pTypeInfo.get() ) - } - else if (nReturn == RET_CANCEL) - bOk = sal_False; + static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->Invalidate(); + static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->RowInserted(0); + } + break; + case RET_CANCEL: + bOk = sal_False; + break; } } return bOk; @@ -1471,7 +1390,7 @@ void OTableController::alterColumns() bNeedAppendKey = sal_True; } - if ( bNeedDropKey ) + if ( bNeedDropKey && xKeyColumns.is() && xKeyColumns->getElementNames().getLength() ) dropPrimaryKey(); if ( bNeedAppendKey ) diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx index f38c5bcf8..eff3d1390 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignView.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx @@ -64,7 +64,7 @@ #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #endif #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #endif #ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index 17daa1fb5..e084ff76e 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -56,7 +56,7 @@ String STR_TABLEDESIGN_DBFIELDTYPES { - Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER"; + Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER;Bit (fix)"; }; String STR_TABLEDESIGN_UNDO_PRIMKEY diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index eaf7c45e5..e391f2394 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -58,6 +58,8 @@ #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> #include <com/sun/star/sdbc/XParameters.hpp> #include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XBlob.hpp> +#include <com/sun/star/sdbc/XClob.hpp> #include <com/sun/star/sdbcx/XRowLocate.hpp> #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> #include <com/sun/star/sdb/SQLContext.hpp> @@ -127,6 +129,8 @@ namespace dbaui using ::com::sun::star::sdbc::XParameters; using ::com::sun::star::sdbc::XResultSet; using ::com::sun::star::sdbc::XRow; + using ::com::sun::star::sdbc::XBlob; + using ::com::sun::star::sdbc::XClob; using ::com::sun::star::sdbcx::XRowLocate; using ::com::sun::star::sdbc::XResultSetMetaDataSupplier; using ::com::sun::star::sdbc::XResultSetMetaData; @@ -1281,6 +1285,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou case DataType::LONGVARBINARY: case DataType::BINARY: case DataType::VARBINARY: + case DataType::BIT: aTransfer.transferComplexValue( &XRow::getBytes, &XParameters::setBytes ); break; @@ -1295,8 +1300,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou case DataType::TIMESTAMP: aTransfer.transferComplexValue( &XRow::getTimestamp, &XParameters::setTimestamp ); break; - - case DataType::BIT: + case DataType::BOOLEAN: aTransfer.transferValue( &XRow::getBoolean, &XParameters::setBoolean ); break; @@ -1313,6 +1317,14 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou aTransfer.transferValue( &XRow::getInt, &XParameters::setInt ); break; + case DataType::BLOB: + aTransfer.transferComplexValue( &XRow::getBlob, &XParameters::setBlob ); + break; + + case DataType::CLOB: + aTransfer.transferComplexValue( &XRow::getClob, &XParameters::setClob ); + break; + default: { ::rtl::OUString aMessage( String( ModuleRes( STR_CTW_UNSUPPORTED_COLUMN_TYPE ) ) ); |