diff options
Diffstat (limited to 'dbaccess/source/core')
108 files changed, 1155 insertions, 1558 deletions
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index 75dfc24f5869..75b369885e3b 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -27,12 +27,8 @@ using namespace dbaccess; using namespace ::connectivity; using namespace ::dbtools; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace ::osl; void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet,const OUString& i_sRowSetFilter) { diff --git a/dbaccess/source/core/api/CIndexes.cxx b/dbaccess/source/core/api/CIndexes.cxx index 409d877288b8..9b3dd5aefa83 100644 --- a/dbaccess/source/core/api/CIndexes.cxx +++ b/dbaccess/source/core/api/CIndexes.cxx @@ -25,11 +25,8 @@ using namespace connectivity::sdbcx; 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::container; -using namespace ::com::sun::star::lang; using namespace dbaccess; -using namespace cppu; ObjectType OIndexes::createObject(const OUString& _rName) diff --git a/dbaccess/source/core/api/CIndexes.hxx b/dbaccess/source/core/api/CIndexes.hxx index f20da6cbefa9..d8dbeb82a8f6 100644 --- a/dbaccess/source/core/api/CIndexes.hxx +++ b/dbaccess/source/core/api/CIndexes.hxx @@ -20,6 +20,7 @@ #pragma once #include <connectivity/TIndexes.hxx> +#include <utility> namespace dbaccess { @@ -35,9 +36,9 @@ namespace dbaccess OIndexes(connectivity::OTableHelper* _pTable, ::osl::Mutex& _rMutex, const std::vector< OUString> &_rVector, - const css::uno::Reference< css::container::XNameAccess >& _rxIndexes + css::uno::Reference< css::container::XNameAccess > _rxIndexes ) : connectivity::OIndexesHelper(_pTable,_rMutex,_rVector) - ,m_xIndexes(_rxIndexes) + ,m_xIndexes(std::move(_rxIndexes)) {} virtual void disposing() override; diff --git a/dbaccess/source/core/api/CRowSetColumn.cxx b/dbaccess/source/core/api/CRowSetColumn.cxx index 556b1250eec0..98435b7c4498 100644 --- a/dbaccess/source/core/api/CRowSetColumn.cxx +++ b/dbaccess/source/core/api/CRowSetColumn.cxx @@ -19,9 +19,11 @@ #include <stringconstants.hxx> -#include <apitools.hxx> +#include <strings.hxx> #include "CRowSetColumn.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; @@ -42,33 +44,30 @@ ORowSetColumn::ORowSetColumn( const Reference < XResultSetMetaData >& _xMetaData ::cppu::IPropertyArrayHelper* ORowSetColumn::createArrayHelper( ) const { - css::uno::Sequence< css::beans::Property> aDescriptor(21); - css::beans::Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - - pDesc[nPos++] = css::beans::Property(PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_DISPLAYSIZE, PROPERTY_ID_DISPLAYSIZE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISCASESENSITIVE, PROPERTY_ID_ISCASESENSITIVE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISDEFINITELYWRITABLE, PROPERTY_ID_ISDEFINITELYWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISSEARCHABLE, PROPERTY_ID_ISSEARCHABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISSIGNED, PROPERTY_ID_ISSIGNED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISWRITABLE, PROPERTY_ID_ISWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_PRECISION, PROPERTY_ID_PRECISION, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_SCALE, PROPERTY_ID_SCALE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_SERVICENAME, PROPERTY_ID_SERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_TYPE, PROPERTY_ID_TYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_VALUE, PROPERTY_ID_VALUE, cppu::UnoType<Any>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::BOUND); - - OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); + css::uno::Sequence< css::beans::Property> aDescriptor + { + { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_DISPLAYSIZE, PROPERTY_ID_DISPLAYSIZE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISCASESENSITIVE, PROPERTY_ID_ISCASESENSITIVE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISDEFINITELYWRITABLE, PROPERTY_ID_ISDEFINITELYWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISSEARCHABLE, PROPERTY_ID_ISSEARCHABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISSIGNED, PROPERTY_ID_ISSIGNED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISWRITABLE, PROPERTY_ID_ISWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_PRECISION, PROPERTY_ID_PRECISION, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SCALE, PROPERTY_ID_SCALE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SERVICENAME, PROPERTY_ID_SERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TYPE, PROPERTY_ID_TYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_VALUE, PROPERTY_ID_VALUE, cppu::UnoType<Any>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::BOUND} + }; Sequence< Property > aRegisteredProperties; describeProperties( aRegisteredProperties ); diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index e55063b6e2a8..693e1ad3dd75 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -20,11 +20,12 @@ #include "CRowSetDataColumn.hxx" #include <stringconstants.hxx> -#include <apitools.hxx> +#include <strings.hxx> #include <cppuhelper/exc_hlp.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/sdbc/SQLException.hpp> +#include <utility> using namespace dbaccess; using namespace comphelper; @@ -34,7 +35,6 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; using namespace cppu; using namespace osl; @@ -44,13 +44,13 @@ ORowSetDataColumn::ORowSetDataColumn( const Reference < XResultSetMetaData >& _x const Reference < XRowUpdate >& _xRowUpdate, sal_Int32 _nPos, const Reference< XDatabaseMetaData >& _rxDBMeta, - const OUString& _rDescription, - const OUString& i_sLabel, - const std::function<const ORowSetValue& (sal_Int32)> &_getValue) + OUString i_sDescription, + OUString i_sLabel, + std::function<const ORowSetValue& (sal_Int32)> _getValue) :ODataColumn(_xMetaData,_xRow,_xRowUpdate,_nPos,_rxDBMeta) - ,m_pGetValue(_getValue) - ,m_sLabel(i_sLabel) - ,m_aDescription(_rDescription) + ,m_pGetValue(std::move(_getValue)) + ,m_sLabel(std::move(i_sLabel)) + ,m_aDescription(std::move(i_sDescription)) { OColumnSettings::registerProperties( *this ); registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, PropertyAttribute::READONLY, &m_aDescription, cppu::UnoType<decltype(m_aDescription)>::get() ); @@ -63,32 +63,30 @@ ORowSetDataColumn::~ORowSetDataColumn() // comphelper::OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* ORowSetDataColumn::createArrayHelper( ) const { - css::uno::Sequence< css::beans::Property> aDescriptor(21); - css::beans::Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - pDesc[nPos++] = css::beans::Property(PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_DISPLAYSIZE, PROPERTY_ID_DISPLAYSIZE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISCASESENSITIVE, PROPERTY_ID_ISCASESENSITIVE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISDEFINITELYWRITABLE, PROPERTY_ID_ISDEFINITELYWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISSEARCHABLE, PROPERTY_ID_ISSEARCHABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISSIGNED, PROPERTY_ID_ISSIGNED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISWRITABLE, PROPERTY_ID_ISWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_PRECISION, PROPERTY_ID_PRECISION, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_SCALE, PROPERTY_ID_SCALE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_SERVICENAME, PROPERTY_ID_SERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_TYPE, PROPERTY_ID_TYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY ); - pDesc[nPos++] = css::beans::Property(PROPERTY_VALUE, PROPERTY_ID_VALUE, cppu::UnoType<Any>::get(), css::beans::PropertyAttribute::BOUND ); - - OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); + css::uno::Sequence< css::beans::Property> aDescriptor + { + { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_DISPLAYSIZE, PROPERTY_ID_DISPLAYSIZE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISCASESENSITIVE, PROPERTY_ID_ISCASESENSITIVE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISDEFINITELYWRITABLE, PROPERTY_ID_ISDEFINITELYWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISSEARCHABLE, PROPERTY_ID_ISSEARCHABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISSIGNED, PROPERTY_ID_ISSIGNED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISWRITABLE, PROPERTY_ID_ISWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_PRECISION, PROPERTY_ID_PRECISION, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SCALE, PROPERTY_ID_SCALE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SERVICENAME, PROPERTY_ID_SERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TYPE, PROPERTY_ID_TYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_VALUE, PROPERTY_ID_VALUE, cppu::UnoType<Any>::get(), css::beans::PropertyAttribute::BOUND } + }; Sequence< Property > aRegisteredProperties; describeProperties( aRegisteredProperties ); @@ -194,12 +192,12 @@ void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue) ORowSetDataColumns::ORowSetDataColumns( bool _bCase, - const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns, + ::rtl::Reference< ::connectivity::OSQLColumns> _xColumns, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const std::vector< OUString> &_rVector ) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) - ,m_aColumns(_rColumns) + ,m_aColumns(std::move(_xColumns)) { } diff --git a/dbaccess/source/core/api/CRowSetDataColumn.hxx b/dbaccess/source/core/api/CRowSetDataColumn.hxx index f0efcbf8d85c..a19aad8497e5 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.hxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.hxx @@ -49,9 +49,9 @@ namespace dbaccess const css::uno::Reference < css::sdbc::XRowUpdate >& _xRowUpdate, sal_Int32 _nPos, const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rxDBMeta, - const OUString& _rDescription, - const OUString& i_sLabel, - const std::function<const ::connectivity::ORowSetValue& (sal_Int32)> &_getValue); + OUString i_sDescription, + OUString i_sLabel, + std::function<const ::connectivity::ORowSetValue& (sal_Int32)> _getValue); // css::lang::XTypeProvider @@ -84,7 +84,7 @@ namespace dbaccess public: ORowSetDataColumns( bool _bCase, - const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns, + ::rtl::Reference< ::connectivity::OSQLColumns> _xColumns, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const std::vector< OUString> &_rVector diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index 366a727be58d..dd266949cb7f 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -36,7 +36,7 @@ #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <osl/diagnose.h> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace comphelper; @@ -50,7 +50,6 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::io; -using namespace ::osl; OCacheSet::OCacheSet(sal_Int32 i_nMaxRows) @@ -167,7 +166,7 @@ void OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQ aSql[aSql.getLength() - 1] = ')'; aValues[aValues.getLength() - 1] = ')'; - aSql.append(aValues.makeStringAndClear()); + aSql.append(aValues); // now create end execute the prepared statement { Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); @@ -282,7 +281,7 @@ void OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOri { aCondition.setLength(aCondition.getLength()-5); - aSql.append(" WHERE " + aCondition.makeStringAndClear()); + aSql.append(" WHERE " + aCondition); } else ::dbtools::throwSQLException( diff --git a/dbaccess/source/core/api/FilteredContainer.cxx b/dbaccess/source/core/api/FilteredContainer.cxx index 70eb85210a80..955a7f1c222f 100644 --- a/dbaccess/source/core/api/FilteredContainer.cxx +++ b/dbaccess/source/core/api/FilteredContainer.cxx @@ -26,7 +26,7 @@ #include <comphelper/types.hxx> #include <connectivity/dbtools.hxx> #include <tools/wldcrd.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <optional> #include <sal/log.hxx> @@ -34,12 +34,8 @@ namespace dbaccess { using namespace dbtools; using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; - using namespace ::com::sun::star::sdb; - using namespace ::com::sun::star::sdbcx; - using namespace ::com::sun::star::util; using namespace ::com::sun::star::container; using namespace ::osl; using namespace ::comphelper; @@ -132,7 +128,7 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: static void lcl_ensureComposedName( TableInfo& _io_tableInfo, const Reference< XDatabaseMetaData >& _metaData ) { if ( !_metaData.is() ) - throw RuntimeException(); + throw RuntimeException("lcl_ensureComposedName: _metaData cannot be null!"); if ( !_io_tableInfo.sComposedName ) { @@ -153,7 +149,7 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: lcl_ensureComposedName( _io_tableInfo, _metaData ); if ( !_masterContainer.is() ) - throw RuntimeException(); + throw RuntimeException("lcl_ensureType: _masterContainer cannot be null!"); OUString sTypeName; try @@ -341,7 +337,7 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: } } - static constexpr OUStringLiteral sAll = u"%"; + static constexpr OUString sAll = u"%"_ustr; Reference< XResultSet > xTables = m_xMetaData->getTables( Any(), sAll, sAll, aTableTypeFilter ); Reference< XRow > xCurrentRow( xTables, UNO_QUERY_THROW ); @@ -430,9 +426,9 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std:: OSL_VERIFY( aFilterModeSetting >>= nFilterMode ); } - static const OUStringLiteral sAll( u"%" ); - static const OUStringLiteral sView( u"VIEW" ); - static const OUStringLiteral sTable( u"TABLE" ); + static constexpr OUString sAll( u"%"_ustr ); + static constexpr OUString sView( u"VIEW"_ustr ); + static constexpr OUString sTable( u"TABLE"_ustr ); switch ( nFilterMode ) { diff --git a/dbaccess/source/core/api/HelperCollections.cxx b/dbaccess/source/core/api/HelperCollections.cxx index dfc18badc688..2a04b632a7ce 100644 --- a/dbaccess/source/core/api/HelperCollections.cxx +++ b/dbaccess/source/core/api/HelperCollections.cxx @@ -20,6 +20,7 @@ #include "HelperCollections.hxx" #include <strings.hxx> +#include <utility> #include <osl/diagnose.h> @@ -30,23 +31,19 @@ namespace dbaccess using namespace connectivity; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; - using namespace ::com::sun::star::sdbcx; - using namespace ::com::sun::star::container; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::script; using namespace ::cppu; using namespace ::osl; - OPrivateColumns::OPrivateColumns(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns, + OPrivateColumns::OPrivateColumns(::rtl::Reference< ::connectivity::OSQLColumns> _xColumns, bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const std::vector< OUString> &_rVector, bool _bUseAsIndex ) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector,_bUseAsIndex) - ,m_aColumns(_rColumns) + ,m_aColumns(std::move(_xColumns)) { } diff --git a/dbaccess/source/core/api/HelperCollections.hxx b/dbaccess/source/core/api/HelperCollections.hxx index ed89fc643054..2c066064de54 100644 --- a/dbaccess/source/core/api/HelperCollections.hxx +++ b/dbaccess/source/core/api/HelperCollections.hxx @@ -25,15 +25,10 @@ namespace dbaccess { using namespace dbtools; - using namespace comphelper; using namespace connectivity; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; - using namespace ::com::sun::star::sdbcx; - using namespace ::com::sun::star::container; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::script; using namespace ::cppu; using namespace ::osl; @@ -50,7 +45,7 @@ namespace dbaccess return nullptr; } public: - OPrivateColumns(const ::rtl::Reference< ::connectivity::OSQLColumns>& _rColumns, + OPrivateColumns(::rtl::Reference< ::connectivity::OSQLColumns> _xColumns, bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, @@ -83,7 +78,7 @@ namespace dbaccess return nullptr; } public: - OPrivateTables( const OSQLTables& _rTables, + OPrivateTables( OSQLTables _rTables, bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 86b397cbbff2..4ef85e0ce1af 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <composertools.hxx> +#include <utility> #include "PrivateRow.hxx" using namespace dbaccess; @@ -62,7 +63,6 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; using namespace ::com::sun::star; using namespace ::cppu; -using namespace ::osl; using std::vector; namespace @@ -103,17 +103,17 @@ namespace } -OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, - const OUString& _rUpdateTableName, // this can be the alias or the full qualified name +OKeySet::OKeySet(connectivity::OSQLTable _xTable, + OUString _sUpdateTableName, // this can be the alias or the full qualified name const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, sal_Int32 i_nMaxRows, sal_Int32& o_nRowCount) :OCacheSet(i_nMaxRows) ,m_aParameterValueForCache(new ORowSetValueVector(_aParameterValueForCache)) - ,m_xTable(_xTable) + ,m_xTable(std::move(_xTable)) ,m_xComposer(_xComposer) - ,m_sUpdateTableName(_rUpdateTableName) + ,m_sUpdateTableName(std::move(_sUpdateTableName)) ,m_rRowCount(o_nRowCount) ,m_bRowCountFinal(false) { @@ -282,7 +282,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet, const OUStrin Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); Reference<XColumnsSupplier> xQueryColSup(m_xComposer, UNO_QUERY); const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns(); - findTableColumnsMatching_throw( makeAny(m_xTable), m_sUpdateTableName, xMeta, xQueryColumns, m_pKeyColumnNames ); + findTableColumnsMatching_throw( Any(m_xTable), m_sUpdateTableName, xMeta, xQueryColumns, m_pKeyColumnNames ); Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY); Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); @@ -406,7 +406,7 @@ Any OKeySet::getBookmark() { OSL_ENSURE(m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(), "getBookmark is only possible when we stand on a valid row!"); - return makeAny(m_aKeyIter->first); + return Any(m_aKeyIter->first); } bool OKeySet::moveToBookmark( const Any& bookmark ) @@ -444,9 +444,9 @@ void OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrigi OUStringBuffer aSql = "UPDATE " + m_aComposedTableName + " SET "; // list all columns that should be set - static OUString aPara(" = ?,"); + constexpr OUStringLiteral aPara(u" = ?,"); OUString aQuote = getIdentifierQuoteString(); - static OUString aAnd(" AND "); + constexpr OUString aAnd(u" AND "_ustr); OUString sIsNull(" IS NULL"); OUString sParam(" = ?"); @@ -463,7 +463,6 @@ void OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrigi std::vector<sal_Int32> aIndexColumnPositions; const sal_Int32 nOldLength = aSql.getLength(); - sal_Int32 i = 1; // here we build the condition part for the update statement for (auto const& columnName : *m_pColumnNames) { @@ -499,7 +498,6 @@ void OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrigi { aSql.append(::dbtools::quoteName( aQuote,columnName.second.sRealName) + aPara); } - ++i; } if( aSql.getLength() != nOldLength ) @@ -514,15 +512,15 @@ void OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrigi aSql.append(" WHERE "); if(!sKeyCondition.isEmpty() && !sIndexCondition.isEmpty()) { - aSql.append(sKeyCondition.makeStringAndClear() + sIndexCondition.makeStringAndClear()); + aSql.append(sKeyCondition + sIndexCondition); } else if(!sKeyCondition.isEmpty()) { - aSql.append(sKeyCondition.makeStringAndClear()); + aSql.append(sKeyCondition); } else if(!sIndexCondition.isEmpty()) { - aSql.append(sIndexCondition.makeStringAndClear()); + aSql.append(sIndexCondition); } aSql.setLength(aSql.getLength()-5); // remove the last AND } @@ -540,7 +538,6 @@ void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rO Reference< XParameters > xParameter(xPrep,UNO_QUERY); bool bRefetch = true; - Reference<XRow> xRow; sal_Int32 i = 1; // first the set values for (auto const& columnName : *m_pColumnNames) @@ -584,8 +581,9 @@ void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rO { const sal_Int32 nBookmark = ::comphelper::getINT32((*_rInsertRow)[0].getAny()); m_aKeyIter = m_aKeyMap.find(nBookmark); + assert(m_aKeyIter != m_aKeyMap.end()); m_aKeyIter->second.second.first = 2; - m_aKeyIter->second.second.second = xRow; + m_aKeyIter->second.second.second.clear(); copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark); tryRefetch(_rInsertRow,bRefetch); } @@ -622,7 +620,7 @@ void OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLT aSql[aSql.getLength() - 1] = ')'; aValues[aValues.getLength() - 1] = ')'; - aSql.append(aValues.makeStringAndClear()); + aSql.append(aValues); // now create,fill and execute the prepared statement executeInsert(_rInsertRow,aSql.makeStringAndClear(),u"",bRefetch); } @@ -725,7 +723,7 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const OUString& i_sSQ if(!sMaxStmt.isEmpty()) { sMaxStmt[sMaxStmt.getLength()-1] = ' '; - OUString sStmt = "SELECT " + sMaxStmt.makeStringAndClear() + "FROM "; + OUString sStmt = "SELECT " + sMaxStmt + "FROM "; OUString sCatalog,sSchema,sTable; ::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation); sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); @@ -763,7 +761,7 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const OUString& i_sSQ m_aKeyIter = m_aKeyMap.emplace( aKeyIter->first + 1, OKeySetValue(aKeyRow,std::pair<sal_Int32,Reference<XRow> >(1,Reference<XRow>())) ).first; // now we set the bookmark for this row - (*_rInsertRow)[0] = makeAny(static_cast<sal_Int32>(m_aKeyIter->first)); + (*_rInsertRow)[0] = Any(static_cast<sal_Int32>(m_aKeyIter->first)); tryRefetch(_rInsertRow,bRefetch); } } @@ -886,7 +884,7 @@ void OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTa } } } - aSql.append(sIndexCondition.makeStringAndClear()); + aSql.append(sIndexCondition); aSql.setLength(aSql.getLength()-5); // now create end execute the prepared statement @@ -912,7 +910,9 @@ void OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTa if(m_bDeleted) { sal_Int32 nBookmark = ::comphelper::getINT32((*_rDeleteRow)[0].getAny()); - if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end()) + const auto iter = m_aKeyMap.find(nBookmark); + assert(iter != m_aKeyMap.end()); + if(m_aKeyIter == iter && m_aKeyIter != m_aKeyMap.end()) ++m_aKeyIter; m_aKeyMap.erase(nBookmark); m_bDeleted = true; @@ -1381,7 +1381,7 @@ namespace dbaccess void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, const css::uno::Sequence< OUString >& _aColumnNames, - const OUString& _rsUpdateTableName, + std::u16string_view _rsUpdateTableName, SelectColumnsMetaData& o_rColumnNames, bool i_bAppendTableName) { diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index e5d3c61ea5ac..bd30f3960eb3 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -23,6 +23,7 @@ #include <memory> #include <map> +#include <utility> #include <vector> #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> @@ -49,8 +50,8 @@ namespace dbaccess { } - SelectColumnDescription( sal_Int32 _nPosition, sal_Int32 _nType, sal_Int32 _nScale,bool _bNullable, const OUString& _rDefaultValue ) - :sDefaultValue( _rDefaultValue ) + SelectColumnDescription( sal_Int32 _nPosition, sal_Int32 _nType, sal_Int32 _nScale, bool _bNullable, OUString _sDefaultValue ) + :sDefaultValue(std::move( _sDefaultValue )) ,nPosition( _nPosition ) ,nType( _nType ) ,nScale( _nScale ) @@ -63,7 +64,7 @@ namespace dbaccess // the elements of _rxQueryColumns must have the properties PROPERTY_REALNAME and PROPERTY_TABLENAME void getColumnPositions(const css::uno::Reference< css::container::XNameAccess >& _rxQueryColumns, const css::uno::Sequence< OUString >& _rColumnNames, - const OUString& _rsUpdateTableName, + std::u16string_view _rsUpdateTableName, SelectColumnsMetaData& o_rColumnNames /* out */, bool i_bAppendTableName = false); @@ -142,8 +143,8 @@ namespace dbaccess virtual ~OKeySet() override; public: - OKeySet(const connectivity::OSQLTable& _xTable, - const OUString& _rUpdateTableName, + OKeySet(connectivity::OSQLTable _aTable, + OUString _sUpdateTableName, const css::uno::Reference< css::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, sal_Int32 i_nMaxRows, diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index c214402f50c5..df09d7b77588 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -41,17 +41,13 @@ using namespace dbaccess; using namespace ::connectivity; using namespace ::dbtools; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; using namespace ::com::sun::star; -using namespace ::cppu; -using namespace ::osl; typedef std::map<OUString, OUStringBuffer> TSQLStatements; namespace @@ -208,7 +204,7 @@ void OptimisticSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _ OUString sCatalog,sSchema,sTable; ::dbtools::qualifiedNameComponents(xMetaData,elem.first,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation); OUStringBuffer sSql("UPDATE " + ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ) + - " SET " + elem.second.toString()); + " SET " + elem.second); OUStringBuffer& rCondition = aKeyConditions[elem.first]; if ( !rCondition.isEmpty() ) sSql.append(" WHERE " + rCondition ); @@ -266,14 +262,14 @@ void OptimisticSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity: OUString sCatalog,sSchema,sTable; ::dbtools::qualifiedNameComponents(xMetaData,elem.first,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation); OUString sComposedTableName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); - OUString sSql("INSERT INTO " + sComposedTableName + " ( " + elem.second.toString() + - ") VALUES ( " + aParameter[elem.first].toString() + " )"); + OUString sSql("INSERT INTO " + sComposedTableName + " ( " + elem.second + + ") VALUES ( " + aParameter[elem.first] + " )"); OUStringBuffer& rCondition = aKeyConditions[elem.first]; if ( !rCondition.isEmpty() ) { - OUString sQuery("SELECT " + elem.second.toString() + " FROM " + sComposedTableName + - " WHERE " + rCondition.toString()); + OUString sQuery("SELECT " + elem.second + " FROM " + sComposedTableName + + " WHERE " + rCondition); try { @@ -330,7 +326,7 @@ void OptimisticSet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity:: OUString sCatalog,sSchema,sTable; ::dbtools::qualifiedNameComponents(xMetaData,keyCondition.first,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation); OUString sSql("DELETE FROM " + ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ) + - " WHERE " + rCondition.toString() ); + " WHERE " + rCondition ); executeDelete(_rDeleteRow, sSql, keyCondition.first); } } @@ -353,7 +349,9 @@ void OptimisticSet::executeDelete(const ORowSetRow& _rDeleteRow,const OUString& if(m_bDeleted) { sal_Int32 nBookmark = ::comphelper::getINT32((*_rDeleteRow)[0].getAny()); - if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end()) + const auto iter = m_aKeyMap.find(nBookmark); + assert(iter != m_aKeyMap.end()); + if(m_aKeyIter == iter && m_aKeyIter != m_aKeyMap.end()) ++m_aKeyIter; m_aKeyMap.erase(nBookmark); m_bDeleted = true; @@ -544,8 +542,8 @@ void OptimisticSet::fillMissingValues(ORowSetValueVector::Vector& io_aRow) const OUString sCatalog,sSchema,sTable; ::dbtools::qualifiedNameComponents(xMetaData,elem.first,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation); OUString sComposedTableName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); - OUString sQuery("SELECT " + elem.second.toString() + " FROM " + sComposedTableName + " WHERE " + - rCondition.makeStringAndClear()); + OUString sQuery("SELECT " + elem.second + " FROM " + sComposedTableName + " WHERE " + rCondition); + rCondition.setLength(0); try { diff --git a/dbaccess/source/core/api/PrivateRow.cxx b/dbaccess/source/core/api/PrivateRow.cxx index 9bf2709606bd..7e2df82aaeed 100644 --- a/dbaccess/source/core/api/PrivateRow.cxx +++ b/dbaccess/source/core/api/PrivateRow.cxx @@ -21,12 +21,9 @@ using namespace dbaccess; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star; diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 79dd9d4a593b..d9904071d64b 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -31,11 +31,13 @@ #include "CRowSetDataColumn.hxx" #include "RowSetCache.hxx" #include <strings.hrc> +#include <strings.hxx> #include <core_resource.hxx> #include <tablecontainer.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/ErrorCondition.hpp> @@ -68,9 +70,8 @@ #include <i18nlangtag/languagetag.hxx> #include <o3tl/safeint.hxx> #include <unotools/syslocale.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> -using namespace utl; using namespace dbaccess; using namespace connectivity; using namespace comphelper; @@ -417,18 +418,6 @@ void SAL_CALL ORowSet::release() noexcept ORowSet_BASE1::release(); } -// css::XUnoTunnel -sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - -Sequence< sal_Int8 > ORowSet::getUnoTunnelId() -{ - static const comphelper::UnoIdInit s_Id; - return s_Id.getSeq(); -} - // css::XAggregation Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) { @@ -616,7 +605,7 @@ void SAL_CALL ORowSet::close( ) MutexGuard aGuard( m_aMutex ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); } - // additionals things to set + // additional things to set freeResources( true ); } @@ -972,7 +961,7 @@ void SAL_CALL ORowSet::deleteRow( ) // this call position the cache indirect Any aBookmarkToDelete( m_aBookmark ); - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); sal_Int32 nDeletePosition = m_pCache->getRow(); notifyRowSetAndClonesRowDelete( aBookmarkToDelete ); @@ -1019,7 +1008,7 @@ void ORowSet::implCancelRowUpdates( bool _bNotifyModified ) if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) throwFunctionSequenceException(*this); - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); ORowSetRow aOldValues; if ( !m_bModified && _bNotifyModified && !m_aCurrentRow.isNull() ) @@ -1169,12 +1158,12 @@ void SAL_CALL ORowSet::moveToInsertRow( ) ORowSetRow aOldValues; if ( rowDeleted() ) { - positionCache( MOVE_FORWARD ); + positionCache( CursorMoveDirection::Forward ); m_pCache->next(); setCurrentRow( true, false, aOldValues, aGuard); } else - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); // check before because the resultset could be empty if ( !m_bBeforeFirst @@ -1224,18 +1213,18 @@ void ORowSet::impl_setDataColumnsWriteable_throw() dataColumn->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly; *aReadIter = bReadOnly; - dataColumn->setPropertyValue(PROPERTY_ISREADONLY,makeAny(false)); + dataColumn->setPropertyValue(PROPERTY_ISREADONLY,Any(false)); ++aReadIter; } } void ORowSet::impl_restoreDataColumnsWriteable_throw() { - assert(m_aDataColumns.size() == m_aReadOnlyDataColumns.size() || m_aReadOnlyDataColumns.size() == 0 ); + assert(m_aDataColumns.size() == m_aReadOnlyDataColumns.size() || m_aReadOnlyDataColumns.empty()); TDataColumns::const_iterator aIter = m_aDataColumns.begin(); for (bool readOnlyDataColumn : m_aReadOnlyDataColumns) { - (*aIter)->setPropertyValue(PROPERTY_ISREADONLY, makeAny(readOnlyDataColumn) ); + (*aIter)->setPropertyValue(PROPERTY_ISREADONLY, Any(readOnlyDataColumn) ); ++aIter; } m_aReadOnlyDataColumns.clear(); @@ -1263,7 +1252,7 @@ void SAL_CALL ORowSet::moveToCurrentRow( ) if ( !notifyAllListenersCursorBeforeMove( aGuard ) ) return; - positionCache( MOVE_NONE_REFRESH ); + positionCache( CursorMoveDirection::CurrentRefresh ); ORowSetNotifier aNotifier( this ); @@ -1614,8 +1603,8 @@ void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxSta } } - _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) ); - _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) ); + _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, Any( nResultSetType ) ); + _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, Any( nResultSetConcurrency ) ); } void ORowSet::impl_ensureStatement_throw() @@ -1642,8 +1631,8 @@ void ORowSet::impl_ensureStatement_throw() // set the result set type and concurrency try { - xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( true ) ); - xStatementProps->setPropertyValue( PROPERTY_MAXROWS, makeAny( m_nMaxRows ) ); + xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, Any( true ) ); + xStatementProps->setPropertyValue( PROPERTY_MAXROWS, Any( m_nMaxRows ) ); setStatementResultSetType( xStatementProps, m_nResultSetType, m_nResultSetConcurrency ); } @@ -1660,8 +1649,7 @@ void ORowSet::impl_ensureStatement_throw() // append information about what we were actually going to execute OUString sInfo(m_sErrorString.replaceFirst("$command$", sCommandToExecute)); - css::uno::Any aAppend = SQLExceptionInfo::createException(SQLExceptionInfo::TYPE::SQLContext, sInfo, OUString(), 0); - pLastExceptionInChain->NextException = aAppend; + pLastExceptionInChain->NextException = SQLExceptionInfo::createException(SQLExceptionInfo::TYPE::SQLContext, sInfo, OUString(), 0); // propagate throw; @@ -1718,8 +1706,8 @@ void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertyS // a number of properties is plain copied const OUString aPropertyNames[] = { - OUString(PROPERTY_ALIGN), OUString(PROPERTY_RELATIVEPOSITION), OUString(PROPERTY_WIDTH), OUString(PROPERTY_HIDDEN), OUString(PROPERTY_CONTROLMODEL), - OUString(PROPERTY_HELPTEXT), OUString(PROPERTY_CONTROLDEFAULT) + PROPERTY_ALIGN, PROPERTY_RELATIVEPOSITION, PROPERTY_WIDTH, PROPERTY_HIDDEN, PROPERTY_CONTROLMODEL, + PROPERTY_HELPTEXT, PROPERTY_CONTROLDEFAULT }; for (const auto & aPropertyName : aPropertyNames) { @@ -1739,7 +1727,7 @@ void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertyS } if ( !nFormatKey && m_xNumberFormatTypes.is() ) nFormatKey = ::dbtools::getDefaultNumberFormat( _rxTemplateColumn, m_xNumberFormatTypes, SvtSysLocale().GetLanguageTag().getLocale() ); - _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, makeAny( nFormatKey ) ); + _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, Any( nFormatKey ) ); } catch(Exception&) { @@ -1871,7 +1859,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi aNames.push_back(sName); m_aDataColumns.push_back(pColumn.get()); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1) != rKeyColumns.end())); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,Any(rKeyColumns.find(i+1) != rKeyColumns.end())); try { @@ -1880,10 +1868,10 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi nFormatKey = ::dbtools::getDefaultNumberFormat(pColumn,m_xNumberFormatTypes,aLocale); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,makeAny(sal_Int32(i+1))); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,makeAny(sal_Int32(227))); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,makeAny(sal_Int32(0))); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,Any(nFormatKey)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,Any(sal_Int32(i+1))); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,Any(sal_Int32(227))); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,Any(sal_Int32(0))); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN, css::uno::Any(false)); } catch(Exception&) @@ -1971,7 +1959,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi }); aColumns->emplace_back(pColumn); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end())); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,Any(rKeyColumns.find(i) != rKeyColumns.end())); if(sColumnLabel.isEmpty()) { @@ -2069,7 +2057,7 @@ Reference< XResultSet > SAL_CALL ORowSet::createResultSet( ) if(m_xStatement.is()) { rtl::Reference<ORowSetClone> pClone = new ORowSetClone( m_aContext, *this, m_pMutex ); - m_aClones.emplace_back(static_cast<cppu::OWeakObject*>(pClone.get())); + m_aClones.emplace_back(css::uno::Reference< css::uno::XWeak >(pClone)); return pClone; } return Reference< XResultSet >(); @@ -2143,7 +2131,7 @@ void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark ) // notify the clones for (auto const& elem : m_aClones) { - auto pClone = comphelper::getFromUnoTunnel<ORowSetClone>(elem.get()); + rtl::Reference<ORowSetClone> pClone = dynamic_cast<ORowSetClone*>(elem.get().get()); if(pClone) pClone->onDeleteRow( _rBookmark ); } @@ -2156,7 +2144,7 @@ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 // notify the clones for (auto const& clone : m_aClones) { - auto pClone = comphelper::getFromUnoTunnel<ORowSetClone>(clone.get()); + rtl::Reference<ORowSetClone> pClone = dynamic_cast<ORowSetClone*>(clone.get().get()); if(pClone) pClone->onDeletedRow( _rBookmark, _nPos ); } @@ -2699,7 +2687,7 @@ void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) if ( m_aCurrentRow.isNull() ) ::dbtools::throwSQLException( DBA_RES( RID_STR_INVALID_CURSOR_STATE ), StandardSQLState::INVALID_CURSOR_STATE, *this ); - if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->size()) <= columnIndex ) + if ( columnIndex <= 0 || (*m_aCurrentRow)->size() <= o3tl::make_unsigned(columnIndex) ) ::dbtools::throwSQLException( DBA_RES( RID_STR_INVALID_INDEX ), StandardSQLState::INVALID_DESCRIPTOR_INDEX, *this ); } @@ -2735,7 +2723,7 @@ void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard) ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex ) :OSubComponent(m_aMutex, rParent) - ,ORowSetBase( _rContext, OComponentHelper::rBHelper, _pMutex ) + ,ORowSetBase( _rContext, WeakComponentImplHelper::rBHelper, _pMutex ) ,m_pParent(&rParent) ,m_nFetchDirection(rParent.m_nFetchDirection) ,m_nFetchSize(rParent.m_nFetchSize) @@ -2795,7 +2783,7 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS 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)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,Any(nFormatKey)); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION)); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH)); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN)); @@ -2881,8 +2869,8 @@ void ORowSetClone::close() { { MutexGuard aGuard( m_aMutex ); - if (OComponentHelper::rBHelper.bDisposed) - throw DisposedException(); + if (WeakComponentImplHelper::rBHelper.bDisposed) + return; } dispose(); } @@ -2901,18 +2889,6 @@ void ORowSetClone::close() return *::comphelper::OPropertyArrayUsageHelper<ORowSetClone>::getArrayHelper(); } -Sequence< sal_Int8 > ORowSetClone::getUnoTunnelId() -{ - static const comphelper::UnoIdInit implId; - return implId.getSeq(); -} - -// css::XUnoTunnel -sal_Int64 SAL_CALL ORowSetClone::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) { if ( nHandle == PROPERTY_ID_FETCHSIZE ) diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx index da4da6c24e01..3cf6fe690193 100644 --- a/dbaccess/source/core/api/RowSet.hxx +++ b/dbaccess/source/core/api/RowSet.hxx @@ -255,10 +255,6 @@ namespace dbaccess virtual void SAL_CALL acquire() noexcept override; virtual void SAL_CALL release() noexcept override; - // css::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); - // css::uno::XAggregation virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override; @@ -487,10 +483,6 @@ namespace dbaccess virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - // css::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); - // OComponentHelper virtual void SAL_CALL disposing() override; diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index cae0d29eb3b7..042f1fabc2d0 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -34,7 +34,7 @@ #include <comphelper/seqstream.hxx> #include <connectivity/dbexception.hxx> #include <o3tl/safeint.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace dbaccess; using namespace connectivity; @@ -94,7 +94,7 @@ ORowSetBase::ORowSetBase( const Reference<XComponentContext>& _rContext, ::cppu: { sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT; - registerPropertyNoMember( PROPERTY_ROWCOUNT, PROPERTY_ID_ROWCOUNT, nRBT, cppu::UnoType<sal_Int32>::get(), css::uno::makeAny<sal_Int32>(0) ); + registerPropertyNoMember( PROPERTY_ROWCOUNT, PROPERTY_ID_ROWCOUNT, nRBT, cppu::UnoType<sal_Int32>::get(), css::uno::Any(sal_Int32(0)) ); registerPropertyNoMember( PROPERTY_ISROWCOUNTFINAL, PROPERTY_ID_ISROWCOUNTFINAL, nRBT, cppu::UnoType<bool>::get(), css::uno::Any(false) ); } @@ -207,7 +207,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex) if ( !bValidCurrentRow ) { // currentrow is null when the clone moves the window - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); m_aCurrentRow = m_pCache->m_aMatrixIter; m_bIsInsertRow = false; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null."); @@ -228,7 +228,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex) for (; k != m_pCache->getEnd(); ++k) { ORowSetValueVector* pTemp = k->get(); - OSL_ENSURE( pTemp != reinterpret_cast<void*>(0xfeeefeee),"HALT!" ); + OSL_ENSURE( pTemp != reinterpret_cast<void*>(sal_uIntPtr(0xfeeefeee)),"HALT!" ); } OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!"); #endif @@ -338,7 +338,7 @@ Reference< css::io::XInputStream > SAL_CALL ORowSetBase::getBinaryStream( sal_In bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() ); if ( !bValidCurrentRow ) { - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); m_aCurrentRow = m_pCache->m_aMatrixIter; m_bIsInsertRow = false; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null."); @@ -579,7 +579,7 @@ sal_Bool SAL_CALL ORowSetBase::next( ) ORowSetRow aOldValues = getOldRow(bWasNew); - positionCache( MOVE_FORWARD ); + positionCache( CursorMoveDirection::Forward ); bool bAfterLast = m_pCache->isAfterLast(); bRet = m_pCache->next(); doCancelModification( ); @@ -662,7 +662,7 @@ sal_Bool SAL_CALL ORowSetBase::isFirst( ) if ( impl_rowDeleted() ) return ( m_nDeletedPosition == 1 ); - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); bool bIsFirst = m_pCache->isFirst(); SAL_INFO("dbaccess", "ORowSetBase::isFirst() = " << bIsFirst << " Clone = " << m_bClone); @@ -692,7 +692,7 @@ sal_Bool SAL_CALL ORowSetBase::isLast( ) return ( m_nDeletedPosition == impl_getRowCount() ); } - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); bool bIsLast = m_pCache->isLast(); SAL_INFO("dbaccess", "ORowSetBase::isLast() = " << bIsLast << " Clone = " << m_bClone); @@ -864,7 +864,7 @@ sal_Int32 ORowSetBase::impl_getRow() nPos = 0; else { - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); nPos = m_pCache->getRow(); } SAL_INFO("dbaccess", "ORowSetBase::impl_getRow() = " << nPos << " Clone = " << m_bClone); @@ -944,7 +944,7 @@ sal_Bool SAL_CALL ORowSetBase::relative( sal_Int32 rows ) ORowSetRow aOldValues = getOldRow(bWasNew); - positionCache( rows > 0 ? MOVE_FORWARD : MOVE_BACKWARD ); + positionCache( rows > 0 ? CursorMoveDirection::Forward : CursorMoveDirection::Backward ); bRet = m_pCache->relative(rows); doCancelModification( ); @@ -992,7 +992,7 @@ sal_Bool SAL_CALL ORowSetBase::previous( ) ORowSetRow aOldValues = getOldRow(bWasNew); - positionCache( MOVE_BACKWARD ); + positionCache( CursorMoveDirection::Backward ); bRet = m_pCache->previous(); doCancelModification( ); @@ -1095,7 +1095,7 @@ void SAL_CALL ORowSetBase::refreshRow( ) { bool bWasNew = m_pCache->m_bNew || impl_rowDeleted(); ORowSetRow aOldValues = getOldRow(bWasNew); - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); m_pCache->refreshRow(); firePropertyChange(aOldValues); } @@ -1213,8 +1213,8 @@ bool ORowSetBase::isPropertyChangeNotificationEnabled() const void ORowSetBase::fireProperty( sal_Int32 _nProperty, bool _bNew, bool _bOld ) { - Any aNew = css::uno::makeAny( _bNew ); - Any aOld = css::uno::makeAny( _bOld ); + Any aNew( _bNew ); + Any aOld( _bOld ); fire( &_nProperty, &aNew, &aOld, 1, false ); } @@ -1225,7 +1225,7 @@ void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection ) bool bSuccess = false; if ( m_aBookmark.hasValue() ) { - if (_ePrepareForDirection == MOVE_NONE_REFRESH || + if (_ePrepareForDirection == CursorMoveDirection::CurrentRefresh || (m_pCache->isAfterLast() != bool(isAfterLast())) || ( m_pCache->isBeforeFirst() != bool(isBeforeFirst()) ) || m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL ) bSuccess = m_pCache->moveToBookmark( m_aBookmark ); @@ -1249,7 +1249,7 @@ void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection ) OSL_ENSURE( m_nDeletedPosition >= 1, "ORowSetBase::positionCache: no bookmark, and no valid 'deleted position'!" ); switch ( _ePrepareForDirection ) { - case MOVE_FORWARD: + case CursorMoveDirection::Forward: if ( m_nDeletedPosition > 1 ) bSuccess = m_pCache->absolute( m_nDeletedPosition - 1 ); else @@ -1259,7 +1259,7 @@ void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection ) } break; - case MOVE_BACKWARD: + case CursorMoveDirection::Backward: if ( m_pCache->m_bRowCountFinal && ( m_nDeletedPosition == impl_getRowCount() ) ) { m_pCache->afterLast(); @@ -1269,8 +1269,8 @@ void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection ) bSuccess = m_pCache->absolute( m_nDeletedPosition ); break; - case MOVE_NONE: - case MOVE_NONE_REFRESH: + case CursorMoveDirection::Current: + case CursorMoveDirection::CurrentRefresh: bSuccess = false; // will be asserted below break; } @@ -1324,7 +1324,7 @@ void ORowSetBase::onDeleteRow( const Any& _rBookmark ) //OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark isn't valid!" ); if ( compareBookmarks( _rBookmark, m_aBookmark ) == CompareBookmark::EQUAL ) { - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); m_nDeletedPosition = m_pCache->getRow(); } } @@ -1358,12 +1358,6 @@ sal_Int32 ORowSetBase::impl_getRowCount() const return nRowCount; } -struct ORowSetNotifierImpl -{ - std::vector<sal_Int32> aChangedColumns; - ORowSetValueVector::Vector aRow; -}; - ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet ) :m_pRowSet( _pRowSet ) @@ -1383,14 +1377,12 @@ ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet ) } ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet, ORowSetValueVector::Vector&& i_aRow ) - :m_pImpl(new ORowSetNotifierImpl) - ,m_pRowSet( _pRowSet ) + :m_pRowSet( _pRowSet ) ,m_bWasNew( false ) ,m_bWasModified( false ) { - OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This will crash." ); - m_pImpl->aRow = std::move(i_aRow); // yes, create a copy to store the old values + aRow = std::move(i_aRow); // yes, create a copy to store the old values } ORowSetNotifier::~ORowSetNotifier( ) @@ -1413,24 +1405,19 @@ void ORowSetNotifier::fire() m_pRowSet->fireProperty( PROPERTY_ID_ISNEW, false, true, ORowSetBase::GrantNotifierAccess() ); } -std::vector<sal_Int32>& ORowSetNotifier::getChangedColumns() const +std::vector<sal_Int32>& ORowSetNotifier::getChangedColumns() { - OSL_ENSURE(m_pImpl, "Illegal CTor call, use the other one!"); - return m_pImpl->aChangedColumns; + return aChangedColumns; } void ORowSetNotifier::firePropertyChange() { - OSL_ENSURE(m_pImpl, "Illegal CTor call, use the other one!"); - if (m_pImpl) + for (auto const& changedColumn : aChangedColumns) { - for (auto const& changedColumn : m_pImpl->aChangedColumns) - { - m_pRowSet->firePropertyChange(changedColumn-1 ,m_pImpl->aRow[changedColumn-1], ORowSetBase::GrantNotifierAccess()); - } - if ( !m_pImpl->aChangedColumns.empty() ) - m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,true,false, ORowSetBase::GrantNotifierAccess()); + m_pRowSet->firePropertyChange(changedColumn-1, aRow[changedColumn-1], ORowSetBase::GrantNotifierAccess()); } + if ( !aChangedColumns.empty() ) + m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,true,false, ORowSetBase::GrantNotifierAccess()); } } // namespace dbaccess diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx index f5443a2afcad..13d6464cddbf 100644 --- a/dbaccess/source/core/api/RowSetBase.hxx +++ b/dbaccess/source/core/api/RowSetBase.hxx @@ -19,7 +19,7 @@ #pragma once #include <memory> -#include <cppuhelper/implbase10.hxx> +#include <cppuhelper/implbase9.hxx> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbc/XColumnLocate.hpp> @@ -28,7 +28,6 @@ #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> #include <com/sun/star/sdbc/XWarningsSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <cppuhelper/interfacecontainer.h> #include <connectivity/sqlerror.hxx> #include <connectivity/CommonTools.hxx> @@ -51,7 +50,7 @@ namespace dbaccess { class OEmptyCollection; - typedef ::cppu::ImplHelper10< css::sdbcx::XRowLocate, + typedef ::cppu::ImplHelper9< css::sdbcx::XRowLocate, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier, css::sdbc::XWarningsSupplier, @@ -59,8 +58,7 @@ namespace dbaccess css::sdbcx::XColumnsSupplier, css::lang::XServiceInfo, css::sdbc::XRowSet, - css::sdbc::XCloseable, - css::lang::XUnoTunnel> ORowSetBase_BASE; + css::sdbc::XCloseable> ORowSetBase_BASE; class ORowSetCache; class ORowSetDataColumns; @@ -143,16 +141,16 @@ namespace dbaccess virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, css::uno::Any& _rDefault ) const override; virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue,sal_Int32 nHandle) const override; - enum CursorMoveDirection + enum class CursorMoveDirection { /// denotes a cursor move forward - MOVE_FORWARD, + Forward, /// denotes a cursor move backwards - MOVE_BACKWARD, + Backward, /// denotes no cursor move at all, but move cache to current row (if it is not there already) - MOVE_NONE, + Current, /// denotes no cursor move at all, but force the cache to move to current row (and refresh the row) - MOVE_NONE_REFRESH + CurrentRefresh }; /** positions the cache in preparation of a cursor move @@ -347,11 +345,11 @@ namespace dbaccess <p>The class can only be used on the stack, within a method of ORowSetBase (or derivees)</p> */ - struct ORowSetNotifierImpl; class ORowSetNotifier { private: - std::unique_ptr<ORowSetNotifierImpl> m_pImpl; + std::vector<sal_Int32> aChangedColumns; + ORowSetValueVector::Vector aRow; ORowSetBase* m_pRowSet; // not acquired! This is not necessary because this class here is to be used on the stack within // a method of ORowSetBase (or derivees) @@ -391,9 +389,9 @@ namespace dbaccess */ void firePropertyChange(); - /** use this one to store the inde of the changed column values + /** use this one to store the index of the changed column values */ - std::vector<sal_Int32>& getChangedColumns() const; + std::vector<sal_Int32>& getChangedColumns(); }; diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 1df68462a444..a41d9e991964 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -45,7 +45,7 @@ #include <connectivity/sqlnode.hxx> #include <connectivity/sqlparse.hxx> #include <sqlbison.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <o3tl/safeint.hxx> #include <osl/diagnose.h> @@ -60,9 +60,7 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; using namespace ::cppu; -using namespace ::osl; // This class calls m_pCacheSet->FOO_checked(..., sal_False) // (where FOO is absolute, last, previous) @@ -207,7 +205,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()); ::dbaccess::getColumnPositions(xSelColumns,xPrimaryKeyColumns->getElementNames(),aUpdateTableName,aColumnNames); - bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xPrimaryKeyColumns->getElementNames().getLength(); + bAllKeysFound = !aColumnNames.empty() && aColumnNames.size() == o3tl::make_unsigned(xPrimaryKeyColumns->getElementNames().getLength()); } } } @@ -455,7 +453,7 @@ static Any lcl_getBookmark(ORowSetValue& i_aValue,OCacheSet* i_pCacheSet) case DataType::TINYINT: case DataType::SMALLINT: case DataType::INTEGER: - return makeAny(i_aValue.getInt32()); + return Any(i_aValue.getInt32()); default: if ( i_pCacheSet && i_aValue.isNull()) i_aValue = i_pCacheSet->getBookmark(); @@ -591,7 +589,7 @@ void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference rInsert[columnIndex].setBound(true); rInsert[columnIndex] = aSeq; rInsert[columnIndex].setModified(true); - io_aRow[columnIndex] = makeAny(x); + io_aRow[columnIndex] = Any(x); m_xCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); @@ -946,7 +944,7 @@ void ORowSetCache::moveWindow() if ( nRowsInCache < m_nFetchSize ) { // There is some unused space in *m_pMatrix; fill it - OSL_ENSURE((nRowsInCache >= static_cast<ORowSetMatrix::difference_type>(0)) && (nRowsInCache < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!"); + OSL_ENSURE((nRowsInCache >= static_cast<ORowSetMatrix::difference_type>(0)) && (o3tl::make_unsigned(nRowsInCache) < m_pMatrix->size()),"Position is invalid!"); sal_Int32 nPos = m_nEndPos + 1; bool bCheck = m_xCacheSet->absolute(nPos); ORowSetMatrix::iterator aIter = m_pMatrix->begin() + nRowsInCache; @@ -964,7 +962,7 @@ void ORowSetCache::moveWindow() // The rows behind this can be reused ORowSetMatrix::iterator aIter = m_pMatrix->begin(); const sal_Int32 nNewStartPosInMatrix = nNewStartPos - m_nStartPos; - OSL_ENSURE((nNewStartPosInMatrix >= static_cast<ORowSetMatrix::difference_type>(0)) && (nNewStartPosInMatrix < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!"); + OSL_ENSURE((nNewStartPosInMatrix >= static_cast<ORowSetMatrix::difference_type>(0)) && (o3tl::make_unsigned(nNewStartPosInMatrix) < m_pMatrix->size()),"Position is invalid!"); // first position we reuse const ORowSetMatrix::const_iterator aEnd = m_pMatrix->begin() + nNewStartPosInMatrix; // End of used portion of the matrix. Is < m_pMatrix->end() if less data than window size @@ -1623,8 +1621,8 @@ void ORowSetCache::clearInsertRow() ORowSetMatrix::iterator ORowSetCache::calcPosition() const { sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1; - OSL_ENSURE((nValue >= static_cast<ORowSetMatrix::difference_type>(0)) && (nValue < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!"); - return ( nValue < 0 || nValue >= static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue); + OSL_ENSURE((nValue >= static_cast<ORowSetMatrix::difference_type>(0)) && (o3tl::make_unsigned(nValue) < m_pMatrix->size()),"Position is invalid!"); + return ( nValue < 0 || o3tl::make_unsigned(nValue) >= m_pMatrix->size() ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue); } TORowSetOldRowHelperRef ORowSetCache::registerOldRow() diff --git a/dbaccess/source/core/api/RowSetCacheIterator.hxx b/dbaccess/source/core/api/RowSetCacheIterator.hxx index 9c7a9afd4deb..f5d5e6783b65 100644 --- a/dbaccess/source/core/api/RowSetCacheIterator.hxx +++ b/dbaccess/source/core/api/RowSetCacheIterator.hxx @@ -21,6 +21,7 @@ #include <sal/config.h> #include <map> +#include <utility> #include "RowSetRow.hxx" @@ -43,8 +44,8 @@ namespace dbaccess ORowSetCache* m_pCache; ORowSetBase* m_pRowSet; - ORowSetCacheIterator(const ORowSetCacheMap::iterator& _rIter,ORowSetCache* _pCache,ORowSetBase* _pRowSet) - : m_aIter(_rIter) + ORowSetCacheIterator(ORowSetCacheMap::iterator _aIter, ORowSetCache* _pCache,ORowSetBase* _pRowSet) + : m_aIter(std::move(_aIter)) ,m_pCache(_pCache) ,m_pRowSet(_pRowSet) { diff --git a/dbaccess/source/core/api/RowSetRow.hxx b/dbaccess/source/core/api/RowSetRow.hxx index 7f24267b7530..a847399dd1e9 100644 --- a/dbaccess/source/core/api/RowSetRow.hxx +++ b/dbaccess/source/core/api/RowSetRow.hxx @@ -22,6 +22,7 @@ #include <connectivity/CommonTools.hxx> #include <connectivity/FValue.hxx> #include <salhelper/simplereferenceobject.hxx> +#include <utility> namespace dbaccess { @@ -36,8 +37,8 @@ namespace dbaccess ORowSetOldRowHelper& operator=(const ORowSetOldRowHelper& _rRH) = delete; ORowSetOldRowHelper(const ORowSetOldRowHelper& _rRh) = delete; public: - explicit ORowSetOldRowHelper(const ORowSetRow& _rRow) - : m_aRow(_rRow) + explicit ORowSetOldRowHelper(ORowSetRow _aRow) + : m_aRow(std::move(_aRow)) {} const ORowSetRow& getRow() const { return m_aRow; } diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 401d2dcf4fb9..f6dffbd1314a 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -21,6 +21,7 @@ #include <sal/log.hxx> #include <composertools.hxx> #include <strings.hrc> +#include <strings.hxx> #include <core_resource.hxx> #include <stringconstants.hxx> #include "HelperCollections.hxx" @@ -48,7 +49,7 @@ #include <connectivity/dbtools.hxx> #include <connectivity/PColumn.hxx> #include <connectivity/predicateinput.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <unotools/sharedunocomponent.hxx> @@ -79,15 +80,15 @@ namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode; constexpr OUStringLiteral STR_SELECT = u"SELECT "; constexpr OUStringLiteral STR_FROM = u" FROM "; -constexpr OUStringLiteral STR_WHERE = u" WHERE "; +constexpr OUString STR_WHERE = u" WHERE "_ustr; constexpr OUStringLiteral STR_GROUP_BY = u" GROUP BY "; constexpr OUStringLiteral STR_HAVING = u" HAVING "; constexpr OUStringLiteral STR_ORDER_BY = u" ORDER BY "; -constexpr OUStringLiteral STR_AND = u" AND "; -constexpr OUStringLiteral STR_OR = u" OR "; +constexpr OUString STR_AND = u" AND "_ustr; +constexpr OUString STR_OR = u" OR "_ustr; constexpr OUStringLiteral STR_LIKE = u" LIKE "; -constexpr OUStringLiteral L_BRACKET = u"("; -constexpr OUStringLiteral R_BRACKET = u")"; +constexpr OUString L_BRACKET = u"("_ustr; +constexpr OUString R_BRACKET = u")"_ustr; constexpr OUStringLiteral COMMA = u","; namespace @@ -105,8 +106,8 @@ namespace { OUString sSQLStateGeneralError( getStandardSQLState( StandardSQLState::GENERAL_ERROR ) ); SQLException aError2( aErrorMsg, _rxContext, sSQLStateGeneralError, 1000, Any() ); - SQLException aError1( _rStatement, _rxContext, sSQLStateGeneralError, 1000, makeAny( aError2 ) ); - throw SQLException(_rParser.getContext().getErrorMessage(OParseContext::ErrorCode::General),_rxContext,sSQLStateGeneralError,1000,makeAny(aError1)); + SQLException aError1( _rStatement, _rxContext, sSQLStateGeneralError, 1000, Any( aError2 ) ); + throw SQLException(_rParser.getContext().getErrorMessage(OParseContext::ErrorCode::General),_rxContext,sSQLStateGeneralError,1000,Any(aError1)); } return pNewSqlParseNode; } @@ -132,7 +133,7 @@ namespace // and now really ... SQLException aError1( _rOriginatingCommand, _rxContext, getStandardSQLState( StandardSQLState::GENERAL_ERROR ), 1000, Any() ); throw SQLException( DBA_RES( RID_STR_ONLY_QUERY ), _rxContext, - getStandardSQLState( StandardSQLState::GENERAL_ERROR ), 1000, makeAny( aError1 ) ); + getStandardSQLState( StandardSQLState::GENERAL_ERROR ), 1000, Any( aError1 ) ); } delete pOldNode; @@ -216,7 +217,7 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc const Reference<XComponentContext>& _rContext ) :OSubComponent(m_aMutex,_xConnection) ,OPropertyContainer(m_aBHelper) - ,m_aSqlParser( _rContext, &m_aParseContext ) + ,m_aSqlParser( _rContext, &m_aParseContext, &m_aNeutralContext ) ,m_aSqlIterator( _xConnection, _rxTables, m_aSqlParser ) ,m_aAdditiveIterator( _xConnection, _rxTables, m_aSqlParser ) ,m_aElementaryParts( size_t(SQLPartCount) ) @@ -244,7 +245,7 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc { Any aValue; Reference<XInterface> xDs = dbaccess::getDataSource(_xConnection); - if ( dbtools::getDataSourceSetting(xDs,static_cast <OUString> (PROPERTY_BOOLEANCOMPARISONMODE),aValue) ) + if ( dbtools::getDataSourceSetting(xDs,PROPERTY_BOOLEANCOMPARISONMODE,aValue) ) { OSL_VERIFY( aValue >>= m_nBoolCompareMode ); } @@ -473,7 +474,7 @@ OUString OSingleSelectQueryComposer::impl_getColumnRealName_throw(const Referenc { OUString sError(DBA_RES(RID_STR_COLUMN_UNKNOWN_PROP)); SQLException aErr(sError.replaceAll("%value", PROPERTY_NAME),*this,SQLSTATE_GENERAL,1000,Any() ); - throw SQLException(DBA_RES(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) ); + throw SQLException(DBA_RES(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any(aErr) ); } OUString aName, aNewName; @@ -510,9 +511,9 @@ OUString OSingleSelectQueryComposer::impl_getColumnRealName_throw(const Referenc { if(sTableName.indexOf('.') != -1) { - OUString aCatlog,aSchema,aTable; - ::dbtools::qualifiedNameComponents(m_xMetaData,sTableName,aCatlog,aSchema,aTable,::dbtools::EComposeRule::InDataManipulation); - sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, true, ::dbtools::EComposeRule::InDataManipulation ); + OUString aCatalog,aSchema,aTable; + ::dbtools::qualifiedNameComponents(m_xMetaData,sTableName,aCatalog,aSchema,aTable,::dbtools::EComposeRule::InDataManipulation); + sTableName = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, true, ::dbtools::EComposeRule::InDataManipulation ); } else if (!sTableName.isEmpty()) sTableName = ::dbtools::quoteName(aQuote,sTableName); @@ -543,7 +544,7 @@ OUString OSingleSelectQueryComposer::impl_getColumnNameOrderBy_throw(const Refer { OUString sError(DBA_RES(RID_STR_COLUMN_UNKNOWN_PROP)); SQLException aErr(sError.replaceAll("%value", PROPERTY_NAME),*this,SQLSTATE_GENERAL,1000,Any() ); - throw SQLException(DBA_RES(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) ); + throw SQLException(DBA_RES(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any(aErr) ); } OUString aName; @@ -846,7 +847,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) { xStatement.reset( Reference< XStatement >( m_xConnection->createStatement(), UNO_SET_THROW ) ); Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW ); - try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( false ) ); } + try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, Any( false ) ); } catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); } xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW ); xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_SET_THROW ); @@ -1523,9 +1524,9 @@ OUString OSingleSelectQueryComposer::getStatementPart( TGetParseNode const & _aG namespace { - OUString lcl_getDecomposedColumnName(const OUString& rComposedName, const OUString& rQuoteString) + OUString lcl_getDecomposedColumnName(const OUString& rComposedName, std::u16string_view rQuoteString) { - const sal_Int32 nQuoteLength = rQuoteString.getLength(); + const size_t nQuoteLength = rQuoteString.size(); OUString sName = rComposedName.trim(); OUString sColumnName; sal_Int32 nPos, nRPos = 0; @@ -1538,7 +1539,7 @@ namespace nRPos = sName.indexOf( rQuoteString, nPos + nQuoteLength ); if ( nRPos > nPos ) { - if ( nRPos + nQuoteLength < sName.getLength() ) + if ( static_cast<sal_Int32>(nRPos + nQuoteLength) < sName.getLength() ) { nRPos += nQuoteLength; // -1 + 1 skip dot } @@ -1560,7 +1561,7 @@ namespace OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter, const OPredicateInputController& i_aPredicateInputController, const Reference< XNameAccess >& i_xSelectColumns, - const OUString& rQuoteString) + std::u16string_view rQuoteString) { OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); @@ -1659,9 +1660,9 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; if(sTableName.indexOf('.') != -1) { - OUString aCatlog,aSchema,aTable; - ::dbtools::qualifiedNameComponents(m_xMetaData,sTableName,aCatlog,aSchema,aTable,::dbtools::EComposeRule::InDataManipulation); - sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, true, ::dbtools::EComposeRule::InDataManipulation ); + OUString aCatalog,aSchema,aTable; + ::dbtools::qualifiedNameComponents(m_xMetaData,sTableName,aCatalog,aSchema,aTable,::dbtools::EComposeRule::InDataManipulation); + sTableName = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, true, ::dbtools::EComposeRule::InDataManipulation ); } else sTableName = ::dbtools::quoteName(aQuote,sTableName); diff --git a/dbaccess/source/core/api/StaticSet.cxx b/dbaccess/source/core/api/StaticSet.cxx index 82948e6f1d4e..57eea66f34cf 100644 --- a/dbaccess/source/core/api/StaticSet.cxx +++ b/dbaccess/source/core/api/StaticSet.cxx @@ -23,17 +23,14 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <connectivity/CommonTools.hxx> #include <comphelper/types.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> using namespace dbaccess; using namespace connectivity; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace ::osl; void OStaticSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 /*_nPosition*/) { @@ -43,7 +40,7 @@ void OStaticSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 /*_nPosition*/) // css::sdbcx::XRowLocate Any OStaticSet::getBookmark() { - return makeAny(getRow()); + return Any(getRow()); } bool OStaticSet::moveToBookmark( const Any& bookmark ) @@ -193,7 +190,7 @@ bool OStaticSet::absolute( sal_Int32 row ) } else if(row > 0) { - if(row >= static_cast<sal_Int32>(m_aSet.size())) + if(o3tl::make_unsigned(row) >= m_aSet.size()) { if(!m_bEnd) { @@ -202,7 +199,7 @@ bool OStaticSet::absolute( sal_Int32 row ) bNext = fetchRow(); } - if(row > static_cast<sal_Int32>(m_aSet.size())) + if(o3tl::make_unsigned(row) > m_aSet.size()) m_aSetIter = m_aSet.end(); // check again else m_aSetIter = m_aSet.begin() + row; diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx index 03b8a9495cb9..92821750f9dc 100644 --- a/dbaccess/source/core/api/TableDeco.cxx +++ b/dbaccess/source/core/api/TableDeco.cxx @@ -18,9 +18,9 @@ */ #include <TableDeco.hxx> -#include <apitools.hxx> #include <definitioncolumn.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <core_resource.hxx> #include <strings.hrc> #include <osl/diagnose.h> @@ -477,7 +477,7 @@ sal_Int64 SAL_CALL ODBTableDecorator::getSomething( const Sequence< sal_Int8 >& return nRet; } -Sequence< sal_Int8 > ODBTableDecorator::getUnoTunnelId() +const Sequence< sal_Int8 > & ODBTableDecorator::getUnoTunnelId() { static const comphelper::UnoIdInit implId; return implId.getSeq(); diff --git a/dbaccess/source/core/api/View.cxx b/dbaccess/source/core/api/View.cxx index c52c4885c757..ce813b29ee82 100644 --- a/dbaccess/source/core/api/View.cxx +++ b/dbaccess/source/core/api/View.cxx @@ -24,7 +24,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { diff --git a/dbaccess/source/core/api/WrappedResultSet.cxx b/dbaccess/source/core/api/WrappedResultSet.cxx index b97fb4182d68..a4ad9f363cae 100644 --- a/dbaccess/source/core/api/WrappedResultSet.cxx +++ b/dbaccess/source/core/api/WrappedResultSet.cxx @@ -23,12 +23,8 @@ using namespace dbaccess; using namespace ::connectivity; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -using namespace ::osl; void WrappedResultSet::construct(const Reference< XResultSet>& _xDriverSet,const OUString& i_sRowSetFilter) { @@ -49,7 +45,7 @@ Any WrappedResultSet::getBookmark() { return m_xRowLocate->getBookmark( ); } - return makeAny(m_xDriverSet->getRow()); + return Any(m_xDriverSet->getRow()); } bool WrappedResultSet::moveToBookmark( const Any& bookmark ) diff --git a/dbaccess/source/core/api/callablestatement.cxx b/dbaccess/source/core/api/callablestatement.cxx index 8f864fbe04dd..25f3f405f8c1 100644 --- a/dbaccess/source/core/api/callablestatement.cxx +++ b/dbaccess/source/core/api/callablestatement.cxx @@ -24,10 +24,7 @@ using namespace dbaccess; 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 ::cppu; using namespace ::osl; @@ -84,7 +81,7 @@ void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY_THROW)->registerOutParameter( parameterIndex, sqlType, typeName ); } @@ -92,7 +89,7 @@ void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY_THROW)->registerNumericOutParameter( parameterIndex, sqlType, scale ); } @@ -101,7 +98,7 @@ void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 paramet sal_Bool SAL_CALL OCallableStatement::wasNull( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->wasNull(); } @@ -109,7 +106,7 @@ sal_Bool SAL_CALL OCallableStatement::wasNull( ) OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getString( columnIndex ); } @@ -117,7 +114,7 @@ OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBoolean( columnIndex ); } @@ -125,7 +122,7 @@ sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getByte( columnIndex ); } @@ -133,63 +130,63 @@ sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getShort( columnIndex ); } sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getInt( columnIndex ); } sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getLong( columnIndex ); } float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getFloat( columnIndex ); } double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getDouble( columnIndex ); } Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBytes( columnIndex ); } css::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getDate( columnIndex ); } css::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getTime( columnIndex ); } css::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getTimestamp( columnIndex ); } @@ -197,7 +194,7 @@ css::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnI Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBinaryStream( columnIndex ); } @@ -205,7 +202,7 @@ Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getCharacterStream( columnIndex ); } @@ -213,7 +210,7 @@ Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStre Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getObject( columnIndex, typeMap ); } @@ -221,28 +218,28 @@ Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Referen Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getRef( columnIndex ); } Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBlob( columnIndex ); } Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getClob( columnIndex ); } Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getArray( columnIndex ); } diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx index 5bc70affbce0..ad205c3248fa 100644 --- a/dbaccess/source/core/api/column.cxx +++ b/dbaccess/source/core/api/column.cxx @@ -34,19 +34,16 @@ #include <connectivity/TTableHelper.hxx> #include <connectivity/dbexception.hxx> #include <cppuhelper/supportsservice.hxx> +#include <utility> #include <osl/diagnose.h> using namespace dbaccess; using namespace connectivity; -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::awt; -using namespace ::com::sun::star::io; using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; using namespace ::osl; using namespace ::comphelper; using namespace ::cppu; @@ -147,7 +144,7 @@ OColumns::OColumns(::cppu::OWeakObject& _rParent, } OColumns::OColumns(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, - const css::uno::Reference< css::container::XNameAccess >& _rxDrvColumns, + css::uno::Reference< css::container::XNameAccess > _xDrvColumns, bool _bCaseSensitive,const std::vector< OUString> &_rVector, IColumnFactory* _pColFactory, ::connectivity::sdbcx::IRefreshableColumns* _pRefresh, @@ -156,7 +153,7 @@ OColumns::OColumns(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, bool _bUseHardRef) : OColumns_BASE(_rParent,_bCaseSensitive,_rMutex,_rVector,_bUseHardRef) ,m_pMediator(nullptr) - ,m_xDrvColumns(_rxDrvColumns) + ,m_xDrvColumns(std::move(_xDrvColumns)) ,m_pColFactoryImpl(_pColFactory) ,m_pRefreshColumns(_pRefresh) ,m_bInitialized(false) diff --git a/dbaccess/source/core/api/columnsettings.cxx b/dbaccess/source/core/api/columnsettings.cxx index 3f62a5a691fe..505e0d36b98f 100644 --- a/dbaccess/source/core/api/columnsettings.cxx +++ b/dbaccess/source/core/api/columnsettings.cxx @@ -24,7 +24,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <comphelper/property.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { @@ -121,14 +121,14 @@ namespace dbaccess }; const PropertyDescriptor aProps[] = { - { OUString(PROPERTY_ALIGN), PROPERTY_ID_ALIGN }, - { OUString(PROPERTY_NUMBERFORMAT), PROPERTY_ID_NUMBERFORMAT }, - { OUString(PROPERTY_RELATIVEPOSITION), PROPERTY_ID_RELATIVEPOSITION }, - { OUString(PROPERTY_WIDTH), PROPERTY_ID_WIDTH }, - { OUString(PROPERTY_HELPTEXT), PROPERTY_ID_HELPTEXT }, - { OUString(PROPERTY_CONTROLDEFAULT), PROPERTY_ID_CONTROLDEFAULT }, - { OUString(PROPERTY_CONTROLMODEL), PROPERTY_ID_CONTROLMODEL }, - { OUString(PROPERTY_HIDDEN), PROPERTY_ID_HIDDEN } + { 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 (const auto & aProp : aProps) diff --git a/dbaccess/source/core/api/datacolumn.cxx b/dbaccess/source/core/api/datacolumn.cxx index c597a40649bf..e0953449154a 100644 --- a/dbaccess/source/core/api/datacolumn.cxx +++ b/dbaccess/source/core/api/datacolumn.cxx @@ -25,12 +25,9 @@ using 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::uno; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::container; using namespace ::osl; -using namespace ::comphelper; using namespace ::cppu; diff --git a/dbaccess/source/core/api/datasettings.cxx b/dbaccess/source/core/api/datasettings.cxx index e845f11350f8..f810f8669917 100644 --- a/dbaccess/source/core/api/datasettings.cxx +++ b/dbaccess/source/core/api/datasettings.cxx @@ -27,7 +27,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::comphelper; using namespace ::cppu; diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index 6307e64eddcd..b952edca2e7a 100644 --- a/dbaccess/source/core/api/definitioncolumn.cxx +++ b/dbaccess/source/core/api/definitioncolumn.cxx @@ -19,8 +19,8 @@ #include <bitset> -#include <apitools.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <definitioncolumn.hxx> #include <sdbcoretools.hxx> @@ -30,13 +30,13 @@ #include <comphelper/property.hxx> #include <connectivity/dbtools.hxx> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> 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; @@ -89,7 +89,7 @@ OUString OTableColumnDescriptor::getImplementationName( ) Sequence< OUString > OTableColumnDescriptor::getSupportedServiceNames( ) { - return { m_bActAsDescriptor? OUString(SERVICE_SDBCX_COLUMNDESCRIPTOR) : OUString(SERVICE_SDBCX_COLUMN), + return { m_bActAsDescriptor? SERVICE_SDBCX_COLUMNDESCRIPTOR : SERVICE_SDBCX_COLUMN, SERVICE_SDB_COLUMNSETTINGS }; } @@ -156,9 +156,9 @@ OUString OTableColumn::getImplementationName( ) // OQueryColumn -OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection, const OUString &i_sLabel ) +OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection, OUString i_sLabel ) :OTableColumnDescriptor( false /* do not act as descriptor */ ) - ,m_sLabel(i_sLabel) + ,m_sLabel(std::move(i_sLabel)) { const sal_Int32 nPropAttr = PropertyAttribute::READONLY; registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, cppu::UnoType<decltype(m_sCatalogName)>::get() ); @@ -169,35 +169,35 @@ OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, co if( ! (_rxParserColumn->getPropertyValue( PROPERTY_TYPENAME ) >>= m_aTypeName) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_TYPENAME); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_TYPENAME); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= m_nIsNullable) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_ISNULLABLE); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_ISNULLABLE); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_PRECISION ) >>= m_nPrecision) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_PRECISION); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_PRECISION); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_SCALE ) >>= m_nScale) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_SCALE); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_SCALE); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_TYPE); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_TYPE); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_ISAUTOINCREMENT); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_ISAUTOINCREMENT); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_ISCURRENCY); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_ISCURRENCY); if( ! (_rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_NAME); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_NAME); m_bRowVersion = false; Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW ); if ( xPSI->hasPropertyByName( PROPERTY_DEFAULTVALUE ) ) if( ! (_rxParserColumn->getPropertyValue( PROPERTY_DEFAULTVALUE ) >>= m_aDefaultValue) ) - SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " PROPERTY_DEFAULTVALUE); + SAL_WARN("dbaccess.core", "OQueryColumn: unable to get property " + PROPERTY_DEFAULTVALUE); // copy some optional properties from the parser column struct PropertyDescriptor @@ -207,10 +207,10 @@ OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, co }; const PropertyDescriptor aProps[] = { - { OUString(PROPERTY_CATALOGNAME), PROPERTY_ID_CATALOGNAME }, - { OUString(PROPERTY_SCHEMANAME), PROPERTY_ID_SCHEMANAME }, - { OUString(PROPERTY_TABLENAME), PROPERTY_ID_TABLENAME }, - { OUString(PROPERTY_REALNAME), PROPERTY_ID_REALNAME } + { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME }, + { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME }, + { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME }, + { PROPERTY_REALNAME, PROPERTY_ID_REALNAME } }; for (const auto & aProp : aProps) { @@ -243,11 +243,11 @@ Reference< XPropertySet > OQueryColumn::impl_determineOriginalTableColumn( const // respective properties OUString sCatalog, sSchema, sTable; if( ! (getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog) ) - SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " PROPERTY_CATALOGNAME); + SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " + PROPERTY_CATALOGNAME); if( ! (getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema) ) - SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " PROPERTY_SCHEMANAME); + SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " + PROPERTY_SCHEMANAME); if( ! (getPropertyValue( PROPERTY_TABLENAME ) >>= sTable) ) - SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " PROPERTY_TABLENAME); + SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " + PROPERTY_TABLENAME); if ( sCatalog.isEmpty() && sSchema.isEmpty() && sTable.isEmpty() ) return nullptr; @@ -265,7 +265,7 @@ Reference< XPropertySet > OQueryColumn::impl_determineOriginalTableColumn( const OUString sColumn; if( ! (getPropertyValue( PROPERTY_REALNAME ) >>= sColumn) ) - SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " PROPERTY_REALNAME); + SAL_WARN("dbaccess.core", "impl_determineOriginalTableColumn: unable to get property " + PROPERTY_REALNAME); if ( !xColumns->hasByName( sColumn ) ) return nullptr; diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx index 52f099a4c88f..e7ec79a2ca87 100644 --- a/dbaccess/source/core/api/preparedstatement.cxx +++ b/dbaccess/source/core/api/preparedstatement.cxx @@ -28,13 +28,13 @@ #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> #include <preparedstatement.hxx> +#include <strings.hxx> #include "resultcolumn.hxx" #include "resultset.hxx" -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> 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 ::cppu; @@ -116,7 +116,7 @@ sal_Bool OPreparedStatement::supportsService( const OUString& _rServiceName ) Sequence< OUString > OPreparedStatement::getSupportedServiceNames( ) { - return { SERVICE_SDBC_PREPAREDSTATEMENT, SERVICE_SDB_PREPAREDSTATMENT }; + return { SERVICE_SDBC_PREPAREDSTATEMENT, SERVICE_SDB_PREPAREDSTATEMENT }; } // OComponentHelper @@ -134,7 +134,7 @@ void OPreparedStatement::disposing() Reference< css::container::XNameAccess > OPreparedStatement::getColumns() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // do we have to populate the columns if (!m_pColumns->isInitialized()) @@ -174,7 +174,7 @@ Reference< css::container::XNameAccess > OPreparedStatement::getColumns() Reference< XResultSetMetaData > OPreparedStatement::getMetaData() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XResultSetMetaDataSupplier >( m_xAggregateAsSet, UNO_QUERY_THROW )->getMetaData(); } @@ -182,7 +182,7 @@ Reference< XResultSetMetaData > OPreparedStatement::getMetaData() Reference< XResultSet > OPreparedStatement::executeQuery() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); @@ -201,7 +201,7 @@ Reference< XResultSet > OPreparedStatement::executeQuery() sal_Int32 OPreparedStatement::executeUpdate() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); @@ -211,7 +211,7 @@ sal_Int32 OPreparedStatement::executeUpdate() sal_Bool OPreparedStatement::execute() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); @@ -227,7 +227,7 @@ Reference< XConnection > OPreparedStatement::getConnection() void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setNull(parameterIndex, sqlType); } @@ -235,7 +235,7 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setObjectNull(parameterIndex, sqlType, typeName); } @@ -243,7 +243,7 @@ void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_I void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setBoolean(parameterIndex, x); } @@ -251,7 +251,7 @@ void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setByte(parameterIndex, x); } @@ -259,7 +259,7 @@ void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setShort(parameterIndex, x); } @@ -267,7 +267,7 @@ void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setInt(parameterIndex, x); } @@ -275,7 +275,7 @@ void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setLong(parameterIndex, x); } @@ -283,7 +283,7 @@ void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setFloat(parameterIndex, x); } @@ -291,7 +291,7 @@ void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setDouble(parameterIndex, x); } @@ -299,7 +299,7 @@ void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const OUString& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setString(parameterIndex, x); } @@ -307,7 +307,7 @@ void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const OUS void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setBytes(parameterIndex, x); } @@ -315,7 +315,7 @@ void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequ void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const css::util::Date& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setDate(parameterIndex, x); } @@ -323,7 +323,7 @@ void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const css:: void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const css::util::Time& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setTime(parameterIndex, x); } @@ -331,7 +331,7 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const css:: void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const css::util::DateTime& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setTimestamp(parameterIndex, x); } @@ -339,7 +339,7 @@ void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setBinaryStream(parameterIndex, x, length); } @@ -347,7 +347,7 @@ void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, con void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setCharacterStream(parameterIndex, x, length); } @@ -355,7 +355,7 @@ void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setObject(parameterIndex, x); } @@ -363,7 +363,7 @@ void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setObjectWithInfo(parameterIndex, x, targetSqlType, scale); } @@ -371,7 +371,7 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setRef(parameterIndex, x); } @@ -379,7 +379,7 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Refere void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setBlob(parameterIndex, x); } @@ -387,7 +387,7 @@ void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Refer void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setClob(parameterIndex, x); } @@ -395,7 +395,7 @@ void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Refer void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->setArray(parameterIndex, x); } @@ -403,7 +403,7 @@ void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Refe void SAL_CALL OPreparedStatement::clearParameters( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); m_xAggregateAsParameters->clearParameters(); } diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index f043db068d5e..c8e723853a7a 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -25,9 +25,9 @@ #include "HelperCollections.hxx" #include <core_resource.hxx> #include <strings.hrc> +#include <strings.hxx> -#include <cppuhelper/interfacecontainer.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <com/sun/star/sdbc/XConnection.hpp> @@ -40,6 +40,7 @@ #include <definitioncolumn.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <ContainerMediator.hxx> using namespace dbaccess; @@ -48,7 +49,6 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::comphelper; diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx index 5f33eefbd48d..9c41f344ccf5 100644 --- a/dbaccess/source/core/api/querycomposer.cxx +++ b/dbaccess/source/core/api/querycomposer.cxx @@ -18,6 +18,7 @@ */ #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sdbc/ColumnSearch.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <comphelper/sequence.hxx> @@ -26,6 +27,7 @@ #include <comphelper/types.hxx> #include <com/sun/star/sdb/SQLFilterOperator.hpp> #include <querycomposer.hxx> +#include <strings.hxx> #include <composertools.hxx> #include <algorithm> @@ -41,7 +43,6 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::cppu; using namespace ::osl; -using namespace ::utl; OQueryComposer::OQueryComposer(const Reference< XConnection>& _xConnection) diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx index 6e3f05ea4d18..8e386dc411cd 100644 --- a/dbaccess/source/core/api/querycontainer.cxx +++ b/dbaccess/source/core/api/querycontainer.cxx @@ -19,6 +19,7 @@ #include <querycontainer.hxx> #include "query.hxx" +#include <strings.hxx> #include <objectnameapproval.hxx> #include <veto.hxx> @@ -43,7 +44,6 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::container; using namespace ::com::sun::star::util; using namespace ::osl; @@ -195,7 +195,7 @@ void SAL_CALL OQueryContainer::appendByDescriptor( const Reference< XPropertySet { m_eDoingCurrently = AggregateAction::Inserting; OAutoActionReset aAutoReset(*this); - m_xCommandDefinitions->insertByName(sNewObjectName, makeAny(xCommandDefinitionPart)); + m_xCommandDefinitions->insertByName(sNewObjectName, Any(xCommandDefinitionPart)); } implAppend( sNewObjectName, xNewObject ); @@ -260,7 +260,7 @@ void SAL_CALL OQueryContainer::elementInserted( const css::container::ContainerE // insert an own new element xNewElement = implCreateWrapper(sElementName); } - insertByName(sElementName,makeAny(xNewElement)); + insertByName(sElementName,Any(xNewElement)); } void SAL_CALL OQueryContainer::elementRemoved( const css::container::ContainerEvent& _rEvent ) @@ -292,7 +292,7 @@ void SAL_CALL OQueryContainer::elementReplaced( const css::container::ContainerE xNewElement = implCreateWrapper(sAccessor); } - replaceByName(sAccessor,makeAny(xNewElement)); + replaceByName(sAccessor,Any(xNewElement)); } Reference< XVeto > SAL_CALL OQueryContainer::approveInsertElement( const ContainerEvent& Event ) diff --git a/dbaccess/source/core/api/querydescriptor.cxx b/dbaccess/source/core/api/querydescriptor.cxx index 52948614519a..0aff2b0aaba1 100644 --- a/dbaccess/source/core/api/querydescriptor.cxx +++ b/dbaccess/source/core/api/querydescriptor.cxx @@ -18,18 +18,15 @@ */ #include "querydescriptor.hxx" -#include <apitools.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; using namespace ::osl; using namespace ::cppu; @@ -144,22 +141,6 @@ OQueryDescriptor_Base::~OQueryDescriptor_Base() m_pColumns->disposing(); } -sal_Int64 SAL_CALL OQueryDescriptor_Base::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) -{ - return comphelper::getSomethingImpl(_rIdentifier, this); -} - -css::uno::Sequence<sal_Int8> OQueryDescriptor_Base::getUnoTunnelId() -{ - static const comphelper::UnoIdInit aId; - return aId.getSeq(); -} - -css::uno::Sequence<sal_Int8> OQueryDescriptor_Base::getImplementationId() -{ - return css::uno::Sequence<sal_Int8>(); -} - void OQueryDescriptor_Base::setColumnsOutOfDate( bool _bOutOfDate ) { m_bColumnsOutOfDate = _bOutOfDate; diff --git a/dbaccess/source/core/api/querydescriptor.hxx b/dbaccess/source/core/api/querydescriptor.hxx index e0930c8335a3..181b8e4d436d 100644 --- a/dbaccess/source/core/api/querydescriptor.hxx +++ b/dbaccess/source/core/api/querydescriptor.hxx @@ -19,13 +19,12 @@ #pragma once -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase2.hxx> #include <comphelper/proparrhlp.hxx> #include <osl/mutex.hxx> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <apitools.hxx> #include <column.hxx> @@ -38,9 +37,8 @@ namespace dbaccess { // OQueryDescriptor_Base - a query descriptor (as the name suggests :) -typedef ::cppu::ImplHelper3< +typedef ::cppu::ImplHelper2< css::sdbcx::XColumnsSupplier, - css::lang::XUnoTunnel, css::lang::XServiceInfo > OQueryDescriptor_BASE; class OQueryDescriptor_Base @@ -75,12 +73,6 @@ public: // css::sdbcx::XColumnsSupplier virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; -// css::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); - - // css::lang::XServiceInfo virtual OUString SAL_CALL getImplementationName( ) override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; diff --git a/dbaccess/source/core/api/resultcolumn.cxx b/dbaccess/source/core/api/resultcolumn.cxx index 8852da26c94a..fbc8cb8a343f 100644 --- a/dbaccess/source/core/api/resultcolumn.cxx +++ b/dbaccess/source/core/api/resultcolumn.cxx @@ -18,19 +18,18 @@ */ #include "resultcolumn.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/sdbc/XRow.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <stringconstants.hxx> -#include <apitools.hxx> +#include <strings.hxx> using namespace ::com::sun::star::sdbc; 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 ::osl; using namespace ::comphelper; using namespace ::cppu; @@ -67,7 +66,7 @@ void OResultColumn::impl_determineIsRowVersion_nothrow() try { Reference< XResultSet > xVersionColumns = m_xDBMetaData->getVersionColumns( - makeAny( sCatalog ), sSchema, sTable ); + Any( sCatalog ), sSchema, sTable ); if ( xVersionColumns.is() ) // allowed to be NULL { Reference< XRow > xResultRow( xVersionColumns, UNO_QUERY_THROW ); @@ -124,32 +123,32 @@ void OResultColumn::disposing() // comphelper::OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* OResultColumn::createArrayHelper( ) const { - css::uno::Sequence< css::beans::Property> aDescriptor(21); - css::beans::Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - pDesc[nPos++] = css::beans::Property(PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_DISPLAYSIZE, PROPERTY_ID_DISPLAYSIZE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISCASESENSITIVE, PROPERTY_ID_ISCASESENSITIVE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISDEFINITELYWRITABLE, PROPERTY_ID_ISDEFINITELYWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISSEARCHABLE, PROPERTY_ID_ISSEARCHABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISSIGNED, PROPERTY_ID_ISSIGNED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISWRITABLE, PROPERTY_ID_ISWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_PRECISION, PROPERTY_ID_PRECISION, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_SCALE, PROPERTY_ID_SCALE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_SERVICENAME, PROPERTY_ID_SERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_TYPE, PROPERTY_ID_TYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); - return new ::cppu::OPropertyArrayHelper(aDescriptor); + return new ::cppu::OPropertyArrayHelper + { + { + { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_DISPLAYSIZE, PROPERTY_ID_DISPLAYSIZE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISAUTOINCREMENT, PROPERTY_ID_ISAUTOINCREMENT, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISCASESENSITIVE, PROPERTY_ID_ISCASESENSITIVE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISCURRENCY, PROPERTY_ID_ISCURRENCY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISDEFINITELYWRITABLE, PROPERTY_ID_ISDEFINITELYWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISNULLABLE, PROPERTY_ID_ISNULLABLE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISROWVERSION, PROPERTY_ID_ISROWVERSION, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISSEARCHABLE, PROPERTY_ID_ISSEARCHABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISSIGNED, PROPERTY_ID_ISSIGNED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_ISWRITABLE, PROPERTY_ID_ISWRITABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_LABEL, PROPERTY_ID_LABEL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_PRECISION, PROPERTY_ID_PRECISION, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SCALE, PROPERTY_ID_SCALE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SERVICENAME, PROPERTY_ID_SERVICENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TYPE, PROPERTY_ID_TYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY } + } + }; } // cppu::OPropertySetHelper diff --git a/dbaccess/source/core/api/resultset.cxx b/dbaccess/source/core/api/resultset.cxx index f545c2e3153d..cc6a6fe018f4 100644 --- a/dbaccess/source/core/api/resultset.cxx +++ b/dbaccess/source/core/api/resultset.cxx @@ -20,14 +20,15 @@ #include "resultset.hxx" #include <sal/log.hxx> #include <stringconstants.hxx> -#include <apitools.hxx> +#include <strings.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/sdbc/ResultSetType.hpp> #include <com/sun/star/sdbc/SQLException.hpp> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> #include <comphelper/types.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include "datacolumn.hxx" #include <connectivity/dbexception.hxx> #include <connectivity/dbtools.hxx> @@ -185,17 +186,17 @@ Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() // comphelper::OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const { - css::uno::Sequence< css::beans::Property> aDescriptor(6); - css::beans::Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - pDesc[nPos++] = css::beans::Property(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY); - OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); - return new ::cppu::OPropertyArrayHelper(aDescriptor); + return new ::cppu::OPropertyArrayHelper + { + { + { PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::READONLY } + } + }; } // cppu::OPropertySetHelper diff --git a/dbaccess/source/core/api/statement.cxx b/dbaccess/source/core/api/statement.cxx index 82236dfe7202..1a20823ab9dd 100644 --- a/dbaccess/source/core/api/statement.cxx +++ b/dbaccess/source/core/api/statement.cxx @@ -20,6 +20,8 @@ #include <statement.hxx> #include "resultset.hxx" #include <stringconstants.hxx> +#include <strings.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> #include <com/sun/star/sdbc/SQLException.hpp> #include <cppuhelper/queryinterface.hxx> @@ -27,7 +29,7 @@ #include <cppuhelper/typeprovider.hxx> #include <comphelper/property.hxx> #include <comphelper/types.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <connectivity/dbexception.hxx> using namespace ::com::sun::star::sdb; @@ -44,7 +46,7 @@ using namespace dbtools; OStatementBase::OStatementBase(const Reference< XConnection > & _xConn, const Reference< XInterface > & _xStatement) :OSubComponent(m_aMutex, _xConn) - ,OPropertySetHelper(OComponentHelper::rBHelper) + ,OPropertySetHelper(WeakComponentImplHelper::rBHelper) ,m_bUseBookmarks( false ) ,m_bEscapeProcessing( true ) @@ -122,7 +124,7 @@ void OStatementBase::disposeResultSet() Reference< XComponent > xComp(m_aResultSet.get(), UNO_QUERY); if (xComp.is()) xComp->dispose(); - m_aResultSet = nullptr; + m_aResultSet.clear(); } // OComponentHelper @@ -162,7 +164,7 @@ void OStatementBase::close() { { MutexGuard aGuard( m_aMutex ); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); } dispose(); } @@ -176,21 +178,21 @@ Reference< XPropertySetInfo > OStatementBase::getPropertySetInfo() // comphelper::OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* OStatementBase::createArrayHelper( ) const { - css::uno::Sequence< css::beans::Property> aDescriptor(10); - css::beans::Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - pDesc[nPos++] = css::beans::Property(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, cppu::UnoType<bool>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_MAXFIELDSIZE, PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_MAXROWS, PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_QUERYTIMEOUT, PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0); - pDesc[nPos++] = css::beans::Property(PROPERTY_USEBOOKMARKS, PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0); - OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); - return new ::cppu::OPropertyArrayHelper(aDescriptor); + return new ::cppu::OPropertyArrayHelper + { + { + { PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0 }, + { PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, cppu::UnoType<bool>::get(), 0 }, + { PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_MAXFIELDSIZE, PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_MAXROWS, PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_QUERYTIMEOUT, PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0 }, + { PROPERTY_USEBOOKMARKS, PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0 } + } + }; } // cppu::OPropertySetHelper @@ -291,7 +293,7 @@ void OStatementBase::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) cons Any OStatementBase::getWarnings() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); return Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY_THROW)->getWarnings(); } @@ -299,7 +301,7 @@ Any OStatementBase::getWarnings() void OStatementBase::clearWarnings() { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY_THROW)->clearWarnings(); } @@ -318,7 +320,7 @@ void OStatementBase::cancel() Reference< XResultSet > SAL_CALL OStatementBase::getResultSet( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -331,7 +333,7 @@ Reference< XResultSet > SAL_CALL OStatementBase::getResultSet( ) sal_Int32 SAL_CALL OStatementBase::getUpdateCount( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -344,7 +346,7 @@ sal_Int32 SAL_CALL OStatementBase::getUpdateCount( ) sal_Bool SAL_CALL OStatementBase::getMoreResults( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -361,7 +363,7 @@ sal_Bool SAL_CALL OStatementBase::getMoreResults( ) void SAL_CALL OStatementBase::addBatch( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -374,7 +376,7 @@ void SAL_CALL OStatementBase::addBatch( ) void SAL_CALL OStatementBase::clearBatch( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -387,7 +389,7 @@ void SAL_CALL OStatementBase::clearBatch( ) Sequence< sal_Int32 > SAL_CALL OStatementBase::executeBatch( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -403,7 +405,7 @@ Sequence< sal_Int32 > SAL_CALL OStatementBase::executeBatch( ) Reference< XResultSet > SAL_CALL OStatementBase::getGeneratedValues( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY); if ( xGRes.is() ) @@ -444,7 +446,7 @@ Sequence< OUString > OStatement::getSupportedServiceNames( ) Reference< XResultSet > OStatement::executeQuery( const OUString& _rSQL ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); Reference< XResultSet > xResultSet; @@ -470,7 +472,7 @@ Reference< XResultSet > OStatement::executeQuery( const OUString& _rSQL ) sal_Int32 OStatement::executeUpdate( const OUString& _rSQL ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); @@ -481,7 +483,7 @@ sal_Int32 OStatement::executeUpdate( const OUString& _rSQL ) sal_Bool OStatement::execute( const OUString& _rSQL ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); @@ -492,7 +494,7 @@ sal_Bool OStatement::execute( const OUString& _rSQL ) void OStatement::addBatch( const OUString& _rSQL ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); @@ -506,7 +508,7 @@ void OStatement::addBatch( const OUString& _rSQL ) void OStatement::clearBatch( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); if (!xMeta.is() || !xMeta->supportsBatchUpdates()) @@ -518,7 +520,7 @@ void OStatement::clearBatch( ) Sequence< sal_Int32 > OStatement::executeBatch( ) { MutexGuard aGuard(m_aMutex); - ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); // first check the meta data Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData(); if (!xMeta.is() || !xMeta->supportsBatchUpdates()) diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx index 52d6b5cf64f6..bb2a6f832dea 100644 --- a/dbaccess/source/core/api/table.cxx +++ b/dbaccess/source/core/api/table.cxx @@ -17,10 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <apitools.hxx> #include <table.hxx> #include <definitioncolumn.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <core_resource.hxx> #include <strings.hrc> #include "CIndexes.hxx" @@ -29,7 +29,6 @@ #include <comphelper/servicehelper.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/sdbc/SQLException.hpp> -#include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdb/tools/XTableRename.hpp> #include <com/sun/star/sdb/tools/XTableAlteration.hpp> @@ -41,7 +40,6 @@ using namespace dbaccess; using namespace connectivity; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; @@ -310,18 +308,6 @@ void SAL_CALL ODBTable::alterColumnByName( const OUString& _rName, const Referen m_xColumns->refresh(); } -sal_Int64 SAL_CALL ODBTable::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this, - comphelper::FallbackToGetSomethingOf<OTable_Base>{}); -} - -Sequence< sal_Int8 > ODBTable::getUnoTunnelId() -{ - static const comphelper::UnoIdInit s_Id; - return s_Id.getSeq(); -} - Reference< XPropertySet > ODBTable::createColumnDescriptor() { return new OTableColumnDescriptor( true ); diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx index 7aefea3e2306..1a7e2a261609 100644 --- a/dbaccess/source/core/api/tablecontainer.cxx +++ b/dbaccess/source/core/api/tablecontainer.cxx @@ -17,13 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <apitools.hxx> #include <tablecontainer.hxx> #include <table.hxx> #include <comphelper/property.hxx> #include <comphelper/processfactory.hxx> #include <core_resource.hxx> #include <strings.hrc> +#include <strings.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/PropertyState.hpp> #include <com/sun/star/beans/XPropertyState.hpp> @@ -40,7 +40,7 @@ #include <sdbcoretools.hxx> #include <ContainerMediator.hxx> #include <objectnameapproval.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace dbaccess; using namespace dbtools; @@ -51,7 +51,6 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; using namespace ::osl; using namespace ::comphelper; using namespace ::cppu; @@ -62,26 +61,24 @@ namespace bool lcl_isPropertySetDefaulted(const Sequence< OUString>& _aNames,const Reference<XPropertySet>& _xProp) { Reference<XPropertyState> xState(_xProp,UNO_QUERY); - if ( xState.is() ) + if ( !xState ) + return false; + const OUString* pIter = _aNames.getConstArray(); + const OUString* pEnd = pIter + _aNames.getLength(); + for(;pIter != pEnd;++pIter) { - const OUString* pIter = _aNames.getConstArray(); - const OUString* pEnd = pIter + _aNames.getLength(); - for(;pIter != pEnd;++pIter) + try { - try - { - PropertyState aState = xState->getPropertyState(*pIter); - if ( aState != PropertyState_DEFAULT_VALUE ) - break; - } - catch(const Exception&) - { - TOOLS_WARN_EXCEPTION("dbaccess", "" ); - } + PropertyState aState = xState->getPropertyState(*pIter); + if ( aState != PropertyState_DEFAULT_VALUE ) + break; + } + catch(const Exception&) + { + TOOLS_WARN_EXCEPTION("dbaccess", "" ); } - return ( pIter == pEnd ); } - return false; + return ( pIter == pEnd ); } } @@ -158,7 +155,7 @@ void lcl_createDefinitionObject(const OUString& _rName { // set as folder _xTableDefinition = TableDefinition::createWithName( ::comphelper::getProcessComponentContext(), _rName ); - _xTableDefinitions->insertByName(_rName,makeAny(_xTableDefinition)); + _xTableDefinitions->insertByName(_rName,Any(_xTableDefinition)); } Reference<XColumnsSupplier> xColumnsSupplier(_xTableDefinition,UNO_QUERY); if ( xColumnsSupplier.is() ) @@ -410,7 +407,7 @@ void SAL_CALL OTableContainer::elementInserted( const ContainerEvent& Event ) ObjectType xName = createObject(sName); insertElement(sName,xName); // and notify our listeners - ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(sName), makeAny(xName), Any()); + ContainerEvent aEvent(static_cast<XContainer*>(this), Any(sName), Any(xName), Any()); m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); } } diff --git a/dbaccess/source/core/api/viewcontainer.cxx b/dbaccess/source/core/api/viewcontainer.cxx index 4e35515a4196..7e170b86d43a 100644 --- a/dbaccess/source/core/api/viewcontainer.cxx +++ b/dbaccess/source/core/api/viewcontainer.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <apitools.hxx> +#include <strings.hxx> #include <viewcontainer.hxx> #include <View.hxx> @@ -34,9 +34,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::container; using namespace ::osl; using namespace ::comphelper; diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx index 258cfc473a90..19076507e0b3 100644 --- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx +++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx @@ -18,18 +18,17 @@ */ #include "ComponentDefinition.hxx" -#include <apitools.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <osl/diagnose.h> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <cppuhelper/interfacecontainer.hxx> +//#include <cppuhelper/interfacecontainer.hxx> #include <comphelper/property.hxx> #include <comphelper/propertysequence.hxx> #include <definitioncolumn.hxx> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx index bbf910cbf641..7dd40092fe52 100644 --- a/dbaccess/source/core/dataaccess/ContentHelper.cxx +++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx @@ -31,14 +31,14 @@ #include <com/sun/star/container/ElementExistException.hpp> #include <ucbhelper/propertyvalueset.hxx> #include <ucbhelper/contentidentifier.hxx> -#include <cppuhelper/interfacecontainer.hxx> #include <comphelper/servicehelper.hxx> -#include <tools/diagnose_ex.h> -#include <apitools.hxx> +#include <comphelper/diagnose_ex.hxx> #include <sdbcoretools.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <map> +#include <utility> namespace dbaccess { @@ -48,8 +48,6 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::embed; using namespace ::com::sun::star::container; using namespace ::cppu; @@ -64,13 +62,13 @@ OContentHelper_Impl::~OContentHelper_Impl() OContentHelper::OContentHelper(const Reference< XComponentContext >& _xORB ,const Reference< XInterface >& _xParentContainer - ,const TContentPtr& _pImpl) + ,TContentPtr _pImpl) : OContentHelper_COMPBASE(m_aMutex) ,m_aContentListeners(m_aMutex) ,m_aPropertyChangeListeners(m_aMutex) ,m_xParentContainer( _xParentContainer ) ,m_aContext( _xORB ) - ,m_pImpl(_pImpl) + ,m_pImpl(std::move(_pImpl)) ,m_nCommandId(0) { } @@ -105,12 +103,6 @@ css::uno::Sequence< OUString > SAL_CALL OContentHelper::getSupportedServiceNames } -css::uno::Sequence<sal_Int8> OContentHelper::getUnoTunnelId() -{ - static const comphelper::UnoIdInit aId; - return aId.getSeq(); -} - css::uno::Sequence<sal_Int8> OContentHelper::getImplementationId() { return css::uno::Sequence<sal_Int8>(); @@ -194,7 +186,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -212,7 +204,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -224,7 +216,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma { OSL_FAIL( "No properties!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -250,7 +242,7 @@ Any SAL_CALL OContentHelper::execute( const Command& aCommand, sal_Int32 /*Comma OSL_FAIL( "Content::execute - unsupported command!" ); ucbhelper::cancelCommandExecution( - makeAny( UnsupportedCommandException( + Any( UnsupportedCommandException( OUString(), static_cast< cppu::OWeakObject * >( this ) ) ), Environment ); @@ -503,16 +495,9 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent return; // First, notify listeners interested in changes of every property. - comphelper::OInterfaceContainerHelper2* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( OUString() ); + comphelper::OInterfaceContainerHelper3<XPropertiesChangeListener>* pAllPropsContainer = m_aPropertyChangeListeners.getContainer( OUString() ); if ( pAllPropsContainer ) - { - comphelper::OInterfaceIteratorHelper2 aIter( *pAllPropsContainer ); - while ( aIter.hasMoreElements() ) - { - // Propagate event. - static_cast< XPropertiesChangeListener* >( aIter.next() )->propertiesChange( evt ); - } - } + pAllPropsContainer->notifyEach( &XPropertiesChangeListener::propertiesChange, evt ); typedef std::map< XPropertiesChangeListener*, Sequence< PropertyChangeEvent > > PropertiesEventListenerMap; PropertiesEventListenerMap aListeners; @@ -524,15 +509,15 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent const PropertyChangeEvent& rEvent = *propertyChangeEvent; const OUString& rName = rEvent.PropertyName; - comphelper::OInterfaceContainerHelper2* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName ); + comphelper::OInterfaceContainerHelper3<XPropertiesChangeListener>* pPropsContainer = m_aPropertyChangeListeners.getContainer( rName ); if ( pPropsContainer ) { - comphelper::OInterfaceIteratorHelper2 aIter( *pPropsContainer ); + comphelper::OInterfaceIteratorHelper3 aIter( *pPropsContainer ); while ( aIter.hasMoreElements() ) { Sequence< PropertyChangeEvent >* propertyEvents; - XPropertiesChangeListener* pListener = static_cast< XPropertiesChangeListener * >( aIter.next() ); + XPropertiesChangeListener* pListener = aIter.next().get(); PropertiesEventListenerMap::iterator it = aListeners.find( pListener ); if ( it == aListeners.end() ) { @@ -559,12 +544,6 @@ void OContentHelper::notifyPropertiesChange( const Sequence< PropertyChangeEvent } } -// css::lang::XUnoTunnel -sal_Int64 OContentHelper::getSomething( const Sequence< sal_Int8 > & rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - Reference< XInterface > SAL_CALL OContentHelper::getParent( ) { ::osl::MutexGuard aGuard(m_aMutex); diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 49a74717e559..818e70b5433b 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -48,7 +48,7 @@ #include <comphelper/processfactory.hxx> #include <sfx2/docfile.hxx> #include <sfx2/signaturestate.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/file.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> @@ -58,11 +58,11 @@ #include <i18nlangtag/languagetag.hxx> #include <algorithm> +#include <utility> using namespace css; using namespace ::com::sun::star::document; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; @@ -71,9 +71,7 @@ using namespace ::com::sun::star::embed; using namespace ::com::sun::star::container; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::view; using namespace ::com::sun::star::task; using namespace ::com::sun::star::script; using namespace ::cppu; @@ -353,7 +351,7 @@ void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& So // ODatabaseModelImpl ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _rxContext, ODatabaseContext& _rDBContext ) - :m_aContainer(4) + :m_aContainer() ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_rDBContext( _rDBContext ) @@ -369,7 +367,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r ,m_bModified(false) ,m_bDocumentReadOnly(false) ,m_bMacroCallsSeenWhileLoading(false) - ,m_pSharedConnectionManager(nullptr) ,m_nControllerLockCount(0) { // some kind of default @@ -379,11 +376,11 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r } ODatabaseModelImpl::ODatabaseModelImpl( - const OUString& _rRegistrationName, + OUString _sRegistrationName, const Reference< XComponentContext >& _rxContext, ODatabaseContext& _rDBContext ) - :m_aContainer(4) + :m_aContainer() ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_rDBContext( _rDBContext ) @@ -392,7 +389,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( ,m_bDocumentInitialized( false ) ,m_nScriptingSignatureState(SignatureState::UNKNOWN) ,m_aContext( _rxContext ) - ,m_sName(_rRegistrationName) + ,m_sName(std::move(_sRegistrationName)) ,m_nLoginTimeout(0) ,m_bReadOnly(false) ,m_bPasswordRequired(false) @@ -400,7 +397,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( ,m_bModified(false) ,m_bDocumentReadOnly(false) ,m_bMacroCallsSeenWhileLoading(false) - ,m_pSharedConnectionManager(nullptr) ,m_nControllerLockCount(0) { impl_construct_nothrow(); @@ -441,7 +437,7 @@ void ODatabaseModelImpl::impl_construct_nothrow() pSettings->ValueType, PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT | PropertyAttribute::MAYBEVOID ); - xSettingsSet->insert( makeAny( aProperty ) ); + xSettingsSet->insert( Any( aProperty ) ); } else { @@ -467,10 +463,10 @@ namespace const char* pAsciiName( nullptr ); switch ( _eType ) { - case ODatabaseModelImpl::E_FORM: pAsciiName = "forms"; break; - case ODatabaseModelImpl::E_REPORT: pAsciiName = "reports"; break; - case ODatabaseModelImpl::E_QUERY: pAsciiName = "queries"; break; - case ODatabaseModelImpl::E_TABLE: pAsciiName = "tables"; break; + case ODatabaseModelImpl::ObjectType::Form: pAsciiName = "forms"; break; + case ODatabaseModelImpl::ObjectType::Report: pAsciiName = "reports"; break; + case ODatabaseModelImpl::ObjectType::Query: pAsciiName = "queries"; break; + case ODatabaseModelImpl::ObjectType::Table: pAsciiName = "tables"; break; default: throw RuntimeException(); } @@ -560,7 +556,8 @@ bool ODatabaseModelImpl::objectHasMacros( const Reference< XStorage >& _rxContai void ODatabaseModelImpl::reset() { m_bReadOnly = false; - std::vector<TContentPtr>(4).swap(m_aContainer); + for (auto & i : m_aContainer) + i.reset(); if ( m_pStorageAccess.is() ) { @@ -622,7 +619,6 @@ void ODatabaseModelImpl::clearConnections() } } - m_pSharedConnectionManager = nullptr; m_xSharedConnectionManager = nullptr; } @@ -649,7 +645,8 @@ void ODatabaseModelImpl::dispose() if ( elem ) elem->m_pDataSource = nullptr; } - m_aContainer.clear(); + for (auto & i : m_aContainer) + i.reset(); clearConnections(); @@ -833,7 +830,7 @@ bool ODatabaseModelImpl::commitEmbeddedStorage( bool _bPreventRootCommits ) bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference< XStorage >& _rxStorage ) { bool bTryToPreserveScriptSignature = false; - utl::TempFile aTempFile; + utl::TempFileNamed aTempFile; aTempFile.EnableKillingFile(); OUString sTmpFileUrl = aTempFile.GetURL(); SignatureState aSignatureState = getScriptingSignatureState(); @@ -887,7 +884,7 @@ bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference< uno::Reference<embed::XStorage> xTargetMetaInf = _rxStorage->openStorageElement("META-INF", embed::ElementModes::READWRITE); - if (xMetaInf.is() && xTargetMetaInf.is()) + if (xMetaInf.is() && xTargetMetaInf.is() && xMetaInf->hasByName(aScriptSignName)) { xMetaInf->copyElementTo(aScriptSignName, xTargetMetaInf, aScriptSignName); @@ -976,7 +973,7 @@ Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership() try { Reference< XGlobalEventBroadcaster > xModelCollection = theGlobalEventBroadcaster::get( m_aContext ); - xModelCollection->insert( makeAny( xModel ) ); + xModelCollection->insert( Any( xModel ) ); } catch( const Exception& ) { @@ -1032,68 +1029,68 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() static const AsciiPropertyValue aKnownSettings[] = { // known JDBC settings - AsciiPropertyValue( "JavaDriverClass", makeAny( OUString() ) ), - AsciiPropertyValue( "JavaDriverClassPath", makeAny( OUString() ) ), - AsciiPropertyValue( "IgnoreCurrency", makeAny( false ) ), + AsciiPropertyValue( "JavaDriverClass", Any( OUString() ) ), + AsciiPropertyValue( "JavaDriverClassPath", Any( OUString() ) ), + AsciiPropertyValue( "IgnoreCurrency", Any( false ) ), // known settings for file-based drivers - AsciiPropertyValue( "Extension", makeAny( OUString() ) ), - AsciiPropertyValue( "CharSet", makeAny( OUString() ) ), - AsciiPropertyValue( "HeaderLine", makeAny( true ) ), - AsciiPropertyValue( "FieldDelimiter", makeAny( OUString( "," ) ) ), - AsciiPropertyValue( "StringDelimiter", makeAny( OUString( "\"" ) ) ), - AsciiPropertyValue( "DecimalDelimiter", makeAny( OUString( "." ) ) ), - AsciiPropertyValue( "ThousandDelimiter", makeAny( OUString() ) ), - AsciiPropertyValue( "ShowDeleted", makeAny( false ) ), + AsciiPropertyValue( "Extension", Any( OUString() ) ), + AsciiPropertyValue( "CharSet", Any( OUString() ) ), + AsciiPropertyValue( "HeaderLine", Any( true ) ), + AsciiPropertyValue( "FieldDelimiter", Any( OUString( "," ) ) ), + AsciiPropertyValue( "StringDelimiter", Any( OUString( "\"" ) ) ), + AsciiPropertyValue( "DecimalDelimiter", Any( OUString( "." ) ) ), + AsciiPropertyValue( "ThousandDelimiter", Any( OUString() ) ), + AsciiPropertyValue( "ShowDeleted", Any( false ) ), // known ODBC settings - AsciiPropertyValue( "SystemDriverSettings", makeAny( OUString() ) ), - AsciiPropertyValue( "UseCatalog", makeAny( false ) ), - AsciiPropertyValue( "TypeInfoSettings", makeAny( Sequence< Any >()) ), + AsciiPropertyValue( "SystemDriverSettings", Any( OUString() ) ), + AsciiPropertyValue( "UseCatalog", Any( false ) ), + AsciiPropertyValue( "TypeInfoSettings", Any( Sequence< Any >()) ), // settings related to auto increment handling - AsciiPropertyValue( "AutoIncrementCreation", makeAny( OUString() ) ), - AsciiPropertyValue( "AutoRetrievingStatement", makeAny( OUString() ) ), - AsciiPropertyValue( "IsAutoRetrievingEnabled", makeAny( false ) ), + AsciiPropertyValue( "AutoIncrementCreation", Any( OUString() ) ), + AsciiPropertyValue( "AutoRetrievingStatement", Any( OUString() ) ), + AsciiPropertyValue( "IsAutoRetrievingEnabled", Any( false ) ), // known LDAP driver settings - AsciiPropertyValue( "HostName", makeAny( OUString() ) ), - AsciiPropertyValue( "PortNumber", makeAny( sal_Int32(389) ) ), - AsciiPropertyValue( "BaseDN", makeAny( OUString() ) ), - AsciiPropertyValue( "MaxRowCount", makeAny( sal_Int32(100) ) ), + AsciiPropertyValue( "HostName", Any( OUString() ) ), + AsciiPropertyValue( "PortNumber", Any( sal_Int32(389) ) ), + AsciiPropertyValue( "BaseDN", Any( OUString() ) ), + AsciiPropertyValue( "MaxRowCount", Any( sal_Int32(100) ) ), // known MySQLNative driver settings - AsciiPropertyValue( "LocalSocket", makeAny( OUString() ) ), - AsciiPropertyValue( "NamedPipe", makeAny( OUString() ) ), + AsciiPropertyValue( "LocalSocket", Any( OUString() ) ), + AsciiPropertyValue( "NamedPipe", Any( OUString() ) ), // misc known driver settings - AsciiPropertyValue( "ParameterNameSubstitution", makeAny( false ) ), - AsciiPropertyValue( "AddIndexAppendix", makeAny( true ) ), - AsciiPropertyValue( "IgnoreDriverPrivileges", makeAny( true ) ), + AsciiPropertyValue( "ParameterNameSubstitution", Any( false ) ), + AsciiPropertyValue( "AddIndexAppendix", Any( true ) ), + AsciiPropertyValue( "IgnoreDriverPrivileges", Any( true ) ), AsciiPropertyValue( "ImplicitCatalogRestriction", ::cppu::UnoType< OUString >::get() ), AsciiPropertyValue( "ImplicitSchemaRestriction", ::cppu::UnoType< OUString >::get() ), AsciiPropertyValue( "PrimaryKeySupport", ::cppu::UnoType< sal_Bool >::get() ), - AsciiPropertyValue( "ShowColumnDescription", makeAny( false ) ), + AsciiPropertyValue( "ShowColumnDescription", Any( false ) ), // known SDB level settings - AsciiPropertyValue( "NoNameLengthLimit", makeAny( false ) ), - AsciiPropertyValue( "AppendTableAliasName", makeAny( false ) ), - AsciiPropertyValue( "GenerateASBeforeCorrelationName", makeAny( false ) ), - AsciiPropertyValue( "ColumnAliasInOrderBy", makeAny( true ) ), - AsciiPropertyValue( "EnableSQL92Check", makeAny( false ) ), - AsciiPropertyValue( "BooleanComparisonMode", makeAny( BooleanComparisonMode::EQUAL_INTEGER ) ), - AsciiPropertyValue( "TableTypeFilterMode", makeAny( sal_Int32(3) ) ), - AsciiPropertyValue( "RespectDriverResultSetType", makeAny( false ) ), - AsciiPropertyValue( "UseSchemaInSelect", makeAny( true ) ), - AsciiPropertyValue( "UseCatalogInSelect", makeAny( true ) ), - AsciiPropertyValue( "EnableOuterJoinEscape", makeAny( true ) ), - AsciiPropertyValue( "PreferDosLikeLineEnds", makeAny( false ) ), - AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( true ) ), - AsciiPropertyValue( "EscapeDateTime", makeAny( true ) ), + AsciiPropertyValue( "NoNameLengthLimit", Any( false ) ), + AsciiPropertyValue( "AppendTableAliasName", Any( false ) ), + AsciiPropertyValue( "GenerateASBeforeCorrelationName", Any( false ) ), + AsciiPropertyValue( "ColumnAliasInOrderBy", Any( true ) ), + AsciiPropertyValue( "EnableSQL92Check", Any( false ) ), + AsciiPropertyValue( "BooleanComparisonMode", Any( BooleanComparisonMode::EQUAL_INTEGER ) ), + AsciiPropertyValue( "TableTypeFilterMode", Any( sal_Int32(3) ) ), + AsciiPropertyValue( "RespectDriverResultSetType", Any( false ) ), + AsciiPropertyValue( "UseSchemaInSelect", Any( true ) ), + AsciiPropertyValue( "UseCatalogInSelect", Any( true ) ), + AsciiPropertyValue( "EnableOuterJoinEscape", Any( true ) ), + AsciiPropertyValue( "PreferDosLikeLineEnds", Any( false ) ), + AsciiPropertyValue( "FormsCheckRequiredFields", Any( true ) ), + AsciiPropertyValue( "EscapeDateTime", Any( true ) ), // known services to handle database tasks - AsciiPropertyValue( "TableAlterationServiceName", makeAny( OUString() ) ), - AsciiPropertyValue( "TableRenameServiceName", makeAny( OUString() ) ), - AsciiPropertyValue( "ViewAlterationServiceName", makeAny( OUString() ) ), - AsciiPropertyValue( "ViewAccessServiceName", makeAny( OUString() ) ), - AsciiPropertyValue( "CommandDefinitions", makeAny( OUString() ) ), - AsciiPropertyValue( "Forms", makeAny( OUString() ) ), - AsciiPropertyValue( "Reports", makeAny( OUString() ) ), - AsciiPropertyValue( "KeyAlterationServiceName", makeAny( OUString() ) ), - AsciiPropertyValue( "IndexAlterationServiceName", makeAny( OUString() ) ), + AsciiPropertyValue( "TableAlterationServiceName", Any( OUString() ) ), + AsciiPropertyValue( "TableRenameServiceName", Any( OUString() ) ), + AsciiPropertyValue( "ViewAlterationServiceName", Any( OUString() ) ), + AsciiPropertyValue( "ViewAccessServiceName", Any( OUString() ) ), + AsciiPropertyValue( "CommandDefinitions", Any( OUString() ) ), + AsciiPropertyValue( "Forms", Any( OUString() ) ), + AsciiPropertyValue( "Reports", Any( OUString() ) ), + AsciiPropertyValue( "KeyAlterationServiceName", Any( OUString() ) ), + AsciiPropertyValue( "IndexAlterationServiceName", Any( OUString() ) ), AsciiPropertyValue() }; @@ -1102,7 +1099,6 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType ) { - OSL_PRECOND( _eType >= E_FORM && _eType <= E_TABLE, "ODatabaseModelImpl::getObjectContainer: illegal index!" ); TContentPtr& rContentPtr = m_aContainer[ _eType ]; if ( !rContentPtr ) @@ -1123,7 +1119,8 @@ bool ODatabaseModelImpl::checkMacrosOnLoading() { Reference< XInteractionHandler > xInteraction; xInteraction = m_aMediaDescriptor.getOrDefault( "InteractionHandler", xInteraction ); - return m_aMacroMode.checkMacrosOnLoading( xInteraction ); + const bool bHasMacros = m_aMacroMode.hasMacros(); + return m_aMacroMode.checkMacrosOnLoading(xInteraction, false /*HasValidContentSignature*/, bHasMacros); } void ODatabaseModelImpl::resetMacroExecutionMode() @@ -1321,17 +1318,17 @@ ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros() { if ( ::sfx2::DocumentMacroMode::storageHasMacros( getOrCreateRootStorage() ) ) { - m_aEmbeddedMacros = eDocumentWideMacros; + m_aEmbeddedMacros = EmbeddedMacros::DocumentWide; } - else if ( lcl_hasObjectsWithMacros_nothrow( *this, E_FORM ) - || lcl_hasObjectsWithMacros_nothrow( *this, E_REPORT ) + else if ( lcl_hasObjectsWithMacros_nothrow( *this, ObjectType::Form ) + || lcl_hasObjectsWithMacros_nothrow( *this, ObjectType::Report ) ) { - m_aEmbeddedMacros = eSubDocumentMacros; + m_aEmbeddedMacros = EmbeddedMacros::SubDocument; } else { - m_aEmbeddedMacros = eNoMacros; + m_aEmbeddedMacros = EmbeddedMacros::NONE; } } return *m_aEmbeddedMacros; @@ -1340,7 +1337,7 @@ ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros() bool ODatabaseModelImpl::documentStorageHasMacros() const { const_cast< ODatabaseModelImpl* >( this )->determineEmbeddedMacros(); - return ( *m_aEmbeddedMacros != eNoMacros ); + return ( *m_aEmbeddedMacros != EmbeddedMacros::NONE ); } bool ODatabaseModelImpl::macroCallsSeenWhileLoading() const @@ -1358,7 +1355,8 @@ SignatureState ODatabaseModelImpl::getScriptingSignatureState() return m_nScriptingSignatureState; } -bool ODatabaseModelImpl::hasTrustedScriptingSignature(bool bAllowUIToAddAuthor) +bool ODatabaseModelImpl::hasTrustedScriptingSignature( + const css::uno::Reference<css::task::XInteractionHandler>& _rxInteraction) { bool bResult = false; @@ -1390,20 +1388,15 @@ bool ODatabaseModelImpl::hasTrustedScriptingSignature(bool bAllowUIToAddAuthor) }); } - if (!bResult && bAllowUIToAddAuthor) + if (!bResult && _rxInteraction) { - Reference<XInteractionHandler> xInteraction; - xInteraction = m_aMediaDescriptor.getOrDefault("InteractionHandler", xInteraction); - if (xInteraction.is()) - { - task::DocumentMacroConfirmationRequest aRequest; - aRequest.DocumentURL = m_sDocFileLocation; - aRequest.DocumentStorage = xStorage; - aRequest.DocumentSignatureInformation = aInfo; - aRequest.DocumentVersion = aODFVersion; - aRequest.Classification = task::InteractionClassification_QUERY; - bResult = SfxMedium::CallApproveHandler(xInteraction, uno::makeAny(aRequest), true); - } + task::DocumentMacroConfirmationRequest aRequest; + aRequest.DocumentURL = m_sDocFileLocation; + aRequest.DocumentStorage = xStorage; + aRequest.DocumentSignatureInformation = aInfo; + aRequest.DocumentVersion = aODFVersion; + aRequest.Classification = task::InteractionClassification_QUERY; + bResult = SfxMedium::CallApproveHandler(_rxInteraction, uno::Any(aRequest), true); } } catch (uno::Exception&) @@ -1418,8 +1411,8 @@ void ODatabaseModelImpl::storageIsModified() setModified( true ); } -ModelDependentComponent::ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model ) - :m_pImpl( _model ) +ModelDependentComponent::ModelDependentComponent( ::rtl::Reference< ODatabaseModelImpl > _model ) + :m_pImpl(std::move( _model )) { } diff --git a/dbaccess/source/core/dataaccess/SharedConnection.cxx b/dbaccess/source/core/dataaccess/SharedConnection.cxx index 31a8e68ba7b1..d893a8e298b3 100644 --- a/dbaccess/source/core/dataaccess/SharedConnection.cxx +++ b/dbaccess/source/core/dataaccess/SharedConnection.cxx @@ -38,8 +38,8 @@ OSharedConnection::~OSharedConnection() {} void SAL_CALL OSharedConnection::disposing() { - OSharedConnection_BASE::disposing(); OConnectionWrapper::disposing(); + OSharedConnection_BASE::disposing(); } Reference<XStatement> SAL_CALL OSharedConnection::createStatement() diff --git a/dbaccess/source/core/dataaccess/SharedConnection.hxx b/dbaccess/source/core/dataaccess/SharedConnection.hxx index ea6e961cf19d..2c88e58fd55d 100644 --- a/dbaccess/source/core/dataaccess/SharedConnection.hxx +++ b/dbaccess/source/core/dataaccess/SharedConnection.hxx @@ -34,11 +34,10 @@ namespace dbaccess // datasource is asked for not isolated connection. typedef ::cppu::WeakComponentImplHelper< css::sdbc::XConnection > OSharedConnection_BASE; - typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2; class OSharedConnection : public ::cppu::BaseMutex , public OSharedConnection_BASE - , public OSharedConnection_BASE2 + , public ::connectivity::OConnectionWrapper { protected: virtual void SAL_CALL disposing() override; @@ -54,7 +53,7 @@ namespace dbaccess { return ::comphelper::concatSequences( OSharedConnection_BASE::getTypes(), - OSharedConnection_BASE2::getTypes() + ::connectivity::OConnectionWrapper::getTypes() ); } @@ -62,7 +61,7 @@ namespace dbaccess { css::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType); if ( !aReturn.hasValue() ) - aReturn = OSharedConnection_BASE2::queryInterface(_rType); + aReturn = ::connectivity::OConnectionWrapper::queryInterface(_rType); return aReturn; } diff --git a/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx b/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx index bee7a0cbb7b9..a03caea57e93 100644 --- a/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx +++ b/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx @@ -19,6 +19,7 @@ #include <bookmarkcontainer.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <comphelper/enumhelper.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> @@ -96,10 +97,8 @@ void SAL_CALL OBookmarkContainer::insertByName( const OUString& _rName, const An // notify the listeners if (m_aContainerListeners.getLength()) { - ContainerEvent aEvent(*this, makeAny(_rName), makeAny(sNewLink), Any()); - OInterfaceIteratorHelper3 aListenerIterator(m_aContainerListeners); - while (aListenerIterator.hasMoreElements()) - aListenerIterator.next()->elementInserted(aEvent); + ContainerEvent aEvent(*this, Any(_rName), Any(sNewLink), Any()); + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); } } @@ -126,10 +125,8 @@ void SAL_CALL OBookmarkContainer::removeByName( const OUString& _rName ) // notify the listeners if (m_aContainerListeners.getLength()) { - ContainerEvent aEvent(*this, makeAny(_rName), makeAny(sOldBookmark), Any()); - OInterfaceIteratorHelper3 aListenerIterator(m_aContainerListeners); - while (aListenerIterator.hasMoreElements()) - aListenerIterator.next()->elementRemoved(aEvent); + ContainerEvent aEvent(*this, Any(_rName), Any(sOldBookmark), Any()); + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); } } @@ -161,10 +158,8 @@ void SAL_CALL OBookmarkContainer::replaceByName( const OUString& _rName, const A aGuard.clear(); if (m_aContainerListeners.getLength()) { - ContainerEvent aEvent(*this, makeAny(_rName), makeAny(sNewLink), makeAny(sOldLink)); - OInterfaceIteratorHelper3 aListenerIterator(m_aContainerListeners); - while (aListenerIterator.hasMoreElements()) - aListenerIterator.next()->elementReplaced(aEvent); + ContainerEvent aEvent(*this, Any(_rName), Any(sNewLink), Any(sOldLink)); + m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvent ); } } @@ -185,7 +180,6 @@ void SAL_CALL OBookmarkContainer::removeContainerListener( const Reference< XCon // XElementAccess Type SAL_CALL OBookmarkContainer::getElementType( ) { - MutexGuard aGuard(m_rMutex); return ::cppu::UnoType<OUString>::get(); } @@ -213,10 +207,10 @@ Any SAL_CALL OBookmarkContainer::getByIndex( sal_Int32 _nIndex ) { MutexGuard aGuard(m_rMutex); - if ((_nIndex < 0) || (_nIndex >= static_cast<sal_Int32>(m_aBookmarksIndexed.size()))) + if ((_nIndex < 0) || (o3tl::make_unsigned(_nIndex) >= m_aBookmarksIndexed.size())) throw IndexOutOfBoundsException(); - return makeAny(m_aBookmarksIndexed[_nIndex]->second); + return Any(m_aBookmarksIndexed[_nIndex]->second); } Any SAL_CALL OBookmarkContainer::getByName( const OUString& _rName ) @@ -226,7 +220,7 @@ Any SAL_CALL OBookmarkContainer::getByName( const OUString& _rName ) if (!checkExistence(_rName)) throw NoSuchElementException(); - return makeAny(m_aBookmarks[_rName]); + return Any(m_aBookmarks[_rName]); } Sequence< OUString > SAL_CALL OBookmarkContainer::getElementNames( ) diff --git a/dbaccess/source/core/dataaccess/commandcontainer.cxx b/dbaccess/source/core/dataaccess/commandcontainer.cxx index 8afb81520e2d..7f646c61722e 100644 --- a/dbaccess/source/core/dataaccess/commandcontainer.cxx +++ b/dbaccess/source/core/dataaccess/commandcontainer.cxx @@ -24,11 +24,7 @@ #include <com/sun/star/sdb/CommandDefinition.hpp> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::ucb; -using namespace ::osl; using namespace ::comphelper; using namespace ::cppu; diff --git a/dbaccess/source/core/dataaccess/commanddefinition.cxx b/dbaccess/source/core/dataaccess/commanddefinition.cxx index f460911f3392..b3f4fa8b0ead 100644 --- a/dbaccess/source/core/dataaccess/commanddefinition.cxx +++ b/dbaccess/source/core/dataaccess/commanddefinition.cxx @@ -18,16 +18,14 @@ */ #include "commanddefinition.hxx" -#include <apitools.hxx> #include <stringconstants.hxx> +#include <strings.hxx> #include <com/sun/star/container/ElementExistException.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -126,9 +124,9 @@ void SAL_CALL OCommandDefinition::rename( const OUString& newName ) { sal_Int32 nHandle = PROPERTY_ID_NAME; osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex); - Any aOld = makeAny(m_pImpl->m_aProps.aTitle); + Any aOld(m_pImpl->m_aProps.aTitle); aGuard.clear(); - Any aNew = makeAny(newName); + Any aNew(newName); fire(&nHandle, &aNew, &aOld, 1, true ); m_pImpl->m_aProps.aTitle = newName; diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index 0da533536a9d..fa4c934a056e 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -24,6 +24,7 @@ #include "connection.hxx" #include "datasource.hxx" #include <strings.hrc> +#include <strings.hxx> #include <core_resource.hxx> #include <statement.hxx> #include <preparedstatement.hxx> @@ -38,7 +39,7 @@ #include <com/sun/star/beans/NamedValue.hpp> #include <connectivity/dbtools.hxx> #include <connectivity/dbmetadata.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> @@ -46,7 +47,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdb::application; using namespace ::com::sun::star::sdbc; @@ -629,7 +629,7 @@ Reference< XInterface > SAL_CALL OConnection::createInstance( const OUString& _s if ( aFind == m_aSupportServices.end() ) { Reference<XConnection> xMy(this); - Sequence<Any> aArgs{ Any(NamedValue("ActiveConnection",makeAny(xMy))) }; + Sequence<Any> aArgs{ Any(NamedValue("ActiveConnection",Any(xMy))) }; aFind = m_aSupportServices.emplace( _sServiceSpecifier, m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sServiceSpecifier, aArgs, m_aContext) diff --git a/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx b/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx index 97a8f5b9fb86..ef5239a6793f 100644 --- a/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx +++ b/dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx @@ -35,7 +35,6 @@ #include <comphelper/uno3.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> -#include <rtl/ref.hxx> namespace { diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 79c657db3054..54c2ae37f356 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -20,6 +20,7 @@ #include <config_features.h> #include <strings.hrc> +#include <strings.hxx> #include <core_resource.hxx> #include <databasecontext.hxx> #include "databaseregistrations.hxx" @@ -57,7 +58,7 @@ #include <rtl/uri.hxx> #include <sal/log.hxx> #include <svl/filenotation.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/urlobj.hxx> #include <ucbhelper/content.hxx> #include <rtl/ref.hxx> @@ -73,7 +74,6 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::container; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::registry; using namespace ::com::sun::star; using namespace ::cppu; using namespace ::osl; @@ -176,12 +176,7 @@ ODatabaseContext::ODatabaseContext( const Reference< XComponentContext >& _rxCon #endif osl_atomic_increment( &m_refCount ); - { - m_xDBRegistrationAggregate.set( createDataSourceRegistrations( m_aContext ), UNO_SET_THROW ); - m_xDatabaseRegistrations.set( m_xDBRegistrationAggregate, UNO_QUERY_THROW ); - - m_xDBRegistrationAggregate->setDelegator( *this ); - } + m_xDatabaseRegistrations = createDataSourceRegistrations( m_aContext ); osl_atomic_decrement( &m_refCount ); } @@ -192,8 +187,6 @@ ODatabaseContext::~ODatabaseContext() #endif m_xDatabaseDocumentLoader.clear(); - m_xDBRegistrationAggregate->setDelegator( nullptr ); - m_xDBRegistrationAggregate.clear(); m_xDatabaseRegistrations.clear(); } @@ -313,10 +306,11 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa OUString sErrorMessage( DBA_RES( RID_STR_FILE_DOES_NOT_EXIST ) ); ::svt::OFileNotation aTransformer( _sURL ); - SQLException aError; - aError.Message = sErrorMessage.replaceAll( "$file$", aTransformer.get( ::svt::OFileNotation::N_SYSTEM ) ); + SQLException aError(sErrorMessage.replaceAll( + "$file$", aTransformer.get(::svt::OFileNotation::N_SYSTEM)), + {}, {}, 0, {}); - throw WrappedTargetException( _sURL, *this, makeAny( aError ) ); + throw WrappedTargetException( _sURL, *this, Any( aError ) ); } throw WrappedTargetException( _sURL, *this, ::cppu::getCaughtException() ); } @@ -439,7 +433,7 @@ void ODatabaseContext::registerObject(const OUString& _rName, const Reference< X } // notify our container listeners - ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rName), makeAny(_rxObject), Any()); + ContainerEvent aEvent(static_cast<XContainer*>(this), Any(_rName), Any(_rxObject), Any()); m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); } @@ -458,7 +452,7 @@ void ODatabaseContext::storeTransientProperties( ODatabaseModelImpl& _rModelImpl if (xSetInfo.is()) aProperties = xSetInfo->getProperties(); - for ( const Property& rProperty : std::as_const(aProperties) ) + for (const Property& rProperty : aProperties) { if ( ( ( rProperty.Attributes & PropertyAttribute::TRANSIENT) != 0 ) && ( ( rProperty.Attributes & PropertyAttribute::READONLY) == 0 ) @@ -527,7 +521,7 @@ void ODatabaseContext::revokeObject(const OUString& _rName) m_aDatabaseObjects.erase( aExistent ); // notify our container listeners - ContainerEvent aEvent( *this, makeAny( _rName ), Any(), Any() ); + ContainerEvent aEvent( *this, Any( _rName ), Any(), Any() ); aGuard.clear(); m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); } @@ -610,7 +604,7 @@ Any ODatabaseContext::getByName(const OUString& _rName) { Reference< XInterface > xExistent = getObject( _rName ); if ( xExistent.is() ) - return makeAny( xExistent ); + return Any( xExistent ); // see whether this is a registered name OUString sURL; @@ -627,7 +621,7 @@ Any ODatabaseContext::getByName(const OUString& _rName) if ( !xExistent.is() ) // try to load this as URL xExistent = loadObjectFromURL( _rName, sURL ); - return makeAny( xExistent ); + return Any( xExistent ); } catch (const NoSuchElementException&) { // let these exceptions through @@ -706,17 +700,6 @@ void ODatabaseContext::databaseDocumentURLChange( const OUString& _rOldURL, cons m_aDatabaseObjects.erase( oldPos ); } -sal_Int64 SAL_CALL ODatabaseContext::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - -Sequence< sal_Int8 > ODatabaseContext::getUnoTunnelId() -{ - static const comphelper::UnoIdInit implId; - return implId.getSeq(); -} - void ODatabaseContext::onBasicManagerCreated( const Reference< XModel >& _rxForDocument, BasicManager& _rBasicManager ) { #if !HAVE_FEATURE_SCRIPTING @@ -735,7 +718,7 @@ void ODatabaseContext::onBasicManagerCreated( const Reference< XModel >& _rxForD // ... whose BasicManager has just been created, then add the global DatabaseDocument variable to its scope. if ( xDatabaseDocument.is() ) - _rBasicManager.SetGlobalUNOConstant( "ThisDatabaseDocument", makeAny( xDatabaseDocument ) ); + _rBasicManager.SetGlobalUNOConstant( "ThisDatabaseDocument", Any( xDatabaseDocument ) ); #endif } diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index b8b352a3a59c..204bad556e5d 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -24,9 +24,11 @@ #include <databasecontext.hxx> #include "documentcontainer.hxx" #include <sdbcoretools.hxx> +#include <strings.hxx> #include <recovery/dbdocrecovery.hxx> #include <officecfg/Office/Common.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> @@ -71,7 +73,7 @@ #include <cppuhelper/supportsservice.hxx> #include <framework/titlehelper.hxx> #include <unotools/saveopt.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <vcl/GraphicObject.hxx> @@ -195,28 +197,12 @@ Any SAL_CALL ODatabaseDocument::queryInterface( const Type& _rType ) ) return Any(); - Any aReturn = ODatabaseDocument_OfficeDocument::queryInterface(_rType); - if (!aReturn.hasValue()) - aReturn = ODatabaseDocument_Title::queryInterface(_rType); - return aReturn; -} - -void SAL_CALL ODatabaseDocument::acquire( ) noexcept -{ - ODatabaseDocument_OfficeDocument::acquire(); -} - -void SAL_CALL ODatabaseDocument::release( ) noexcept -{ - ODatabaseDocument_OfficeDocument::release(); + return ODatabaseDocument_OfficeDocument::queryInterface(_rType); } Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) { - Sequence< Type > aTypes = ::comphelper::concatSequences( - ODatabaseDocument_OfficeDocument::getTypes(), - ODatabaseDocument_Title::getTypes() - ); + Sequence< Type > aTypes = ODatabaseDocument_OfficeDocument::getTypes(); // strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report // which already contains macros. In this case, the database document itself is not @@ -304,17 +290,17 @@ namespace Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const ::comphelper::NamedValueCollection& _rDescriptor, const OUString& _rURL ) { + if ( _rURL.isEmpty() ) + return _rDescriptor.getPropertyValues(); + ::comphelper::NamedValueCollection aMutableDescriptor( _rDescriptor ); - if ( !_rURL.isEmpty() ) - { - aMutableDescriptor.put( "FileName", _rURL ); - aMutableDescriptor.put( "URL", _rURL ); - } + aMutableDescriptor.put( "FileName", _rURL ); + aMutableDescriptor.put( "URL", _rURL ); return aMutableDescriptor.getPropertyValues(); } } -constexpr OUStringLiteral sPictures = u"Pictures"; +constexpr OUString sPictures = u"Pictures"_ustr; // base documents seem to have a different behaviour to other documents, the // root storage contents at least seem to be re-used over different saves, thus if there is a @@ -432,9 +418,8 @@ namespace { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString("UsePrettyPrinting"), 0, ::cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - { OUString(), 0, css::uno::Type(), 0, 0 } + { OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, + { OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, }; } @@ -450,8 +435,8 @@ void ODatabaseDocument::impl_import_nolck_throw( const Reference< XComponentCont if (sBaseURI.isEmpty()) sBaseURI = _rResource.getOrDefault("URL",OUString()); assert(!sBaseURI.isEmpty()); // needed for relative URLs - xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sBaseURI)); - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); + xInfoSet->setPropertyValue("BaseURI", uno::Any(sBaseURI)); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml"))); const sal_Int32 nCount = aFilterCreationArgs.getLength(); aFilterCreationArgs.realloc(nCount + 1); @@ -774,7 +759,7 @@ bool ODatabaseDocument::impl_attachResource( const OUString& i_rLogicalDocumentU // determine whether the document as a whole, or sub documents, have macros. Especially the latter // controls the availability of our XEmbeddedScripts and XScriptInvocationContext interfaces, and we // should know this before anybody actually uses the object. - m_bAllowDocumentScripting = ( m_pImpl->determineEmbeddedMacros() != ODatabaseModelImpl::eSubDocumentMacros ); + m_bAllowDocumentScripting = ( m_pImpl->determineEmbeddedMacros() != ODatabaseModelImpl::EmbeddedMacros::SubDocument ); _rDocGuard.clear(); // <- SYNCHRONIZED @@ -1028,7 +1013,7 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph if ( !bIsInitializationProcess ) { _rGuard.clear(); - m_aEventNotifier.notifyDocumentEvent( _eType == SAVE ? "OnSave" : "OnSaveAs", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEvent( _eType == SAVE ? "OnSave" : "OnSaveAs", nullptr, Any( _rURL ) ); _rGuard.reset(); } @@ -1088,13 +1073,13 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph catch( const IOException& ) { if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) ); throw; } catch( const RuntimeException& ) { if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) ); throw; } catch( const Exception& ) @@ -1103,14 +1088,14 @@ void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comph // notify the failure if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) ); impl_throwIOExceptionCausedBySave_throw( aError, _rURL ); } // notify the document event if ( !bIsInitializationProcess ) - m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveDone" : "OnSaveAsDone", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveDone" : "OnSaveAsDone", nullptr, Any( _rURL ) ); // reset our "modified" flag, and clear the guard impl_setModified_nothrow( false, _rGuard ); @@ -1250,7 +1235,7 @@ void SAL_CALL ODatabaseDocument::storeToURL( const OUString& _rURL, const Sequen { aGuard.clear(); - m_aEventNotifier.notifyDocumentEvent( "OnSaveTo", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEvent( "OnSaveTo", nullptr, Any( _rURL ) ); aGuard.reset(); } @@ -1282,7 +1267,7 @@ void SAL_CALL ODatabaseDocument::storeToURL( const OUString& _rURL, const Sequen impl_throwIOExceptionCausedBySave_throw( aError, _rURL ); } - m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToDone", nullptr, makeAny( _rURL ) ); + m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToDone", nullptr, Any( _rURL ) ); } // XModifyBroadcaster @@ -1412,10 +1397,10 @@ void ODatabaseDocument::clearObjectContainer( WeakReference< XNameAccess >& _rxC Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType ) { - if ( ( _eType != ODatabaseModelImpl::E_FORM ) && ( _eType != ODatabaseModelImpl::E_REPORT ) ) + if ( ( _eType != ODatabaseModelImpl::ObjectType::Form ) && ( _eType != ODatabaseModelImpl::ObjectType::Report ) ) throw IllegalArgumentException(); - bool bFormsContainer = _eType == ODatabaseModelImpl::E_FORM; + bool bFormsContainer = _eType == ODatabaseModelImpl::ObjectType::Form; WeakReference< XNameAccess >& rContainerRef( bFormsContainer ? m_xForms : m_xReports ); Reference< XNameAccess > xContainer = rContainerRef; @@ -1429,7 +1414,7 @@ Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODa aValue >>= sSupportService; if ( !sSupportService.isEmpty() ) { - Sequence<Any> aArgs{ Any(NamedValue("DatabaseDocument",makeAny(xMy))) }; + Sequence<Any> aArgs{ Any(NamedValue("DatabaseDocument",Any(xMy))) }; xContainer.set( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(sSupportService, aArgs, m_pImpl->m_aContext), UNO_QUERY); @@ -1548,13 +1533,13 @@ void SAL_CALL ODatabaseDocument::removeCloseListener( const Reference< css::util Reference< XNameAccess > SAL_CALL ODatabaseDocument::getFormDocuments( ) { DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit ); - return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_FORM ); + return impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType::Form ); } Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) { DocumentGuard aGuard( *this, DocumentGuard::MethodUsedDuringInit ); - return impl_getDocumentContainer_throw( ODatabaseModelImpl::E_REPORT ); + return impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType::Report ); } void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const char* pStreamName, @@ -1580,8 +1565,8 @@ void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xC xSeek->seek(0); Reference< XPropertySet > xStreamProp( xOutputStream, UNO_QUERY_THROW ); - xStreamProp->setPropertyValue( INFO_MEDIATYPE, makeAny( OUString( "text/xml" ) ) ); - xStreamProp->setPropertyValue( "Compressed", makeAny( true ) ); + xStreamProp->setPropertyValue( INFO_MEDIATYPE, Any( OUString( "text/xml" ) ) ); + xStreamProp->setPropertyValue( "Compressed", Any( true ) ); // write the stuff WriteThroughComponent( xOutputStream, xComponent, pServiceName, _rArguments, rMediaDesc ); @@ -1627,17 +1612,17 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); - xInfoSet->setPropertyValue("UsePrettyPrinting", uno::makeAny(officecfg::Office::Common::Save::Document::PrettyPrinting::get())); + xInfoSet->setPropertyValue("UsePrettyPrinting", uno::Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get())); if ( officecfg::Office::Common::Save::URL::FileSystem::get() ) { OUString sBaseURI = _rMediaDescriptor.getOrDefault("BaseURI", OUString()); if (sBaseURI.isEmpty()) sBaseURI = _rMediaDescriptor.getOrDefault("URL",OUString()); - xInfoSet->setPropertyValue("BaseURI", uno::makeAny(sBaseURI)); + xInfoSet->setPropertyValue("BaseURI", uno::Any(sBaseURI)); } // Set TargetStorage, so it doesn't have to be re-constructed based on possibly empty URL. - xInfoSet->setPropertyValue("TargetStorage", uno::makeAny(m_pImpl->getRootStorage())); + xInfoSet->setPropertyValue("TargetStorage", uno::Any(m_pImpl->getRootStorage())); // Set StreamRelPath, in case this document is an embedded one. OUString sStreamRelPath; @@ -1651,14 +1636,14 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r sStreamRelPath = sStreamRelPath.copy(1); } if (!sStreamRelPath.isEmpty()) - xInfoSet->setPropertyValue("StreamRelPath", uno::makeAny(sStreamRelPath)); + xInfoSet->setPropertyValue("StreamRelPath", uno::Any(sStreamRelPath)); sal_Int32 nArgsLen = aDelegatorArguments.getLength(); aDelegatorArguments.realloc(nArgsLen+1); aDelegatorArguments.getArray()[nArgsLen++] <<= xInfoSet; Reference< XPropertySet > xProp( _rxTargetStorage, UNO_QUERY_THROW ); - xProp->setPropertyValue( INFO_MEDIATYPE, makeAny( OUString(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII) ) ); + xProp->setPropertyValue( INFO_MEDIATYPE, Any( MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII ) ); OUString aVersion; SvtSaveOptions::ODFSaneDefaultVersion const nDefVersion = @@ -1678,7 +1663,7 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r { try { - xProp->setPropertyValue("Version" , uno::makeAny(aVersion)); + xProp->setPropertyValue("Version" , uno::Any(aVersion)); } catch (const uno::Exception&) { @@ -1691,11 +1676,11 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r Sequence< PropertyValue > aMediaDescriptor; _rMediaDescriptor >>= aMediaDescriptor; - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("settings.xml"))); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("settings.xml"))); WriteThroughComponent( xComponent, "settings.xml", "com.sun.star.comp.sdb.XMLSettingsExporter", aDelegatorArguments, aMediaDescriptor, _rxTargetStorage ); - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml"))); WriteThroughComponent( xComponent, "content.xml", "com.sun.star.comp.sdb.DBExportFilter", aDelegatorArguments, aMediaDescriptor, _rxTargetStorage ); @@ -1868,6 +1853,11 @@ void ODatabaseDocument::disposing() void SAL_CALL ODatabaseDocument::dispose( ) { ::cppu::WeakComponentImplHelperBase::dispose(); + m_xTitleHelper.clear(); + m_xModuleManager.clear(); + m_pEventExecutor.clear(); + m_xCurrentController.clear(); + m_xUIConfigurationManager.clear(); } void SAL_CALL ODatabaseDocument::addEventListener( const Reference< lang::XEventListener >& _xListener ) @@ -1910,7 +1900,6 @@ comphelper::PropertyMapEntry const aEmbeddedImportInfoMap[] = {OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, {OUString("StreamName"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, {OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0}, - {OUString(), 0, css::uno::Type(), 0, 0} }; } @@ -1919,10 +1908,9 @@ void SAL_CALL ODatabaseDocument::loadFromStorage(const Reference<XStorage>& xSto DocumentGuard aGuard(*this, DocumentGuard::InitMethod); uno::Reference<beans::XPropertySet> xInfoSet(comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aEmbeddedImportInfoMap))); - comphelper::NamedValueCollection aDescriptor(rMediaDescriptor); - xInfoSet->setPropertyValue("StreamRelPath", uno::makeAny(aDescriptor.getOrDefault("HierarchicalDocumentName", OUString()))); - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); - xInfoSet->setPropertyValue("SourceStorage", uno::makeAny(xStorage)); + xInfoSet->setPropertyValue("StreamRelPath", uno::Any(comphelper::NamedValueCollection::getOrDefault(rMediaDescriptor, u"HierarchicalDocumentName", OUString()))); + xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml"))); + xInfoSet->setPropertyValue("SourceStorage", uno::Any(xStorage)); uno::Sequence<uno::Any> aFilterCreationArgs{ Any(xInfoSet) }; @@ -2037,7 +2025,7 @@ struct CreateAny { Any operator() (const Reference<XController>& lhs) const { - return makeAny(lhs); + return Any(lhs); } }; @@ -2106,13 +2094,9 @@ uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHel m_xModuleManager.set( ModuleManager::create(m_pImpl->m_aContext) ); OUString sModuleId; - try - { - sModuleId = m_xModuleManager->identify( _xComponent ); - } - catch(const uno::Exception&) - { - } + if (_xComponent.is()) + sModuleId = m_xModuleManager->identify(_xComponent); + uno::Reference< frame::XUntitledNumbers > xNumberedControllers; TNumberedController::const_iterator aFind = m_aNumberedControllers.find(sModuleId); @@ -2201,11 +2185,11 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* com_sun_star_comp_dba_ODatabaseDocument(css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const &) { - Reference<XUnoTunnel> xDBContextTunnel(DatabaseContext::create(context), UNO_QUERY_THROW); - dbaccess::ODatabaseContext* pContext - = comphelper::getFromUnoTunnel<dbaccess::ODatabaseContext>(xDBContextTunnel); + Reference<XInterface> xDBContextTunnel(DatabaseContext::create(context), UNO_QUERY_THROW); + rtl::Reference<dbaccess::ODatabaseContext> pContext + = dynamic_cast<dbaccess::ODatabaseContext*>(xDBContextTunnel.get()); assert(pContext); - + rtl::Reference pImpl( new dbaccess::ODatabaseModelImpl(context, *pContext)); css::uno::Reference<XInterface> inst(pImpl->createNewModel_deliverOwnership()); diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx index bd458d1b9259..6278aa039a63 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.hxx +++ b/dbaccess/source/core/dataaccess/databasedocument.hxx @@ -148,16 +148,13 @@ typedef cppu::PartialWeakComponentImplHelper< css::frame::XModel3 , css::document::XEventsSupplier , css::frame::XLoadable , css::document::XDocumentRecovery + , css::frame::XTitle + , css::frame::XTitleChangeBroadcaster + , css::frame::XUntitledNumbers > ODatabaseDocument_OfficeDocument; -typedef ::cppu::ImplHelper3< css::frame::XTitle - , css::frame::XTitleChangeBroadcaster - , css::frame::XUntitledNumbers - > ODatabaseDocument_Title; - class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first! ,public ODatabaseDocument_OfficeDocument - ,public ODatabaseDocument_Title { enum InitState { @@ -299,8 +296,6 @@ public: // XInterface virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; - virtual void SAL_CALL acquire( ) noexcept override; - virtual void SAL_CALL release( ) noexcept override; // XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.cxx b/dbaccess/source/core/dataaccess/databaseregistrations.cxx index bd215b397852..3b19de41c366 100644 --- a/dbaccess/source/core/dataaccess/databaseregistrations.cxx +++ b/dbaccess/source/core/dataaccess/databaseregistrations.cxx @@ -27,7 +27,7 @@ #include <cppuhelper/basemutex.hxx> #include <comphelper/interfacecontainer3.hxx> -#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase.hxx> #include <osl/diagnose.h> #include <unotools/pathoptions.hxx> #include <tools/urlobj.hxx> @@ -39,7 +39,7 @@ namespace dbaccess { using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::container::NoSuchElementException; @@ -51,24 +51,13 @@ namespace dbaccess using ::com::sun::star::sdb::DatabaseRegistrationEvent; using ::com::sun::star::uno::XAggregation; - static OUString getConfigurationRootPath() - { - return "org.openoffice.Office.DataAccess/RegisteredNames"; - } - - static OUString getLocationNodeName() - { - return "Location"; - } - - static OUString getNameNodeName() - { - return "Name"; - } + constexpr OUString CONF_ROOT_PATH = u"org.openoffice.Office.DataAccess/RegisteredNames"_ustr; + constexpr OUString LOCATION = u"Location"_ustr; + constexpr OUString NAME = u"Name"_ustr; // DatabaseRegistrations - declaration - typedef ::cppu::WeakAggImplHelper1 < XDatabaseRegistrations - > DatabaseRegistrations_Base; + typedef ::cppu::WeakImplHelper< XDatabaseRegistrations + > DatabaseRegistrations_Base; namespace { @@ -100,7 +89,7 @@ namespace dbaccess ::utl::OConfigurationNode impl_checkValidName_throw_must_not_exist(const OUString& _rName); - void impl_checkValidLocation_throw( const OUString& _rLocation ); + void impl_checkValidLocation_throw( std::u16string_view _rLocation ); /** retrieves the configuration node whose "Name" sub node has the given value @@ -147,7 +136,7 @@ namespace dbaccess ,m_aRegistrationListeners( m_aMutex ) { m_aConfigurationRoot = ::utl::OConfigurationTreeRoot::createWithComponentContext( - m_aContext, getConfigurationRootPath() ); + m_aContext, CONF_ROOT_PATH ); } DatabaseRegistrations::~DatabaseRegistrations() @@ -162,7 +151,7 @@ namespace dbaccess ::utl::OConfigurationNode aNodeForName = m_aConfigurationRoot.openNode( nodeName ); OUString sTestName; - OSL_VERIFY( aNodeForName.getNodeValue( getNameNodeName() ) >>= sTestName ); + OSL_VERIFY( aNodeForName.getNodeValue( NAME ) >>= sTestName ); if ( sTestName == _rName ) return aNodeForName; } @@ -196,7 +185,7 @@ namespace dbaccess } ::utl::OConfigurationNode aNewNode( m_aConfigurationRoot.createNode( sNewNodeName ) ); - aNewNode.setNodeValue( getNameNodeName(), makeAny( _rName ) ); + aNewNode.setNodeValue( NAME, Any( _rName ) ); return aNewNode; } @@ -221,9 +210,9 @@ namespace dbaccess return impl_getNodeForName_throw_must_not_exist(_rName); } - void DatabaseRegistrations::impl_checkValidLocation_throw( const OUString& _rLocation ) + void DatabaseRegistrations::impl_checkValidLocation_throw( std::u16string_view _rLocation ) { - if ( _rLocation.isEmpty() ) + if ( _rLocation.empty() ) throw IllegalArgumentException( OUString(), *this, 2 ); INetURLObject aURL( _rLocation ); @@ -251,7 +240,7 @@ namespace dbaccess for ( auto const & name : aProgrammaticNames ) { ::utl::OConfigurationNode aRegistrationNode = m_aConfigurationRoot.openNode( name ); - OSL_VERIFY( aRegistrationNode.getNodeValue( getNameNodeName() ) >>= *pDisplayName ); + OSL_VERIFY( aRegistrationNode.getNodeValue( NAME ) >>= *pDisplayName ); ++pDisplayName; } @@ -265,7 +254,7 @@ namespace dbaccess ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw_must_exist(Name); OUString sLocation; - OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation ); + OSL_VERIFY( aNodeForName.getNodeValue( LOCATION ) >>= sLocation ); sLocation = SvtPathOptions().SubstituteVariable( sLocation ); return sLocation; @@ -280,7 +269,7 @@ namespace dbaccess ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw_must_not_exist(Name); // register - aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( Location ) ); + aDataSourceRegistration.setNodeValue( LOCATION, Any( Location ) ); m_aConfigurationRoot.commit(); // notify @@ -298,7 +287,7 @@ namespace dbaccess // obtain properties for notification OUString sLocation; - OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation ); + OSL_VERIFY( aNodeForName.getNodeValue( LOCATION ) >>= sLocation ); // revoke if ( aNodeForName.isReadonly() @@ -327,10 +316,10 @@ namespace dbaccess // obtain properties for notification OUString sOldLocation; - OSL_VERIFY( aDataSourceRegistration.getNodeValue( getLocationNodeName() ) >>= sOldLocation ); + OSL_VERIFY( aDataSourceRegistration.getNodeValue( LOCATION ) >>= sOldLocation ); // change - aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( NewLocation ) ); + aDataSourceRegistration.setNodeValue( LOCATION, Any( NewLocation ) ); m_aConfigurationRoot.commit(); // notify @@ -359,7 +348,7 @@ namespace dbaccess } // DatabaseRegistrations - factory - Reference< XAggregation > createDataSourceRegistrations( const Reference<XComponentContext> & _rxContext ) + Reference< XDatabaseRegistrations > createDataSourceRegistrations( const Reference<XComponentContext> & _rxContext ) { return new DatabaseRegistrations( _rxContext ); } diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.hxx b/dbaccess/source/core/dataaccess/databaseregistrations.hxx index 709bc9f98490..52def1de5aa2 100644 --- a/dbaccess/source/core/dataaccess/databaseregistrations.hxx +++ b/dbaccess/source/core/dataaccess/databaseregistrations.hxx @@ -20,11 +20,11 @@ #pragma once #include <com/sun/star/uno/XAggregation.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> namespace dbaccess { -css::uno::Reference<css::uno::XAggregation> +css::uno::Reference<css::sdb::XDatabaseRegistrations> createDataSourceRegistrations(const css::uno::Reference<css::uno::XComponentContext>& _rxContext); } // namespace dbaccess diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 45ad2e500d8b..fbb0ac1bd86b 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -22,6 +22,7 @@ #include <stringconstants.hxx> #include <core_resource.hxx> #include <strings.hrc> +#include <strings.hxx> #include "connection.hxx" #include "SharedConnection.hxx" #include "databasedocument.hxx" @@ -55,13 +56,12 @@ #include <connectivity/dbtools.hxx> #include <cppuhelper/typeprovider.hxx> #include <officecfg/Office/Common.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <osl/process.h> #include <sal/log.hxx> #include <tools/urlobj.hxx> #include <unotools/sharedunocomponent.hxx> -#include <rtl/digest.h> #include <algorithm> #include <iterator> @@ -249,69 +249,6 @@ void SAL_CALL OAuthenticationContinuation::setRememberAccount( RememberAuthentic SAL_WARN("dbaccess","OAuthenticationContinuation::setRememberAccount: not supported!"); } -namespace { - -/** The class OSharedConnectionManager implements a structure to share connections. - It owns the master connections which will be disposed when the last connection proxy is gone. -*/ -// need to hold the digest -struct TDigestHolder -{ - sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1]; - TDigestHolder() - { - m_pBuffer[0] = 0; - } - -}; - -} - -class OSharedConnectionManager : public ::cppu::WeakImplHelper< XEventListener > -{ - - // contains the currently used master connections - struct TConnectionHolder - { - Reference< XConnection > xMasterConnection; - oslInterlockedCount nALiveCount; - }; - - // the less-compare functor, used for the stl::map - struct TDigestLess - { - bool operator() (const TDigestHolder& x, const TDigestHolder& y) const - { - sal_uInt32 i; - for(i=0;i < RTL_DIGEST_LENGTH_SHA1 && (x.m_pBuffer[i] >= y.m_pBuffer[i]); ++i) - ; - return i < RTL_DIGEST_LENGTH_SHA1; - } - }; - - typedef std::map< TDigestHolder,TConnectionHolder,TDigestLess> TConnectionMap; // holds the master connections - typedef std::map< Reference< XConnection >,TConnectionMap::iterator> TSharedConnectionMap;// holds the shared connections - - ::osl::Mutex m_aMutex; - TConnectionMap m_aConnections; // remember the master connection in conjunction with the digest - TSharedConnectionMap m_aSharedConnection; // the shared connections with conjunction with an iterator into the connections map - Reference< XProxyFactory > m_xProxyFactory; - -protected: - virtual ~OSharedConnectionManager() override; - -public: - explicit OSharedConnectionManager(const Reference< XComponentContext >& _rxContext); - - void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - Reference<XConnection> getConnection( const OUString& url, - const OUString& user, - const OUString& password, - const Sequence< PropertyValue >& _aInfo, - ODatabaseSource* _pDataSource); - void addEventListener(const Reference<XConnection>& _rxConnection, TConnectionMap::iterator const & _rIter); -}; - OSharedConnectionManager::OSharedConnectionManager(const Reference< XComponentContext >& _rxContext) { m_xProxyFactory.set( ProxyFactory::create( _rxContext ) ); @@ -607,8 +544,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString if ( xModel) { //See ODbTypeWizDialogSetup::SaveDatabaseDocument - ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); - aArgs.get("IgnoreFirebirdMigration") >>= bIgnoreMigration; + ::comphelper::NamedValueCollection::get(xModel->getArgs(), u"IgnoreFirebirdMigration") >>= bIgnoreMigration; } else { @@ -642,7 +578,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString if (bNeedMigration) { // back up content xml file if migration was successful - static constexpr OUStringLiteral BACKUP_XML_NAME = u"content_before_migration.xml"; + static constexpr OUString BACKUP_XML_NAME = u"content_before_migration.xml"_ustr; try { if(xRootStorage->isStreamElement(BACKUP_XML_NAME)) @@ -766,11 +702,11 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString OUString sMessage = DBA_RES(pExceptionMessageId) .replaceAll("$name$", m_pImpl->m_sConnectURL); - SQLContext aContext; - aContext.Message = DBA_RES(RID_STR_CONNECTION_REQUEST). - replaceFirst("$name$", m_pImpl->m_sConnectURL); + SQLContext aContext( + DBA_RES(RID_STR_CONNECTION_REQUEST).replaceFirst("$name$", m_pImpl->m_sConnectURL), + {}, {}, 0, {}, {}); - throwGenericSQLException( sMessage, static_cast< XDataSource* >( this ), makeAny( aContext ) ); + throwGenericSQLException( sMessage, static_cast< XDataSource* >( this ), Any( aContext ) ); } #if ENABLE_FIREBIRD_SDBC @@ -796,25 +732,26 @@ Reference< XPropertySetInfo > ODatabaseSource::getPropertySetInfo() // comphelper::OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* ODatabaseSource::createArrayHelper( ) const { - css::uno::Sequence< css::beans::Property> aDescriptor(13); - css::beans::Property* pDesc = aDescriptor.getArray(); - sal_Int32 nPos = 0; - pDesc[nPos++] = css::beans::Property(PROPERTY_INFO, PROPERTY_ID_INFO, cppu::UnoType<Sequence< PropertyValue >>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISPASSWORDREQUIRED, PROPERTY_ID_ISPASSWORDREQUIRED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, cppu::UnoType<Sequence< PropertyValue >>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_NUMBERFORMATSSUPPLIER, PROPERTY_ID_NUMBERFORMATSSUPPLIER, - cppu::UnoType<XNumberFormatsSupplier>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); - pDesc[nPos++] = css::beans::Property(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::TRANSIENT); - pDesc[nPos++] = css::beans::Property(PROPERTY_SETTINGS, PROPERTY_ID_SETTINGS, cppu::UnoType<XPropertySet>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY); - pDesc[nPos++] = css::beans::Property(PROPERTY_SUPPRESSVERSIONCL, PROPERTY_ID_SUPPRESSVERSIONCL, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_TABLEFILTER, PROPERTY_ID_TABLEFILTER, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_TABLETYPEFILTER, PROPERTY_ID_TABLETYPEFILTER, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_URL, PROPERTY_ID_URL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); - pDesc[nPos++] = css::beans::Property(PROPERTY_USER, PROPERTY_ID_USER, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); - OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?"); - return new ::cppu::OPropertyArrayHelper(aDescriptor); + return new ::cppu::OPropertyArrayHelper + { + { + // a change here means a change should also been done in OApplicationController::disposing() + { PROPERTY_INFO, PROPERTY_ID_INFO, cppu::UnoType<Sequence< PropertyValue >>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_ISPASSWORDREQUIRED, PROPERTY_ID_ISPASSWORDREQUIRED, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_ISREADONLY, PROPERTY_ID_ISREADONLY, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, cppu::UnoType<Sequence< PropertyValue >>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY }, + { PROPERTY_NUMBERFORMATSSUPPLIER, PROPERTY_ID_NUMBERFORMATSSUPPLIER, cppu::UnoType<XNumberFormatsSupplier>::get(), + css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT }, + { PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::TRANSIENT }, + { PROPERTY_SETTINGS, PROPERTY_ID_SETTINGS, cppu::UnoType<XPropertySet>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY }, + { PROPERTY_SUPPRESSVERSIONCL, PROPERTY_ID_SUPPRESSVERSIONCL, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_TABLEFILTER, PROPERTY_ID_TABLEFILTER, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_TABLETYPEFILTER, PROPERTY_ID_TABLETYPEFILTER, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_URL, PROPERTY_ID_URL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND }, + { PROPERTY_USER, PROPERTY_ID_USER, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND } + } + }; } // cppu::OPropertySetHelper @@ -861,7 +798,7 @@ sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & if (!(rValue >>= aValues)) throw IllegalArgumentException(); - for ( auto const & checkName : std::as_const(aValues) ) + for (auto const& checkName : aValues) { if ( checkName.Name.isEmpty() ) throw IllegalArgumentException(); @@ -1159,7 +1096,7 @@ Reference< XConnection > ODatabaseSource::connectWithCompletion( const Reference aRequest.HasUserName = aRequest.HasPassword = true; aRequest.UserName = m_pImpl->m_sUser; aRequest.Password = m_pImpl->m_sFailedPassword.isEmpty() ? m_pImpl->m_aPassword : m_pImpl->m_sFailedPassword; - rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest(makeAny(aRequest)); + rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest(Any(aRequest)); // some knittings pRequest->addContinuation(pAbort); pRequest->addContinuation(pAuthenticate); @@ -1234,14 +1171,9 @@ Reference< XConnection > ODatabaseSource::getConnection(const OUString& user, co { // create a new proxy for the connection if ( !m_pImpl->m_xSharedConnectionManager.is() ) { - // TODO ideally we could just have one field, but to make that work - // we'd need to move OSharedConnectionManager into its own file and header - rtl::Reference<OSharedConnectionManager> manager = - new OSharedConnectionManager( m_pImpl->m_aContext ); - m_pImpl->m_pSharedConnectionManager = manager.get(); - m_pImpl->m_xSharedConnectionManager = m_pImpl->m_pSharedConnectionManager; + m_pImpl->m_xSharedConnectionManager = new OSharedConnectionManager( m_pImpl->m_aContext ); } - xConn = m_pImpl->m_pSharedConnectionManager->getConnection( + xConn = m_pImpl->m_xSharedConnectionManager->getConnection( m_pImpl->m_sConnectURL, user, password, m_pImpl->m_xSettings->getPropertyValues(), this ); } @@ -1278,13 +1210,13 @@ Reference< XNameAccess > SAL_CALL ODatabaseSource::getQueryDefinitions( ) aValue >>= sSupportService; if ( !sSupportService.isEmpty() ) { - Sequence<Any> aArgs{ Any(NamedValue("DataSource",makeAny(xMy))) }; + Sequence<Any> aArgs{ Any(NamedValue("DataSource",Any(xMy))) }; xContainer.set( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(sSupportService, aArgs, m_pImpl->m_aContext), UNO_QUERY); } } if ( !xContainer.is() ) { - TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::E_QUERY ) ); + TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::ObjectType::Query ) ); xContainer = new OCommandContainer( m_pImpl->m_aContext, *this, rContainerData, false ); } m_pImpl->m_xCommandDefinitions = xContainer; @@ -1300,7 +1232,7 @@ Reference< XNameAccess > ODatabaseSource::getTables() Reference< XNameAccess > xContainer = m_pImpl->m_xTableDefinitions; if ( !xContainer.is() ) { - TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::E_TABLE ) ); + TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::ObjectType::Table ) ); xContainer = new OCommandContainer( m_pImpl->m_aContext, *this, rContainerData, true ); m_pImpl->m_xTableDefinitions = xContainer; } diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx index 53824f87388f..807dc5ec98c3 100644 --- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx +++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx @@ -18,11 +18,12 @@ */ #include <definitioncontainer.hxx> -#include <apitools.hxx> #include <core_resource.hxx> #include <strings.hrc> +#include <strings.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <comphelper/enumhelper.hxx> #include <cppuhelper/exc_hlp.hxx> @@ -32,7 +33,6 @@ #include <com/sun/star/sdb/ErrorCondition.hpp> #include <comphelper/servicehelper.hxx> #include <comphelper/types.hxx> -#include <cppuhelper/interfacecontainer.hxx> #include <rtl/ref.hxx> using namespace ::com::sun::star::uno; @@ -287,7 +287,7 @@ void ODefinitionContainer::notifyByName( ResettableMutexGuard& _rGuard, const OU if ( !rContainer.getLength() ) return; - ContainerEvent aEvent( *this, makeAny( _rName ), makeAny( _xNewElement ), makeAny( _xOldElement ) ); + ContainerEvent aEvent( *this, Any( _rName ), Any( _xNewElement ), Any( _xOldElement ) ); _rGuard.clear(); switch ( _eOperation ) @@ -373,7 +373,7 @@ Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex ) { MutexGuard aGuard(m_aMutex); - if ((_nIndex < 0) || (_nIndex >= static_cast<sal_Int32>(m_aDocuments.size()))) + if ((_nIndex < 0) || (o3tl::make_unsigned(_nIndex) >= m_aDocuments.size())) throw IndexOutOfBoundsException(); Documents::iterator aPos = m_aDocuments[_nIndex]; @@ -386,14 +386,14 @@ Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex ) // and update the name-access map } - return makeAny(xProp); + return Any(xProp); } Any SAL_CALL ODefinitionContainer::getByName( const OUString& _rName ) { MutexGuard aGuard(m_aMutex); - return makeAny( implGetByName( _rName, true ) ); + return Any( implGetByName( _rName, true ) ); } Reference< XContent > ODefinitionContainer::implGetByName(const OUString& _rName, bool _bReadIfNecessary) @@ -533,7 +533,7 @@ void ODefinitionContainer::implAppend(const OUString& _rName, const Reference< X // #i44786# lcl_ensureName( _rxNewObject, _rName ); - ::rtl::Reference< OContentHelper > pContent = comphelper::getFromUnoTunnel<OContentHelper>( _rxNewObject ); + ::rtl::Reference< OContentHelper > pContent = dynamic_cast<OContentHelper*>( _rxNewObject.get() ); if ( pContent.is() ) { TContentPtr pImpl = pContent->getImpl(); @@ -592,7 +592,7 @@ void ODefinitionContainer::approveNewObject(const OUString& _sName,const Referen DBA_RES( RID_STR_NAME_ALREADY_USED ), *this ); - ::rtl::Reference< OContentHelper > pContent( comphelper::getFromUnoTunnel<OContentHelper>( _rxObject ) ); + ::rtl::Reference< OContentHelper > pContent( dynamic_cast<OContentHelper*>( _rxObject.get() ) ); if ( !pContent.is() ) throw IllegalArgumentException( DBA_RES( RID_STR_OBJECT_CONTAINER_MISMATCH ), diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index f878e7b57ee7..48971a3c74f5 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -34,6 +34,7 @@ #include <connectivity/sqlerror.hxx> #include <core_resource.hxx> #include <strings.hrc> +#include <strings.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/servicehelper.hxx> @@ -41,6 +42,7 @@ #include <vcl/svapp.hxx> #include <osl/mutex.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -50,7 +52,6 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::io; using namespace ::osl; using namespace ::comphelper; using namespace ::cppu; @@ -155,7 +156,7 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL ODocumentContainer Sequence< OUString > SAL_CALL ODocumentContainer::getSupportedServiceNames( ) { - return { m_bFormsContainer ? OUString(SERVICE_NAME_FORM_COLLECTION) : OUString(SERVICE_NAME_REPORT_COLLECTION) }; + return { m_bFormsContainer ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION }; } OUString ODocumentContainer::determineContentType() const @@ -391,7 +392,7 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments Reference<XContent > xNew(xORB->createInstanceWithArguments(sServiceName,aArguments),UNO_QUERY); Reference<XNameContainer> xNameContainer(xContent,UNO_QUERY); if ( xNameContainer.is() ) - xNameContainer->insertByName(*elements,makeAny(xNew)); + xNameContainer->insertByName(*elements,Any(xNew)); } } } @@ -421,7 +422,7 @@ Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 Com { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -448,7 +449,7 @@ Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 Com { // Unsupported. ucbhelper::cancelCommandExecution( - makeAny( UnsupportedOpenModeException( + Any( UnsupportedOpenModeException( OUString(), static_cast< cppu::OWeakObject * >( this ), sal_Int16( aOpenCommand.Mode ) ) ), @@ -465,7 +466,7 @@ Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 Com { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -491,10 +492,10 @@ Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 Com namespace { - bool lcl_queryContent(const OUString& _sName,Reference< XNameContainer >& _xNameContainer,Any& _rRet,OUString& _sSimpleName) + bool lcl_queryContent(std::u16string_view _sName,Reference< XNameContainer >& _xNameContainer,Any& _rRet,OUString& _sSimpleName) { sal_Int32 nIndex = 0; - OUString sName = _sName.getToken(0,'/',nIndex); + OUString sName( o3tl::getToken(_sName,0,'/',nIndex) ); bool bRet = _xNameContainer->hasByName(sName); if ( bRet ) { @@ -502,7 +503,7 @@ namespace _rRet = _xNameContainer->getByName(_sSimpleName); while ( nIndex != -1 && bRet ) { - sName = _sName.getToken(0,'/',nIndex); + sName = o3tl::getToken(_sName,0,'/',nIndex); _xNameContainer.set(_rRet,UNO_QUERY); bRet = _xNameContainer.is(); if ( bRet ) @@ -610,7 +611,7 @@ void SAL_CALL ODocumentContainer::insertByHierarchicalName( const OUString& _sNa sal_Int32 index = sName.getLength(); OUString sMessage( DBA_RES(RID_STR_NO_SUB_FOLDER).replaceFirst("$folder$", - _sName.getToken(0,'/',index))); + o3tl::getToken(_sName, 0,'/',index))); throw IllegalArgumentException( sMessage, *this, 1 ); } @@ -666,7 +667,7 @@ OUString SAL_CALL ODocumentContainer::composeHierarchicalName( const OUString& i ::rtl::Reference<OContentHelper> pContent; try { - pContent = comphelper::getFromUnoTunnel<OContentHelper>(const_cast<ODocumentContainer*>(this)->implGetByName( _sName, true )); + pContent = dynamic_cast<OContentHelper*>(const_cast<ODocumentContainer*>(this)->implGetByName( _sName, true ).get()); } catch(const Exception&) { @@ -710,7 +711,7 @@ void SAL_CALL ODocumentContainer::revert( ) Reference< XStorage> ODocumentContainer::getContainerStorage() const { return m_pImpl->m_pDataSource - ? m_pImpl->m_pDataSource->getStorage( m_bFormsContainer ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) + ? m_pImpl->m_pDataSource->getStorage( m_bFormsContainer ? ODatabaseModelImpl::ObjectType::Form : ODatabaseModelImpl::ObjectType::Report ) : Reference< XStorage>(); } @@ -749,8 +750,8 @@ void SAL_CALL ODocumentContainer::rename( const OUString& newName ) return; sal_Int32 nHandle = PROPERTY_ID_NAME; - Any aOld = makeAny(m_pImpl->m_aProps.aTitle); - Any aNew = makeAny(newName); + Any aOld(m_pImpl->m_aProps.aTitle); + Any aNew(newName); aGuard.clear(); fire(&nHandle, &aNew, &aOld, 1, true ); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index e4dc881a1a63..227bde4cde1b 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -21,8 +21,9 @@ #include <ModelImpl.hxx> #include <stringconstants.hxx> #include <sdbcoretools.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> +#include <comphelper/compbase.hxx> #include <comphelper/sequence.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/classids.hxx> @@ -32,6 +33,7 @@ #include <com/sun/star/frame/XUntitledNumbers.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -76,6 +78,7 @@ #include <com/sun/star/view/XViewSettingsSupplier.hpp> #include <core_resource.hxx> #include <strings.hrc> +#include <strings.hxx> #include <com/sun/star/task/XInteractionApprove.hpp> #include <com/sun/star/task/XInteractionDisapprove.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> @@ -145,22 +148,20 @@ namespace dbaccess } // OEmbedObjectHolder - typedef ::cppu::WeakComponentImplHelper< embed::XStateChangeListener > TEmbedObjectHolder; + typedef ::comphelper::WeakComponentImplHelper< embed::XStateChangeListener > TEmbedObjectHolder; namespace { - class OEmbedObjectHolder : public ::cppu::BaseMutex - ,public TEmbedObjectHolder + class OEmbedObjectHolder : public TEmbedObjectHolder { Reference< XEmbeddedObject > m_xBroadCaster; ODocumentDefinition* m_pDefinition; bool m_bInStateChange; protected: - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; public: OEmbedObjectHolder(const Reference< XEmbeddedObject >& _xBroadCaster,ODocumentDefinition* _pDefinition) - : TEmbedObjectHolder(m_aMutex) - ,m_xBroadCaster(_xBroadCaster) + : m_xBroadCaster(_xBroadCaster) ,m_pDefinition(_pDefinition) ,m_bInStateChange(false) { @@ -179,7 +180,7 @@ namespace dbaccess } - void SAL_CALL OEmbedObjectHolder::disposing() + void OEmbedObjectHolder::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { if ( m_xBroadCaster.is() ) m_xBroadCaster->removeStateChangeListener(this); @@ -506,7 +507,7 @@ void SAL_CALL ODocumentDefinition::getFastPropertyValue( Any& o_rValue, sal_Int3 OUString sPersistentPath; if ( !m_pImpl->m_aProps.sPersistentName.isEmpty() ) { - sPersistentPath = ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) + sPersistentPath = ODatabaseModelImpl::getObjectContainerStorageName( m_bForm ? ODatabaseModelImpl::ObjectType::Form : ODatabaseModelImpl::ObjectType::Report ) + "/" + m_pImpl->m_aProps.sPersistentName; } o_rValue <<= sPersistentPath; @@ -719,14 +720,14 @@ void ODocumentDefinition::impl_initFormEditView( const Reference< XController >& LayoutManagerLock aLockLayout( _rxController ); // setting of the visual properties - xViewSettings->setPropertyValue("ShowRulers",makeAny(true)); - xViewSettings->setPropertyValue("ShowVertRuler",makeAny(true)); - xViewSettings->setPropertyValue("ShowHoriRuler",makeAny(true)); - xViewSettings->setPropertyValue("IsRasterVisible",makeAny(true)); - xViewSettings->setPropertyValue("IsSnapToRaster",makeAny(true)); - xViewSettings->setPropertyValue("ShowOnlineLayout",makeAny(true)); - xViewSettings->setPropertyValue("RasterSubdivisionX",makeAny(sal_Int32(5))); - xViewSettings->setPropertyValue("RasterSubdivisionY",makeAny(sal_Int32(5))); + xViewSettings->setPropertyValue("ShowRulers",Any(true)); + xViewSettings->setPropertyValue("ShowVertRuler",Any(true)); + xViewSettings->setPropertyValue("ShowHoriRuler",Any(true)); + xViewSettings->setPropertyValue("IsRasterVisible",Any(true)); + xViewSettings->setPropertyValue("IsSnapToRaster",Any(true)); + xViewSettings->setPropertyValue("ShowOnlineLayout",Any(true)); + xViewSettings->setPropertyValue("RasterSubdivisionX",Any(sal_Int32(5))); + xViewSettings->setPropertyValue("RasterSubdivisionY",Any(sal_Int32(5))); } catch( const Exception& ) { @@ -850,7 +851,7 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons // So, in such a case, and with 2. above, we would silently execute those macros, // regardless of the global security settings - which would be a security issue, of // course. - if ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::eNoMacros ) + if ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::EmbeddedMacros::NONE ) { // this is case 2. from above // So, pass a USE_CONFIG to the to-be-loaded document. This means that @@ -880,7 +881,7 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons { // not supported ucbhelper::cancelCommandExecution( - makeAny( UnsupportedOpenModeException( + Any( UnsupportedOpenModeException( OUString(), static_cast< cppu::OWeakObject * >( this ), sal_Int16( nOpenMode ) ) ), @@ -928,8 +929,8 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons xReportEngine->setReportDefinition(xReportDefinition); xReportEngine->setActiveConnection(m_xLastKnownConnection); if ( bOpenHidden ) - return makeAny( xReportEngine->createDocumentModel() ); - return makeAny( xReportEngine->createDocumentAlive( nullptr ) ); + return Any( xReportEngine->createDocumentModel() ); + return Any( xReportEngine->createDocumentAlive( nullptr ) ); } if ( _bActivate && !bOpenHidden ) @@ -947,7 +948,7 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign ) ODocumentDefinition::fillReportData( m_aContext, getComponent(), xConnection ); - return makeAny( xModel ); + return Any( xModel ); } Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) @@ -994,7 +995,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co if ( !bIsAliveNewStyleReport ) { impl_onActivateEmbeddedObject_nothrow( true ); - return makeAny( getComponent() ); + return Any( getComponent() ); } } } @@ -1015,7 +1016,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co { OSL_FAIL( "Wrong argument type!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -1041,7 +1042,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co { OSL_FAIL( "Wrong argument count!" ); ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( + Any( IllegalArgumentException( OUString(), static_cast< cppu::OWeakObject * >( this ), -1 ) ), @@ -1112,7 +1113,7 @@ namespace try { Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW ); - xFormProps->setPropertyValue( PROPERTY_DATASOURCENAME, makeAny( OUString() ) ); + xFormProps->setPropertyValue( PROPERTY_DATASOURCENAME, Any( OUString() ) ); } catch( const Exception& ) { @@ -1158,7 +1159,7 @@ void ODocumentDefinition::onCommandInsert( const OUString& _sURL, const Referenc Sequence<OUString> aProps { PROPERTY_URL }; ucbhelper::cancelCommandExecution( - makeAny( MissingPropertiesException( + Any( MissingPropertiesException( OUString(), static_cast< cppu::OWeakObject * >( this ), aProps ) ), @@ -1228,7 +1229,7 @@ bool ODocumentDefinition::save(bool _bApprove, const css::uno::Reference<css::aw } aRequest.Content.set(m_xParentContainer,UNO_QUERY); - rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest(makeAny(aRequest)); + rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest(Any(aRequest)); // some knittings // two continuations allowed: OK and Cancel rtl::Reference<ODocumentSaveContinuation> pDocuSave; @@ -1269,7 +1270,7 @@ bool ODocumentDefinition::save(bool _bApprove, const css::uno::Reference<css::aw m_pImpl->m_aProps.aTitle = pDocuSave->getName(); Reference< XContent> xContent = this; - xNC->insertByName(pDocuSave->getName(),makeAny(xContent)); + xNC->insertByName(pDocuSave->getName(),Any(xContent)); updateDocumentTitle(); } @@ -1314,7 +1315,7 @@ void ODocumentDefinition::saveAs() aRequest.Name = m_pImpl->m_aProps.aTitle; aRequest.Content.set(m_xParentContainer,UNO_QUERY); - rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest(makeAny(aRequest)); + rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest(Any(aRequest)); // some knittings // two continuations allowed: OK and Cancel rtl::Reference<ODocumentSaveContinuation> pDocuSave = new ODocumentSaveContinuation; @@ -1360,7 +1361,7 @@ void ODocumentDefinition::saveAs() Reference< XMultiServiceFactory > xORB( m_xParentContainer, UNO_QUERY_THROW ); Reference< XInterface > xComponent( xORB->createInstanceWithArguments( SERVICE_SDB_DOCUMENTDEFINITION, aArguments ) ); Reference< XNameContainer > xNameContainer( m_xParentContainer, UNO_QUERY_THROW ); - xNameContainer->insertByName( sOldName, makeAny( xComponent ) ); + xNameContainer->insertByName( sOldName, Any( xComponent ) ); } catch(const Exception&) { @@ -1386,7 +1387,7 @@ namespace { void lcl_putLoadArgs( ::comphelper::NamedValueCollection& _io_rArgs, const optional_bool& _bSuppressMacros, const optional_bool& _bReadOnly ) { - if ( !!_bSuppressMacros ) + if ( _bSuppressMacros.has_value() ) { if ( *_bSuppressMacros ) { @@ -1403,7 +1404,7 @@ namespace } } - if ( !!_bReadOnly ) + if ( _bReadOnly.has_value() ) _io_rArgs.put( "ReadOnly", *_bReadOnly ); } } @@ -1429,7 +1430,7 @@ namespace bool ODocumentDefinition::objectSupportsEmbeddedScripts() const { bool bAllowDocumentMacros = !m_pImpl->m_pDataSource - || ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::eSubDocumentMacros ); + || ( m_pImpl->m_pDataSource->determineEmbeddedMacros() == ODatabaseModelImpl::EmbeddedMacros::SubDocument ); // if *any* of the objects of the database document already has macros, we // continue to allow it to have them, until the user does a migration. @@ -1565,9 +1566,7 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& i_ Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName); if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() ) { - css::io::WrongFormatException aWFE; - aWFE.Message = DBA_RES( RID_STR_MISSING_EXTENSION ); - throw aWFE; + throw css::io::WrongFormatException(DBA_RES(RID_STR_MISSING_EXTENSION)); } } if ( !aClassID.hasElements() ) @@ -1925,7 +1924,7 @@ void SAL_CALL ODocumentDefinition::rename( const OUString& _rNewName ) Reference< XStorage> ODocumentDefinition::getContainerStorage() const { return m_pImpl->m_pDataSource - ? m_pImpl->m_pDataSource->getStorage( m_bForm ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT ) + ? m_pImpl->m_pDataSource->getStorage( m_bForm ? ODatabaseModelImpl::ObjectType::Form : ODatabaseModelImpl::ObjectType::Report ) : Reference< XStorage>(); } @@ -2075,8 +2074,8 @@ void ODocumentDefinition::firePropertyChange( sal_Int32 i_nHandle, const Any& i_ NameChangeNotifier::NameChangeNotifier( ODocumentDefinition& i_rDocumentDefinition, const OUString& i_rNewName, ::osl::ResettableMutexGuard& i_rClearForNotify ) :m_rDocumentDefinition( i_rDocumentDefinition ) - ,m_aOldValue( makeAny( i_rDocumentDefinition.getCurrentName() ) ) - ,m_aNewValue( makeAny( i_rNewName ) ) + ,m_aOldValue( Any( i_rDocumentDefinition.getCurrentName() ) ) + ,m_aNewValue( Any( i_rNewName ) ) ,m_rClearForNotify( i_rClearForNotify ) { impl_fireEvent_throw( true ); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.hxx b/dbaccess/source/core/dataaccess/documentdefinition.hxx index 389ab601f2ab..5569276d4a7d 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.hxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.hxx @@ -207,7 +207,7 @@ private: @throws css::uno::RuntimeException */ static void impl_removeFrameFromDesktop_throw( - const css::uno::Reference< css::uno::XComponentContext >& _rContxt, + const css::uno::Reference< css::uno::XComponentContext >& _rContext, const css::uno::Reference< css::frame::XFrame >& _rxFrame ); diff --git a/dbaccess/source/core/dataaccess/documenteventexecutor.cxx b/dbaccess/source/core/dataaccess/documenteventexecutor.cxx index 3d16ee6ebb79..e1cb9f3f4e57 100644 --- a/dbaccess/source/core/dataaccess/documenteventexecutor.cxx +++ b/dbaccess/source/core/dataaccess/documenteventexecutor.cxx @@ -27,7 +27,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/weakref.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> namespace dbaccess @@ -57,24 +57,14 @@ namespace dbaccess using namespace ::com::sun::star; - // DocumentEventExecutor_Data - struct DocumentEventExecutor_Data - { - WeakReference< XEventsSupplier > xDocument; - Reference< XURLTransformer > xURLTransformer; - - explicit DocumentEventExecutor_Data( const Reference< XEventsSupplier >& _rxDocument ) - :xDocument( _rxDocument ) - { - } - }; - namespace { - void lcl_dispatchScriptURL_throw( DocumentEventExecutor_Data const & _rDocExecData, + void lcl_dispatchScriptURL_throw( + css::uno::WeakReference< css::document::XEventsSupplier > const & xWeakDocument, + css::uno::Reference< css::util::XURLTransformer > const & xURLTransformer, const OUString& _rScriptURL, const DocumentEvent& _rTrigger ) { - Reference< XModel > xDocument( _rDocExecData.xDocument.get(), UNO_QUERY_THROW ); + Reference< XModel > xDocument( xWeakDocument.get(), UNO_QUERY_THROW ); Reference< XController > xController( xDocument->getCurrentController() ); Reference< XDispatchProvider > xDispProv; @@ -88,8 +78,8 @@ namespace dbaccess URL aScriptURL; aScriptURL.Complete = _rScriptURL; - if ( _rDocExecData.xURLTransformer.is() ) - _rDocExecData.xURLTransformer->parseStrict( aScriptURL ); + if ( xURLTransformer.is() ) + xURLTransformer->parseStrict( aScriptURL ); // unfortunately, executing a script can trigger all kind of complex stuff, and unfortunately, not // every component involved into this properly cares for thread safety. To be on the safe side, @@ -113,7 +103,7 @@ namespace dbaccess // DocumentEventExecutor DocumentEventExecutor::DocumentEventExecutor( const Reference<XComponentContext> & _rContext, const Reference< XEventsSupplier >& _rxDocument ) - :m_pData( new DocumentEventExecutor_Data( _rxDocument ) ) + :mxDocument( _rxDocument ) { Reference< XDocumentEventBroadcaster > xBroadcaster( _rxDocument, UNO_QUERY_THROW ); @@ -125,7 +115,7 @@ namespace dbaccess try { - m_pData->xURLTransformer = URLTransformer::create(_rContext); + mxURLTransformer = URLTransformer::create(_rContext); } catch( const Exception& ) { @@ -139,8 +129,8 @@ namespace dbaccess void SAL_CALL DocumentEventExecutor::documentEventOccured( const DocumentEvent& Event ) { - Reference< XEventsSupplier > xEventsSupplier( m_pData->xDocument.get(), UNO_QUERY ); - if ( !xEventsSupplier.is() ) + Reference< XEventsSupplier > xEventsSupplier( mxDocument.get(), UNO_QUERY ); + if ( !xEventsSupplier ) { OSL_FAIL( "DocumentEventExecutor::documentEventOccurred: no document anymore, but still being notified?" ); return; @@ -179,7 +169,7 @@ namespace dbaccess if ( bDispatchScriptURL && bNonEmptyScript ) { - lcl_dispatchScriptURL_throw( *m_pData, sScript, Event ); + lcl_dispatchScriptURL_throw( mxDocument, mxURLTransformer, sScript, Event ); } } catch( const RuntimeException& ) { throw; } diff --git a/dbaccess/source/core/dataaccess/documenteventexecutor.hxx b/dbaccess/source/core/dataaccess/documenteventexecutor.hxx index 90dc9083c4a3..58aee4bcd590 100644 --- a/dbaccess/source/core/dataaccess/documenteventexecutor.hxx +++ b/dbaccess/source/core/dataaccess/documenteventexecutor.hxx @@ -23,15 +23,13 @@ #include <com/sun/star/document/XEventsSupplier.hpp> #include <cppuhelper/implbase.hxx> - -#include <memory> +#include <cppuhelper/weakref.hxx> namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::util { class XURLTransformer; } namespace dbaccess { - - struct DocumentEventExecutor_Data; // DocumentEventExecutor typedef ::cppu::WeakImplHelper < css::document::XDocumentEventListener > DocumentEventExecutor_Base; @@ -51,7 +49,8 @@ namespace dbaccess virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; private: - std::unique_ptr< DocumentEventExecutor_Data > m_pData; + css::uno::WeakReference< css::document::XEventsSupplier > mxDocument; + css::uno::Reference< css::util::XURLTransformer > mxURLTransformer; }; } // namespace dbaccess diff --git a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx index 6a7088f95787..475b16c0b551 100644 --- a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx +++ b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx @@ -24,7 +24,7 @@ #include <comphelper/asyncnotification.hxx> #include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/weak.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> namespace dbaccess diff --git a/dbaccess/source/core/dataaccess/documentevents.cxx b/dbaccess/source/core/dataaccess/documentevents.cxx index cd4428775e03..6dbe9ad5965d 100644 --- a/dbaccess/source/core/dataaccess/documentevents.cxx +++ b/dbaccess/source/core/dataaccess/documentevents.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/sequence.hxx> @@ -35,23 +36,6 @@ namespace dbaccess using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Type; - // DocumentEvents_Data - struct DocumentEvents_Data - { - ::cppu::OWeakObject& rParent; - ::osl::Mutex& rMutex; - DocumentEventsData& rEventsData; - - DocumentEvents_Data( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData ) - :rParent( _rParent ) - ,rMutex( _rMutex ) - ,rEventsData( _rEventsData ) - { - } - DocumentEvents_Data(const DocumentEvents_Data&) = delete; - const DocumentEvents_Data& operator=(const DocumentEvents_Data&) = delete; - }; - namespace { // helper @@ -96,15 +80,15 @@ namespace dbaccess // DocumentEvents DocumentEvents::DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData ) - :m_pData( new DocumentEvents_Data( _rParent, _rMutex, _rEventsData ) ) + :mrParent(_rParent), mrMutex(_rMutex), mrEventsData(_rEventsData) { const DocumentEventData* pEventData = lcl_getDocumentEventData(); while ( pEventData->pAsciiEventName ) { OUString sEventName = OUString::createFromAscii( pEventData->pAsciiEventName ); - DocumentEventsData::const_iterator existingPos = m_pData->rEventsData.find( sEventName ); - if ( existingPos == m_pData->rEventsData.end() ) - m_pData->rEventsData[ sEventName ] = Sequence< PropertyValue >(); + DocumentEventsData::const_iterator existingPos = mrEventsData.find( sEventName ); + if ( existingPos == mrEventsData.end() ) + mrEventsData[ sEventName ] = Sequence< PropertyValue >(); ++pEventData; } } @@ -115,20 +99,20 @@ namespace dbaccess void SAL_CALL DocumentEvents::acquire() noexcept { - m_pData->rParent.acquire(); + mrParent.acquire(); } void SAL_CALL DocumentEvents::release() noexcept { - m_pData->rParent.release(); + mrParent.release(); } - bool DocumentEvents::needsSynchronousNotification( const OUString& _rEventName ) + bool DocumentEvents::needsSynchronousNotification( std::u16string_view _rEventName ) { const DocumentEventData* pEventData = lcl_getDocumentEventData(); while ( pEventData->pAsciiEventName ) { - if ( _rEventName.equalsAscii( pEventData->pAsciiEventName ) ) + if ( o3tl::equalsAscii( _rEventName, pEventData->pAsciiEventName ) ) return pEventData->bNeedsSyncNotify; ++pEventData; } @@ -139,10 +123,10 @@ namespace dbaccess void SAL_CALL DocumentEvents::replaceByName( const OUString& Name, const Any& Element ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - DocumentEventsData::iterator elementPos = m_pData->rEventsData.find( Name ); - if ( elementPos == m_pData->rEventsData.end() ) + DocumentEventsData::iterator elementPos = mrEventsData.find( Name ); + if ( elementPos == mrEventsData.end() ) throw NoSuchElementException( Name, *this ); Sequence< PropertyValue > aEventDescriptor; @@ -172,10 +156,10 @@ namespace dbaccess Any SAL_CALL DocumentEvents::getByName( const OUString& Name ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - DocumentEventsData::const_iterator elementPos = m_pData->rEventsData.find( Name ); - if ( elementPos == m_pData->rEventsData.end() ) + DocumentEventsData::const_iterator elementPos = mrEventsData.find( Name ); + if ( elementPos == mrEventsData.end() ) throw NoSuchElementException( Name, *this ); Any aReturn; @@ -187,16 +171,16 @@ namespace dbaccess Sequence< OUString > SAL_CALL DocumentEvents::getElementNames( ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - return comphelper::mapKeysToSequence( m_pData->rEventsData ); + return comphelper::mapKeysToSequence( mrEventsData ); } sal_Bool SAL_CALL DocumentEvents::hasByName( const OUString& Name ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - return m_pData->rEventsData.find( Name ) != m_pData->rEventsData.end(); + return mrEventsData.find( Name ) != mrEventsData.end(); } Type SAL_CALL DocumentEvents::getElementType( ) @@ -206,8 +190,8 @@ namespace dbaccess sal_Bool SAL_CALL DocumentEvents::hasElements( ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); - return !m_pData->rEventsData.empty(); + ::osl::MutexGuard aGuard( mrMutex ); + return !mrEventsData.empty(); } } // namespace dbaccess diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx index 3e7f309976f9..26b85cbb8f3b 100644 --- a/dbaccess/source/core/dataaccess/intercept.cxx +++ b/dbaccess/source/core/dataaccess/intercept.cxx @@ -20,7 +20,7 @@ #include "intercept.hxx" -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <memory> @@ -28,13 +28,11 @@ namespace dbaccess { using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; -using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::io; -using namespace ::com::sun::star::embed; using namespace ::com::sun::star::container; using namespace ::comphelper; using namespace ::cppu; @@ -208,7 +206,7 @@ void SAL_CALL OInterceptor::addStatusListener( { osl::MutexGuard aGuard(m_aMutex); if(!m_pStatCL) - m_pStatCL.reset( new PropertyChangeListenerContainer(m_aMutex) ); + m_pStatCL.reset( new StatusListenerContainer(m_aMutex) ); } m_pStatCL->addInterface(URL.Complete,Control); @@ -225,7 +223,7 @@ void SAL_CALL OInterceptor::addStatusListener( { osl::MutexGuard aGuard(m_aMutex); if(!m_pStatCL) - m_pStatCL.reset( new PropertyChangeListenerContainer(m_aMutex) ); + m_pStatCL.reset( new StatusListenerContainer(m_aMutex) ); } m_pStatCL->addInterface(URL.Complete,Control); @@ -249,7 +247,7 @@ void SAL_CALL OInterceptor::addStatusListener( { osl::MutexGuard aGuard(m_aMutex); if(!m_pStatCL) - m_pStatCL.reset( new PropertyChangeListenerContainer(m_aMutex) ); + m_pStatCL.reset( new StatusListenerContainer(m_aMutex) ); } m_pStatCL->addInterface(URL.Complete,Control); @@ -303,14 +301,13 @@ Reference< XDispatch > SAL_CALL OInterceptor::queryDispatch( const URL& URL,cons Sequence< Reference< XDispatch > > SAL_CALL OInterceptor::queryDispatches( const Sequence<DispatchDescriptor >& Requests ) { - Sequence< Reference< XDispatch > > aRet; osl::MutexGuard aGuard(m_aMutex); - if(m_xSlaveDispatchProvider.is()) - aRet = m_xSlaveDispatchProvider->queryDispatches(Requests); - else - aRet.realloc(Requests.getLength()); - auto aRetRange = asNonConstRange(aRet); + typedef Sequence<Reference<XDispatch>> DispatchSeq; + DispatchSeq aRet = m_xSlaveDispatchProvider.is() ? + m_xSlaveDispatchProvider->queryDispatches(Requests) : + DispatchSeq(Requests.getLength()); + auto aRetRange = asNonConstRange(aRet); for(sal_Int32 i = 0; i < Requests.getLength(); ++i) { const OUString* pIter = m_aInterceptedURL.getConstArray(); diff --git a/dbaccess/source/core/dataaccess/intercept.hxx b/dbaccess/source/core/dataaccess/intercept.hxx index 16077c3c9e52..7ce53752f19d 100644 --- a/dbaccess/source/core/dataaccess/intercept.hxx +++ b/dbaccess/source/core/dataaccess/intercept.hxx @@ -103,7 +103,9 @@ private: css::uno::Sequence< OUString > m_aInterceptedURL; - std::unique_ptr<PropertyChangeListenerContainer> m_pStatCL; + typedef comphelper::OMultiTypeInterfaceContainerHelperVar3<css::frame::XStatusListener, OUString> + StatusListenerContainer; + std::unique_ptr<StatusListenerContainer> m_pStatCL; }; } // namespace dbaccess diff --git a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx index e0d32d56971b..495f4868851e 100644 --- a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx +++ b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx @@ -17,82 +17,38 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <utility> #include <vector> -#include <ucbhelper/contentidentifier.hxx> - #include "myucp_datasupplier.hxx" #include <ContentHelper.hxx> #include <com/sun/star/ucb/IllegalIdentifierException.hpp> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::io; using namespace ::com::sun::star::container; -// @@@ Adjust namespace name. using namespace dbaccess; -// @@@ Adjust namespace name. -namespace dbaccess -{ - -namespace { - -// struct ResultListEntry. -struct ResultListEntry -{ - OUString aId; - Reference< XContentIdentifier > xId; - ::rtl::Reference< OContentHelper > xContent; - Reference< XRow > xRow; - const ContentProperties& rData; - - explicit ResultListEntry(const ContentProperties& rEntry) : rData( rEntry ) {} -}; - -} - -// struct DataSupplier_Impl. -struct DataSupplier_Impl -{ - osl::Mutex m_aMutex; - std::vector< std::unique_ptr<ResultListEntry> > m_aResults; - rtl::Reference< ODocumentContainer > m_xContent; - bool m_bCountFinal; - - explicit DataSupplier_Impl(const rtl::Reference< ODocumentContainer >& rContent) - : m_xContent(rContent) - , m_bCountFinal(false) - { - } -}; - -} - -// DataSupplier Implementation. DataSupplier::DataSupplier( const rtl::Reference< ODocumentContainer >& rContent ) -: m_pImpl( new DataSupplier_Impl( rContent ) ) +: m_xContent( rContent ) { - } DataSupplier::~DataSupplier() { - } OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( static_cast<size_t>(nIndex) < m_pImpl->m_aResults.size() ) + if ( static_cast<size_t>(nIndex) < m_aResults.size() ) { - OUString aId = m_pImpl->m_aResults[ nIndex ]->aId; + OUString aId = m_aResults[ nIndex ]->aId; if ( !aId.isEmpty() ) { // Already cached. @@ -102,14 +58,14 @@ OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) if ( getResult( nIndex ) ) { - OUString aId = m_pImpl->m_xContent->getIdentifier()->getContentIdentifier(); + OUString aId = m_xContent->getIdentifier()->getContentIdentifier(); if ( !aId.isEmpty() ) aId += "/"; - aId += m_pImpl->m_aResults[ nIndex ]->rData.aTitle; + aId += m_aResults[ nIndex ]->rData.aTitle; - m_pImpl->m_aResults[ nIndex ]->aId = aId; + m_aResults[ nIndex ]->aId = aId; return aId; } return OUString(); @@ -118,11 +74,11 @@ OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex ) Reference< XContentIdentifier > DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( static_cast<size_t>(nIndex) < m_pImpl->m_aResults.size() ) + if ( static_cast<size_t>(nIndex) < m_aResults.size() ) { - Reference< XContentIdentifier > xId = m_pImpl->m_aResults[ nIndex ]->xId; + Reference< XContentIdentifier > xId = m_aResults[ nIndex ]->xId; if ( xId.is() ) { // Already cached. @@ -134,7 +90,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) if ( !aId.isEmpty() ) { Reference< XContentIdentifier > xId = new ::ucbhelper::ContentIdentifier( aId ); - m_pImpl->m_aResults[ nIndex ]->xId = xId; + m_aResults[ nIndex ]->xId = xId; return xId; } return Reference< XContentIdentifier >(); @@ -143,11 +99,11 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex ) Reference< XContent > DataSupplier::queryContent( sal_uInt32 _nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( static_cast<size_t>(_nIndex) < m_pImpl->m_aResults.size() ) + if ( static_cast<size_t>(_nIndex) < m_aResults.size() ) { - Reference< XContent > xContent = m_pImpl->m_aResults[ _nIndex ]->xContent; + Reference< XContent > xContent = m_aResults[ _nIndex ]->xContent; if ( xContent.is() ) { // Already cached. @@ -164,9 +120,9 @@ DataSupplier::queryContent( sal_uInt32 _nIndex ) OUString sName = xId->getContentIdentifier(); sName = sName.copy(sName.lastIndexOf('/')+1); - m_pImpl->m_aResults[ _nIndex ]->xContent = m_pImpl->m_xContent->getContent(sName); + m_aResults[ _nIndex ]->xContent = m_xContent->getContent(sName); - xContent = m_pImpl->m_aResults[ _nIndex ]->xContent.get(); + xContent = m_aResults[ _nIndex ]->xContent.get(); return xContent; } @@ -179,9 +135,9 @@ DataSupplier::queryContent( sal_uInt32 _nIndex ) bool DataSupplier::getResult( sal_uInt32 nIndex ) { - osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - if ( static_cast<size_t>(nIndex) < m_pImpl->m_aResults.size() ) + if ( static_cast<size_t>(nIndex) < m_aResults.size() ) { // Result already present. return true; @@ -189,25 +145,25 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) // Result not (yet) present. - if ( m_pImpl->m_bCountFinal ) + if ( m_bCountFinal ) return false; // Try to obtain result... - sal_uInt32 nOldCount = m_pImpl->m_aResults.size(); + sal_uInt32 nOldCount = m_aResults.size(); bool bFound = false; sal_uInt32 nPos = nOldCount; // @@@ Obtain data and put it into result list... - Sequence< OUString> aSeq = m_pImpl->m_xContent->getElementNames(); + Sequence< OUString> aSeq = m_xContent->getElementNames(); if ( nIndex < sal::static_int_cast< sal_uInt32 >( aSeq.getLength() ) ) { const OUString* pIter = aSeq.getConstArray(); const OUString* pEnd = pIter + aSeq.getLength(); for(pIter = pIter + nPos;pIter != pEnd;++pIter,++nPos) { - m_pImpl->m_aResults.emplace_back( - new ResultListEntry( m_pImpl->m_xContent->getContent(*pIter)->getContentProperties() ) ); + m_aResults.emplace_back( + new ResultListEntry( m_xContent->getContent(*pIter)->getContentProperties() ) ); if ( nPos == nIndex ) { @@ -219,7 +175,7 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) } if ( !bFound ) - m_pImpl->m_bCountFinal = true; + m_bCountFinal = true; rtl::Reference< ::ucbhelper::ResultSet > xResultSet = getResultSet(); if ( xResultSet.is() ) @@ -227,11 +183,10 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) // Callbacks follow! aGuard.clear(); - if ( static_cast<size_t>(nOldCount) < m_pImpl->m_aResults.size() ) - xResultSet->rowCountChanged( - nOldCount, m_pImpl->m_aResults.size() ); + if ( static_cast<size_t>(nOldCount) < m_aResults.size() ) + xResultSet->rowCountChanged( nOldCount, m_aResults.size() ); - if ( m_pImpl->m_bCountFinal ) + if ( m_bCountFinal ) xResultSet->rowCountFinal(); } @@ -240,22 +195,22 @@ bool DataSupplier::getResult( sal_uInt32 nIndex ) sal_uInt32 DataSupplier::totalCount() { - osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); - if ( m_pImpl->m_bCountFinal ) - return m_pImpl->m_aResults.size(); + if ( m_bCountFinal ) + return m_aResults.size(); - sal_uInt32 nOldCount = m_pImpl->m_aResults.size(); + sal_uInt32 nOldCount = m_aResults.size(); // @@@ Obtain data and put it into result list... - Sequence< OUString> aSeq = m_pImpl->m_xContent->getElementNames(); + Sequence< OUString> aSeq = m_xContent->getElementNames(); const OUString* pIter = aSeq.getConstArray(); const OUString* pEnd = pIter + aSeq.getLength(); for(;pIter != pEnd;++pIter) - m_pImpl->m_aResults.emplace_back( - new ResultListEntry( m_pImpl->m_xContent->getContent(*pIter)->getContentProperties() ) ); + m_aResults.emplace_back( + new ResultListEntry( m_xContent->getContent(*pIter)->getContentProperties() ) ); - m_pImpl->m_bCountFinal = true; + m_bCountFinal = true; rtl::Reference< ::ucbhelper::ResultSet > xResultSet = getResultSet(); if ( xResultSet.is() ) @@ -263,34 +218,33 @@ sal_uInt32 DataSupplier::totalCount() // Callbacks follow! aGuard.clear(); - if ( static_cast<size_t>(nOldCount) < m_pImpl->m_aResults.size() ) - xResultSet->rowCountChanged( - nOldCount, m_pImpl->m_aResults.size() ); + if ( static_cast<size_t>(nOldCount) < m_aResults.size() ) + xResultSet->rowCountChanged( nOldCount, m_aResults.size() ); xResultSet->rowCountFinal(); } - return m_pImpl->m_aResults.size(); + return m_aResults.size(); } sal_uInt32 DataSupplier::currentCount() { - return m_pImpl->m_aResults.size(); + return m_aResults.size(); } bool DataSupplier::isCountFinal() { - return m_pImpl->m_bCountFinal; + return m_bCountFinal; } Reference< XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( static_cast<size_t>(nIndex) < m_pImpl->m_aResults.size() ) + if ( static_cast<size_t>(nIndex) < m_aResults.size() ) { - Reference< XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow; + Reference< XRow > xRow = m_aResults[ nIndex ]->xRow; if ( xRow.is() ) { // Already cached. @@ -300,11 +254,11 @@ DataSupplier::queryPropertyValues( sal_uInt32 nIndex ) if ( getResult( nIndex ) ) { - if ( !m_pImpl->m_aResults[ nIndex ]->xContent.is() ) + if ( !m_aResults[ nIndex ]->xContent.is() ) queryContent(nIndex); - Reference< XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xContent->getPropertyValues(getResultSet()->getProperties()); - m_pImpl->m_aResults[ nIndex ]->xRow = xRow; + Reference< XRow > xRow = m_aResults[ nIndex ]->xContent->getPropertyValues(getResultSet()->getProperties()); + m_aResults[ nIndex ]->xRow = xRow; return xRow; } @@ -313,10 +267,10 @@ DataSupplier::queryPropertyValues( sal_uInt32 nIndex ) void DataSupplier::releasePropertyValues( sal_uInt32 nIndex ) { - osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); + osl::Guard< osl::Mutex > aGuard( m_aMutex ); - if ( static_cast<size_t>(nIndex) < m_pImpl->m_aResults.size() ) - m_pImpl->m_aResults[ nIndex ]->xRow.clear(); + if ( static_cast<size_t>(nIndex) < m_aResults.size() ) + m_aResults[ nIndex ]->xRow.clear(); } void DataSupplier::close() diff --git a/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx b/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx index 8083f5ef59fa..65a45ad7fef6 100644 --- a/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx +++ b/dbaccess/source/core/dataaccess/myucp_datasupplier.hxx @@ -20,17 +20,33 @@ #pragma once #include <rtl/ref.hxx> +#include <ucbhelper/contentidentifier.hxx> #include <ucbhelper/resultset.hxx> #include "documentcontainer.hxx" #include <memory> namespace dbaccess { -struct DataSupplier_Impl; +struct ResultListEntry +{ + OUString aId; + css::uno::Reference<css::ucb::XContentIdentifier> xId; + ::rtl::Reference<OContentHelper> xContent; + css::uno::Reference<css::sdbc::XRow> xRow; + const ContentProperties& rData; + + explicit ResultListEntry(const ContentProperties& rEntry) + : rData(rEntry) + { + } +}; class DataSupplier : public ucbhelper::ResultSetDataSupplier { - std::unique_ptr<DataSupplier_Impl> m_pImpl; + osl::Mutex m_aMutex; + std::vector<std::unique_ptr<ResultListEntry>> m_aResults; + rtl::Reference<ODocumentContainer> m_xContent; + bool m_bCountFinal = false; public: explicit DataSupplier(const rtl::Reference<ODocumentContainer>& rxContent); diff --git a/dbaccess/source/core/dataaccess/myucp_resultset.cxx b/dbaccess/source/core/dataaccess/myucp_resultset.cxx index 67c1ad7c8b4b..9ba383e0aa18 100644 --- a/dbaccess/source/core/dataaccess/myucp_resultset.cxx +++ b/dbaccess/source/core/dataaccess/myucp_resultset.cxx @@ -26,14 +26,13 @@ *************************************************************************/ +#include <utility> + #include "myucp_datasupplier.hxx" #include "myucp_resultset.hxx" using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::io; using namespace ::com::sun::star::container; @@ -42,11 +41,11 @@ using namespace dbaccess; // DynamicResultSet Implementation. DynamicResultSet::DynamicResultSet( const Reference< XComponentContext >& rxContext, - const rtl::Reference< ODocumentContainer >& rxContent, + rtl::Reference< ODocumentContainer > xContent, const OpenCommandArgument2& rCommand, const Reference< XCommandEnvironment >& rxEnv ) :ResultSetImplHelper( rxContext, rCommand ) - ,m_xContent(rxContent) + ,m_xContent(std::move(xContent)) ,m_xEnv( rxEnv ) { } diff --git a/dbaccess/source/core/dataaccess/myucp_resultset.hxx b/dbaccess/source/core/dataaccess/myucp_resultset.hxx index ae269ffb8ac9..220bdf0a70b7 100644 --- a/dbaccess/source/core/dataaccess/myucp_resultset.hxx +++ b/dbaccess/source/core/dataaccess/myucp_resultset.hxx @@ -39,7 +39,7 @@ private: public: DynamicResultSet( const css::uno::Reference< css::uno::XComponentContext >& rxContext, - const rtl::Reference< ODocumentContainer >& rxContent, + rtl::Reference< ODocumentContainer > xContent, const css::ucb::OpenCommandArgument2& rCommand, const css::uno::Reference< css::ucb::XCommandEnvironment >& rxEnv ); }; diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx index 471729982b9d..d60521a4328d 100644 --- a/dbaccess/source/core/inc/ContentHelper.hxx +++ b/dbaccess/source/core/inc/ContentHelper.hxx @@ -25,12 +25,11 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/compbase.hxx> #include <cppuhelper/basemutex.hxx> #include <comphelper/interfacecontainer3.hxx> -#include <comphelper/multiinterfacecontainer2.hxx> +#include <comphelper/multiinterfacecontainer3.hxx> #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/sdbcx/XRename.hpp> @@ -72,7 +71,7 @@ namespace dbaccess typedef std::shared_ptr<OContentHelper_Impl> TContentPtr; - typedef comphelper::OMultiTypeInterfaceContainerHelperVar2<OUString> + typedef comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertiesChangeListener, OUString> PropertyChangeListenerContainer; typedef ::cppu::WeakComponentImplHelper< css::ucb::XContent , css::ucb::XCommandProcessor @@ -80,7 +79,6 @@ namespace dbaccess , css::beans::XPropertiesChangeNotifier , css::beans::XPropertyContainer , css::lang::XInitialization - , css::lang::XUnoTunnel , css::container::XChild , css::sdbcx::XRename > OContentHelper_COMPBASE; @@ -122,7 +120,7 @@ namespace dbaccess OContentHelper( const css::uno::Reference< css::uno::XComponentContext >& _xORB ,const css::uno::Reference< css::uno::XInterface >& _xParentContainer - ,const TContentPtr& _pImpl + ,TContentPtr _pImpl ); // css::lang::XTypeProvider @@ -155,10 +153,6 @@ namespace dbaccess // XInitialization virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; - // css::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); - // css::container::XChild virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx index b5b2c0ae6143..8c2029634b8a 100644 --- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -220,7 +220,7 @@ private: ::osl::MutexGuard aGuard(m_aMutex); if ( _member != Value ) { - prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l); + prepareSet(_sProperty, css::uno::Any(_member), css::uno::Any(Value), &l); _member = Value; } } diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx index b6e2fe729ffb..2fc19830ca42 100644 --- a/dbaccess/source/core/inc/ModelImpl.hxx +++ b/dbaccess/source/core/inc/ModelImpl.hxx @@ -27,18 +27,23 @@ #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/reflection/ProxyFactory.hpp> #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> + #include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/weakref.hxx> #include <vcl/svapp.hxx> #include <sfx2/docmacromode.hxx> #include <sfx2/docstoragemodifylistener.hxx> #include <unotools/sharedunocomponent.hxx> +#include <rtl/digest.h> #include <rtl/ref.hxx> +#include <o3tl/enumarray.hxx> namespace comphelper { @@ -84,35 +89,95 @@ struct AsciiPropertyValue } }; -class ODatabaseContext; -class OSharedConnectionManager; - // ODatabaseModelImpl typedef ::utl::SharedUNOComponent< css::embed::XStorage > SharedStorage; class ODatabaseContext; class DocumentStorageAccess; -class OSharedConnectionManager; +class ODatabaseSource; + + +/** The class OSharedConnectionManager implements a structure to share connections. + It owns the master connections which will be disposed when the last connection proxy is gone. +*/ +// need to hold the digest +struct TDigestHolder +{ + sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1]; + TDigestHolder() + { + m_pBuffer[0] = 0; + } + +}; + +class OSharedConnectionManager : public ::cppu::WeakImplHelper< css::lang::XEventListener > +{ + // contains the currently used master connections + struct TConnectionHolder + { + css::uno::Reference< css::sdbc::XConnection > xMasterConnection; + oslInterlockedCount nALiveCount; + }; + + // the less-compare functor, used for the stl::map + struct TDigestLess + { + bool operator() (const TDigestHolder& x, const TDigestHolder& y) const + { + sal_uInt32 i; + for(i=0;i < RTL_DIGEST_LENGTH_SHA1 && (x.m_pBuffer[i] >= y.m_pBuffer[i]); ++i) + ; + return i < RTL_DIGEST_LENGTH_SHA1; + } + }; + + typedef std::map< TDigestHolder,TConnectionHolder,TDigestLess> TConnectionMap; // holds the master connections + typedef std::map< css::uno::Reference< css::sdbc::XConnection >,TConnectionMap::iterator> TSharedConnectionMap;// holds the shared connections + + ::osl::Mutex m_aMutex; + TConnectionMap m_aConnections; // remember the master connection in conjunction with the digest + TSharedConnectionMap m_aSharedConnection; // the shared connections with conjunction with an iterator into the connections map + css::uno::Reference< css::reflection::XProxyFactory > m_xProxyFactory; + +protected: + virtual ~OSharedConnectionManager() override; + +public: + explicit OSharedConnectionManager(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); + + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + css::uno::Reference< css::sdbc::XConnection > getConnection( const OUString& url, + const OUString& user, + const OUString& password, + const css::uno::Sequence< css::beans::PropertyValue >& _aInfo, + ODatabaseSource* _pDataSource); + void addEventListener(const css::uno::Reference< css::sdbc::XConnection >& _rxConnection, TConnectionMap::iterator const & _rIter); +}; + + class ODatabaseModelImpl :public ::sfx2::IMacroDocumentAccess ,public ::sfx2::IModifiableDocument { public: - enum ObjectType + + enum class ObjectType { - E_FORM = 0, - E_REPORT = 1, - E_QUERY = 2, - E_TABLE = 3 + Form = 0, + Report = 1, + Query = 2, + Table = 3, + LAST = Table }; - enum EmbeddedMacros + enum class EmbeddedMacros { // the database document (storage) itself contains macros - eDocumentWideMacros, + DocumentWide, // there are sub document( storage)s containing macros - eSubDocumentMacros, + SubDocument, // there are no known macro( storage)s - eNoMacros + NONE }; private: @@ -120,7 +185,7 @@ private: css::uno::WeakReference< css::sdbc::XDataSource > m_xDataSource; rtl::Reference<DocumentStorageAccess> m_pStorageAccess; - std::vector< TContentPtr > m_aContainer; // one for each ObjectType + o3tl::enumarray< ObjectType, TContentPtr > m_aContainer; // one for each ObjectType ::sfx2::DocumentMacroMode m_aMacroMode; sal_Int16 m_nImposedMacroExecMode; @@ -187,9 +252,7 @@ public: m_xSettings; css::uno::Sequence< OUString > m_aTableFilter; css::uno::Sequence< OUString > m_aTableTypeFilter; - OSharedConnectionManager* m_pSharedConnectionManager; - css::uno::Reference< css::lang::XEventListener > - m_xSharedConnectionManager; + rtl::Reference< OSharedConnectionManager > m_xSharedConnectionManager; css::uno::Reference<css::awt::XWindow> m_xDialogParent; sal_uInt16 m_nControllerLockCount; @@ -221,7 +284,7 @@ public: virtual ~ODatabaseModelImpl(); ODatabaseModelImpl( - const OUString& _rRegistrationName, + OUString _sRegistrationName, const css::uno::Reference< css::uno::XComponentContext >& _rxContext, ODatabaseContext& _rDBContext ); @@ -416,7 +479,8 @@ public: virtual bool macroCallsSeenWhileLoading() const override; virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override; virtual SignatureState getScriptingSignatureState() override; - virtual bool hasTrustedScriptingSignature( bool bAllowUIToAddAuthor ) override; + virtual bool hasTrustedScriptingSignature( + const css::uno::Reference<css::task::XInteractionHandler>& _rxInteraction) override; // IModifiableDocument virtual void storageIsModified() override; @@ -451,7 +515,7 @@ protected: ::osl::Mutex m_aMutex; // only use this to init WeakComponentImplHelper protected: - explicit ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model ); + explicit ModelDependentComponent( ::rtl::Reference< ODatabaseModelImpl > _model ); virtual ~ModelDependentComponent(); /** returns the component itself diff --git a/dbaccess/source/core/inc/PropertyForward.hxx b/dbaccess/source/core/inc/PropertyForward.hxx index b8e602fc05cf..daf31758d000 100644 --- a/dbaccess/source/core/inc/PropertyForward.hxx +++ b/dbaccess/source/core/inc/PropertyForward.hxx @@ -49,7 +49,7 @@ namespace dbaccess public: OPropertyForward( const css::uno::Reference< css::beans::XPropertySet>& _xSource, const css::uno::Reference< css::container::XNameAccess>& _xDestContainer, - const OUString& _sName, + OUString _sName, const std::vector< OUString >& _aPropertyList ); diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx index a0edfd195a69..fdde2d451d17 100644 --- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -76,6 +76,7 @@ namespace dbaccess typedef std::function<const ::connectivity::OSQLParseNode*(::connectivity::OSQLParseTreeIterator *)> TGetParseNode; ::svxform::OSystemParseContext m_aParseContext; + ::svxform::ONeutralParseContext m_aNeutralContext; ::connectivity::OSQLParser m_aSqlParser; ::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement ::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement) diff --git a/dbaccess/source/core/inc/TableDeco.hxx b/dbaccess/source/core/inc/TableDeco.hxx index 5e2cb214fb8a..93a974dac4a4 100644 --- a/dbaccess/source/core/inc/TableDeco.hxx +++ b/dbaccess/source/core/inc/TableDeco.hxx @@ -61,7 +61,6 @@ namespace dbaccess ,public ODBTableDecorator_PROP { void fillPrivileges() const; - protected: css::uno::Reference< css::container::XContainerListener > m_xColumnMediator; css::uno::Reference< css::sdbcx::XColumnsSupplier > m_xTable; css::uno::Reference< css::container::XNameAccess > m_xColumnDefinitions; @@ -75,6 +74,7 @@ namespace dbaccess // note: this thing uses the ref-count of "this", see OCollection::acquire()! std::unique_ptr<::connectivity::sdbcx::OCollection> m_pColumns; + protected: // IColumnFactory virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) const override; virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override; @@ -145,7 +145,7 @@ namespace dbaccess virtual void SAL_CALL setName( const OUString& aName ) override; // css::lang::XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); + static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); // XColumnsSupplier virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx index aebc376b138d..eae96fba3fd6 100644 --- a/dbaccess/source/core/inc/column.hxx +++ b/dbaccess/source/core/inc/column.hxx @@ -128,7 +128,6 @@ namespace dbaccess { OContainerMediator* m_pMediator; - protected: // comes from the driver can be null css::uno::Reference< css::container::XNameAccess > m_xDrvColumns; css::uno::WeakReference< css::uno::XInterface > m_xParent; @@ -139,6 +138,7 @@ namespace dbaccess bool m_bAddColumn : 1; bool m_bDropColumn : 1; + protected: virtual void impl_refresh() override; virtual connectivity::sdbcx::ObjectType createObject(const OUString& _rName) override; virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; @@ -178,7 +178,7 @@ namespace dbaccess OColumns( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, - const css::uno::Reference< css::container::XNameAccess >& _rxDrvColumns, + css::uno::Reference< css::container::XNameAccess > _xDrvColumns, bool _bCaseSensitive, const std::vector< OUString> &_rVector, IColumnFactory* _pColFactory, diff --git a/dbaccess/source/core/inc/databasecontext.hxx b/dbaccess/source/core/inc/databasecontext.hxx index 2f8924f9f837..d94df018d1c0 100644 --- a/dbaccess/source/core/inc/databasecontext.hxx +++ b/dbaccess/source/core/inc/databasecontext.hxx @@ -28,7 +28,6 @@ #include "ModelImpl.hxx" #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/sdb/XDatabaseContext.hpp> #include <com/sun/star/sdb/XDatabaseRegistrations.hpp> #include <com/sun/star/uno/XAggregation.hpp> @@ -55,7 +54,6 @@ class DatabaseDocumentLoader; typedef ::cppu::WeakComponentImplHelper< css::lang::XServiceInfo , css::sdb::XDatabaseContext - , css::lang::XUnoTunnel > DatabaseAccessContext_Base; class ODatabaseContext :public DatabaseAccessContext_Base @@ -84,13 +82,10 @@ private: BasicDLL m_aBasicDLL; #endif -protected: ::osl::Mutex m_aMutex; css::uno::Reference< css::uno::XComponentContext > m_aContext; - css::uno::Reference< css::uno::XAggregation > - m_xDBRegistrationAggregate; css::uno::Reference< css::sdb::XDatabaseRegistrations > m_xDatabaseRegistrations; @@ -156,10 +151,6 @@ public: virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; - // css::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); - void registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl); void revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl); void databaseDocumentURLChange(const OUString& _sOldName, const OUString& _sNewName); diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx index 4d7ff3e170e0..b4c0a5c081a6 100644 --- a/dbaccess/source/core/inc/definitioncolumn.hxx +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -151,7 +151,7 @@ namespace dbaccess OQueryColumn( const css::uno::Reference< css::beans::XPropertySet>& _rxParserColumn, const css::uno::Reference< css::sdbc::XConnection >& _rxConnection, - const OUString &i_sLabel + OUString i_sLabel ); // XTypeProvider diff --git a/dbaccess/source/core/inc/definitioncontainer.hxx b/dbaccess/source/core/inc/definitioncontainer.hxx index bcb6bd364470..02f145776c8f 100644 --- a/dbaccess/source/core/inc/definitioncontainer.hxx +++ b/dbaccess/source/core/inc/definitioncontainer.hxx @@ -36,6 +36,7 @@ #include "ContentHelper.hxx" #include "containerapprove.hxx" #include <comphelper/uno3.hxx> +#include <comphelper/interfacecontainer2.hxx> namespace dbaccess { @@ -129,7 +130,7 @@ protected: with a new one), this new element must pass our own internal approval, plus the approval given here. */ - void setElementApproval( PContainerApprove _pElementApproval ) { m_pElementApproval = _pElementApproval; } + void setElementApproval(const PContainerApprove& _pElementApproval ) { m_pElementApproval = _pElementApproval; } const PContainerApprove& getElementApproval() const { return m_pElementApproval; } protected: diff --git a/dbaccess/source/core/inc/documentevents.hxx b/dbaccess/source/core/inc/documentevents.hxx index 24a7dd24ca17..224fc407d2fe 100644 --- a/dbaccess/source/core/inc/documentevents.hxx +++ b/dbaccess/source/core/inc/documentevents.hxx @@ -24,7 +24,6 @@ #include <cppuhelper/implbase.hxx> -#include <memory> #include <map> namespace dbaccess @@ -33,9 +32,6 @@ namespace dbaccess typedef std::map< OUString, css::uno::Sequence< css::beans::PropertyValue > > DocumentEventsData; - // DocumentEvents - struct DocumentEvents_Data; - typedef ::cppu::WeakImplHelper< css::container::XNameReplace > DocumentEvents_Base; @@ -48,7 +44,7 @@ namespace dbaccess DocumentEvents(const DocumentEvents&) = delete; const DocumentEvents& operator=(const DocumentEvents&) = delete; - static bool needsSynchronousNotification( const OUString& _rEventName ); + static bool needsSynchronousNotification( std::u16string_view _rEventName ); // XInterface virtual void SAL_CALL acquire() noexcept override; @@ -67,7 +63,9 @@ namespace dbaccess virtual sal_Bool SAL_CALL hasElements( ) override; private: - std::unique_ptr< DocumentEvents_Data > m_pData; + ::cppu::OWeakObject& mrParent; + ::osl::Mutex& mrMutex; + DocumentEventsData& mrEventsData; }; } // namespace dbaccess diff --git a/dbaccess/source/core/inc/object.hxx b/dbaccess/source/core/inc/object.hxx deleted file mode 100644 index a947f9c57c3e..000000000000 --- a/dbaccess/source/core/inc/object.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -enum ObjectType -{ - dbaTable, - dbaQuery, - dbaForm, - dbaReport -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/objectnameapproval.hxx b/dbaccess/source/core/inc/objectnameapproval.hxx index ddd538c79edb..e503c347ea4e 100644 --- a/dbaccess/source/core/inc/objectnameapproval.hxx +++ b/dbaccess/source/core/inc/objectnameapproval.hxx @@ -21,14 +21,13 @@ #include <memory> #include "containerapprove.hxx" - +#include <cppuhelper/weakref.hxx> #include <com/sun/star/sdbc/XConnection.hpp> namespace dbaccess { // ObjectNameApproval - struct ObjectNameApproval_Impl; /** implementation of the IContainerApprove interface which approves elements for insertion into a query or tables container. @@ -40,7 +39,8 @@ namespace dbaccess */ class ObjectNameApproval : public IContainerApprove { - std::unique_ptr< ObjectNameApproval_Impl > m_pImpl; + css::uno::WeakReference< css::sdbc::XConnection > mxConnection; + sal_Int32 mnCommandType; public: enum ObjectType diff --git a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx index e5f924650b52..4f0f68d306c9 100644 --- a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx +++ b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx @@ -24,13 +24,11 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <vector> -#include <memory> namespace dbaccess { // DatabaseDocumentRecovery - struct DatabaseDocumentRecovery_Data; class DatabaseDocumentRecovery { public: @@ -63,7 +61,7 @@ namespace dbaccess ); private: - const std::unique_ptr< DatabaseDocumentRecovery_Data > m_pData; + css::uno::Reference<css::uno::XComponentContext> mxContext; }; } // namespace dbaccess diff --git a/dbaccess/source/core/inc/table.hxx b/dbaccess/source/core/inc/table.hxx index 069579c632e3..6c71e7447653 100644 --- a/dbaccess/source/core/inc/table.hxx +++ b/dbaccess/source/core/inc/table.hxx @@ -44,7 +44,6 @@ namespace dbaccess private: ::rtl::Reference< OContainerMediator > m_pColumnMediator; - protected: css::uno::Reference< css::container::XNameAccess > m_xColumnDefinitions; css::uno::Reference< css::container::XNameAccess > m_xDriverColumns; @@ -52,6 +51,7 @@ namespace dbaccess sal_Int32 m_nPrivileges; // </properties> + protected: virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const override; virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; @@ -114,7 +114,6 @@ namespace dbaccess //XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; - static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); // css::lang::XServiceInfo DECLARE_SERVICE_INFO(); @@ -128,9 +127,6 @@ namespace dbaccess // css::sdbcx::XAlterTable, virtual void SAL_CALL alterColumnByName( const OUString& _rName, const css::uno::Reference< css::beans::XPropertySet >& _rxDescriptor ) override; - // css::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - private: using OTable_Base::createArrayHelper; using OTable_Base::getFastPropertyValue; diff --git a/dbaccess/source/core/inc/veto.hxx b/dbaccess/source/core/inc/veto.hxx index 5608e87d11ee..ec44172f70d4 100644 --- a/dbaccess/source/core/inc/veto.hxx +++ b/dbaccess/source/core/inc/veto.hxx @@ -37,7 +37,7 @@ namespace dbaccess const css::uno::Any m_aDetails; public: - Veto( const css::uno::Any& _rDetails ); + Veto( css::uno::Any _aDetails ); virtual OUString SAL_CALL getReason() override; virtual css::uno::Any SAL_CALL getDetails() override; diff --git a/dbaccess/source/core/misc/ContainerMediator.cxx b/dbaccess/source/core/misc/ContainerMediator.cxx index 338858c87e76..0ee0d2e1f93c 100644 --- a/dbaccess/source/core/misc/ContainerMediator.cxx +++ b/dbaccess/source/core/misc/ContainerMediator.cxx @@ -25,7 +25,7 @@ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/sdbcx/XRename.hpp> #include <comphelper/property.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { @@ -222,8 +222,7 @@ void OContainerMediator::notifyElementCreated( const OUString& _sName, const Ref DBG_UNHANDLED_EXCEPTION("dbaccess"); } - ::rtl::Reference pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) ); - m_aForwardList[ _sName ] = pForward; + m_aForwardList[_sName].set(new OPropertyForward(_xDest, m_xSettings, _sName, aPropertyList)); } } // namespace dbaccess diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 9b455c5ae452..d2aa735fa8ba 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -23,9 +23,8 @@ #include <comphelper/types.hxx> #include <comphelper/namedvaluecollection.hxx> #include <connectivity/FValue.hxx> -#include <rtl/math.hxx> #include <sal/macros.h> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/sdb/CommandType.hpp> @@ -38,6 +37,7 @@ #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/XChartDataArray.hpp> +#include <utility> #include <vector> // TODO: update for new HavingClause-aware FilterManager @@ -70,8 +70,8 @@ DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContex uno::Reference<beans::XPropertySet> xProp(static_cast< ::cppu::OWeakObject* >( this ),uno::UNO_QUERY); m_aFilterManager.initialize( m_xAggregateSet ); m_aParameterManager.initialize( xProp, m_xAggregate ); - m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND_TYPE,uno::makeAny(m_CommandType)); - m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,uno::makeAny(m_EscapeProcessing)); + m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND_TYPE,uno::Any(m_CommandType)); + m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,uno::Any(m_EscapeProcessing)); } osl_atomic_decrement( &m_refCount ); } @@ -124,7 +124,7 @@ void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & else if ( !m_xHandler.is() ) (*pIter) >>= m_xHandler; } - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::makeAny( m_xActiveConnection ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::Any( m_xActiveConnection ) ); } // chart2::data::XDataProvider: @@ -202,7 +202,7 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY); if ( xIni.is() ) { - beans::NamedValue aParam("CreateDefaultData",uno::makeAny(true)); + beans::NamedValue aParam("CreateDefaultData",uno::Any(true)); uno::Sequence< uno::Any > aInitArgs{ uno::Any(aParam) }; xIni->initialize(aInitArgs); } @@ -216,9 +216,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArgum { ::comphelper::NamedValueCollection aArguments; aArguments.put( "CellRangeRepresentation", uno::Any( OUString( "all" ) ) ); - aArguments.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + aArguments.put( "DataRowSource", uno::Any( chart::ChartDataRowSource_COLUMNS ) ); // internal data always contains labels - aArguments.put( "FirstCellAsLabel", uno::makeAny( true ) ); + aArguments.put( "FirstCellAsLabel", uno::Any( true ) ); bool bHasCategories = false; if( _xDataSource.is()) @@ -242,7 +242,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArgum } } } - aArguments.put( "HasCategories", uno::makeAny( bHasCategories ) ); + aArguments.put( "HasCategories", uno::Any( bHasCategories ) ); return aArguments.getPropertyValues(); } @@ -256,7 +256,7 @@ uno::Any DatabaseDataProvider::impl_getNumberFormatKey_nothrow(const OUString & std::map< OUString,css::uno::Any>::const_iterator aFind = m_aNumberFormats.find(_sRangeRepresentation); if ( aFind != m_aNumberFormats.end() ) return aFind->second; - return uno::makeAny(sal_Int32(0)); + return uno::Any(sal_Int32(0)); } uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentation(const OUString & _sRangeRepresentation) @@ -264,7 +264,7 @@ uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::cre osl::MutexGuard g(m_aMutex); uno::Reference< chart2::data::XDataSequence > xData = m_xInternal->createDataSequenceByRangeRepresentation(_sRangeRepresentation); uno::Reference<beans::XPropertySet> xProp(xData,uno::UNO_QUERY); - static constexpr OUStringLiteral s_sNumberFormatKey = u"NumberFormatKey"; + static constexpr OUString s_sNumberFormatKey = u"NumberFormatKey"_ustr; if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(s_sNumberFormatKey) ) { xProp->setPropertyValue(s_sNumberFormatKey,impl_getNumberFormatKey_nothrow(_sRangeRepresentation)); @@ -445,7 +445,7 @@ void SAL_CALL DatabaseDataProvider::setCommand(const OUString & the_value) { osl::MutexGuard g(m_aMutex); impl_invalidateParameter_nothrow(); - m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND, uno::makeAny( the_value ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND, uno::Any( the_value ) ); } set(PROPERTY_COMMAND,the_value,m_Command); } @@ -460,7 +460,7 @@ void SAL_CALL DatabaseDataProvider::setCommandType(::sal_Int32 the_value) { { osl::MutexGuard g(m_aMutex); - m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND_TYPE, uno::makeAny( the_value ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND_TYPE, uno::Any( the_value ) ); } set(PROPERTY_COMMAND_TYPE,the_value,m_CommandType); } @@ -490,7 +490,7 @@ void SAL_CALL DatabaseDataProvider::setApplyFilter( sal_Bool the_value ) { { osl::MutexGuard g(m_aMutex); - m_xAggregateSet->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( the_value ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_APPLYFILTER, uno::Any( the_value ) ); } set(PROPERTY_APPLYFILTER,static_cast<bool>(the_value),m_ApplyFilter); } @@ -505,7 +505,7 @@ void SAL_CALL DatabaseDataProvider::setHavingClause( const OUString& the_value ) { { osl::MutexGuard g(m_aMutex); - m_xAggregateSet->setPropertyValue( PROPERTY_HAVING_CLAUSE, uno::makeAny( the_value ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_HAVING_CLAUSE, uno::Any( the_value ) ); } set(PROPERTY_HAVING_CLAUSE,the_value,m_HavingClause); } @@ -520,7 +520,7 @@ void SAL_CALL DatabaseDataProvider::setGroupBy( const OUString& the_value ) { { osl::MutexGuard g(m_aMutex); - m_xAggregateSet->setPropertyValue( PROPERTY_GROUP_BY, uno::makeAny( the_value ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_GROUP_BY, uno::Any( the_value ) ); } set(PROPERTY_GROUP_BY,the_value,m_GroupBy); } @@ -535,7 +535,7 @@ void SAL_CALL DatabaseDataProvider::setOrder( const OUString& the_value ) { { osl::MutexGuard g(m_aMutex); - m_xAggregateSet->setPropertyValue( PROPERTY_ORDER, uno::makeAny( the_value ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ORDER, uno::Any( the_value ) ); } set(PROPERTY_ORDER,the_value,m_Order); } @@ -599,8 +599,8 @@ namespace ,nDataType( sdbc::DataType::VARCHAR ) { } - explicit ColumnDescription( const OUString& i_rName ) - :sName( i_rName ) + explicit ColumnDescription( OUString i_sName ) + :sName(std::move( i_sName )) ,nResultSetPosition( 0 ) ,nDataType( sdbc::DataType::VARCHAR ) { @@ -756,7 +756,7 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(bool _bHasCategor { aRowLabels.push_back(OUString::number(h+1)); std::vector< double > aRow; - const sal_Int32 nSize = SAL_N_ELEMENTS(fDefaultData); + const sal_Int32 nSize = std::size(fDefaultData); for (size_t j = 0; j < (aColumns.size()-1); ++j,++k) { if ( k >= nSize ) @@ -793,7 +793,7 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(bool _bHasCategor void DatabaseDataProvider::impl_fillRowSet_throw() { - m_xAggregateSet->setPropertyValue( PROPERTY_FILTER, uno::makeAny( getFilter() ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_FILTER, uno::Any( getFilter() ) ); uno::Reference< sdbc::XParameters> xParam(m_xRowSet,uno::UNO_QUERY_THROW); xParam->clearParameters( ); } diff --git a/dbaccess/source/core/misc/PropertyForward.cxx b/dbaccess/source/core/misc/PropertyForward.cxx index 239bd422fd41..07e1068f695f 100644 --- a/dbaccess/source/core/misc/PropertyForward.cxx +++ b/dbaccess/source/core/misc/PropertyForward.cxx @@ -24,7 +24,8 @@ #include <com/sun/star/sdbcx/XAppend.hpp> #include <comphelper/property.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { @@ -37,10 +38,10 @@ namespace dbaccess OPropertyForward::OPropertyForward( const Reference< XPropertySet>& _xSource, const Reference< XNameAccess>& _xDestContainer, - const OUString& _sName, const std::vector< OUString>& _aPropertyList ) + OUString _sName, const std::vector< OUString>& _aPropertyList ) :m_xSource( _xSource, UNO_SET_THROW ) ,m_xDestContainer( _xDestContainer, UNO_SET_THROW ) - ,m_sName( _sName ) + ,m_sName(std::move( _sName )) ,m_bInInsert( false ) { diff --git a/dbaccess/source/core/misc/apitools.cxx b/dbaccess/source/core/misc/apitools.cxx index efec92cf5a63..384d5962bd2d 100644 --- a/dbaccess/source/core/misc/apitools.cxx +++ b/dbaccess/source/core/misc/apitools.cxx @@ -29,7 +29,7 @@ using namespace osl; // various helper functions // OSubComponent OSubComponent::OSubComponent(Mutex& _rMutex, const Reference< XInterface > & xParent) - :OComponentHelper(_rMutex) + :WeakComponentImplHelper(_rMutex) ,m_xParent(xParent) { @@ -41,74 +41,51 @@ OSubComponent::~OSubComponent() } -// css::lang::XTypeProvider -Sequence< Type > OSubComponent::getTypes() -{ - OTypeCollection aTypes(cppu::UnoType<XComponent>::get(), - cppu::UnoType<XTypeProvider>::get(), - cppu::UnoType<XWeak>::get()); - - return aTypes.getTypes(); -} - // XInterface void OSubComponent::release() noexcept { - Reference< XInterface > x( xDelegator ); - if (! x.is()) + if (osl_atomic_decrement( &m_refCount ) == 0 ) { - if (osl_atomic_decrement( &m_refCount ) == 0 ) + if (! rBHelper.bDisposed) { - 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; { - // *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; - { - MutexGuard aGuard( rBHelper.rMutex ); - xParent = m_xParent; - m_xParent = nullptr; - } - - SAL_WARN_IF( m_refCount != 1, "dbaccess.core", "OSubComponent::release: invalid ref count (before dispose)!" ); - - // First dispose - dispose(); - - // only the alive ref holds the object - SAL_WARN_IF( m_refCount != 1, "dbaccess.core", "OSubComponent::release: invalid ref count (after dispose)!" ); - - // release the parent in the ~ - if (xParent.is()) - { - MutexGuard aGuard( rBHelper.rMutex ); - m_xParent = xParent; - } - - // destroy the object if xHoldAlive decrement the refcount to 0 - return; + MutexGuard aGuard( rBHelper.rMutex ); + xParent = m_xParent; + m_xParent = nullptr; } - } - // restore the reference count - osl_atomic_increment( &m_refCount ); - } - // as we cover the job of the componenthelper we use the ... - OWeakAggObject::release(); -} + SAL_WARN_IF( m_refCount != 1, "dbaccess.core", "OSubComponent::release: invalid ref count (before dispose)!" ); -Any OSubComponent::queryInterface( const Type & rType ) -{ - Any aReturn; - if (!rType.equals(cppu::UnoType<XAggregation>::get())) - aReturn = OComponentHelper::queryInterface(rType); + // First dispose + dispose(); + + // only the alive ref holds the object + SAL_WARN_IF( m_refCount != 1, "dbaccess.core", "OSubComponent::release: invalid ref count (after dispose)!" ); + + // release the parent in the ~ + if (xParent.is()) + { + MutexGuard aGuard( rBHelper.rMutex ); + m_xParent = xParent; + } + + // destroy the object if xHoldAlive decrement the refcount to 0 + return; + } + } + // restore the reference count + osl_atomic_increment( &m_refCount ); - return aReturn; + // as we cover the job of the WeakComponentImplHelper we use the ... + OWeakObject::release(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 2758b0a6ed6a..6a081c47a1f7 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -17,14 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_java.h> #include <dsntypes.hxx> #include <unotools/confignode.hxx> +#include <o3tl/safeint.hxx> #include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <tools/wldcrd.hxx> #include <osl/file.hxx> #include <officecfg/Office/Common.hxx> #include <comphelper/string.hxx> +#include <utility> namespace dbaccess { @@ -32,17 +35,16 @@ namespace dbaccess using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::lang; namespace { - void lcl_extractHostAndPort(const OUString& _sUrl,OUString& _sHostname,sal_Int32& _nPortNumber) + void lcl_extractHostAndPort(std::u16string_view _sUrl, OUString& _sHostname, sal_Int32& _nPortNumber) { if ( comphelper::string::getTokenCount(_sUrl, ':') >= 2 ) { sal_Int32 nPos {0}; - _sHostname = _sUrl.getToken(0, ':', nPos); - _nPortNumber = _sUrl.getToken(0, ':', nPos).toInt32(); + _sHostname = o3tl::getToken(_sUrl, 0, ':', nPos); + _nPortNumber = o3tl::toInt32(o3tl::getToken(_sUrl, 0, ':', nPos)); } } } @@ -84,7 +86,7 @@ OUString ODsnTypeCollection::cutPrefix(std::u16string_view _sURL) const OUString sOldPattern; // on Windows or with gen rendering, the urls may begin with an ~ - const OUString& sCleanURL = comphelper::string::stripStart(_sURL, '~'); + std::u16string_view sCleanURL = comphelper::string::stripStart(_sURL, '~'); for (auto const& dsnPrefix : m_aDsnPrefixes) { @@ -95,8 +97,8 @@ OUString ODsnTypeCollection::cutPrefix(std::u16string_view _sURL) const // foo* // that is, the very concept of "prefix" applies. OUString prefix(comphelper::string::stripEnd(dsnPrefix, '*')); - OSL_ENSURE(prefix.getLength() <= sCleanURL.getLength(), "How can A match B when A shorter than B?"); - sRet = sCleanURL.copy(prefix.getLength()); + OSL_ENSURE(o3tl::make_unsigned(prefix.getLength()) <= sCleanURL.size(), "How can A match B when A shorter than B?"); + sRet = sCleanURL.substr(prefix.getLength()); sOldPattern = dsnPrefix; } } @@ -104,7 +106,7 @@ OUString ODsnTypeCollection::cutPrefix(std::u16string_view _sURL) const return sRet; } -OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const +OUString ODsnTypeCollection::getPrefix(std::u16string_view _sURL) const { OUString sRet; OUString sOldPattern; @@ -117,7 +119,7 @@ OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const // foo* // that is, the very concept of "prefix" applies. sRet = comphelper::string::stripEnd(dsnPrefix, '*'); - OSL_ENSURE(sRet.getLength() <= _sURL.getLength(), "How can A match B when A shorter than B?"); + OSL_ENSURE(sRet.getLength() <= static_cast<sal_Int32>(_sURL.size()), "How can A match B when A shorter than B?"); sOldPattern = dsnPrefix; } } @@ -226,8 +228,7 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD _rsHostname = sUrl.getToken(0,'/'); _sDatabaseName = sUrl.copy(sUrl.lastIndexOf('/')+1); } - else if ( _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=") - || _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=") ) + else if ( _rDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:")) { OUString sNewFileName; if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None ) @@ -286,7 +287,7 @@ bool ODsnTypeCollection::isEmbeddedDatabase( std::u16string_view _sURL ) OUString ODsnTypeCollection::getEmbeddedDatabase() { - if (officecfg::Office::Common::Misc::ExperimentalMode::get()) + if (!HAVE_FEATURE_JAVA || officecfg::Office::Common::Misc::ExperimentalMode::get()) return "sdbc:embedded:firebird"; else return "sdbc:embedded:hsqldb"; @@ -321,6 +322,9 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(std::u16string_view _rDsn) con if (sDsn.equalsIgnoreAsciiCase("sdbc:embedded:firebird")) return DST_EMBEDDED_FIREBIRD; + if (sDsn.startsWithIgnoreAsciiCase("sdbc:embedded:")) + return DST_EMBEDDED_UNKNOWN; + // find second : nSeparator = sDsn.indexOf(u':', nSeparator + 1); if (-1 == nSeparator) @@ -334,10 +338,7 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(std::u16string_view _rDsn) con { if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:")) { - if (sDsn.startsWithIgnoreAsciiCase("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;")) - return DST_MSACCESS_2007; - else - return DST_MSACCESS; + return DST_MSACCESS; } return DST_ADO; } @@ -348,8 +349,8 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(std::u16string_view _rDsn) con const DATASOURCE_TYPE eType; const bool bMatchComplete; - KnownPrefix( const OUString &_s, const DATASOURCE_TYPE _t, const bool _m ) - :sPrefix( _s ) + KnownPrefix( OUString _s, const DATASOURCE_TYPE _t, const bool _m ) + :sPrefix(std::move( _s )) ,eType ( _t ) ,bMatchComplete( _m ) { @@ -443,11 +444,13 @@ void ODsnTypeCollection::fillPageIds(std::u16string_view _sURL,std::vector<sal_I case DST_ORACLE_JDBC: _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ORACLE); break; + case DST_POSTGRES: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_POSTGRES); + break; case DST_LDAP: _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP); break; case DST_MSACCESS: - case DST_MSACCESS_2007: _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS); break; case DST_OUTLOOKEXP: @@ -461,6 +464,7 @@ void ODsnTypeCollection::fillPageIds(std::u16string_view _sURL,std::vector<sal_I case DST_MACAB: case DST_EMBEDDED_HSQLDB: case DST_EMBEDDED_FIREBIRD: + case DST_EMBEDDED_UNKNOWN: break; default: _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_USERDEFINED); diff --git a/dbaccess/source/core/misc/objectnameapproval.cxx b/dbaccess/source/core/misc/objectnameapproval.cxx index 3ec15caaa4fd..fa03e81e3d09 100644 --- a/dbaccess/source/core/misc/objectnameapproval.cxx +++ b/dbaccess/source/core/misc/objectnameapproval.cxx @@ -23,35 +23,23 @@ #include <com/sun/star/sdb/tools/XConnectionTools.hpp> #include <com/sun/star/sdb/CommandType.hpp> -#include <cppuhelper/weakref.hxx> - namespace dbaccess { using ::com::sun::star::sdbc::XConnection; - using ::com::sun::star::uno::WeakReference; using ::com::sun::star::uno::Reference; using ::com::sun::star::lang::DisposedException; using ::com::sun::star::sdb::tools::XConnectionTools; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::sdb::tools::XObjectNames; - using ::com::sun::star::uno::XInterface; namespace CommandType = com::sun::star::sdb::CommandType; - // ObjectNameApproval_Impl - struct ObjectNameApproval_Impl - { - WeakReference< XConnection > aConnection; - sal_Int32 nCommandType; - }; - // ObjectNameApproval ObjectNameApproval::ObjectNameApproval( const Reference< XConnection >& _rxConnection, ObjectType _eType ) - :m_pImpl( new ObjectNameApproval_Impl ) { - m_pImpl->aConnection = _rxConnection; - m_pImpl->nCommandType = _eType == TypeQuery ? CommandType::QUERY : CommandType::TABLE; + mxConnection = _rxConnection; + mnCommandType = _eType == TypeQuery ? CommandType::QUERY : CommandType::TABLE; } ObjectNameApproval::~ObjectNameApproval() @@ -60,13 +48,13 @@ namespace dbaccess void ObjectNameApproval::approveElement( const OUString& _rName ) { - Reference< XConnection > xConnection( m_pImpl->aConnection ); + Reference< XConnection > xConnection( mxConnection ); if ( !xConnection.is() ) throw DisposedException(); Reference< XConnectionTools > xConnectionTools( xConnection, UNO_QUERY_THROW ); Reference< XObjectNames > xObjectNames( xConnectionTools->getObjectNames(), css::uno::UNO_SET_THROW ); - xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rName ); + xObjectNames->checkNameForCreate( mnCommandType, _rName ); } } // namespace dbaccess diff --git a/dbaccess/source/core/misc/sdbcoretools.cxx b/dbaccess/source/core/misc/sdbcoretools.cxx index 5cd5367ba117..7856a1484591 100644 --- a/dbaccess/source/core/misc/sdbcoretools.cxx +++ b/dbaccess/source/core/misc/sdbcoretools.cxx @@ -27,19 +27,16 @@ #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/ElementModes.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/interaction.hxx> #include <rtl/ref.hxx> -#include <rtl/ustrbuf.hxx> namespace dbaccess { using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; - using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::task; diff --git a/dbaccess/source/core/misc/veto.cxx b/dbaccess/source/core/misc/veto.cxx index d2596d4e1e11..07aa9567ec46 100644 --- a/dbaccess/source/core/misc/veto.cxx +++ b/dbaccess/source/core/misc/veto.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <utility> #include <veto.hxx> namespace dbaccess @@ -25,8 +26,8 @@ namespace dbaccess using ::com::sun::star::uno::Any; // Veto - Veto::Veto( const Any& _rDetails ) - :m_aDetails( _rDetails ) + Veto::Veto( Any _aDetails ) + :m_aDetails(std::move( _aDetails )) { } diff --git a/dbaccess/source/core/recovery/dbdocrecovery.cxx b/dbaccess/source/core/recovery/dbdocrecovery.cxx index db7bb53bd53c..eead0c2c7910 100644 --- a/dbaccess/source/core/recovery/dbdocrecovery.cxx +++ b/dbaccess/source/core/recovery/dbdocrecovery.cxx @@ -28,9 +28,10 @@ #include <com/sun/star/io/TextInputStream.hpp> #include <com/sun/star/util/XModifiable.hpp> +#include <o3tl/string_view.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { @@ -65,30 +66,30 @@ namespace dbaccess o_rBuffer.append( sal_Unicode( i_rComponentDesc.second.bForEditing ? '1' : '0' ) ); } - bool lcl_extractCompDesc( const OUString& i_rIniLine, OUString& o_rStorName, SubComponentDescriptor& o_rCompDesc ) + bool lcl_extractCompDesc( std::u16string_view i_rIniLine, OUString& o_rStorName, SubComponentDescriptor& o_rCompDesc ) { - const sal_Int32 nEqualSignPos = i_rIniLine.indexOf( '=' ); - if ( nEqualSignPos < 1 ) + const size_t nEqualSignPos = i_rIniLine.find( '=' ); + if ( nEqualSignPos == 0 || nEqualSignPos == std::u16string_view::npos ) { OSL_FAIL( "lcl_extractCompDesc: invalid map file entry - unexpected pos of '='" ); return false; } - o_rStorName = i_rIniLine.copy( 0, nEqualSignPos ); + o_rStorName = i_rIniLine.substr( 0, nEqualSignPos ); - const sal_Int32 nCommaPos = i_rIniLine.lastIndexOf( ',' ); - if ( nCommaPos != i_rIniLine.getLength() - 2 ) + const size_t nCommaPos = i_rIniLine.rfind( ',' ); + if ( nCommaPos != i_rIniLine.size() - 2 ) { OSL_FAIL( "lcl_extractCompDesc: invalid map file entry - unexpected pos of ','" ); return false; } - o_rCompDesc.sName = i_rIniLine.copy( nEqualSignPos + 1, nCommaPos - nEqualSignPos - 1 ); + o_rCompDesc.sName = i_rIniLine.substr( nEqualSignPos + 1, nCommaPos - nEqualSignPos - 1 ); o_rCompDesc.bForEditing = ( i_rIniLine[ nCommaPos + 1 ] == '1' ); return true; } - constexpr OUStringLiteral sRecoveryDataSubStorageName = u"recovery"; + constexpr OUString sRecoveryDataSubStorageName = u"recovery"_ustr; - constexpr OUStringLiteral sObjectMapStreamName = u"storage-component-map.ini"; + constexpr OUString sObjectMapStreamName = u"storage-component-map.ini"_ustr; void lcl_writeObjectMap_throw( const Reference<XComponentContext> & i_rContext, const Reference< XStorage >& i_rStorage, const MapStringToCompDesc& i_mapStorageToCompDesc ) @@ -112,12 +113,12 @@ namespace dbaccess aTextOutput.writeLine(); } - bool lcl_isSectionStart( const OUString& i_rIniLine, OUString& o_rSectionName ) + bool lcl_isSectionStart( std::u16string_view i_rIniLine, OUString& o_rSectionName ) { - const sal_Int32 nLen = i_rIniLine.getLength(); - if ( i_rIniLine.startsWith("[") && i_rIniLine.endsWith("]") ) + const size_t nLen = i_rIniLine.size(); + if ( o3tl::starts_with(i_rIniLine, u"[") && o3tl::ends_with(i_rIniLine, u"]") ) { - o_rSectionName = i_rIniLine.copy( 1, nLen -2 ); + o_rSectionName = i_rIniLine.substr( 1, nLen -2 ); return true; } return false; @@ -194,20 +195,9 @@ namespace dbaccess } } - // DatabaseDocumentRecovery_Data - struct DatabaseDocumentRecovery_Data - { - const Reference<XComponentContext> aContext; - - explicit DatabaseDocumentRecovery_Data( const Reference<XComponentContext> & i_rContext ) - :aContext( i_rContext ) - { - } - }; - // DatabaseDocumentRecovery DatabaseDocumentRecovery::DatabaseDocumentRecovery( const Reference<XComponentContext> & i_rContext ) - :m_pData( new DatabaseDocumentRecovery_Data( i_rContext ) ) + : mxContext( i_rContext ) { } @@ -243,7 +233,7 @@ namespace dbaccess for ( auto const & component : aComponents ) { - SubComponentRecovery aComponentRecovery( m_pData->aContext, xDatabaseUI, component ); + SubComponentRecovery aComponentRecovery( mxContext, xDatabaseUI, component ); aComponentRecovery.saveToRecoveryStorage( xRecoveryStorage, aMapCompDescs ); } } @@ -252,7 +242,7 @@ namespace dbaccess { Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement( SubComponentRecovery::getComponentsStorageName( elem.first ), ElementModes::WRITE | ElementModes::NOCREATE ) ); - lcl_writeObjectMap_throw( m_pData->aContext, xComponentsStor, elem.second ); + lcl_writeObjectMap_throw( mxContext, xComponentsStor, elem.second ); tools::stor::commitStorageIfWriteable( xComponentsStor ); } } @@ -284,7 +274,7 @@ namespace dbaccess Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement( SubComponentRecovery::getComponentsStorageName( aKnownType ), ElementModes::READ ) ); - lcl_readObjectMap_throw( m_pData->aContext, xComponentsStor, aMapCompDescs[ aKnownType ] ); + lcl_readObjectMap_throw( mxContext, xComponentsStor, aMapCompDescs[ aKnownType ] ); xComponentsStor->dispose(); } @@ -318,7 +308,7 @@ namespace dbaccess // recover the single component Reference< XStorage > xCompStor( xComponentsStor->openStorageElement( elem.first, ElementModes::READ ) ); - SubComponentRecovery aComponentRecovery( m_pData->aContext, xDocumentUI, eComponentType ); + SubComponentRecovery aComponentRecovery( mxContext, xDocumentUI, eComponentType ); Reference< XComponent > xSubComponent( aComponentRecovery.recoverFromStorage( xCompStor, sComponentName, elem.second.bForEditing ) ); // at the moment, we only store, during session save, sub components which are modified. So, set this diff --git a/dbaccess/source/core/recovery/settingsimport.cxx b/dbaccess/source/core/recovery/settingsimport.cxx index 2353202681c4..00db4ddf3bab 100644 --- a/dbaccess/source/core/recovery/settingsimport.cxx +++ b/dbaccess/source/core/recovery/settingsimport.cxx @@ -19,7 +19,7 @@ #include "settingsimport.hxx" -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmltoken.hxx> @@ -139,7 +139,7 @@ namespace dbaccess o_rValue.clear(); // the characters building up th evalue - const OUString sValue = getAccumulatedCharacters().toString(); + std::u16string_view sValue = getAccumulatedCharacters(); const OUString& rItemType( getItemType() ); ENSURE_OR_RETURN_VOID( !rItemType.isEmpty(), "no item type -> no item value" ); @@ -170,7 +170,7 @@ namespace dbaccess } else if ( ::xmloff::token::IsXMLToken( rItemType, ::xmloff::token::XML_STRING ) ) { - o_rValue <<= sValue; + o_rValue <<= OUString(sValue); } else { diff --git a/dbaccess/source/core/recovery/storagestream.cxx b/dbaccess/source/core/recovery/storagestream.cxx index 2831f406bbf7..613bfb729903 100644 --- a/dbaccess/source/core/recovery/storagestream.cxx +++ b/dbaccess/source/core/recovery/storagestream.cxx @@ -21,13 +21,12 @@ #include <com/sun/star/embed/ElementModes.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::embed::XStorage; using ::com::sun::star::io::XStream; diff --git a/dbaccess/source/core/recovery/storagetextstream.cxx b/dbaccess/source/core/recovery/storagetextstream.cxx index 32f68da9a087..a60890fa8555 100644 --- a/dbaccess/source/core/recovery/storagetextstream.cxx +++ b/dbaccess/source/core/recovery/storagetextstream.cxx @@ -28,15 +28,8 @@ namespace dbaccess using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::embed::XStorage; using ::com::sun::star::io::TextOutputStream; - using ::com::sun::star::io::XTextOutputStream2; - // StorageTextOutputStream_Data - struct StorageTextOutputStream_Data - { - Reference< XTextOutputStream2 > xTextOutput; - }; - - constexpr OUStringLiteral sLineFeed = u"\n"; + constexpr OUString sLineFeed = u"\n"_ustr; // StorageTextOutputStream StorageTextOutputStream::StorageTextOutputStream( const Reference<XComponentContext>& i_rContext, @@ -44,11 +37,10 @@ namespace dbaccess const OUString& i_rStreamName ) :StorageOutputStream( i_rParentStorage, i_rStreamName ) - ,m_pData( new StorageTextOutputStream_Data ) { - m_pData->xTextOutput = TextOutputStream::create( i_rContext ); - m_pData->xTextOutput->setEncoding( "UTF-8" ); - m_pData->xTextOutput->setOutputStream( getOutputStream() ); + mxTextOutput = TextOutputStream::create( i_rContext ); + mxTextOutput->setEncoding( "UTF-8" ); + mxTextOutput->setOutputStream( getOutputStream() ); } StorageTextOutputStream::~StorageTextOutputStream() @@ -57,13 +49,13 @@ namespace dbaccess void StorageTextOutputStream::writeLine( const OUString& i_rLine ) { - m_pData->xTextOutput->writeString( i_rLine ); - m_pData->xTextOutput->writeString( sLineFeed ); + mxTextOutput->writeString( i_rLine ); + mxTextOutput->writeString( sLineFeed ); } void StorageTextOutputStream::writeLine() { - m_pData->xTextOutput->writeString( sLineFeed ); + mxTextOutput->writeString( sLineFeed ); } } // namespace dbaccess diff --git a/dbaccess/source/core/recovery/storagetextstream.hxx b/dbaccess/source/core/recovery/storagetextstream.hxx index 46c3e5b2ee26..31bef3d83bd8 100644 --- a/dbaccess/source/core/recovery/storagetextstream.hxx +++ b/dbaccess/source/core/recovery/storagetextstream.hxx @@ -23,13 +23,12 @@ #include <com/sun/star/uno/XComponentContext.hpp> -#include <memory> +namespace com::sun::star::io { class XTextOutputStream2; } namespace dbaccess { // StorageTextStream - struct StorageTextOutputStream_Data; class StorageTextOutputStream : public StorageOutputStream { public: @@ -44,8 +43,8 @@ namespace dbaccess void writeLine(); private: - std::unique_ptr< StorageTextOutputStream_Data > m_pData; - }; + css::uno::Reference< css::io::XTextOutputStream2 > mxTextOutput; + }; } // namespace dbaccess diff --git a/dbaccess/source/core/recovery/storagexmlstream.cxx b/dbaccess/source/core/recovery/storagexmlstream.cxx index e76dabefec0e..e828ac73d38d 100644 --- a/dbaccess/source/core/recovery/storagexmlstream.cxx +++ b/dbaccess/source/core/recovery/storagexmlstream.cxx @@ -25,10 +25,7 @@ #include <com/sun/star/xml/sax/Writer.hpp> #include <rtl/ref.hxx> -#include <tools/diagnose_ex.h> -#include <xmloff/attrlist.hxx> - -#include <stack> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { @@ -43,28 +40,19 @@ namespace dbaccess using ::com::sun::star::xml::sax::Parser; using ::com::sun::star::xml::sax::InputSource; - // StorageXMLOutputStream_Data - struct StorageXMLOutputStream_Data - { - Reference< XDocumentHandler > xHandler; - std::stack< OUString > aElements; - ::rtl::Reference< SvXMLAttributeList > xAttributes; - }; - // StorageXMLOutputStream StorageXMLOutputStream::StorageXMLOutputStream( const Reference<XComponentContext>& i_rContext, const Reference< XStorage >& i_rParentStorage, const OUString& i_rStreamName ) :StorageOutputStream( i_rParentStorage, i_rStreamName ) - ,m_pData( new StorageXMLOutputStream_Data ) { const Reference< XWriter > xSaxWriter = Writer::create( i_rContext ); xSaxWriter->setOutputStream( getOutputStream() ); - m_pData->xHandler.set( xSaxWriter, UNO_QUERY_THROW ); - m_pData->xHandler->startDocument(); + mxHandler.set( xSaxWriter, UNO_QUERY_THROW ); + mxHandler->startDocument(); - m_pData->xAttributes = new SvXMLAttributeList; + mxAttributes = new comphelper::AttributeList; } StorageXMLOutputStream::~StorageXMLOutputStream() @@ -73,48 +61,48 @@ namespace dbaccess void StorageXMLOutputStream::close() { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "illegal document handler" ); - m_pData->xHandler->endDocument(); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "illegal document handler" ); + mxHandler->endDocument(); // do not call the base class, it would call closeOutput on the output stream, which is already done by // endDocument } void StorageXMLOutputStream::addAttribute( const OUString& i_rName, const OUString& i_rValue ) const { - m_pData->xAttributes->AddAttribute( i_rName, i_rValue ); + mxAttributes->AddAttribute( i_rName, i_rValue ); } - void StorageXMLOutputStream::startElement( const OUString& i_rElementName ) const + void StorageXMLOutputStream::startElement( const OUString& i_rElementName ) { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); - m_pData->xHandler->startElement( i_rElementName, m_pData->xAttributes ); - m_pData->xAttributes = new SvXMLAttributeList; - m_pData->aElements.push( i_rElementName ); + mxHandler->startElement( i_rElementName, mxAttributes ); + mxAttributes = new comphelper::AttributeList; + maElements.push( i_rElementName ); } - void StorageXMLOutputStream::endElement() const + void StorageXMLOutputStream::endElement() { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); - ENSURE_OR_RETURN_VOID( !m_pData->aElements.empty(), "no element on the stack" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( !maElements.empty(), "no element on the stack" ); - const OUString sElementName( m_pData->aElements.top() ); - m_pData->xHandler->endElement( sElementName ); - m_pData->aElements.pop(); + const OUString sElementName( maElements.top() ); + mxHandler->endElement( sElementName ); + maElements.pop(); } void StorageXMLOutputStream::ignorableWhitespace( const OUString& i_rWhitespace ) const { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); - m_pData->xHandler->ignorableWhitespace( i_rWhitespace ); + mxHandler->ignorableWhitespace( i_rWhitespace ); } void StorageXMLOutputStream::characters( const OUString& i_rCharacters ) const { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); - m_pData->xHandler->characters( i_rCharacters ); + mxHandler->characters( i_rCharacters ); } // StorageXMLInputStream diff --git a/dbaccess/source/core/recovery/storagexmlstream.hxx b/dbaccess/source/core/recovery/storagexmlstream.hxx index fd762ae05dc8..8a340b6fea0c 100644 --- a/dbaccess/source/core/recovery/storagexmlstream.hxx +++ b/dbaccess/source/core/recovery/storagexmlstream.hxx @@ -25,14 +25,13 @@ #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> - -#include <memory> +#include <comphelper/attributelist.hxx> +#include <rtl/ref.hxx> +#include <stack> namespace dbaccess { - // StorageXMLOutputStream - struct StorageXMLOutputStream_Data; class StorageXMLOutputStream : public StorageOutputStream { public: @@ -47,8 +46,8 @@ namespace dbaccess void addAttribute( const OUString& i_rName, const OUString& i_rValue ) const; - void startElement( const OUString& i_rElementName ) const; - void endElement() const; + void startElement( const OUString& i_rElementName ); + void endElement(); void ignorableWhitespace( const OUString& i_rWhitespace ) const; void characters( const OUString& i_rCharacters ) const; @@ -58,7 +57,9 @@ namespace dbaccess StorageXMLOutputStream& operator=( const StorageXMLOutputStream& ) = delete; private: - std::unique_ptr< StorageXMLOutputStream_Data > m_pData; + css::uno::Reference< css::xml::sax::XDocumentHandler > mxHandler; + std::stack< OUString > maElements; + ::rtl::Reference<comphelper::AttributeList> mxAttributes; }; class StorageXMLInputStream diff --git a/dbaccess/source/core/recovery/subcomponentloader.cxx b/dbaccess/source/core/recovery/subcomponentloader.cxx index 3393c3d13d08..a416b997fa38 100644 --- a/dbaccess/source/core/recovery/subcomponentloader.cxx +++ b/dbaccess/source/core/recovery/subcomponentloader.cxx @@ -22,7 +22,7 @@ #include <com/sun/star/ucb/Command.hpp> #include <com/sun/star/frame/XController2.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace dbaccess { diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx index e7ffffd61452..3a7a30d016f0 100644 --- a/dbaccess/source/core/recovery/subcomponentrecovery.cxx +++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx @@ -36,7 +36,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/implbase.hxx> #include <connectivity/dbtools.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <xmloff/XMLSettingsExportContext.hxx> #include <xmloff/SettingsExportHelper.hxx> @@ -47,12 +47,10 @@ namespace dbaccess { using css::uno::Reference; - using css::uno::XInterface; using css::uno::UNO_QUERY; using css::uno::UNO_QUERY_THROW; using css::uno::UNO_SET_THROW; using css::uno::Exception; - using css::uno::RuntimeException; using css::uno::Any; using css::uno::Sequence; using css::uno::XComponentContext; @@ -160,8 +158,8 @@ namespace dbaccess return xCommandProcessor; } - constexpr OUStringLiteral sSettingsStreamName = u"settings.xml"; - constexpr OUStringLiteral sCurrentQueryDesignName = u"ooo:current-query-design"; + constexpr OUString sSettingsStreamName = u"settings.xml"_ustr; + constexpr OUString sCurrentQueryDesignName = u"ooo:current-query-design"_ustr; } namespace { @@ -170,7 +168,7 @@ namespace dbaccess class SettingsExportContext : public ::xmloff::XMLSettingsExportContext { public: - SettingsExportContext( const Reference<XComponentContext>& i_rContext, const StorageXMLOutputStream& i_rDelegator ) + SettingsExportContext( const Reference<XComponentContext>& i_rContext, StorageXMLOutputStream& i_rDelegator ) :m_rContext( i_rContext ) ,m_rDelegator( i_rDelegator ) ,m_aNamespace( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_NP_CONFIG ) ) @@ -199,7 +197,7 @@ namespace dbaccess private: const Reference<XComponentContext>& m_rContext; - const StorageXMLOutputStream& m_rDelegator; + StorageXMLOutputStream& m_rDelegator; const OUString m_aNamespace; }; @@ -480,7 +478,7 @@ namespace dbaccess StorageXMLOutputStream aDesignOutput( m_rContext, i_rObjectStorage, sSettingsStreamName ); SettingsExportContext aSettingsExportContext( m_rContext, aDesignOutput ); - static const OUStringLiteral sWhitespace( u" " ); + static constexpr OUString sWhitespace( u" "_ustr ); aDesignOutput.startElement( "office:settings" ); aDesignOutput.ignorableWhitespace( sWhitespace ); diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.hxx b/dbaccess/source/core/recovery/subcomponentrecovery.hxx index 26b81c63f374..ee41a32dfc89 100644 --- a/dbaccess/source/core/recovery/subcomponentrecovery.hxx +++ b/dbaccess/source/core/recovery/subcomponentrecovery.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <utility> namespace dbaccess { @@ -35,10 +36,10 @@ namespace dbaccess SubComponentRecovery( const css::uno::Reference< css::uno::XComponentContext >& i_rContext, const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI >& i_rController, - const css::uno::Reference< css::lang::XComponent >& i_rComponent ) + css::uno::Reference< css::lang::XComponent > i_xComponent ) :m_rContext( i_rContext ) ,m_xDocumentUI( i_rController, css::uno::UNO_SET_THROW ) - ,m_xComponent( i_rComponent ) + ,m_xComponent(std::move( i_xComponent )) ,m_eType( UNKNOWN ) ,m_aCompDesc() { |