summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-28 10:00:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-28 11:48:50 +0000
commit4e0db1771a10f694857bedc0f1750532e4f41e7c (patch)
tree8098fd349a7ab21fed14d7e76527657e64cc4d8d /package
parent69794d012fa640d60fd808e1d576cb919129ade4 (diff)
flatten OWriteStream
no need to use pimpl pattern here Change-Id: Iebc412aaad83c2f1fc149cc320729ce25030cbc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147949 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r--package/source/xstor/owriteablestream.cxx202
-rw-r--r--package/source/xstor/owriteablestream.hxx9
2 files changed, 100 insertions, 111 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 56971fbd37d8..859facc6fad2 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -46,7 +46,6 @@
#include <comphelper/servicehelper.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/ofopxmlhelper.hxx>
-#include <comphelper/multicontainer2.hxx>
#include <comphelper/refcountedmutex.hxx>
#include <comphelper/sequence.hxx>
@@ -65,21 +64,6 @@
using namespace ::com::sun::star;
-struct WSInternalData_Impl
-{
- rtl::Reference<comphelper::RefCountedMutex> m_xSharedMutex;
- ::std::optional< ::cppu::OTypeCollection> m_oTypeCollection;
- comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenersContainer; // list of listeners
- sal_Int32 m_nStorageType;
-
- // the mutex reference MUST NOT be empty
- WSInternalData_Impl( const rtl::Reference<comphelper::RefCountedMutex>& rMutexRef, sal_Int32 nStorageType )
- : m_xSharedMutex( rMutexRef )
- , m_aListenersContainer( rMutexRef->GetMutex() )
- , m_nStorageType( nStorageType )
- {}
-};
-
namespace package
{
@@ -1543,6 +1527,9 @@ void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStora
OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, bool bTransacted )
: m_pImpl( pImpl )
+, m_xSharedMutex( pImpl->m_xMutex )
+, m_aListenersContainer( pImpl->m_xMutex->GetMutex() )
+, m_nStorageType( m_pImpl->m_nStorageType )
, m_bInStreamDisconnected( false )
, m_bInitOnDemand( true )
, m_nInitPosition( 0 )
@@ -1553,12 +1540,13 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, bool bTransacted )
if ( !m_pImpl || !m_pImpl->m_xMutex.is() )
throw uno::RuntimeException(); // just a disaster
-
- m_pData.reset(new WSInternalData_Impl(pImpl->m_xMutex, m_pImpl->m_nStorageType));
}
OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStream > const & xStream, bool bTransacted )
: m_pImpl( pImpl )
+, m_xSharedMutex( pImpl->m_xMutex )
+, m_aListenersContainer( pImpl->m_xMutex->GetMutex() )
+, m_nStorageType( m_pImpl->m_nStorageType )
, m_bInStreamDisconnected( false )
, m_bInitOnDemand( false )
, m_nInitPosition( 0 )
@@ -1570,8 +1558,6 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStrea
if ( !m_pImpl || !m_pImpl->m_xMutex.is() )
throw uno::RuntimeException(); // just a disaster
- m_pData.reset(new WSInternalData_Impl(pImpl->m_xMutex, m_pImpl->m_nStorageType));
-
if ( xStream.is() )
{
m_xInStream = xStream->getInputStream();
@@ -1583,7 +1569,7 @@ OWriteStream::OWriteStream( OWriteStream_Impl* pImpl, uno::Reference< io::XStrea
OWriteStream::~OWriteStream()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( m_pImpl )
{
osl_atomic_increment(&m_refCount);
@@ -1638,7 +1624,7 @@ void OWriteStream::CheckInitOnDemand()
void OWriteStream::CopyToStreamInternally_Impl( const uno::Reference< io::XStream >& xDest )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -1687,12 +1673,12 @@ void OWriteStream::CopyToStreamInternally_Impl( const uno::Reference< io::XStrea
// the order of the properties setting is not important for StorageStream API
OUString aPropName ("Compressed");
xDestProps->setPropertyValue( aPropName, getPropertyValue( aPropName ) );
- if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE || m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE || m_nStorageType == embed::StorageFormats::OFOPXML )
{
aPropName = "MediaType";
xDestProps->setPropertyValue( aPropName, getPropertyValue( aPropName ) );
- if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
aPropName = "UseCommonStoragePasswordEncryption";
xDestProps->setPropertyValue( aPropName, getPropertyValue( aPropName ) );
@@ -1733,14 +1719,14 @@ uno::Any SAL_CALL OWriteStream::queryInterface( const uno::Type& rType )
if ( aReturn.hasValue() )
return aReturn ;
- if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
aReturn = ::cppu::queryInterface
( rType
, static_cast<embed::XEncryptionProtectedSource2*> ( this )
, static_cast<embed::XEncryptionProtectedSource*> ( this ) );
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
aReturn = ::cppu::queryInterface
( rType
@@ -1776,15 +1762,15 @@ void SAL_CALL OWriteStream::release() noexcept
uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
{
- if (! m_pData->m_oTypeCollection)
+ if (! m_oTypeCollection)
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
- if (! m_pData->m_oTypeCollection)
+ if (! m_oTypeCollection)
{
if ( m_bTransacted )
{
- if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
::cppu::OTypeCollection aTmpCollection
( cppu::UnoType<lang::XTypeProvider>::get()
@@ -1800,13 +1786,13 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<embed::XTransactedObject>::get()
, cppu::UnoType<embed::XTransactionBroadcaster>::get());
- m_pData->m_oTypeCollection.emplace(
+ m_oTypeCollection.emplace(
cppu::UnoType<beans::XPropertySet>::get()
, aTmpCollection.getTypes());
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
- m_pData->m_oTypeCollection.emplace(
+ m_oTypeCollection.emplace(
cppu::UnoType<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1822,7 +1808,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
}
else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
{
- m_pData->m_oTypeCollection.emplace(
+ m_oTypeCollection.emplace(
cppu::UnoType<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1838,9 +1824,9 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
}
else
{
- if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
- m_pData->m_oTypeCollection.emplace(
+ m_oTypeCollection.emplace(
cppu::UnoType<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1852,9 +1838,9 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<embed::XEncryptionProtectedSource>::get()
, cppu::UnoType<beans::XPropertySet>::get());
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
- m_pData->m_oTypeCollection.emplace(
+ m_oTypeCollection.emplace(
cppu::UnoType<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1867,7 +1853,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
}
else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
{
- m_pData->m_oTypeCollection.emplace(
+ m_oTypeCollection.emplace(
cppu::UnoType<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1881,7 +1867,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
}
}
- return m_pData->m_oTypeCollection->getTypes() ;
+ return m_oTypeCollection->getTypes() ;
}
uno::Sequence< sal_Int8 > SAL_CALL OWriteStream::getImplementationId()
@@ -1892,7 +1878,7 @@ uno::Sequence< sal_Int8 > SAL_CALL OWriteStream::getImplementationId()
sal_Int32 SAL_CALL OWriteStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -1910,7 +1896,7 @@ sal_Int32 SAL_CALL OWriteStream::readBytes( uno::Sequence< sal_Int8 >& aData, sa
sal_Int32 SAL_CALL OWriteStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -1928,7 +1914,7 @@ sal_Int32 SAL_CALL OWriteStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData
void SAL_CALL OWriteStream::skipBytes( sal_Int32 nBytesToSkip )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -1946,7 +1932,7 @@ void SAL_CALL OWriteStream::skipBytes( sal_Int32 nBytesToSkip )
sal_Int32 SAL_CALL OWriteStream::available( )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -1965,7 +1951,7 @@ sal_Int32 SAL_CALL OWriteStream::available( )
void SAL_CALL OWriteStream::closeInput( )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -1988,7 +1974,7 @@ void SAL_CALL OWriteStream::closeInput( )
uno::Reference< io::XInputStream > SAL_CALL OWriteStream::getInputStream()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2004,7 +1990,7 @@ uno::Reference< io::XInputStream > SAL_CALL OWriteStream::getInputStream()
uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
try
{
@@ -2030,7 +2016,7 @@ uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream()
void SAL_CALL OWriteStream::writeBytes( const uno::Sequence< sal_Int8 >& aData )
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
// the write method makes initialization itself, since it depends from the aData length
// NO CheckInitOnDemand()!
@@ -2096,7 +2082,7 @@ void OWriteStream::writeBytes( const sal_Int8* pData, sal_Int32 nBytesToWrite )
{
assert(nBytesToWrite >= 0);
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
// the write method makes initialization itself, since it depends from the aData length
// NO CheckInitOnDemand()!
@@ -2171,7 +2157,7 @@ void SAL_CALL OWriteStream::flush()
// during own commit but a user can explicitly flush the stream
// so the changes will be available through cloning functionality.
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2213,7 +2199,7 @@ void OWriteStream::CloseOutput_Impl()
void SAL_CALL OWriteStream::closeOutput()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -2234,7 +2220,7 @@ void SAL_CALL OWriteStream::closeOutput()
void SAL_CALL OWriteStream::seek( sal_Int64 location )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -2252,7 +2238,7 @@ void SAL_CALL OWriteStream::seek( sal_Int64 location )
sal_Int64 SAL_CALL OWriteStream::getPosition()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -2270,7 +2256,7 @@ sal_Int64 SAL_CALL OWriteStream::getPosition()
sal_Int64 SAL_CALL OWriteStream::getLength()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
CheckInitOnDemand();
@@ -2288,7 +2274,7 @@ sal_Int64 SAL_CALL OWriteStream::getLength()
void SAL_CALL OWriteStream::truncate()
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
CheckInitOnDemand();
@@ -2313,7 +2299,7 @@ void SAL_CALL OWriteStream::dispose()
{
// should be an internal method since it can be called only from parent storage
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2366,13 +2352,13 @@ void SAL_CALL OWriteStream::dispose()
// in future a more elegant way should be found
lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
- m_pData->m_aListenersContainer.disposeAndClear( aSource );
+ m_aListenersContainer.disposeAndClear( aSource );
}
void SAL_CALL OWriteStream::addEventListener(
const uno::Reference< lang::XEventListener >& xListener )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2380,14 +2366,14 @@ void SAL_CALL OWriteStream::addEventListener(
throw lang::DisposedException();
}
- m_pData->m_aListenersContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(),
+ m_aListenersContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(),
xListener );
}
void SAL_CALL OWriteStream::removeEventListener(
const uno::Reference< lang::XEventListener >& xListener )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2395,13 +2381,13 @@ void SAL_CALL OWriteStream::removeEventListener(
throw lang::DisposedException();
}
- m_pData->m_aListenersContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(),
+ m_aListenersContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(),
xListener );
}
void SAL_CALL OWriteStream::setEncryptionPassword( const OUString& aPass )
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
CheckInitOnDemand();
@@ -2420,7 +2406,7 @@ void SAL_CALL OWriteStream::setEncryptionPassword( const OUString& aPass )
void SAL_CALL OWriteStream::removeEncryption()
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
CheckInitOnDemand();
@@ -2439,7 +2425,7 @@ void SAL_CALL OWriteStream::removeEncryption()
void SAL_CALL OWriteStream::setEncryptionData( const uno::Sequence< beans::NamedValue >& aEncryptionData )
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
CheckInitOnDemand();
@@ -2458,7 +2444,7 @@ void SAL_CALL OWriteStream::setEncryptionData( const uno::Sequence< beans::Named
sal_Bool SAL_CALL OWriteStream::hasEncryptionData()
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
if (!m_pImpl)
return false;
@@ -2491,7 +2477,7 @@ sal_Bool SAL_CALL OWriteStream::hasEncryptionData()
sal_Bool SAL_CALL OWriteStream::hasByID( const OUString& sID )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2499,7 +2485,7 @@ sal_Bool SAL_CALL OWriteStream::hasByID( const OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
try
@@ -2517,7 +2503,7 @@ sal_Bool SAL_CALL OWriteStream::hasByID( const OUString& sID )
OUString SAL_CALL OWriteStream::getTargetByID( const OUString& sID )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2525,7 +2511,7 @@ OUString SAL_CALL OWriteStream::getTargetByID( const OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
const uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -2538,7 +2524,7 @@ OUString SAL_CALL OWriteStream::getTargetByID( const OUString& sID )
OUString SAL_CALL OWriteStream::getTypeByID( const OUString& sID )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2546,7 +2532,7 @@ OUString SAL_CALL OWriteStream::getTypeByID( const OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
const uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -2559,7 +2545,7 @@ OUString SAL_CALL OWriteStream::getTypeByID( const OUString& sID )
uno::Sequence< beans::StringPair > SAL_CALL OWriteStream::getRelationshipByID( const OUString& sID )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2567,7 +2553,7 @@ uno::Sequence< beans::StringPair > SAL_CALL OWriteStream::getRelationshipByID(
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
// TODO/LATER: in future the unification of the ID could be checked
@@ -2584,7 +2570,7 @@ uno::Sequence< beans::StringPair > SAL_CALL OWriteStream::getRelationshipByID(
uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getRelationshipsByType( const OUString& sType )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2592,7 +2578,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getRe
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
// TODO/LATER: in future the unification of the ID could be checked
@@ -2610,7 +2596,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getRe
uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getAllRelationships()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2618,7 +2604,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getAl
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
return m_pImpl->GetAllRelationshipsIfAny();
@@ -2626,7 +2612,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getAl
void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const uno::Sequence< beans::StringPair >& aEntry, sal_Bool bReplace )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2634,7 +2620,7 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
const beans::StringPair aIDRel("Id", sID);
@@ -2676,7 +2662,7 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const OUString& sID, const
void SAL_CALL OWriteStream::removeRelationshipByID( const OUString& sID )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2684,7 +2670,7 @@ void SAL_CALL OWriteStream::removeRelationshipByID( const OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
@@ -2710,7 +2696,7 @@ void SAL_CALL OWriteStream::removeRelationshipByID( const OUString& sID )
void SAL_CALL OWriteStream::insertRelationships( const uno::Sequence< uno::Sequence< beans::StringPair > >& aEntries, sal_Bool bReplace )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2718,7 +2704,7 @@ void SAL_CALL OWriteStream::insertRelationships( const uno::Sequence< uno::Sequ
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
OUString aIDTag( "Id" );
@@ -2763,7 +2749,7 @@ void SAL_CALL OWriteStream::insertRelationships( const uno::Sequence< uno::Sequ
void SAL_CALL OWriteStream::clearRelationships()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2771,7 +2757,7 @@ void SAL_CALL OWriteStream::clearRelationships()
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
m_pImpl->m_aNewRelInfo.realloc( 0 );
@@ -2781,7 +2767,7 @@ void SAL_CALL OWriteStream::clearRelationships()
uno::Reference< beans::XPropertySetInfo > SAL_CALL OWriteStream::getPropertySetInfo()
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
//TODO:
return uno::Reference< beans::XPropertySetInfo >();
@@ -2789,7 +2775,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL OWriteStream::getPropertySetI
void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
{
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
if ( !m_pImpl )
{
@@ -2800,7 +2786,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
m_pImpl->GetStreamProperties();
static constexpr OUStringLiteral aCompressedString( u"Compressed" );
static constexpr OUStringLiteral aMediaTypeString( u"MediaType" );
- if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName == aMediaTypeString )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName == aMediaTypeString )
{
// if the "Compressed" property is not set explicitly, the MediaType can change the default value
bool bCompressedValueFromType = true;
@@ -2831,7 +2817,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
rProp.Value = aValue;
}
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
+ else if ( m_nStorageType == embed::StorageFormats::PACKAGE
&& aPropertyName == "UseCommonStoragePasswordEncryption" )
{
bool bUseCommonEncryption = false;
@@ -2854,7 +2840,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
else
m_pImpl->m_bUseCommonEncryption = false;
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == aMediaTypeString )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == aMediaTypeString )
{
for ( auto& rProp : asNonConstRange(m_pImpl->m_aProps) )
{
@@ -2862,7 +2848,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
rProp.Value = aValue;
}
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == "RelationsInfoStream" )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == "RelationsInfoStream" )
{
uno::Reference< io::XInputStream > xInRelStream;
if ( !( aValue >>= xInRelStream ) || !xInRelStream.is() )
@@ -2881,14 +2867,14 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
m_pImpl->m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED_STREAM;
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == "RelationsInfo" )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == "RelationsInfo" )
{
if ( !(aValue >>= m_pImpl->m_aNewRelInfo) )
throw lang::IllegalArgumentException(); // TODO
}
else if ( aPropertyName == "Size" )
throw beans::PropertyVetoException(); // TODO
- else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
+ else if ( m_nStorageType == embed::StorageFormats::PACKAGE
&& ( aPropertyName == "IsEncrypted" || aPropertyName == "Encrypted" ) )
throw beans::PropertyVetoException(); // TODO
else if ( aPropertyName == "RelId" )
@@ -2904,7 +2890,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
uno::Any SAL_CALL OWriteStream::getPropertyValue( const OUString& aProp )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2923,9 +2909,9 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const OUString& aProp )
else
aPropertyName = aProp;
- if ( ( ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE || m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
+ if ( ( ( m_nStorageType == embed::StorageFormats::PACKAGE || m_nStorageType == embed::StorageFormats::OFOPXML )
&& aPropertyName == "MediaType" )
- || ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName == "Encrypted" )
+ || ( m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName == "Encrypted" )
|| aPropertyName == "Compressed" )
{
m_pImpl->GetStreamProperties();
@@ -2935,7 +2921,7 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const OUString& aProp )
if (pProp != std::cend(m_pImpl->m_aProps))
return pProp->Value;
}
- else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
+ else if ( m_nStorageType == embed::StorageFormats::PACKAGE
&& aPropertyName == "UseCommonStoragePasswordEncryption" )
return uno::Any( m_pImpl->m_bUseCommonEncryption );
else if ( aPropertyName == "Size" )
@@ -2962,7 +2948,7 @@ void SAL_CALL OWriteStream::addPropertyChangeListener(
const OUString& /*aPropertyName*/,
const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2977,7 +2963,7 @@ void SAL_CALL OWriteStream::removePropertyChangeListener(
const OUString& /*aPropertyName*/,
const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -2992,7 +2978,7 @@ void SAL_CALL OWriteStream::addVetoableChangeListener(
const OUString& /*PropertyName*/,
const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -3007,7 +2993,7 @@ void SAL_CALL OWriteStream::removeVetoableChangeListener(
const OUString& /*PropertyName*/,
const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -3038,7 +3024,7 @@ void OWriteStream::BroadcastTransaction( sal_Int8 nMessage )
lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
comphelper::OInterfaceContainerHelper2* pContainer =
- m_pData->m_aListenersContainer.getContainer(
+ m_aListenersContainer.getContainer(
cppu::UnoType<embed::XTransactionListener>::get());
if ( !pContainer )
return;
@@ -3081,7 +3067,7 @@ void SAL_CALL OWriteStream::commit()
try {
BroadcastTransaction( STOR_MESS_PRECOMMIT );
- osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::ClearableMutexGuard aGuard(m_xSharedMutex->GetMutex());
if ( !m_pImpl )
{
@@ -3139,7 +3125,7 @@ void SAL_CALL OWriteStream::revert()
BroadcastTransaction( STOR_MESS_PREREVERT );
{
- osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex());
+ osl::MutexGuard aGuard(m_xSharedMutex->GetMutex());
if (!m_pImpl)
{
@@ -3182,7 +3168,7 @@ void SAL_CALL OWriteStream::revert()
void SAL_CALL OWriteStream::addTransactionListener( const uno::Reference< embed::XTransactionListener >& aListener )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -3193,13 +3179,13 @@ void SAL_CALL OWriteStream::addTransactionListener( const uno::Reference< embed:
if ( !m_bTransacted )
throw uno::RuntimeException();
- m_pData->m_aListenersContainer.addInterface( cppu::UnoType<embed::XTransactionListener>::get(),
+ m_aListenersContainer.addInterface( cppu::UnoType<embed::XTransactionListener>::get(),
aListener );
}
void SAL_CALL OWriteStream::removeTransactionListener( const uno::Reference< embed::XTransactionListener >& aListener )
{
- ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() );
+ ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() );
if ( !m_pImpl )
{
@@ -3210,7 +3196,7 @@ void SAL_CALL OWriteStream::removeTransactionListener( const uno::Reference< emb
if ( !m_bTransacted )
throw uno::RuntimeException();
- m_pData->m_aListenersContainer.removeInterface( cppu::UnoType<embed::XTransactionListener>::get(),
+ m_aListenersContainer.removeInterface( cppu::UnoType<embed::XTransactionListener>::get(),
aListener );
}
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index bd677110f1ef..6b8e886e6748 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -38,6 +38,8 @@
#include <com/sun/star/beans/StringPair.hpp>
#include <cppuhelper/weak.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/multicontainer2.hxx>
#include <comphelper/bytereader.hxx>
#include <comphelper/refcountedmutex.hxx>
@@ -59,8 +61,6 @@ namespace package {
bool PackageEncryptionDataLessOrEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 );
}
-struct WSInternalData_Impl;
-
struct OStorage_Impl;
class OWriteStream;
@@ -242,7 +242,10 @@ protected:
css::uno::Reference < css::io::XSeekable > m_xSeekable;
OWriteStream_Impl* m_pImpl;
- std::unique_ptr<WSInternalData_Impl> m_pData;
+ rtl::Reference<comphelper::RefCountedMutex> m_xSharedMutex;
+ ::std::optional< ::cppu::OTypeCollection> m_oTypeCollection;
+ comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenersContainer; // list of listeners
+ sal_Int32 m_nStorageType;
bool m_bInStreamDisconnected;
bool m_bInitOnDemand;