package/source/xstor/xstorage.cxx | 93 +++++++++++++++++++------------------- package/source/xstor/xstorage.hxx | 3 + 2 files changed, 51 insertions(+), 45 deletions(-)
New commits: commit 689152a6809cf9bc75f2f09892579ec02ab05805 Author: Noel Grandin <[email protected]> AuthorDate: Mon Jan 12 15:01:40 2026 +0100 Commit: Aron Budea <[email protected]> CommitDate: Thu Jan 15 13:10:52 2026 +0100 tdf#170283 crashed when opening a .ppt file Revert "no need to have duplicate m_nStorageType fields" This reverts commit 9a9bb1f212bb7eb40dcf34c15a3422e633fc195d. Change-Id: Ia471d291ebb99aea47c798cf923d7571711de356 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197118 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> (cherry picked from commit 9b90b680e5703f58146c883fb33972a95951b446) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197163 Reviewed-by: Xisco Fauli <[email protected]> (cherry picked from commit 3a1e9ea688adec439500011541b36888570d6fc5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197311 Reviewed-by: Aron Budea <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 2dbb2077fec4..18b12d3f763a 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -1741,6 +1741,7 @@ OStorage::OStorage( uno::Reference< io::XInputStream > const & xInputStream, : m_pImpl( new OStorage_Impl( xInputStream, nMode, xProperties, xContext, nStorageType ) ) , m_xSharedMutex( m_pImpl->m_xMutex ) , m_aListenersContainer( m_pImpl->m_xMutex->GetMutex() ) +, m_nStorageType( m_pImpl->m_nStorageType ) , m_bReadOnlyWrap( false ) { m_pImpl->m_pAntiImpl = this; @@ -1754,6 +1755,7 @@ OStorage::OStorage( uno::Reference< io::XStream > const & xStream, : m_pImpl( new OStorage_Impl( xStream, nMode, xProperties, xContext, nStorageType ) ) , m_xSharedMutex( m_pImpl->m_xMutex ) , m_aListenersContainer( m_pImpl->m_xMutex->GetMutex() ) +, m_nStorageType( m_pImpl->m_nStorageType ) , m_bReadOnlyWrap( false ) { m_pImpl->m_pAntiImpl = this; @@ -1763,6 +1765,7 @@ OStorage::OStorage( OStorage_Impl* pImpl, bool bReadOnlyWrap ) : m_pImpl( pImpl ) , m_xSharedMutex( m_pImpl->m_xMutex ) , m_aListenersContainer( m_pImpl->m_xMutex->GetMutex() ) +, m_nStorageType( m_pImpl->m_nStorageType ) , m_bReadOnlyWrap( bReadOnlyWrap ) { // this call can be done only from OStorage_Impl implementation to create child storage @@ -2039,7 +2042,7 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType ) if ( aReturn.hasValue() ) return aReturn ; - if ( m_pImpl->m_nStorageType == embed::StorageFormats::PACKAGE ) + if ( m_nStorageType == embed::StorageFormats::PACKAGE ) { if ( m_pImpl->m_bIsRoot ) { @@ -2057,7 +2060,7 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType ) , static_cast<embed::XStorageRawAccess*> ( this ) ); } } - else if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML ) + else if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { aReturn = ::cppu::queryInterface ( rType @@ -2089,7 +2092,7 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes() if (! m_oTypeCollection) { - if ( m_pImpl->m_nStorageType == embed::StorageFormats::PACKAGE ) + if ( m_nStorageType == embed::StorageFormats::PACKAGE ) { if ( m_pImpl->m_bIsRoot ) { @@ -2119,7 +2122,7 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes() , cppu::UnoType<beans::XPropertySet>::get()); } } - else if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML ) + else if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { m_oTypeCollection.emplace( cppu::UnoType<lang::XTypeProvider>::get() @@ -2219,7 +2222,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openStreamElement( if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable element name if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_bReadOnlyWrap ) @@ -2314,7 +2317,7 @@ rtl::Reference< OStorage > OStorage::openStorageElement2( if ( aStorName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStorName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aStorName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aStorName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name if ( ( nStorageMode & embed::ElementModes::WRITE ) && m_bReadOnlyWrap ) @@ -2444,7 +2447,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::cloneStreamElement( const OUStr if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name try @@ -2570,7 +2573,7 @@ void SAL_CALL OStorage::copyStorageElementLastCommitTo( if ( aStorName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStorName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aStorName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aStorName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name try @@ -2646,7 +2649,7 @@ sal_Bool SAL_CALL OStorage::isStreamElement( const OUString& aElementName ) if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable name SotElement_Impl* pElement = nullptr; @@ -2704,7 +2707,7 @@ sal_Bool SAL_CALL OStorage::isStorageElement( const OUString& aElementName ) if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); SotElement_Impl* pElement = nullptr; @@ -2765,7 +2768,7 @@ void SAL_CALL OStorage::removeElement( const OUString& aElementName ) throw lang::IllegalArgumentException(THROW_WHERE "Unexpected entry name syntax.", uno::Reference<uno::XInterface>(), 1); - if (m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels") + if (m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels") throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), 1); // TODO: unacceptable name @@ -2844,7 +2847,7 @@ void SAL_CALL OStorage::renameElement( const OUString& aElementName, const OUStr throw lang::IllegalArgumentException(THROW_WHERE "Unexpected entry name syntax.", uno::Reference<uno::XInterface>(), 1); - if (m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML + if (m_nStorageType == embed::StorageFormats::OFOPXML && (aElementName == "_rels" || aNewName == "_rels")) throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), 0); // TODO: unacceptable element name @@ -2944,7 +2947,7 @@ void SAL_CALL OStorage::copyElementTo( const OUString& aElementName, // || xDest == getXWeak() ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 2 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); // unacceptable element name try @@ -3028,7 +3031,7 @@ void SAL_CALL OStorage::moveElementTo( const OUString& aElementName, if (!xDest.is() || xDest == getXWeak()) throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), 2); - if (m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML + if (m_nStorageType == embed::StorageFormats::OFOPXML && (aElementName == "_rels" || aNewName == "_rels")) throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), 0); // unacceptable element name @@ -3268,7 +3271,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getPlainRawStreamElement( throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); // the interface is not supported and must not be accessible if ( sStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, false ) ) @@ -3358,7 +3361,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getRawEncrStreamElement( throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw packages::NoEncryptionException( THROW_WHERE ); if ( sStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, false ) ) @@ -3457,7 +3460,7 @@ void SAL_CALL OStorage::insertRawEncrStreamElement( const OUString& aStreamName, throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw embed::InvalidStorageException( THROW_WHERE ); if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, false ) ) @@ -3766,7 +3769,7 @@ uno::Any SAL_CALL OStorage::getByName( const OUString& aName ) if ( aName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable element name uno::Any aResult; @@ -3852,7 +3855,7 @@ sal_Bool SAL_CALL OStorage::hasByName( const OUString& aName ) if ( aName.isEmpty() ) return false; - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" ) return false; SotElement_Impl* pElement = nullptr; @@ -4000,7 +4003,7 @@ void SAL_CALL OStorage::removeEncryption() throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw uno::RuntimeException( THROW_WHERE ); // the interface must be visible only for package storage SAL_WARN_IF( !m_pImpl->m_bIsRoot, "package.xstor", "removeEncryption() method is not available for nonroot storages!" ); @@ -4061,7 +4064,7 @@ void SAL_CALL OStorage::setEncryptionData( const uno::Sequence< beans::NamedValu throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw uno::RuntimeException( THROW_WHERE ); // the interface must be visible only for package storage if ( !aEncryptionData.hasElements() ) @@ -4126,7 +4129,7 @@ void SAL_CALL OStorage::setEncryptionAlgorithms( const uno::Sequence< beans::Nam throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw uno::RuntimeException( THROW_WHERE ); // the interface must be visible only for package storage if ( !aAlgorithms.hasElements() ) @@ -4186,7 +4189,7 @@ void SAL_CALL OStorage::setGpgProperties( const uno::Sequence< uno::Sequence< be throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw uno::RuntimeException( THROW_WHERE ); // the interface must be visible only for package storage if ( !aProps.hasElements() ) @@ -4246,7 +4249,7 @@ uno::Sequence< beans::NamedValue > SAL_CALL OStorage::getEncryptionAlgorithms() throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw uno::RuntimeException( THROW_WHERE ); // the interface must be visible only for package storage uno::Sequence< beans::NamedValue > aResult; @@ -4329,9 +4332,9 @@ void SAL_CALL OStorage::setPropertyValue( const OUString& aPropertyName, const u if ( m_bReadOnlyWrap && aPropertyName != "Version" ) throw uno::RuntimeException( THROW_WHERE ); // TODO: Access denied - if ( m_pImpl->m_nStorageType == embed::StorageFormats::ZIP ) + if ( m_nStorageType == embed::StorageFormats::ZIP ) throw beans::UnknownPropertyException( aPropertyName ); - else if ( m_pImpl->m_nStorageType == embed::StorageFormats::PACKAGE ) + else if ( m_nStorageType == embed::StorageFormats::PACKAGE ) { if ( aPropertyName == "MediaType" ) { @@ -4365,7 +4368,7 @@ void SAL_CALL OStorage::setPropertyValue( const OUString& aPropertyName, const u else throw beans::UnknownPropertyException( aPropertyName ); } - else if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML ) + else if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { if ( aPropertyName == "RelationsInfoStream" ) { @@ -4420,7 +4423,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const OUString& aPropertyName ) throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType == embed::StorageFormats::PACKAGE + if ( m_nStorageType == embed::StorageFormats::PACKAGE && ( aPropertyName == "MediaType" || aPropertyName == MEDIATYPE_FALLBACK_USED_PROPERTY || aPropertyName == "Version" ) ) { try @@ -4473,7 +4476,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const OUString& aPropertyName ) return uno::Any( false ); // RepairPackage } - else if ( m_pImpl->m_nStorageType == embed::StorageFormats::PACKAGE + else if ( m_nStorageType == embed::StorageFormats::PACKAGE && ( aPropertyName == HAS_ENCRYPTED_ENTRIES_PROPERTY || aPropertyName == HAS_NONENCRYPTED_ENTRIES_PROPERTY || aPropertyName == ENCRYPTION_GPG_PROPERTIES @@ -4578,7 +4581,7 @@ sal_Bool SAL_CALL OStorage::hasByID( const OUString& sID ) throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); try @@ -4614,7 +4617,7 @@ OUString SAL_CALL OStorage::getTargetByID( const OUString& sID ) throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); const uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID ); @@ -4635,7 +4638,7 @@ OUString SAL_CALL OStorage::getTypeByID( const OUString& sID ) throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); const uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID ); @@ -4656,7 +4659,7 @@ uno::Sequence< beans::StringPair > SAL_CALL OStorage::getRelationshipByID( cons throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); // TODO/LATER: in future the unification of the ID could be checked @@ -4682,7 +4685,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OStorage::getRelati throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); // TODO/LATER: in future the unification of the ID could be checked @@ -4711,7 +4714,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OStorage::getAllRel throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); uno::Sequence< uno::Sequence< beans::StringPair > > aRet; @@ -4748,7 +4751,7 @@ void SAL_CALL OStorage::insertRelationshipByID( const OUString& sID, const uno: throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); const beans::StringPair aIDRel(u"Id"_ustr, sID); @@ -4798,7 +4801,7 @@ void SAL_CALL OStorage::removeRelationshipByID( const OUString& sID ) throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships(); @@ -4832,7 +4835,7 @@ void SAL_CALL OStorage::insertRelationships( const uno::Sequence< uno::Sequence throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); OUString aIDTag( u"Id"_ustr ); @@ -4885,7 +4888,7 @@ void SAL_CALL OStorage::clearRelationships() throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::OFOPXML ) + if ( m_nStorageType != embed::StorageFormats::OFOPXML ) throw uno::RuntimeException( THROW_WHERE ); m_pImpl->m_aRelInfo.realloc( 0 ); @@ -4919,7 +4922,7 @@ void SAL_CALL OStorage::insertStreamElementDirect( if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name if ( m_bReadOnlyWrap ) @@ -4998,7 +5001,7 @@ void SAL_CALL OStorage::copyElementDirectlyTo( if ( !xDest.is() || xDest == getXWeak() ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 2 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); // unacceptable name try @@ -5200,7 +5203,7 @@ uno::Any SAL_CALL OStorage::getElementPropertyValue( const OUString& aElementNam if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // TODO: unacceptable name try @@ -5210,7 +5213,7 @@ uno::Any SAL_CALL OStorage::getElementPropertyValue( const OUString& aElementNam throw container::NoSuchElementException( THROW_WHERE ); // TODO/LATER: Currently it is only implemented for MediaType property of substorages, might be changed in future - if ( !pElement->m_bIsStorage || m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE || aPropertyName != "MediaType" ) + if ( !pElement->m_bIsStorage || m_nStorageType != embed::StorageFormats::PACKAGE || aPropertyName != "MediaType" ) throw beans::PropertyVetoException( THROW_WHERE ); if (!pElement->m_xStorage) @@ -5286,7 +5289,7 @@ void SAL_CALL OStorage::copyStreamElementData( const OUString& aStreamName, cons if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, false ) ) throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); - if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) + if ( m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // unacceptable name if ( !xTargetStream.is() ) @@ -5442,7 +5445,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted throw lang::DisposedException( THROW_WHERE ); } - if ( m_pImpl->m_nStorageType != embed::StorageFormats::PACKAGE ) + if ( m_nStorageType != embed::StorageFormats::PACKAGE ) throw packages::NoEncryptionException( THROW_WHERE ); if ( aStreamPath.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, true ) ) diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index f6e9890c43a3..067893a274fb 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -283,6 +283,9 @@ class OStorage final : public css::lang::XTypeProvider rtl::Reference<comphelper::RefCountedMutex> m_xSharedMutex; comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenersContainer; // list of listeners ::std::optional< ::cppu::OTypeCollection> m_oTypeCollection; + // m_nStorageType is both here, and in m_pImpl->m_nStorageType because + // sometimes we need the value when m_pImpl is nullptr. + sal_Int32 m_nStorageType; // the mode in which the storage is used bool m_bReadOnlyWrap; ::rtl::Reference<OChildDispListener_Impl> m_pSubElDispListener; ::std::vector< css::uno::WeakReference< css::lang::XComponent > > m_aOpenSubComponentsVector;
