summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-10-13 09:54:28 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-10-23 14:30:30 +0200
commit1b3122a1895e6eff7341fda39a5f68d7a60c7aa0 (patch)
treeba255b57efda771d9ce2376ad375836c39427e0c /package
parent152c4afef44d6e6456777a7cd0de4e3a3a2a9338 (diff)
package: Add pure virtual ZipPackageEntry::saveChild()
..and adapt what needs to be changed. So that, we can kill at least some usages of horrible ContentInfo struct. Change-Id: I32d41f3b8ce2dfb65f0d1df18a540a3f67dcab6d
Diffstat (limited to 'package')
-rw-r--r--package/inc/ZipPackageEntry.hxx17
-rw-r--r--package/inc/ZipPackageFolder.hxx24
-rw-r--r--package/inc/ZipPackageStream.hxx13
-rw-r--r--package/source/zippackage/ZipPackage.cxx8
-rw-r--r--package/source/zippackage/ZipPackageEntry.cxx5
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx157
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx11
7 files changed, 116 insertions, 119 deletions
diff --git a/package/inc/ZipPackageEntry.hxx b/package/inc/ZipPackageEntry.hxx
index cfe1895f2804..d1ff8de8b5cf 100644
--- a/package/inc/ZipPackageEntry.hxx
+++ b/package/inc/ZipPackageEntry.hxx
@@ -21,13 +21,19 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <ZipEntry.hxx>
#include <cppuhelper/implbase5.hxx>
+#include <vector>
+
+typedef void* rtlRandomPool;
+class ZipOutputStream;
class ZipPackageFolder;
class ZipPackageEntry : public cppu::WeakImplHelper5
@@ -40,15 +46,18 @@ class ZipPackageEntry : public cppu::WeakImplHelper5
>
{
protected:
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
OUString msName;
bool mbIsFolder:1;
bool mbAllowRemoveOnInsert:1;
// com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xParent;
OUString msMediaType;
ZipPackageFolder* mpParent;
+ sal_Int32 m_nFormat;
+
public:
ZipEntry aEntry;
- ZipPackageEntry ( bool bNewFolder = false );
+ ZipPackageEntry();
virtual ~ZipPackageEntry( void );
const OUString& GetMediaType () const { return msMediaType; }
@@ -58,6 +67,12 @@ public:
const ZipPackageFolder* GetParent () const { return mpParent; }
void SetFolder ( bool bSetFolder ) { mbIsFolder = bSetFolder; }
+ virtual bool saveChild( const OUString &rPath,
+ std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
+ ZipOutputStream & rZipOut,
+ const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
+ const rtlRandomPool &rRandomPool ) = 0;
+
void clearParent ( void )
{
// xParent.clear();
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index dd0ff95ba8ad..52a64e6dee02 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -28,20 +28,8 @@
#include <cppuhelper/implbase2.hxx>
#include <vector>
-namespace com { namespace sun { namespace star {
-namespace beans
-{
- struct PropertyValue;
-}
-namespace packages
-{
- class ContentInfo;
-}
-} } }
-
class ZipOutputStream;
struct ZipEntry;
-typedef void* rtlRandomPool;
class ZipPackageFolder : public cppu::ImplInheritanceHelper2
<
@@ -51,14 +39,12 @@ class ZipPackageFolder : public cppu::ImplInheritanceHelper2
>
{
private:
- css::uno::Reference< css::uno::XComponentContext> m_xContext;
ContentHash maContents;
- sal_Int32 m_nFormat;
OUString m_sVersion;
public:
- ZipPackageFolder( css::uno::Reference< css::uno::XComponentContext> xContext,
+ ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext,
sal_Int32 nFormat,
bool bAllowRemoveOnInsert );
virtual ~ZipPackageFolder();
@@ -80,7 +66,13 @@ public:
static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId();
void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
- void setRemoveOnInsertMode_Impl( bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
+ void setRemoveOnInsertMode_Impl( bool bRemove ) { mbAllowRemoveOnInsert = bRemove; }
+
+ virtual bool saveChild( const OUString &rPath,
+ std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
+ ZipOutputStream & rZipOut,
+ const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
+ const rtlRandomPool &rRandomPool ) SAL_OVERRIDE;
// Recursive functions
void saveContents(
diff --git a/package/inc/ZipPackageStream.hxx b/package/inc/ZipPackageStream.hxx
index d7c19f1636f8..758dbb8e4d70 100644
--- a/package/inc/ZipPackageStream.hxx
+++ b/package/inc/ZipPackageStream.hxx
@@ -48,7 +48,6 @@ class ZipPackageStream : public cppu::ImplInheritanceHelper2
{
private:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xStream;
- const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
ZipPackage &m_rZipPackage;
bool m_bToBeCompressed, m_bToBeEncrypted, m_bHaveOwnKey, m_bIsEncrypted;
@@ -140,9 +139,10 @@ public:
void CloseOwnStreamIfAny();
- ZipPackageStream ( ZipPackage & rNewPackage,
- const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& xContext,
- bool bAllowRemoveOnInsert );
+ ZipPackageStream( ZipPackage & rNewPackage,
+ const css::uno::Reference < css::uno::XComponentContext >& xContext,
+ sal_Int32 nFormat,
+ bool bAllowRemoveOnInsert );
virtual ~ZipPackageStream( void );
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetRawEncrStreamNoHeaderCopy();
@@ -150,6 +150,11 @@ public:
bool bAddHeaderForEncr );
bool ParsePackageRawStream();
+ virtual bool saveChild( const OUString &rPath,
+ std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
+ ZipOutputStream & rZipOut,
+ const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
+ const rtlRandomPool &rRandomPool ) SAL_OVERRIDE;
void setZipEntryOnLoading( const ZipEntry &rInEntry);
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData()
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 0a26c5a2591d..63fee5d30771 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -556,7 +556,7 @@ void ZipPackage::getZipFileContents()
{
nStreamIndex++;
sTemp = rName.copy( nStreamIndex, rName.getLength() - nStreamIndex );
- pPkgStream = new ZipPackageStream( *this, m_xContext, m_bAllowRemoveOnInsert );
+ pPkgStream = new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
pPkgStream->SetPackageMember( true );
pPkgStream->setZipEntryOnLoading( rEntry );
pPkgStream->setName( sTemp );
@@ -942,7 +942,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
uno::Reference< XInterface > SAL_CALL ZipPackage::createInstance()
throw( Exception, RuntimeException, std::exception )
{
- uno::Reference < XInterface > xRef = *( new ZipPackageStream ( *this, m_xContext, m_bAllowRemoveOnInsert ) );
+ uno::Reference < XInterface > xRef = *( new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert ) );
return xRef;
}
@@ -954,9 +954,9 @@ uno::Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( c
if ( aArguments.getLength() )
aArguments[0] >>= bArg;
if ( bArg )
- xRef = *new ZipPackageFolder ( m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
+ xRef = *new ZipPackageFolder( m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
else
- xRef = *new ZipPackageStream ( *this, m_xContext, m_bAllowRemoveOnInsert );
+ xRef = *new ZipPackageStream( *this, m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
return xRef;
}
diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx
index 860f7170434d..4d5d63d25197 100644
--- a/package/source/zippackage/ZipPackageEntry.cxx
+++ b/package/source/zippackage/ZipPackageEntry.cxx
@@ -40,9 +40,8 @@ using namespace com::sun::star::packages::zip::ZipConstants;
#define THROW_WHERE ""
#endif
-ZipPackageEntry::ZipPackageEntry ( bool bNewFolder )
-: mbIsFolder ( bNewFolder )
-, mbAllowRemoveOnInsert( true )
+ZipPackageEntry::ZipPackageEntry()
+: mbIsFolder( false )
, mpParent ( NULL )
{
}
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index c6a3b372a399..60b229694510 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -61,14 +61,13 @@ using namespace ::com::sun::star;
namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationId, lcl_CachedImplId > {}; }
-ZipPackageFolder::ZipPackageFolder ( css::uno::Reference< css::uno::XComponentContext> xContext,
- sal_Int32 nFormat,
- bool bAllowRemoveOnInsert )
- : m_xContext( xContext )
- , m_nFormat( nFormat )
+ZipPackageFolder::ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext,
+ sal_Int32 nFormat,
+ bool bAllowRemoveOnInsert )
{
- this->mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
-
+ m_xContext = xContext;
+ m_nFormat = nFormat;
+ mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
SetFolder ( true );
aEntry.nVersion = -1;
aEntry.nFlag = 0;
@@ -297,14 +296,12 @@ static void ImplSetStoredData( ZipEntry & rEntry, uno::Reference< XInputStream>
rEntry.nCrc = aCRC32.getValue();
}
-static bool ZipPackageFolder_saveChild(
- const ContentInfo &rInfo,
+bool ZipPackageFolder::saveChild(
const OUString &rPath,
std::vector < uno::Sequence < PropertyValue > > &rManList,
ZipOutputStream & rZipOut,
const uno::Sequence < sal_Int8 >& rEncryptionKey,
- const rtlRandomPool &rRandomPool,
- sal_Int32 nFormat)
+ const rtlRandomPool &rRandomPool)
{
bool bSuccess = true;
@@ -313,42 +310,35 @@ static bool ZipPackageFolder_saveChild(
const OUString sFullPathProperty ("FullPath");
uno::Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
-
- assert( rInfo.bFolder && rInfo.pFolder && "A valid child object is expected!" );
-
OUString sTempName = rPath + "/";
- if ( !rInfo.pFolder->GetMediaType().isEmpty() )
+ if ( !GetMediaType().isEmpty() )
{
aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
- aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pFolder->GetMediaType();
+ aPropSet[PKG_MNFST_MEDIATYPE].Value <<= GetMediaType();
aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
- aPropSet[PKG_MNFST_VERSION].Value <<= rInfo.pFolder->GetVersion();
+ aPropSet[PKG_MNFST_VERSION].Value <<= GetVersion();
aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName;
}
else
aPropSet.realloc( 0 );
- rInfo.pFolder->saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
+ saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
// folder can have a mediatype only in package format
- if ( aPropSet.getLength()
- && ( nFormat == embed::StorageFormats::PACKAGE || ( nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
+ if ( aPropSet.getLength() && ( m_nFormat == embed::StorageFormats::PACKAGE ) )
rManList.push_back( aPropSet );
return bSuccess;
}
-static bool ZipPackageStream_saveChild(
- css::uno::Reference< css::uno::XComponentContext> xContext,
- const ContentInfo &rInfo,
+bool ZipPackageStream::saveChild(
const OUString &rPath,
std::vector < uno::Sequence < PropertyValue > > &rManList,
ZipOutputStream & rZipOut,
const uno::Sequence < sal_Int8 >& rEncryptionKey,
- const rtlRandomPool &rRandomPool,
- sal_Int32 nFormat)
+ const rtlRandomPool &rRandomPool)
{
bool bSuccess = true;
@@ -367,8 +357,6 @@ static bool ZipPackageStream_saveChild(
uno::Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
- assert( !rInfo.bFolder && rInfo.pStream && "A valid child object is expected!" );
-
// if pTempEntry is necessary, it will be released and passed to the ZipOutputStream
// and be deleted in the ZipOutputStream destructor
unique_ptr < ZipEntry > pAutoTempEntry ( new ZipEntry );
@@ -377,42 +365,42 @@ static bool ZipPackageStream_saveChild(
// In case the entry we are reading is also the entry we are writing, we will
// store the ZipEntry data in pTempEntry
- ZipPackageFolder::copyZipEntry ( *pTempEntry, rInfo.pStream->aEntry );
+ ZipPackageFolder::copyZipEntry ( *pTempEntry, aEntry );
pTempEntry->sPath = rPath;
pTempEntry->nPathLen = (sal_Int16)( OUStringToOString( pTempEntry->sPath, RTL_TEXTENCODING_UTF8 ).getLength() );
- bool bToBeEncrypted = rInfo.pStream->IsToBeEncrypted() && (rEncryptionKey.getLength() || rInfo.pStream->HasOwnKey());
- bool bToBeCompressed = bToBeEncrypted ? sal_True : rInfo.pStream->IsToBeCompressed();
+ bool bToBeEncrypted = IsToBeEncrypted() && (rEncryptionKey.getLength() || HasOwnKey());
+ bool bToBeCompressed = bToBeEncrypted ? sal_True : IsToBeCompressed();
aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
- aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pStream->GetMediaType( );
+ aPropSet[PKG_MNFST_MEDIATYPE].Value <<= GetMediaType( );
aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
aPropSet[PKG_MNFST_VERSION].Value <<= OUString(); // no version is stored for streams currently
aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
aPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
- OSL_ENSURE( rInfo.pStream->GetStreamMode() != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" );
+ OSL_ENSURE( GetStreamMode() != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" );
bool bRawStream = false;
- if ( rInfo.pStream->GetStreamMode() == PACKAGE_STREAM_DETECT )
- bRawStream = rInfo.pStream->ParsePackageRawStream();
- else if ( rInfo.pStream->GetStreamMode() == PACKAGE_STREAM_RAW )
+ if ( GetStreamMode() == PACKAGE_STREAM_DETECT )
+ bRawStream = ParsePackageRawStream();
+ else if ( GetStreamMode() == PACKAGE_STREAM_RAW )
bRawStream = true;
bool bTransportOwnEncrStreamAsRaw = false;
// During the storing the original size of the stream can be changed
// TODO/LATER: get rid of this hack
- sal_Int64 nOwnStreamOrigSize = bRawStream ? rInfo.pStream->GetMagicalHackSize() : rInfo.pStream->getSize();
+ sal_Int64 nOwnStreamOrigSize = bRawStream ? GetMagicalHackSize() : getSize();
bool bUseNonSeekableAccess = false;
uno::Reference < XInputStream > xStream;
- if ( !rInfo.pStream->IsPackageMember() && !bRawStream && !bToBeEncrypted && bToBeCompressed )
+ if ( !IsPackageMember() && !bRawStream && !bToBeEncrypted && bToBeCompressed )
{
// the stream is not a package member, not a raw stream,
// it should not be encrypted and it should be compressed,
// in this case nonseekable access can be used
- xStream = rInfo.pStream->GetOwnStreamNoWrap();
+ xStream = GetOwnStreamNoWrap();
uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
bUseNonSeekableAccess = ( xStream.is() && !xSeek.is() );
@@ -420,7 +408,7 @@ static bool ZipPackageStream_saveChild(
if ( !bUseNonSeekableAccess )
{
- xStream = rInfo.pStream->getRawData();
+ xStream = getRawData();
if ( !xStream.is() )
{
@@ -440,7 +428,7 @@ static bool ZipPackageStream_saveChild(
{
// The raw stream can neither be encrypted nor connected
OSL_ENSURE( !bRawStream || !(bToBeCompressed || bToBeEncrypted), "The stream is already encrypted!\n" );
- xSeek->seek ( bRawStream ? rInfo.pStream->GetMagicalHackPos() : 0 );
+ xSeek->seek ( bRawStream ? GetMagicalHackPos() : 0 );
ImplSetStoredData ( *pTempEntry, xStream );
// TODO/LATER: Get rid of hacks related to switching of Flag Method and Size properties!
@@ -460,10 +448,10 @@ static bool ZipPackageStream_saveChild(
// check if it's one of our own streams, if it is then we know that
// each time we ask for it we'll get a new stream that will be
// at position zero...otherwise, assert and skip this stream...
- if ( rInfo.pStream->IsPackageMember() )
+ if ( IsPackageMember() )
{
// if the password has been changed than the stream should not be package member any more
- if ( rInfo.pStream->IsEncrypted() && rInfo.pStream->IsToBeEncrypted() )
+ if ( IsEncrypted() && IsToBeEncrypted() )
{
// Should be handled close to the raw stream handling
bTransportOwnEncrStreamAsRaw = true;
@@ -492,17 +480,17 @@ static bool ZipPackageStream_saveChild(
{
if ( bToBeEncrypted && !bTransportOwnEncrStreamAsRaw )
{
- uno::Sequence < sal_Int8 > aSalt( 16 ), aVector( rInfo.pStream->GetBlockSize() );
+ uno::Sequence < sal_Int8 > aSalt( 16 ), aVector( GetBlockSize() );
rtl_random_getBytes ( rRandomPool, aSalt.getArray(), 16 );
rtl_random_getBytes ( rRandomPool, aVector.getArray(), aVector.getLength() );
sal_Int32 nIterationCount = 1024;
- if ( !rInfo.pStream->HasOwnKey() )
- rInfo.pStream->setKey ( rEncryptionKey );
+ if ( !HasOwnKey() )
+ setKey ( rEncryptionKey );
- rInfo.pStream->setInitialisationVector ( aVector );
- rInfo.pStream->setSalt ( aSalt );
- rInfo.pStream->setIterationCount ( nIterationCount );
+ setInitialisationVector ( aVector );
+ setSalt ( aSalt );
+ setIterationCount ( nIterationCount );
}
// last property is digest, which is inserted later if we didn't have
@@ -510,11 +498,11 @@ static bool ZipPackageStream_saveChild(
aPropSet.realloc(PKG_SIZE_ENCR_MNFST);
aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
- aPropSet[PKG_MNFST_INIVECTOR].Value <<= rInfo.pStream->getInitialisationVector();
+ aPropSet[PKG_MNFST_INIVECTOR].Value <<= getInitialisationVector();
aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
- aPropSet[PKG_MNFST_SALT].Value <<= rInfo.pStream->getSalt();
+ aPropSet[PKG_MNFST_SALT].Value <<= getSalt();
aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
- aPropSet[PKG_MNFST_ITERATION].Value <<= rInfo.pStream->getIterationCount ();
+ aPropSet[PKG_MNFST_ITERATION].Value <<= getIterationCount ();
// Need to store the uncompressed size in the manifest
OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
@@ -523,12 +511,12 @@ static bool ZipPackageStream_saveChild(
if ( bRawStream || bTransportOwnEncrStreamAsRaw )
{
- ::rtl::Reference< EncryptionData > xEncData = rInfo.pStream->GetEncryptionData();
+ ::rtl::Reference< EncryptionData > xEncData = GetEncryptionData();
if ( !xEncData.is() )
throw uno::RuntimeException();
aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
- aPropSet[PKG_MNFST_DIGEST].Value <<= rInfo.pStream->getDigest();
+ aPropSet[PKG_MNFST_DIGEST].Value <<= getDigest();
aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
@@ -545,15 +533,15 @@ static bool ZipPackageStream_saveChild(
// want for this write...copy it raw
if ( !bUseNonSeekableAccess
&& ( bRawStream || bTransportOwnEncrStreamAsRaw
- || ( rInfo.pStream->IsPackageMember() && !bToBeEncrypted
- && ( ( rInfo.pStream->aEntry.nMethod == DEFLATED && bToBeCompressed )
- || ( rInfo.pStream->aEntry.nMethod == STORED && !bToBeCompressed ) ) ) ) )
+ || ( IsPackageMember() && !bToBeEncrypted
+ && ( ( aEntry.nMethod == DEFLATED && bToBeCompressed )
+ || ( aEntry.nMethod == STORED && !bToBeCompressed ) ) ) ) )
{
// If it's a PackageMember, then it's an unbuffered stream and we need
// to get a new version of it as we can't seek backwards.
- if ( rInfo.pStream->IsPackageMember() )
+ if ( IsPackageMember() )
{
- xStream = rInfo.pStream->getRawData();
+ xStream = getRawData();
if ( !xStream.is() )
{
// Make sure that we actually _got_ a new one !
@@ -565,9 +553,9 @@ static bool ZipPackageStream_saveChild(
try
{
if ( bRawStream )
- xStream->skipBytes( rInfo.pStream->GetMagicalHackPos() );
+ xStream->skipBytes( GetMagicalHackPos() );
- ZipOutputEntry aZipEntry(xContext, rZipOut.getChucker(), *pTempEntry, rInfo.pStream, false);
+ ZipOutputEntry aZipEntry(m_xContext, rZipOut.getChucker(), *pTempEntry, this, false);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release();
@@ -605,9 +593,9 @@ static bool ZipPackageStream_saveChild(
// If it's a PackageMember, then our previous reference held a 'raw' stream
// so we need to re-get it, unencrypted, uncompressed and positioned at the
// beginning of the stream
- if ( rInfo.pStream->IsPackageMember() )
+ if ( IsPackageMember() )
{
- xStream = rInfo.pStream->getInputStream();
+ xStream = getInputStream();
if ( !xStream.is() )
{
// Make sure that we actually _got_ a new one !
@@ -625,7 +613,7 @@ static bool ZipPackageStream_saveChild(
try
{
- ZipOutputEntry aZipEntry(xContext, rZipOut.getChucker(), *pTempEntry, rInfo.pStream, bToBeEncrypted);
+ ZipOutputEntry aZipEntry(m_xContext, rZipOut.getChucker(), *pTempEntry, this, bToBeEncrypted);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release();
@@ -652,12 +640,12 @@ static bool ZipPackageStream_saveChild(
if ( bToBeEncrypted )
{
- ::rtl::Reference< EncryptionData > xEncData = rInfo.pStream->GetEncryptionData();
+ ::rtl::Reference< EncryptionData > xEncData = GetEncryptionData();
if ( !xEncData.is() )
throw uno::RuntimeException();
aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
- aPropSet[PKG_MNFST_DIGEST].Value <<= rInfo.pStream->getDigest();
+ aPropSet[PKG_MNFST_DIGEST].Value <<= getDigest();
aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
@@ -667,45 +655,44 @@ static bool ZipPackageStream_saveChild(
aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
- rInfo.pStream->SetIsEncrypted ( true );
+ SetIsEncrypted ( true );
}
}
if( bSuccess )
{
- if ( !rInfo.pStream->IsPackageMember() )
+ if ( !IsPackageMember() )
{
- rInfo.pStream->CloseOwnStreamIfAny();
- rInfo.pStream->SetPackageMember ( true );
+ CloseOwnStreamIfAny();
+ SetPackageMember ( true );
}
if ( bRawStream )
{
// the raw stream was integrated and now behaves
// as usual encrypted stream
- rInfo.pStream->SetToBeEncrypted( true );
+ SetToBeEncrypted( true );
}
// Then copy it back afterwards...
- ZipPackageFolder::copyZipEntry ( rInfo.pStream->aEntry, *pTempEntry );
+ ZipPackageFolder::copyZipEntry ( aEntry, *pTempEntry );
// Remove hacky bit from entry flags
- if ( rInfo.pStream->aEntry.nFlag & ( 1 << 4 ) )
+ if ( aEntry.nFlag & ( 1 << 4 ) )
{
- rInfo.pStream->aEntry.nFlag &= ~( 1 << 4 );
- rInfo.pStream->aEntry.nMethod = STORED;
+ aEntry.nFlag &= ~( 1 << 4 );
+ aEntry.nMethod = STORED;
}
// TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving )
- if ( rInfo.pStream->IsEncrypted() )
- rInfo.pStream->setSize( nOwnStreamOrigSize );
+ if ( IsEncrypted() )
+ setSize( nOwnStreamOrigSize );
- rInfo.pStream->aEntry.nOffset *= -1;
+ aEntry.nOffset *= -1;
}
- // folder can have a mediatype only in package format
if ( aPropSet.getLength()
- && ( nFormat == embed::StorageFormats::PACKAGE || ( nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
+ && ( m_nFormat == embed::StorageFormats::PACKAGE || m_nFormat == embed::StorageFormats::OFOPXML ) )
rManList.push_back( aPropSet );
return bSuccess;
@@ -755,8 +742,8 @@ void ZipPackageFolder::saveContents(
if ( aIter != maContents.end() && !(*aIter).second->bFolder )
{
bMimeTypeStreamStored = true;
- bWritingFailed = !ZipPackageStream_saveChild( m_xContext,
- *aIter->second, rPath + aIter->first, rManList, rZipOut, rEncryptionKey, rRandomPool, m_nFormat );
+ bWritingFailed = !aIter->second->pStream->saveChild(
+ rPath + aIter->first, rManList, rZipOut, rEncryptionKey, rRandomPool );
}
}
@@ -771,13 +758,13 @@ void ZipPackageFolder::saveContents(
{
if (rInfo.bFolder)
{
- bWritingFailed = !ZipPackageFolder_saveChild(
- rInfo, rPath + rShortName, rManList, rZipOut, rEncryptionKey, rRandomPool, m_nFormat );
+ bWritingFailed = !rInfo.pFolder->saveChild(
+ rPath + rShortName, rManList, rZipOut, rEncryptionKey, rRandomPool );
}
else
{
- bWritingFailed = !ZipPackageStream_saveChild( m_xContext,
- rInfo, rPath + rShortName, rManList, rZipOut, rEncryptionKey, rRandomPool, m_nFormat );
+ bWritingFailed = !rInfo.pStream->saveChild(
+ rPath + rShortName, rManList, rZipOut, rEncryptionKey, rRandomPool );
}
}
}
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 01defa9555c6..17b144fa20e3 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -69,9 +69,9 @@ namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationI
ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
const uno::Reference< XComponentContext >& xContext,
+ sal_Int32 nFormat,
bool bAllowRemoveOnInsert )
-: m_xContext( xContext )
-, m_rZipPackage( rNewPackage )
+: m_rZipPackage( rNewPackage )
, m_bToBeCompressed ( true )
, m_bToBeEncrypted ( false )
, m_bHaveOwnKey ( false )
@@ -88,10 +88,9 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
, m_bFromManifest( false )
, m_bUseWinEncoding( false )
{
- OSL_ENSURE( m_xContext.is(), "No factory is provided to ZipPackageStream!\n" );
-
- this->mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
-
+ m_xContext = xContext;
+ m_nFormat = nFormat;
+ mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
SetFolder ( false );
aEntry.nVersion = -1;
aEntry.nFlag = 0;