26#include <com/sun/star/packages/NoEncryptionException.hpp>
27#include <com/sun/star/packages/WrongPasswordException.hpp>
28#include <com/sun/star/uno/XComponentContext.hpp>
29#include <com/sun/star/ucb/SimpleFileAccess.hpp>
30#include <com/sun/star/lang/DisposedException.hpp>
31#include <com/sun/star/lang/XTypeProvider.hpp>
32#include <com/sun/star/io/NotConnectedException.hpp>
33#include <com/sun/star/io/TempFile.hpp>
34#include <com/sun/star/io/XInputStream.hpp>
35#include <com/sun/star/io/IOException.hpp>
36#include <com/sun/star/embed/ElementModes.hpp>
37#include <com/sun/star/embed/StorageFormats.hpp>
38#include <com/sun/star/embed/StorageWrappedTargetException.hpp>
39#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
43#include <osl/diagnose.h>
63#define MAX_STORCACHE_SIZE 30000
71 const css::uno::Reference< css::io::XInputStream >& xInput,
76 if (
auto pByteReader =
dynamic_cast< comphelper::ByteReader*
>( xInput.get() ))
95 rOutput.
WriteBytes ( aSequence.getConstArray(), nRead );
105 bool bResult = !aHash1.empty() && aHash1.size() <= aHash2.size();
107 bResult && aIter != aHash1.end();
110 uno::Sequence< sal_Int8 > aKey1;
111 bResult = ( ( aIter->second >>= aKey1 ) && aKey1.hasElements() );
114 const uno::Sequence< sal_Int8 > aKey2 = aHash2.getUnpackedValueOrDefault( aIter->first.maString, uno::Sequence< sal_Int8 >() );
115 bResult = aKey1.getLength() == aKey2.getLength()
116 && std::equal(std::cbegin(aKey1), std::cend(aKey1), aKey2.begin(), aKey2.end());
128void SetEncryptionKeyProperty_Impl(
const uno::Reference< beans::XPropertySet >& xPropertySet,
129 const uno::Sequence< beans::NamedValue >& aKey )
131 SAL_WARN_IF( !xPropertySet.is(),
"package.xstor",
"No property set is provided!" );
132 if ( !xPropertySet.is() )
133 throw uno::RuntimeException();
138 catch (
const uno::Exception& ex )
141 throw io::IOException(
ex.Message);
145uno::Any GetEncryptionKeyProperty_Impl(
const uno::Reference< beans::XPropertySet >& xPropertySet )
147 SAL_WARN_IF( !xPropertySet.is(),
"package.xstor",
"No property set is provided!" );
148 if ( !xPropertySet.is() )
149 throw uno::RuntimeException();
154 catch (
const uno::Exception& ex )
157 throw io::IOException(
ex.Message);
161bool SequencesEqual(
const uno::Sequence< sal_Int8 >& aSequence1,
const uno::Sequence< sal_Int8 >& aSequence2 )
163 return aSequence1.getLength() == aSequence2.getLength()
164 && std::equal(aSequence1.begin(), aSequence1.end(), aSequence2.begin(), aSequence2.end());
167bool SequencesEqual(
const uno::Sequence< beans::NamedValue >& aSequence1,
const uno::Sequence< beans::NamedValue >& aSequence2 )
169 if ( aSequence1.getLength() != aSequence2.getLength() )
172 for (
const auto& rProp1 : aSequence1 )
174 bool bHasMember =
false;
175 uno::Sequence< sal_Int8 > aMember1;
176 sal_Int32 nMember1 = 0;
177 if ( rProp1.Value >>= aMember1 )
179 for (
const auto& rProp2 : aSequence2 )
181 if ( rProp1.Name == rProp2.Name )
185 uno::Sequence< sal_Int8 > aMember2;
186 if ( !( rProp2.Value >>= aMember2 ) || !SequencesEqual( aMember1, aMember2 ) )
191 else if ( rProp1.Value >>= nMember1 )
193 for (
const auto& rProp2 : aSequence2 )
195 if ( rProp1.Name == rProp2.Name )
199 sal_Int32 nMember2 = 0;
200 if ( !( rProp2.Value >>= nMember2 ) || nMember1 != nMember2 )
215uno::Reference< io::XStream > CreateMemoryStream(
const uno::Reference< uno::XComponentContext >& rContext )
217 static constexpr OUStringLiteral
sName(u
"com.sun.star.comp.MemoryStream");
218 return uno::Reference< io::XStream >(
219 rContext->getServiceManager()->createInstanceWithContext(sName, rContext),
220 uno::UNO_QUERY_THROW);
223const beans::StringPair* lcl_findPairByName(
const uno::Sequence<beans::StringPair>& rSeq,
const OUString& rName)
225 return std::find_if(rSeq.begin(), rSeq.end(),
226 [&rName](
const beans::StringPair& rPair) { return rPair.First == rName; });
232 const uno::Reference< packages::XDataSinkEncrSupport >& xPackageStream,
233 const uno::Reference< lang::XSingleServiceFactory >& xPackage,
234 uno::Reference< uno::XComponentContext > xContext,
235 bool bForceEncrypted,
236 sal_Int32 nStorageType,
237 bool bDefaultCompress,
238 uno::Reference< io::XInputStream > xRelInfoStream )
240, m_pAntiImpl( nullptr )
241, m_bHasDataToFlush( false )
243, m_xPackageStream( xPackageStream )
245, m_pParent( pParent )
246, m_bForceEncrypted( bForceEncrypted )
247, m_bUseCommonEncryption( !bForceEncrypted && nStorageType == embed::StorageFormats::
PACKAGE )
248, m_bHasCachedEncryptionData( false )
249, m_bCompressedSetExplicit( !bDefaultCompress )
251, m_bHasInsertedStreamOptimization( false )
252, m_nStorageType( nStorageType )
253, m_xOrigRelInfoStream(
std::move( xRelInfoStream ))
254, m_bOrigRelInfoBroken( false )
258 SAL_WARN_IF( !xPackageStream.is(),
"package.xstor",
"No package stream is provided!" );
259 SAL_WARN_IF( !xPackage.is(),
"package.xstor",
"No package component is provided!" );
261 OSL_ENSURE( pParent,
"No parent storage is provided!" );
281 uno::Reference< io::XInputStream > xInputCache =
m_xCacheStream->getInputStream();
282 if ( xInputCache.is() )
283 xInputCache->closeInput();
285 catch(
const uno::Exception& )
290 uno::Reference< io::XOutputStream > xOutputCache =
m_xCacheStream->getOutputStream();
291 if ( xOutputCache.is() )
292 xOutputCache->closeOutput();
294 catch(
const uno::Exception& )
302 const uno::Reference< container::XNameContainer >& xParentPackageFolder )
304 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() );
306 SAL_WARN_IF( !
m_bFlushed,
"package.xstor",
"This method must not be called for nonflushed streams!" );
310 uno::Reference< uno::XInterface > xTmp(
m_xPackageStream, uno::UNO_QUERY_THROW );
311 xParentPackageFolder->insertByName(
aName,
uno::Any( xTmp ) );
331 bool bWasEncr =
false;
332 uno::Reference< beans::XPropertySet > xPropSet(
m_xPackageStream, uno::UNO_QUERY );
335 uno::Any aValue = xPropSet->getPropertyValue(
"WasEncrypted");
336 if ( !( aValue >>= bWasEncr ) )
338 SAL_WARN(
"package.xstor",
"The property WasEncrypted has wrong type!" );
342 bool bToBeEncr =
false;
343 for (
const auto& rProp : std::as_const(
m_aProps) )
345 if ( rProp.Name ==
"Encrypted" )
347 if ( !( rProp.Value >>= bToBeEncr ) )
349 SAL_WARN(
"package.xstor",
"The property has wrong type!" );
356 uno::Sequence< beans::NamedValue > aKey;
358 GetEncryptionKeyProperty_Impl( xPropSet ) >>= aKey;
366 if ( !bWasEncr && bToBeEncr && !aKey.hasElements() )
378 SAL_WARN_IF(
m_nStorageType != embed::StorageFormats::PACKAGE,
"package.xstor",
"The encryption is supported only for package storages!" );
380 throw uno::RuntimeException();
393 for (
auto& rProp : asNonConstRange(
m_aProps) )
395 if ( rProp.Name ==
"Encrypted" )
396 rProp.Value <<=
false;
402 SAL_WARN_IF(
m_nStorageType != embed::StorageFormats::PACKAGE,
"package.xstor",
"The encryption is supported only for package storages!" );
404 throw uno::RuntimeException();
406 if ( aEncryptionData.empty() )
407 throw uno::RuntimeException();
416 for (
auto& rProp : asNonConstRange(
m_aProps) )
418 if ( rProp.Name ==
"Encrypted" )
419 rProp.Value <<=
true;
430 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() );
436 catch (
const uno::RuntimeException& )
452 pStream->InternalDispose();
473 catch(
const packages::WrongPasswordException& )
479 catch(
const uno::Exception& )
496 uno::Reference< io::XInputStream > xOrigStream =
m_xPackageStream->getDataStream();
497 if ( !xOrigStream.is() )
500 uno::Reference< io::XStream > xCacheStream = CreateMemoryStream(
m_xContext );
501 SAL_WARN_IF( !xCacheStream.is(),
"package.xstor",
"If the stream can not be created an exception must be thrown!" );
510 if (
aData.getLength() > nRead )
511 aData.realloc( nRead );
515 uno::Reference< io::XStream > xCacheStream = CreateMemoryStream(
m_xContext );
516 SAL_WARN_IF( !xCacheStream.is(),
"package.xstor",
"If the stream can not be created an exception must be thrown!" );
520 uno::Reference< io::XOutputStream > xOutStream( xCacheStream->getOutputStream(), uno::UNO_SET_THROW );
521 xOutStream->writeBytes(
aData );
539 catch(
const packages::WrongPasswordException& )
544 catch(
const uno::Exception& )
555 uno::Reference< io::XStream > xTempStream;
571 catch(
const uno::Exception& )
584 if ( !xTempStream.is() )
585 throw io::IOException(
"no temp stream");
592 uno::Reference< io::XInputStream > xInputStream;
608 catch(
const uno::Exception& )
621 if ( !xInputStream.is() )
622 throw io::IOException();
628 const uno::Sequence< beans::PropertyValue >& aProps )
630 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
639 throw io::IOException(
"m_bHasDataToFlush==true");
648 uno::Reference< beans::XPropertySet > xPropertySet(
m_xPackageStream, uno::UNO_QUERY_THROW );
656 bool bCompressedIsSet =
false;
657 bool bCompressed =
false;
658 OUString aComprPropName(
"Compressed" );
659 OUString aMedTypePropName(
"MediaType" );
660 for (
const auto& rProp : aProps )
662 if ( rProp.Name == aComprPropName )
664 bCompressedIsSet =
true;
665 rProp.Value >>= bCompressed;
668 && rProp.Name == aMedTypePropName )
670 xPropertySet->setPropertyValue( rProp.Name, rProp.Value );
672 else if (
m_nStorageType == embed::StorageFormats::PACKAGE && rProp.Name ==
"UseCommonStoragePasswordEncryption" )
675 throw lang::IllegalArgumentException();
678 if ( rProp.Name == aMedTypePropName || rProp.Name == aComprPropName )
679 for (
auto& rMemProp : asNonConstRange(
m_aProps) )
681 if ( rProp.Name == rMemProp.Name )
682 rMemProp.Value = rProp.Value;
686 if ( bCompressedIsSet )
688 xPropertySet->setPropertyValue( aComprPropName,
uno::Any( bCompressed ) );
695 throw uno::RuntimeException();
699 uno::Any( uno::Sequence< beans::NamedValue >() ) );
700 xPropertySet->setPropertyValue(
"Encrypted",
uno::Any(
true ) );
711 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
718 uno::Reference< packages::XDataSinkEncrSupport > xNewPackageStream;
726 uno::Reference< io::XInputStream > xInStream(
m_xCacheStream->getInputStream(), uno::UNO_SET_THROW );
728 xNewPackageStream.set(
m_xPackage->createInstanceWithArguments(
aSeq ), uno::UNO_QUERY_THROW );
730 xNewPackageStream->setDataStream( xInStream );
741 uno::Reference< io::XInputStream > xInStream;
746 catch(
const uno::Exception& )
751 if ( !xInStream.is() )
752 throw io::IOException();
754 xNewPackageStream.set(
m_xPackage->createInstanceWithArguments(
aSeq ), uno::UNO_QUERY_THROW );
757 xNewPackageStream->setDataStream( xInStream );
767 uno::Reference< beans::XPropertySet > xPropertySet( xNewPackageStream, uno::UNO_QUERY_THROW );
769 for (
auto& rProp : asNonConstRange(
m_aProps) )
771 if ( rProp.Name ==
"Size" )
776 xPropertySet->setPropertyValue( rProp.Name, rProp.Value );
780 xPropertySet->setPropertyValue( rProp.Name, rProp.Value );
786 throw uno::RuntimeException();
790 uno::Any( uno::Sequence< beans::NamedValue >() ) );
791 xPropertySet->setPropertyValue(
"Encrypted",
797 throw uno::RuntimeException();
814 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
842 m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
846 m_aOrigRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
868 const uno::Sequence< beans::PropertyValue >& aProps,
869 bool bUseCommonEncryption )
871 uno::Sequence< beans::PropertyValue > aResult( aProps );
872 beans::PropertyValue aPropVal;
876 aPropVal.Name =
"UseCommonStoragePasswordEncryption";
877 aPropVal.Value <<= bUseCommonEncryption;
883 aPropVal.Name =
"RelationsInfo";
889 throw io::IOException(
"Wrong relinfo stream!" );
891 if (!aPropVal.Name.isEmpty())
894 for (
auto p = aResult.getConstArray();
i < aResult.getLength(); ++
i)
895 if (
p[
i].
Name == aPropVal.Name)
897 if (
i == aResult.getLength())
898 aResult.realloc(
i + 1);
899 aResult.getArray()[
i] = aPropVal;
907 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
922 m_aOrigRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(
933 catch(
const uno::Exception& )
947 m_aNewRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(
954 catch(
const uno::Exception& )
963 sal_Int32 nPropNum = 0;
970 assert(nPropNum >= 2);
971 uno::Sequence< beans::PropertyValue > aResult( nPropNum );
972 auto aResultRange = asNonConstRange(aResult);
976 static constexpr OUStringLiteral
sMediaType =
u"MediaType";
977 static constexpr OUStringLiteral sCompressed =
u"Compressed";
978 static constexpr OUStringLiteral sSize =
u"Size";
979 static constexpr OUStringLiteral sEncrypted =
u"Encrypted";
983 aResultRange[1].Name = sCompressed;
984 aResultRange[2].Name = sSize;
987 aResultRange[3].Name = sEncrypted;
991 aResultRange[0].Name = sCompressed;
992 aResultRange[1].Name = sSize;
997 uno::Reference< beans::XPropertySet > xPropSet(
m_xPackageStream, uno::UNO_QUERY_THROW );
998 for (
auto& rProp : aResultRange )
1001 rProp.Value = xPropSet->getPropertyValue( rProp.Name );
1003 catch(
const uno::Exception& )
1013 const ::comphelper::SequenceAsHashMap& aEncryptionData )
1015 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1020 throw packages::NoEncryptionException();
1028 uno::Reference< io::XStream > xOwnStream =
GetStream( embed::ElementModes::READ, aEncryptionData,
false );
1029 if ( !xOwnStream.is() )
1030 throw io::IOException();
1035 uno::Reference< embed::XEncryptionProtectedSource2 > xEncr( xDestStream, uno::UNO_QUERY );
1037 xEncr->setEncryptionData( aEncryptionData.getAsConstNamedValueList() );
1043 return uno::Sequence< uno::Sequence< beans::StringPair > >();
1052 throw io::IOException(
"Wrong relinfo stream!" );
1057 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1065 uno::Reference< io::XStream > xOwnStream =
GetStream( embed::ElementModes::READ,
false );
1066 if ( !xOwnStream.is() )
1067 throw io::IOException();
1073uno::Reference< io::XStream >
OWriteStream_Impl::GetStream( sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap& aEncryptionData,
bool bHierarchyAccess )
1075 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1080 throw io::IOException();
1083 throw packages::NoEncryptionException();
1085 uno::Reference< io::XStream > xResultStream;
1087 uno::Reference< beans::XPropertySet > xPropertySet(
m_xPackageStream, uno::UNO_QUERY_THROW );
1092 throw packages::WrongPasswordException();
1099 SetEncryptionKeyProperty_Impl( xPropertySet, aEncryptionData.getAsConstNamedValueList() );
1108 catch(
const packages::WrongPasswordException& )
1111 SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() );
1114 catch (
const uno::Exception&
ex )
1117 SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() );
1118 throw io::IOException(
ex.Message);
1122 SAL_WARN_IF( !xResultStream.is(),
"package.xstor",
"In case stream can not be retrieved an exception must be thrown!" );
1124 return xResultStream;
1129 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1134 throw io::IOException();
1136 uno::Reference< io::XStream > xResultStream;
1145 catch(
const packages::NoEncryptionException& )
1148 throw packages::WrongPasswordException();
1151 xResultStream =
GetStream( nStreamMode, aGlobalEncryptionData, bHierarchyAccess );
1156 return xResultStream;
1167 if ( ( nStreamMode & embed::ElementModes::READWRITE ) == embed::ElementModes::READ )
1169 uno::Reference< io::XInputStream > xInStream;
1176 if ( !xInStream.is() )
1177 throw io::IOException();
1183 else if ( ( nStreamMode & embed::ElementModes::READWRITE ) == embed::ElementModes::SEEKABLEREAD )
1188 throw io::IOException();
1193 if ( !xInStream.is() )
1194 throw io::IOException();
1200 else if ( ( nStreamMode & embed::ElementModes::WRITE ) == embed::ElementModes::WRITE )
1203 throw io::IOException();
1205 uno::Reference< io::XStream >
xStream;
1206 if ( ( nStreamMode & embed::ElementModes::TRUNCATE ) == embed::ElementModes::TRUNCATE )
1240 assert(
m_xMutex.is() &&
"No mutex!");
1250 throw lang::IllegalArgumentException();
1255 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1268 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1273 throw io::IOException();
1275 SAL_WARN_IF( !
IsEncrypted(),
"package.xstor",
"Impossible to get raw representation for nonencrypted stream!" );
1277 throw packages::NoEncryptionException();
1284 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() ) ;
1287 throw packages::NoEncryptionException();
1294 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() );
1300 uno::Reference < io::XStream > xTempFile;
1301 if ( !xTargetStream.is() )
1304 xTempFile = xTargetStream;
1306 uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
1308 uno::Reference < io::XOutputStream > xTempOut(xTempFile->getOutputStream(), uno::UNO_SET_THROW);
1310 if ( xDataToCopy.is() )
1313 xTempOut->closeOutput();
1314 xTempSeek->seek( 0 );
1316 uno::Reference< io::XInputStream > xInStream = xTempFile->getInputStream();
1317 if ( !xInStream.is() )
1318 throw io::IOException();
1321 if ( !xTargetStream.is() )
1328 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() );
1332 throw uno::RuntimeException();
1334 uno::Reference< io::XInputStream > xDataToCopy;
1343 catch(
const packages::NoEncryptionException& )
1346 throw packages::WrongPasswordException();
1364 ::osl::MutexGuard aGuard(
m_xMutex->GetMutex() );
1368 throw uno::RuntimeException();
1371 throw packages::NoEncryptionException();
1373 uno::Reference< io::XInputStream > xDataToCopy;
1379 uno::Sequence< beans::NamedValue > aKey = aEncryptionData.getAsConstNamedValueList();
1381 uno::Reference< beans::XPropertySet > xProps(
m_xPackageStream, uno::UNO_QUERY_THROW );
1384 xProps->getPropertyValue(
"Encrypted" ) >>= bEncr;
1386 throw packages::NoEncryptionException();
1388 uno::Sequence< beans::NamedValue > aPackKey;
1390 if ( !SequencesEqual( aKey, aPackKey ) )
1391 throw packages::WrongPasswordException();
1398 uno::Reference< beans::XPropertySet > xPropertySet(
m_xPackageStream, uno::UNO_QUERY );
1399 SetEncryptionKeyProperty_Impl( xPropertySet, aEncryptionData.getAsConstNamedValueList() );
1404 if ( !xDataToCopy.is() )
1406 SAL_WARN(
"package.xstor",
"Encrypted ZipStream must already have input stream inside!" );
1407 SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() );
1410 catch(
const uno::Exception& )
1413 SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() );
1417 SetEncryptionKeyProperty_Impl( xPropertySet, uno::Sequence< beans::NamedValue >() );
1429 OSL_ENSURE(
m_nStorageType == embed::StorageFormats::OFOPXML,
"The method should be used only with OFOPXML format!" );
1434 OSL_ENSURE( !aOrigStreamName.empty() && !aNewStreamName.empty() && xRelStorage.is(),
1435 "Wrong relation persistence information is provided!" );
1437 if ( !xRelStorage.is() || aOrigStreamName.empty() || aNewStreamName.empty() )
1438 throw uno::RuntimeException();
1441 throw io::IOException();
1443 OUString aOrigRelStreamName = OUString::Concat(aOrigStreamName) +
".rels";
1444 OUString aNewRelStreamName = OUString::Concat(aNewStreamName) +
".rels";
1446 bool bRenamed = aOrigRelStreamName != aNewRelStreamName;
1451 if ( bRenamed && xRelStorage->hasByName( aOrigRelStreamName ) )
1452 xRelStorage->removeElement( aOrigRelStreamName );
1458 uno::Reference< io::XStream > xRelsStream =
1459 xRelStorage->openStreamElement( aNewRelStreamName,
1460 embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
1462 uno::Reference< io::XOutputStream > xOutStream = xRelsStream->getOutputStream();
1463 if ( !xOutStream.is() )
1464 throw uno::RuntimeException();
1469 uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
1470 xPropSet->setPropertyValue(
1472 uno::Any( OUString(
"application/vnd.openxmlformats-package.relationships+xml" ) ) );
1480 uno::Reference< io::XStream > xRelsStream =
1481 xRelStorage->openStreamElement( aNewRelStreamName,
1482 embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
1484 uno::Reference< io::XOutputStream > xOutputStream = xRelsStream->getOutputStream();
1485 if ( !xOutputStream.is() )
1486 throw uno::RuntimeException();
1494 uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
1495 xPropSet->setPropertyValue(
"MediaType",
1496 uno::Any( OUString(
"application/vnd.openxmlformats-package.relationships+xml" ) ) );
1512 m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
1518 if ( bRenamed && xRelStorage->hasByName( aOrigRelStreamName ) )
1519 xRelStorage->renameElement( aOrigRelStreamName, aNewRelStreamName );
1527, m_xSharedMutex( rImpl.m_xMutex )
1528, m_aListenersContainer( rImpl.m_xMutex->GetMutex() )
1529, m_nStorageType(
m_pImpl->m_nStorageType )
1530, m_bInStreamDisconnected( false )
1531, m_bInitOnDemand( true )
1532, m_nInitPosition( 0 )
1533, m_bTransacted( bTransacted )
1539, m_xSharedMutex( rImpl.m_xMutex )
1540, m_aListenersContainer( rImpl.m_xMutex->GetMutex() )
1541, m_nStorageType(
m_pImpl->m_nStorageType )
1542, m_bInStreamDisconnected( false )
1543, m_bInitOnDemand( false )
1544, m_nInitPosition( 0 )
1545, m_bTransacted( bTransacted )
1565 catch(
const uno::RuntimeException& )
1590 SAL_INFO(
"package.xstor",
"Disposed!");
1591 throw lang::DisposedException();
1597 SAL_INFO(
"package.xstor",
"package (mv76033) OWriteStream::CheckInitOnDemand, initializing" );
1618 throw uno::RuntimeException();
1621 throw uno::RuntimeException();
1623 uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY_THROW );
1625 uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream();
1626 if ( !xDestOutStream.is() )
1627 throw io::IOException();
1632 uno::Exception eThrown;
1633 bool bThrown =
false;
1637 catch (
const uno::Exception& e )
1648 catch (
const uno::Exception& )
1652 throw uno::RuntimeException();
1669 aPropName =
"UseCommonStoragePasswordEncryption";
1683 xParentModif->setModified(
true );
1693 uno::Any aReturn = ::cppu::queryInterface
1695 ,
static_cast<lang::XTypeProvider*
> (
this )
1696 ,
static_cast<io::XInputStream*
> (
this )
1697 ,
static_cast<io::XOutputStream*
> (
this )
1698 ,
static_cast<io::XStream*
> (
this )
1699 ,
static_cast<embed::XExtendedStorageStream*
> (
this )
1700 ,
static_cast<io::XSeekable*
> (
this )
1701 ,
static_cast<io::XTruncate*
> (
this )
1702 ,
static_cast<lang::XComponent*
> (
this )
1703 ,
static_cast<beans::XPropertySet*
> (
this ) );
1710 aReturn = ::cppu::queryInterface
1712 ,
static_cast<embed::XEncryptionProtectedSource2*
> (
this )
1713 ,
static_cast<embed::XEncryptionProtectedSource*
> (
this ) );
1717 aReturn = ::cppu::queryInterface
1719 ,
static_cast<embed::XRelationshipAccess*
> (
this ) );
1727 aReturn = ::cppu::queryInterface
1729 ,
static_cast<embed::XTransactedObject*
> (
this )
1730 ,
static_cast<embed::XTransactionBroadcaster*
> (
this ) );
1736 return OWeakObject::queryInterface( rType );
1741 OWeakObject::acquire();
1746 OWeakObject::release();
1862 return lcl_ImplId.
getSeq();
1873 SAL_INFO(
"package.xstor",
"Disposed!");
1874 throw lang::DisposedException();
1878 throw io::NotConnectedException();
1891 SAL_INFO(
"package.xstor",
"Disposed!");
1892 throw lang::DisposedException();
1896 throw io::NotConnectedException();
1909 SAL_INFO(
"package.xstor",
"Disposed!");
1910 throw lang::DisposedException();
1914 throw io::NotConnectedException();
1927 SAL_INFO(
"package.xstor",
"Disposed!");
1928 throw lang::DisposedException();
1932 throw io::NotConnectedException();
1944 SAL_INFO(
"package.xstor",
"Disposed!");
1945 throw lang::DisposedException();
1949 throw io::NotConnectedException();
1967 SAL_INFO(
"package.xstor",
"Disposed!");
1968 throw lang::DisposedException();
1972 return uno::Reference< io::XInputStream >();
1985 catch(
const io::IOException& r )
1987 throw lang::WrappedTargetRuntimeException(
"OWriteStream::getOutputStream: Could not create backing temp file",
1988 getXWeak(), css::uno::Any ( r ) );
1993 SAL_INFO(
"package.xstor",
"Disposed!");
1994 throw lang::DisposedException();
1998 return uno::Reference< io::XOutputStream >();
2012 SAL_INFO(
"package.xstor",
"Disposed!");
2013 throw lang::DisposedException();
2019 throw io::NotConnectedException();
2044 SAL_INFO(
"package.xstor",
"package (mv76033) OWriteStream::CheckInitOnDemand, initializing" );
2059 throw io::NotConnectedException();
2069 assert(nBytesToWrite >= 0);
2078 SAL_INFO(
"package.xstor",
"Disposed!");
2079 throw lang::DisposedException();
2085 throw io::NotConnectedException();
2110 SAL_INFO(
"package.xstor",
"package (mv76033) OWriteStream::CheckInitOnDemand, initializing" );
2125 throw io::NotConnectedException();
2127 if (
auto pByteWriter =
dynamic_cast< comphelper::ByteWriter*
>(
m_xOutStream.get() ))
2128 pByteWriter->writeBytes(
pData, nBytesToWrite);
2131 uno::Sequence<sal_Int8>
aData(
pData, nBytesToWrite);
2150 SAL_INFO(
"package.xstor",
"Disposed!");
2151 throw lang::DisposedException();
2157 throw io::NotConnectedException();
2177 throw uno::RuntimeException();
2181 if ( rProp.Name ==
"Size" )
2194 SAL_INFO(
"package.xstor",
"Disposed!");
2195 throw lang::DisposedException();
2199 throw io::NotConnectedException();
2215 SAL_INFO(
"package.xstor",
"Disposed!");
2216 throw lang::DisposedException();
2220 throw uno::RuntimeException();
2233 SAL_INFO(
"package.xstor",
"Disposed!");
2234 throw lang::DisposedException();
2238 throw uno::RuntimeException();
2251 SAL_INFO(
"package.xstor",
"Disposed!");
2252 throw lang::DisposedException();
2256 throw uno::RuntimeException();
2269 SAL_INFO(
"package.xstor",
"Disposed!");
2270 throw lang::DisposedException();
2274 throw uno::RuntimeException();
2276 uno::Reference< io::XTruncate > xTruncate(
m_xOutStream, uno::UNO_QUERY_THROW );
2277 xTruncate->truncate();
2292 SAL_INFO(
"package.xstor",
"Disposed!");
2293 throw lang::DisposedException();
2323 catch(
const uno::Exception& )
2325 uno::Any aCaught( ::cppu::getCaughtException() );
2327 throw lang::WrappedTargetRuntimeException(
"Can not commit/revert the storage!",
2340 lang::EventObject aSource( getXWeak() );
2345 const uno::Reference< lang::XEventListener >& xListener )
2351 SAL_INFO(
"package.xstor",
"Disposed!");
2352 throw lang::DisposedException();
2360 const uno::Reference< lang::XEventListener >& xListener )
2366 SAL_INFO(
"package.xstor",
"Disposed!");
2367 throw lang::DisposedException();
2382 SAL_INFO(
"package.xstor",
"Disposed!");
2383 throw lang::DisposedException();
2401 SAL_INFO(
"package.xstor",
"Disposed!");
2402 throw lang::DisposedException();
2420 SAL_INFO(
"package.xstor",
"Disposed!");
2421 throw lang::DisposedException();
2447 catch(
const uno::RuntimeException& )
2452 catch(
const uno::Exception& )
2454 uno::Any aCaught( ::cppu::getCaughtException() );
2456 throw lang::WrappedTargetRuntimeException(
"Problems on hasEncryptionData!",
2470 SAL_INFO(
"package.xstor",
"Disposed!");
2471 throw lang::DisposedException();
2475 throw uno::RuntimeException();
2482 catch(
const container::NoSuchElementException& )
2496 SAL_INFO(
"package.xstor",
"Disposed!");
2497 throw lang::DisposedException();
2501 throw uno::RuntimeException();
2504 auto pRel = lcl_findPairByName(
aSeq,
"Target");
2505 if (pRel !=
aSeq.end())
2506 return pRel->Second;
2517 SAL_INFO(
"package.xstor",
"Disposed!");
2518 throw lang::DisposedException();
2522 throw uno::RuntimeException();
2525 auto pRel = lcl_findPairByName(
aSeq,
"Type");
2526 if (pRel !=
aSeq.end())
2527 return pRel->Second;
2538 SAL_INFO(
"package.xstor",
"Disposed!");
2539 throw lang::DisposedException();
2543 throw uno::RuntimeException();
2547 const beans::StringPair aIDRel(
"Id", sID);
2548 auto pRel = std::find_if(
aSeq.begin(),
aSeq.end(),
2549 [&aIDRel](
const uno::Sequence<beans::StringPair>& rRel) {
2550 return std::find(rRel.begin(), rRel.end(), aIDRel) != rRel.end(); });
2551 if (pRel !=
aSeq.end())
2554 throw container::NoSuchElementException();
2563 SAL_INFO(
"package.xstor",
"Disposed!");
2564 throw lang::DisposedException();
2568 throw uno::RuntimeException();
2572 const beans::StringPair aTypeRel(
"Type",
sType);
2573 std::vector< uno::Sequence<beans::StringPair> > aResult;
2574 aResult.reserve(
aSeq.getLength());
2576 std::copy_if(
aSeq.begin(),
aSeq.end(), std::back_inserter(aResult),
2577 [&aTypeRel](
const uno::Sequence<beans::StringPair>& rRel) {
2578 return std::find(rRel.begin(), rRel.end(), aTypeRel) != rRel.end(); });
2589 SAL_INFO(
"package.xstor",
"Disposed!");
2590 throw lang::DisposedException();
2594 throw uno::RuntimeException();
2605 SAL_INFO(
"package.xstor",
"Disposed!");
2606 throw lang::DisposedException();
2610 throw uno::RuntimeException();
2612 const beans::StringPair aIDRel(
"Id", sID);
2614 uno::Sequence<beans::StringPair>* pPair =
nullptr;
2618 for ( sal_Int32 nInd = 0; nInd <
aSeq.getLength(); nInd++ )
2620 const auto& rRel =
aSeq[nInd];
2621 if (std::find(rRel.begin(), rRel.end(), aIDRel) != rRel.end())
2622 pPair = &
aSeq.getArray()[nInd];
2625 if ( pPair && !bReplace )
2626 throw container::ElementExistException();
2630 sal_Int32 nIDInd =
aSeq.getLength();
2631 aSeq.realloc( nIDInd + 1 );
2632 pPair = &
aSeq.getArray()[nIDInd];
2635 std::vector<beans::StringPair> aResult;
2636 aResult.reserve(aEntry.getLength() + 1);
2638 aResult.push_back(aIDRel);
2639 std::copy_if(aEntry.begin(), aEntry.end(), std::back_inserter(aResult),
2640 [](
const beans::StringPair& rRel) { return rRel.First !=
"Id"; });
2655 SAL_INFO(
"package.xstor",
"Disposed!");
2656 throw lang::DisposedException();
2660 throw uno::RuntimeException();
2663 const beans::StringPair aIDRel(
"Id", sID);
2664 auto pRel = std::find_if(std::cbegin(
aSeq), std::cend(
aSeq),
2665 [&aIDRel](
const uno::Sequence< beans::StringPair >& rRel) {
2666 return std::find(rRel.begin(), rRel.end(), aIDRel) != rRel.end(); });
2667 if (pRel != std::cend(
aSeq))
2669 auto nInd =
static_cast<sal_Int32
>(std::distance(std::cbegin(
aSeq), pRel));
2680 throw container::NoSuchElementException();
2689 SAL_INFO(
"package.xstor",
"Disposed!");
2690 throw lang::DisposedException();
2694 throw uno::RuntimeException();
2696 OUString aIDTag(
"Id" );
2698 std::vector< uno::Sequence<beans::StringPair> > aResultVec;
2699 aResultVec.reserve(
aSeq.getLength() +
aEntries.getLength());
2701 std::copy_if(
aSeq.begin(),
aSeq.end(), std::back_inserter(aResultVec),
2702 [&aIDTag, &
aEntries, bReplace](
const uno::Sequence<beans::StringPair>& rTargetRel) {
2703 auto pTargetPair = lcl_findPairByName(rTargetRel, aIDTag);
2704 if (pTargetPair == rTargetRel.end())
2707 bool bIsSourceSame = std::any_of(aEntries.begin(), aEntries.end(),
2708 [&pTargetPair](const uno::Sequence<beans::StringPair>& rSourceEntry) {
2709 return std::find(rSourceEntry.begin(), rSourceEntry.end(), *pTargetPair) != rSourceEntry.end(); });
2711 if ( bIsSourceSame && !bReplace )
2712 throw container::ElementExistException();
2715 return !bIsSourceSame;
2718 std::transform(
aEntries.begin(),
aEntries.end(), std::back_inserter(aResultVec),
2719 [&aIDTag](
const uno::Sequence<beans::StringPair>& rEntry) -> uno::Sequence<beans::StringPair> {
2720 auto pPair = lcl_findPairByName(rEntry, aIDTag);
2721 if (pPair == rEntry.end())
2722 throw io::IOException();
2724 auto aResult = comphelper::sequenceToContainer<std::vector<beans::StringPair>>(rEntry);
2725 auto nIDInd = std::distance(rEntry.begin(), pPair);
2726 std::rotate(aResult.begin(), std::next(aResult.begin(), nIDInd), std::next(aResult.begin(), nIDInd + 1));
2728 return comphelper::containerToSequence(aResult);
2732 m_pImpl->m_xNewRelInfoStream.clear();
2742 SAL_INFO(
"package.xstor",
"Disposed!");
2743 throw lang::DisposedException();
2747 throw uno::RuntimeException();
2759 return uno::Reference< beans::XPropertySetInfo >();
2768 SAL_INFO(
"package.xstor",
"Disposed!");
2769 throw lang::DisposedException();
2773 static constexpr OUStringLiteral aCompressedString(
u"Compressed" );
2774 static constexpr OUStringLiteral aMediaTypeString(
u"MediaType" );
2775 if (
m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName == aMediaTypeString )
2778 bool bCompressedValueFromType =
true;
2784 if ( aType ==
"image/jpeg" || aType ==
"image/png" || aType ==
"image/gif" )
2785 bCompressedValueFromType =
false;
2790 if ( aPropertyName == rProp.Name )
2791 rProp.
Value = aValue;
2793 rProp.
Value <<= bCompressedValueFromType;
2796 else if ( aPropertyName == aCompressedString )
2802 if ( aPropertyName == rProp.Name )
2803 rProp.Value = aValue;
2807 && aPropertyName ==
"UseCommonStoragePasswordEncryption" )
2809 bool bUseCommonEncryption =
false;
2810 if ( !(aValue >>= bUseCommonEncryption) )
2811 throw lang::IllegalArgumentException();
2818 else if ( bUseCommonEncryption )
2829 else if (
m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName == aMediaTypeString )
2833 if ( aPropertyName == rProp.Name )
2834 rProp.Value = aValue;
2837 else if (
m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName ==
"RelationsInfoStream" )
2839 uno::Reference< io::XInputStream > xInRelStream;
2840 if ( !( aValue >>= xInRelStream ) || !xInRelStream.is() )
2841 throw lang::IllegalArgumentException();
2843 uno::Reference< io::XSeekable > xSeek( xInRelStream, uno::UNO_QUERY );
2849 throw lang::IllegalArgumentException();
2856 else if (
m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName ==
"RelationsInfo" )
2859 throw lang::IllegalArgumentException();
2861 else if ( aPropertyName ==
"Size" )
2862 throw beans::PropertyVetoException();
2864 && ( aPropertyName ==
"IsEncrypted" || aPropertyName ==
"Encrypted" ) )
2865 throw beans::PropertyVetoException();
2866 else if ( aPropertyName ==
"RelId" )
2871 throw beans::UnknownPropertyException(aPropertyName);
2883 SAL_INFO(
"package.xstor",
"Disposed!");
2884 throw lang::DisposedException();
2887 if ( aProp ==
"RelId" )
2892 OUString aPropertyName;
2893 if ( aProp ==
"IsEncrypted" )
2894 aPropertyName =
"Encrypted";
2896 aPropertyName = aProp;
2899 && aPropertyName ==
"MediaType" )
2900 || (
m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName ==
"Encrypted" )
2901 || aPropertyName ==
"Compressed" )
2906 [&aPropertyName](
const css::beans::PropertyValue& rProp){ return aPropertyName == rProp.Name; });
2908 return pProp->Value;
2911 && aPropertyName ==
"UseCommonStoragePasswordEncryption" )
2913 else if ( aPropertyName ==
"Size" )
2915 bool bThrow =
false;
2920 catch (
const io::IOException&)
2925 throw uno::RuntimeException();
2930 throw beans::UnknownPropertyException(aPropertyName);
2935 const uno::Reference< beans::XPropertyChangeListener >& )
2941 SAL_INFO(
"package.xstor",
"Disposed!");
2942 throw lang::DisposedException();
2950 const uno::Reference< beans::XPropertyChangeListener >& )
2956 SAL_INFO(
"package.xstor",
"Disposed!");
2957 throw lang::DisposedException();
2965 const uno::Reference< beans::XVetoableChangeListener >& )
2971 SAL_INFO(
"package.xstor",
"Disposed!");
2972 throw lang::DisposedException();
2980 const uno::Reference< beans::XVetoableChangeListener >& )
2986 SAL_INFO(
"package.xstor",
"Disposed!");
2987 throw lang::DisposedException();
3006 SAL_INFO(
"package.xstor",
"Disposed!");
3007 throw lang::DisposedException();
3010 lang::EventObject aSource( getXWeak() );
3021 OSL_ENSURE( nMessage >= 1 && nMessage <= 4,
"Wrong internal notification code is used!" );
3026 static_cast<embed::XTransactionListener*
>( pIterator.
next( ) )->preCommit( aSource );
3029 static_cast<embed::XTransactionListener*
>( pIterator.
next( ) )->commited( aSource );
3032 static_cast<embed::XTransactionListener*
>( pIterator.
next( ) )->preRevert( aSource );
3035 static_cast< embed::XTransactionListener*
>( pIterator.
next( ) )->reverted( aSource );
3042 SAL_INFO(
"package.xstor",
"package (mv76033) OWriteStream::commit" );
3046 SAL_INFO(
"package.xstor",
"Disposed!");
3047 throw lang::DisposedException();
3051 throw uno::RuntimeException();
3060 SAL_INFO(
"package.xstor",
"Disposed!");
3061 throw lang::DisposedException();
3069 catch(
const io::IOException& )
3074 catch(
const embed::StorageWrappedTargetException& )
3079 catch(
const uno::RuntimeException& )
3084 catch(
const uno::Exception& )
3086 uno::Any aCaught( ::cppu::getCaughtException() );
3088 throw embed::StorageWrappedTargetException(
"Problems on commit!",
3098 SAL_INFO(
"package.xstor",
"package (mv76033) OWriteStream::revert" );
3104 SAL_INFO(
"package.xstor",
"Disposed!");
3105 throw lang::DisposedException();
3109 throw uno::RuntimeException();
3118 SAL_INFO(
"package.xstor",
"Disposed!");
3119 throw lang::DisposedException();
3125 catch (
const io::IOException&)
3130 catch (
const embed::StorageWrappedTargetException&)
3135 catch (
const uno::RuntimeException&)
3140 catch (
const uno::Exception&)
3142 uno::Any aCaught(::cppu::getCaughtException());
3144 throw embed::StorageWrappedTargetException(
"Problems on revert!",
3161 SAL_INFO(
"package.xstor",
"Disposed!");
3162 throw lang::DisposedException();
3166 throw uno::RuntimeException();
3178 SAL_INFO(
"package.xstor",
"Disposed!");
3179 throw lang::DisposedException();
3183 throw uno::RuntimeException();
Reference< XComponentContext > m_xContext
constexpr OUStringLiteral STORAGE_ENCRYPTION_KEYS_PROPERTY
constexpr OUStringLiteral sMediaType
void ModifyParentUnlockMutex_Impl(osl::ClearableMutexGuard &aGuard)
virtual sal_Int32 SAL_CALL available() override
virtual sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nMaxBytesToRead) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
OWriteStream_Impl * m_pImpl
rtl::Reference< comphelper::RefCountedMutex > m_xSharedMutex
virtual void SAL_CALL revert() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual sal_Int64 SAL_CALL getLength() override
virtual void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
virtual void SAL_CALL setEncryptionPassword(const OUString &aPass) override
virtual void SAL_CALL dispose() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual sal_Bool SAL_CALL hasEncryptionData() override
virtual css::uno::Sequence< css::beans::StringPair > SAL_CALL getRelationshipByID(const OUString &sID) override
virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream() override
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenersContainer
bool m_bInStreamDisconnected
virtual void SAL_CALL removeRelationshipByID(const OUString &sID) override
virtual void SAL_CALL addTransactionListener(const css::uno::Reference< css::embed::XTransactionListener > &aListener) override
void CopyToStreamInternally_Impl(const css::uno::Reference< css::io::XStream > &xStream)
virtual void SAL_CALL seek(sal_Int64 location) override
virtual void SAL_CALL insertRelationshipByID(const OUString &sID, const css::uno::Sequence< css::beans::StringPair > &aEntry, sal_Bool bReplace) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream() override
::std::optional< ::cppu::OTypeCollection > m_oTypeCollection
css::uno::Reference< css::io::XSeekable > m_xSeekable
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
void BroadcastTransaction(sal_Int8 nMessage)
virtual void SAL_CALL truncate() override
virtual sal_Int32 SAL_CALL readBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nBytesToRead) override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > SAL_CALL getAllRelationships() override
virtual void SAL_CALL removeEncryption() override
sal_Int64 m_nInitPosition
virtual void SAL_CALL commit() override
virtual void SAL_CALL closeOutput() override
virtual void SAL_CALL removeTransactionListener(const css::uno::Reference< css::embed::XTransactionListener > &aListener) override
OWriteStream(OWriteStream_Impl &rImpl, bool bTransacted)
virtual css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > SAL_CALL getRelationshipsByType(const OUString &sType) override
css::uno::Reference< css::io::XOutputStream > m_xOutStream
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual sal_Int64 SAL_CALL getPosition() override
virtual void SAL_CALL setEncryptionData(const css::uno::Sequence< css::beans::NamedValue > &aEncryptionData) override
virtual OUString SAL_CALL getTypeByID(const OUString &sID) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
css::uno::Reference< css::io::XInputStream > m_xInStream
virtual sal_Bool SAL_CALL hasByID(const OUString &sID) override
virtual OUString SAL_CALL getTargetByID(const OUString &sID) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL flush() override
virtual void SAL_CALL clearRelationships() override
virtual void SAL_CALL insertRelationships(const css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > &aEntries, sal_Bool bReplace) override
virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override
virtual ~OWriteStream() override
virtual void SAL_CALL closeInput() override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
std::size_t WriteBytes(const void *pData, std::size_t nSize)
sal_uInt64 Seek(sal_uInt64 nPos)
css::uno::XInterface * next()
bool hasMoreElements() const
OInterfaceContainerHelper2 * getContainer(const css::uno::Type &rKey) const
sal_Int32 removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
sal_Int32 addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
void disposeAndClear(const css::lang::EventObject &rEvt)
static css::uno::Sequence< css::beans::NamedValue > CreatePackageEncryptionData(std::u16string_view aPassword)
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
SequenceAsHashMapBase::const_iterator const_iterator
css::uno::Sequence< css::beans::NamedValue > getAsConstNamedValueList() const
const css::uno::Sequence< sal_Int8 > & getSeq() const
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
oslInterlockedCount m_refCount
OString exceptionToString(const css::uno::Any &caught)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
uno::Reference< deployment::XPackage > m_xPackage
ScXMLEditAttributeMap::Entry const aEntries[]
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
const sal_Int32 nConstBufferSize
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
void removeElementAt(css::uno::Sequence< T > &_rSeq, sal_Int32 _nPos)
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, SvStream &rOutput)
bool PackageEncryptionDataLessOrEqual(const ::comphelper::SequenceAsHashMap &aHash1, const ::comphelper::SequenceAsHashMap &aHash2)
#define MAX_STORCACHE_SIZE
bool HasModifiedListener() const
static void completeStorageStreamCopy_Impl(const css::uno::Reference< css::io::XStream > &xSource, const css::uno::Reference< css::io::XStream > &xDest, sal_Int32 nStorageType, const css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > &aRelInfo)
::comphelper::SequenceAsHashMap GetCommonRootEncryptionData()
bool m_bHasCommonEncryptionData
css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > m_aNewRelInfo
bool m_bUseCommonEncryption
void CopyInternallyTo_Impl(const css::uno::Reference< css::io::XStream > &xDestStream, const ::comphelper::SequenceAsHashMap &aEncryptionData)
rtl::Reference< comphelper::RefCountedMutex > m_xMutex
css::uno::Reference< css::io::XStream > m_xCacheStream
friend class OWriteStream
bool m_bHasCachedEncryptionData
css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > m_aOrigRelInfo
void SetEncrypted(const ::comphelper::SequenceAsHashMap &aEncryptionData)
css::uno::Reference< css::io::XSeekable > m_xCacheSeek
::comphelper::SequenceAsHashMap GetCommonRootEncryptionData()
css::uno::Reference< css::io::XInputStream > m_xNewRelInfoStream
void GetCopyOfLastCommit(css::uno::Reference< css::io::XStream > &xTargetStream)
css::uno::Reference< css::packages::XDataSinkEncrSupport > m_xPackageStream
::comphelper::SequenceAsHashMap m_aEncryptionData
void ReadRelInfoIfNecessary()
css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > GetAllRelationshipsIfAny()
void CreateReadonlyCopyBasedOnData(const css::uno::Reference< css::io::XInputStream > &xDataToCopy, const css::uno::Sequence< css::beans::PropertyValue > &aProps, css::uno::Reference< css::io::XStream > &xTargetStream)
css::uno::Reference< css::io::XInputStream > GetPlainRawInStream()
sal_Int16 m_nRelInfoStatus
bool m_bCompressedSetExplicit
OWriteStream * m_pAntiImpl
css::uno::Reference< css::io::XInputStream > m_xOrigRelInfoStream
css::uno::Reference< css::io::XInputStream > GetTempFileAsInputStream()
void GetFilledTempFileIfNo(const css::uno::Reference< css::io::XInputStream > &xStream)
std::optional< utl::TempFileFast > m_oTempFile
css::uno::Reference< css::uno::XComponentContext > m_xContext
void CommitStreamRelInfo(const css::uno::Reference< css::embed::XStorage > &xRelStorage, std::u16string_view aOrigStreamName, std::u16string_view aNewStreamName)
bool m_bOrigRelInfoBroken
css::uno::Sequence< css::beans::PropertyValue > const & GetStreamProperties()
OStorage_Impl * m_pParent
css::uno::Reference< css::io::XStream > GetStream(sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap &aEncryptionData, bool bHierarchyAccess)
css::uno::Reference< css::io::XInputStream > GetRawInStream()
void InsertIntoPackageFolder(const OUString &aName, const css::uno::Reference< css::container::XNameContainer > &xParentPackageFolder)
css::uno::Sequence< css::beans::PropertyValue > m_aProps
friend class OInputCompStream
void InputStreamDisposed(OInputCompStream *pStream)
void InsertStreamDirectly(const css::uno::Reference< css::io::XInputStream > &xInStream, const css::uno::Sequence< css::beans::PropertyValue > &aProps)
bool m_bHasInsertedStreamOptimization
css::uno::Reference< css::lang::XSingleServiceFactory > m_xPackage
css::uno::Reference< css::io::XStream > GetStream_Impl(sal_Int32 nStreamMode, bool bHierarchyAccess)
css::uno::Reference< css::io::XStream > GetTempFileAsStream()
css::uno::Sequence< css::beans::PropertyValue > ReadPackageStreamProperties()
void FillTempGetFileName()
std::vector< OInputCompStream * > m_aInputStreamsVector
css::uno::Sequence< css::beans::PropertyValue > InsertOwnProps(const css::uno::Sequence< css::beans::PropertyValue > &aProps, bool bUseCommonEncryption)
OWriteStream_Impl(OStorage_Impl *pParent, const css::uno::Reference< css::packages::XDataSinkEncrSupport > &xPackageStream, const css::uno::Reference< css::lang::XSingleServiceFactory > &xPackage, css::uno::Reference< css::uno::XComponentContext > xContext, bool bForceEncrypted, sal_Int32 nStorageType, bool bDefaultCompress, css::uno::Reference< css::io::XInputStream > xRelInfoStream=css::uno::Reference< css::io::XInputStream >())
#define STOR_MESS_PREREVERT
#define STOR_MESS_COMMITTED
#define STOR_MESS_REVERTED
#define RELINFO_CHANGED_STREAM_READ
#define RELINFO_CHANGED_BROKEN
#define STOR_MESS_PRECOMMIT
#define RELINFO_CHANGED_STREAM