diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-09-06 21:42:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-07 09:24:55 +0200 |
commit | e801c211911deb673c8f75b5072a58c88832b720 (patch) | |
tree | 77e3e26aafaa3a3688711aea098ae6220d949d17 /dbaccess | |
parent | a8e4bf44012139adff7d1343f17edca13a70d0c5 (diff) |
convert ObjectType to scoped enum
Change-Id: I1c103aebe02a41ed4fa59a72950cb55d3c6c93d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139544
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/ModelImpl.cxx | 23 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/databasedocument.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/datasource.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/documentcontainer.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/documentdefinition.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/inc/ModelImpl.hxx | 16 |
6 files changed, 31 insertions, 26 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index c482e09eb2ae..14d05bb53b35 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -354,7 +354,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 ) @@ -384,7 +384,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _rxContext, ODatabaseContext& _rDBContext ) - :m_aContainer(4) + :m_aContainer() ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) ,m_rDBContext( _rDBContext ) @@ -468,10 +468,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(); } @@ -561,7 +561,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() ) { @@ -650,7 +651,8 @@ void ODatabaseModelImpl::dispose() if ( elem ) elem->m_pDataSource = nullptr; } - m_aContainer.clear(); + for (auto & i : m_aContainer) + i.reset(); clearConnections(); @@ -1103,7 +1105,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 ) @@ -1324,8 +1325,8 @@ ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros() { m_aEmbeddedMacros = eDocumentWideMacros; } - 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; diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 5fed5b674e9a..681966020696 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -1413,10 +1413,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; @@ -1549,13 +1549,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, diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 149eddc4e6eb..91959366aebf 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -1284,7 +1284,7 @@ Reference< XNameAccess > SAL_CALL ODatabaseSource::getQueryDefinitions( ) } 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 +1300,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/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 6a9f17adb0fe..6ac383e85a99 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -712,7 +712,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>(); } diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index b0e14c85afff..2c7bc4b871a7 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -508,7 +508,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; @@ -1927,7 +1927,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>(); } diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx index 974e5c853794..14c6d6a6ad91 100644 --- a/dbaccess/source/core/inc/ModelImpl.hxx +++ b/dbaccess/source/core/inc/ModelImpl.hxx @@ -39,6 +39,7 @@ #include <sfx2/docstoragemodifylistener.hxx> #include <unotools/sharedunocomponent.hxx> #include <rtl/ref.hxx> +#include <o3tl/enumarray.hxx> namespace comphelper { @@ -93,16 +94,19 @@ typedef ::utl::SharedUNOComponent< css::embed::XStorage > SharedStorage; class ODatabaseContext; class DocumentStorageAccess; class OSharedConnectionManager; + 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 @@ -120,7 +124,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; |