[Libreoffice-commits] core.git: 6 commits - package/inc package/source sax/source sd/source

Matúš Kukan matus.kukan at collabora.com
Fri Oct 10 04:46:13 PDT 2014


 package/inc/ZipOutputStream.hxx                |   27 -
 package/inc/ZipPackageEntry.hxx                |   12 
 package/inc/ZipPackageFolder.hxx               |   11 
 package/source/zipapi/ZipOutputStream.cxx      |  241 ++++-----
 package/source/zippackage/ZipPackage.cxx       |    3 
 package/source/zippackage/ZipPackageEntry.cxx  |   24 
 package/source/zippackage/ZipPackageFolder.cxx |  627 +++++++++++++------------
 package/source/zippackage/ZipPackageStream.cxx |   16 
 sax/source/tools/fastserializer.cxx            |    9 
 sd/source/filter/eppt/epptooxml.hxx            |    1 
 sd/source/filter/eppt/pptx-epptooxml.cxx       |    3 
 11 files changed, 496 insertions(+), 478 deletions(-)

New commits:
commit ae0756d8266bb92dfe04473a6b15cbb3fb7a0b69
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Oct 9 13:15:22 2014 +0200

    ZipOutputStream: No need to explicitly set default values
    
    Change-Id: Ia3a20e0692e658d847e1b825fc97e32ac8a1854b

diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index a8d106b..146e642 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -52,7 +52,7 @@ protected:
     CRC32               m_aCRC;
     ByteChucker         m_aChucker;
     ZipEntry            *m_pCurrentEntry;
-    sal_Int16           m_nMethod, m_nLevel, m_nDigested;
+    sal_Int16           m_nDigested;
     bool                m_bFinished, m_bEncryptCurrentEntry;
     ZipPackageStream*   m_pCurrentStream;
 
@@ -69,10 +69,6 @@ public:
         throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
 
     // XZipOutputStream interfaces
-    void SAL_CALL setMethod( sal_Int32 nNewMethod )
-        throw(::com::sun::star::uno::RuntimeException);
-    void SAL_CALL setLevel( sal_Int32 nNewLevel )
-        throw(::com::sun::star::uno::RuntimeException);
     void SAL_CALL putNextEntry( ZipEntry& rEntry,
             ZipPackageStream* pStream,
             bool bEncrypt = false )
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index 0a64d09..34f0979 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -45,8 +45,6 @@ ZipOutputStream::ZipOutputStream( const uno::Reference< uno::XComponentContext >
 , m_aDeflater(DEFAULT_COMPRESSION, true)
 , m_aChucker(xOStream)
 , m_pCurrentEntry(NULL)
-, m_nMethod(DEFLATED)
-, m_nLevel(0)
 , m_nDigested(0)
 , m_bFinished(false)
 , m_bEncryptCurrentEntry(false)
@@ -60,17 +58,6 @@ ZipOutputStream::~ZipOutputStream( void )
         delete m_aZipList[i];
 }
 
-void SAL_CALL ZipOutputStream::setMethod( sal_Int32 nNewMethod )
-    throw(RuntimeException)
-{
-    m_nMethod = static_cast < sal_Int16 > (nNewMethod);
-}
-void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel )
-    throw(RuntimeException)
-{
-    m_aDeflater.setLevel( nNewLevel);
-}
-
 void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
                         ZipPackageStream* pStream,
                         bool bEncrypt)
@@ -81,7 +68,7 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
     if (rEntry.nTime == -1)
         rEntry.nTime = getCurrentDosTime();
     if (rEntry.nMethod == -1)
-        rEntry.nMethod = m_nMethod;
+        rEntry.nMethod = DEFLATED;
     rEntry.nVersion = 20;
     rEntry.nFlag = 1 << 11;
     if (rEntry.nSize == -1 || rEntry.nCompressedSize == -1 ||
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 6dd1e82..3bc0627 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1139,9 +1139,6 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
 
     // Hand it to the ZipOutputStream:
     ZipOutputStream aZipOut( m_xContext, xTempOut );
-    aZipOut.setMethod( DEFLATED );
-    aZipOut.setLevel( DEFAULT_COMPRESSION );
-
     try
     {
         if ( m_nFormat == embed::StorageFormats::PACKAGE )
commit 9f495d128e9e1cc05b2e1f56f11f1ac4055d738d
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Oct 7 16:04:13 2014 +0200

    Split ZipPackageFolder::saveChild into two functions
    
    And make them static. Probably would be better to kill ContentInfo and
    add saveChild as pure virtual into ZipPackageEntry, from which are both
    ZipPackageFolder and ZipPackageStream inheriting.
    
    This will also create a bit more sensible call graph when profiling.
    
    Change-Id: If8151332cfa6359e8736c912b7a5633a9162ab36

diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index 81eddd7..6053b48 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -79,10 +79,13 @@ public:
     void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
     void setRemoveOnInsertMode_Impl( bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
 
-    bool saveChild(const OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool & rRandomPool) const;
-
     // Recursive functions
-    void  saveContents(OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool) const
+    void saveContents(
+            const OUString &rPath,
+            std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList,
+            ZipOutputStream & rZipOut,
+            const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey,
+            const rtlRandomPool & rRandomPool) const
         throw(::com::sun::star::uno::RuntimeException);
     void  releaseUpwardRef();
 
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 9855dc1..c0baf90 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -294,7 +294,57 @@ static void ImplSetStoredData( ZipEntry & rEntry, uno::Reference< XInputStream>
     rEntry.nCrc = aCRC32.getValue();
 }
 
-bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo &rInfo, OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool &rRandomPool) const
+static bool ZipPackageFolder_saveChild(
+        const ContentInfo &rInfo,
+        const OUString &rPath,
+        std::vector < uno::Sequence < PropertyValue > > &rManList,
+        ZipOutputStream & rZipOut,
+        const uno::Sequence < sal_Int8 >& rEncryptionKey,
+        const rtlRandomPool &rRandomPool,
+        sal_Int32 nFormat)
+{
+    bool bSuccess = true;
+
+    const OUString sMediaTypeProperty ("MediaType");
+    const OUString sVersionProperty ("Version");
+    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() )
+    {
+        aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+        aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pFolder->GetMediaType();
+        aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
+        aPropSet[PKG_MNFST_VERSION].Value <<= rInfo.pFolder->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);
+
+    // folder can have a mediatype only in package format
+    if ( aPropSet.getLength()
+      && ( nFormat == embed::StorageFormats::PACKAGE || ( nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
+        rManList.push_back( aPropSet );
+
+    return bSuccess;
+}
+
+static bool ZipPackageStream_saveChild(
+        const ContentInfo &rInfo,
+        const OUString &rPath,
+        std::vector < uno::Sequence < PropertyValue > > &rManList,
+        ZipOutputStream & rZipOut,
+        const uno::Sequence < sal_Int8 >& rEncryptionKey,
+        const rtlRandomPool &rRandomPool,
+        sal_Int32 nFormat)
 {
     bool bSuccess = true;
 
@@ -309,311 +359,165 @@ bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo
     const OUString sEncryptionAlgProperty    ("EncryptionAlgorithm");
     const OUString sStartKeyAlgProperty  ("StartKeyAlgorithm");
     const OUString sDigestAlgProperty    ("DigestAlgorithm");
-    const OUString  sDerivedKeySizeProperty  ("DerivedKeySize");
+    const OUString sDerivedKeySizeProperty  ("DerivedKeySize");
 
     uno::Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
 
-    OSL_ENSURE( ( rInfo.bFolder && rInfo.pFolder ) || ( !rInfo.bFolder && rInfo.pStream ), "A valid child object is expected!" );
-    if ( rInfo.bFolder )
-    {
-        OUString sTempName = rPath + rShortName + "/";
+    assert( !rInfo.bFolder && rInfo.pStream && "A valid child object is expected!" );
 
-        if ( !rInfo.pFolder->GetMediaType().isEmpty() )
-        {
-            aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
-            aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pFolder->GetMediaType();
-            aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
-            aPropSet[PKG_MNFST_VERSION].Value <<= rInfo.pFolder->GetVersion();
-            aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
-            aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName;
-        }
-        else
-            aPropSet.realloc( 0 );
+    // 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 );
+    ZipEntry* pTempEntry = pAutoTempEntry.get();
 
-        rInfo.pFolder->saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
-    }
-    else
-    {
-        // 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 );
-        ZipEntry* pTempEntry = pAutoTempEntry.get();
+    // In case the entry we are reading is also the entry we are writing, we will
+    // store the ZipEntry data in pTempEntry
 
-        // 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 );
+    pTempEntry->sPath = rPath;
+    pTempEntry->nPathLen = (sal_Int16)( OUStringToOString( pTempEntry->sPath, RTL_TEXTENCODING_UTF8 ).getLength() );
 
-        ZipPackageFolder::copyZipEntry ( *pTempEntry, rInfo.pStream->aEntry );
-        pTempEntry->sPath = rPath + rShortName;
-        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 = rInfo.pStream->IsToBeEncrypted() && (rEncryptionKey.getLength() || rInfo.pStream->HasOwnKey());
-        bool bToBeCompressed = bToBeEncrypted ? sal_True : rInfo.pStream->IsToBeCompressed();
+    aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+    aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pStream->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;
 
-        aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
-        aPropSet[PKG_MNFST_MEDIATYPE].Value <<= rInfo.pStream->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( rInfo.pStream->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 )
+        bRawStream = true;
 
-        bool bRawStream = false;
-        if ( rInfo.pStream->GetStreamMode() == PACKAGE_STREAM_DETECT )
-            bRawStream = rInfo.pStream->ParsePackageRawStream();
-        else if ( rInfo.pStream->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();
 
-        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();
+    bool bUseNonSeekableAccess = false;
+    uno::Reference < XInputStream > xStream;
+    if ( !rInfo.pStream->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
 
-        bool bUseNonSeekableAccess = false;
-        uno::Reference < XInputStream > xStream;
-        if ( !rInfo.pStream->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();
+        uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
 
-            xStream = rInfo.pStream->GetOwnStreamNoWrap();
-            uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
+        bUseNonSeekableAccess = ( xStream.is() && !xSeek.is() );
+    }
 
-            bUseNonSeekableAccess = ( xStream.is() && !xSeek.is() );
-        }
+    if ( !bUseNonSeekableAccess )
+    {
+        xStream = rInfo.pStream->getRawData();
 
-        if ( !bUseNonSeekableAccess )
+        if ( !xStream.is() )
         {
-            xStream = rInfo.pStream->getRawData();
-
-            if ( !xStream.is() )
-            {
-                OSL_FAIL( "ZipPackageStream didn't have a stream associated with it, skipping!" );
-                bSuccess = false;
-                return bSuccess;
-            }
+            OSL_FAIL( "ZipPackageStream didn't have a stream associated with it, skipping!" );
+            bSuccess = false;
+            return bSuccess;
+        }
 
-            uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
-            try
+        uno::Reference < XSeekable > xSeek ( xStream, uno::UNO_QUERY );
+        try
+        {
+            if ( xSeek.is() )
             {
-                if ( xSeek.is() )
+                // If the stream is a raw one, then we should be positioned
+                // at the beginning of the actual data
+                if ( !bToBeCompressed || bRawStream )
                 {
-                    // If the stream is a raw one, then we should be positioned
-                    // at the beginning of the actual data
-                    if ( !bToBeCompressed || bRawStream )
-                    {
-                        // 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 );
-                        ImplSetStoredData ( *pTempEntry, xStream );
-
-                        // TODO/LATER: Get rid of hacks related to switching of Flag Method and Size properties!
-                    }
-                    else if ( bToBeEncrypted )
-                    {
-                        // this is the correct original size
-                        pTempEntry->nSize = xSeek->getLength();
-                        nOwnStreamOrigSize = pTempEntry->nSize;
-                    }
+                    // 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 );
+                    ImplSetStoredData ( *pTempEntry, xStream );
 
-                    xSeek->seek ( 0 );
+                    // TODO/LATER: Get rid of hacks related to switching of Flag Method and Size properties!
                 }
-                else
+                else if ( bToBeEncrypted )
                 {
-                    // Okay, we don't have an xSeekable stream. This is possibly bad.
-                    // 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 the password has been changed than the stream should not be package member any more
-                        if ( rInfo.pStream->IsEncrypted() && rInfo.pStream->IsToBeEncrypted() )
-                        {
-                            // Should be handled close to the raw stream handling
-                            bTransportOwnEncrStreamAsRaw = true;
-                            pTempEntry->nMethod = STORED;
-
-                            // TODO/LATER: get rid of this situation
-                            // this size should be different from the one that will be stored in manifest.xml
-                            // it is used in storing algorithms and after storing the correct size will be set
-                            pTempEntry->nSize = pTempEntry->nCompressedSize;
-                        }
-                    }
-                    else
-                    {
-                        bSuccess = false;
-                        return bSuccess;
-                    }
+                    // this is the correct original size
+                    pTempEntry->nSize = xSeek->getLength();
+                    nOwnStreamOrigSize = pTempEntry->nSize;
                 }
-            }
-            catch ( uno::Exception& )
-            {
-                bSuccess = false;
-                return bSuccess;
-            }
 
-            if ( bToBeEncrypted || bRawStream || bTransportOwnEncrStreamAsRaw )
+                xSeek->seek ( 0 );
+            }
+            else
             {
-                if ( bToBeEncrypted && !bTransportOwnEncrStreamAsRaw )
+                // Okay, we don't have an xSeekable stream. This is possibly bad.
+                // 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() )
                 {
-                    uno::Sequence < sal_Int8 > aSalt( 16 ), aVector( rInfo.pStream->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 );
-
-                    rInfo.pStream->setInitialisationVector ( aVector );
-                    rInfo.pStream->setSalt ( aSalt );
-                    rInfo.pStream->setIterationCount ( nIterationCount );
-                }
-
-                // last property is digest, which is inserted later if we didn't have
-                // a magic header
-                aPropSet.realloc(PKG_SIZE_ENCR_MNFST);
-
-                aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
-                aPropSet[PKG_MNFST_INIVECTOR].Value <<= rInfo.pStream->getInitialisationVector();
-                aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
-                aPropSet[PKG_MNFST_SALT].Value <<= rInfo.pStream->getSalt();
-                aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
-                aPropSet[PKG_MNFST_ITERATION].Value <<= rInfo.pStream->getIterationCount ();
-
-                // Need to store the uncompressed size in the manifest
-                OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
-                aPropSet[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
-                aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
-
-                if ( bRawStream || bTransportOwnEncrStreamAsRaw )
-                {
-                    ::rtl::Reference< EncryptionData > xEncData = rInfo.pStream->GetEncryptionData();
-                    if ( !xEncData.is() )
-                        throw uno::RuntimeException();
-
-                    aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
-                    aPropSet[PKG_MNFST_DIGEST].Value <<= rInfo.pStream->getDigest();
-                    aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
-                    aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
-                    aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
-                    aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID;
-                    aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
-                    aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
-                    aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
-                    aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
+                    // if the password has been changed than the stream should not be package member any more
+                    if ( rInfo.pStream->IsEncrypted() && rInfo.pStream->IsToBeEncrypted() )
+                    {
+                        // Should be handled close to the raw stream handling
+                        bTransportOwnEncrStreamAsRaw = true;
+                        pTempEntry->nMethod = STORED;
+
+                        // TODO/LATER: get rid of this situation
+                        // this size should be different from the one that will be stored in manifest.xml
+                        // it is used in storing algorithms and after storing the correct size will be set
+                        pTempEntry->nSize = pTempEntry->nCompressedSize;
+                    }
                 }
-            }
-        }
-
-        // If the entry is already stored in the zip file in the format we
-        // 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 ) ) ) ) )
-        {
-            // 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() )
-            {
-                xStream = rInfo.pStream->getRawData();
-                if ( !xStream.is() )
+                else
                 {
-                    // Make sure that we actually _got_ a new one !
                     bSuccess = false;
                     return bSuccess;
                 }
             }
-
-            try
-            {
-                if ( bRawStream )
-                    xStream->skipBytes( rInfo.pStream->GetMagicalHackPos() );
-
-                rZipOut.putNextEntry ( *pTempEntry, rInfo.pStream, false );
-                // the entry is provided to the ZipOutputStream that will delete it
-                pAutoTempEntry.release();
-
-                uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
-                sal_Int32 nLength;
-
-                do
-                {
-                    nLength = xStream->readBytes( aSeq, n_ConstBufferSize );
-                    rZipOut.rawWrite(aSeq, 0, nLength);
-                }
-                while ( nLength == n_ConstBufferSize );
-
-                rZipOut.rawCloseEntry();
-            }
-            catch ( ZipException& )
-            {
-                bSuccess = false;
-            }
-            catch ( IOException& )
-            {
-                bSuccess = false;
-            }
         }
-        else
+        catch ( uno::Exception& )
         {
-            // This stream is defenitly not a raw stream
-
-            // If nonseekable access is used the stream should be at the beginning and
-            // is useless after the storing. Thus if the storing fails the package should
-            // be thrown away ( as actually it is done currently )!
-            // To allow to reuse the package after the error, the optimization must be removed!
+            bSuccess = false;
+            return bSuccess;
+        }
 
-            // 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 ( bToBeEncrypted || bRawStream || bTransportOwnEncrStreamAsRaw )
+        {
+            if ( bToBeEncrypted && !bTransportOwnEncrStreamAsRaw )
             {
-                xStream = rInfo.pStream->getInputStream();
-                if ( !xStream.is() )
-                {
-                    // Make sure that we actually _got_ a new one !
-                    bSuccess = false;
-                    return bSuccess;
-                }
-            }
+                uno::Sequence < sal_Int8 > aSalt( 16 ), aVector( rInfo.pStream->GetBlockSize() );
+                rtl_random_getBytes ( rRandomPool, aSalt.getArray(), 16 );
+                rtl_random_getBytes ( rRandomPool, aVector.getArray(), aVector.getLength() );
+                sal_Int32 nIterationCount = 1024;
 
-            if ( bToBeCompressed )
-            {
-                pTempEntry->nMethod = DEFLATED;
-                pTempEntry->nCrc = -1;
-                pTempEntry->nCompressedSize = pTempEntry->nSize = -1;
+                if ( !rInfo.pStream->HasOwnKey() )
+                    rInfo.pStream->setKey ( rEncryptionKey );
+
+                rInfo.pStream->setInitialisationVector ( aVector );
+                rInfo.pStream->setSalt ( aSalt );
+                rInfo.pStream->setIterationCount ( nIterationCount );
             }
 
-            try
-            {
-                rZipOut.putNextEntry ( *pTempEntry, rInfo.pStream, bToBeEncrypted);
-                // the entry is provided to the ZipOutputStream that will delete it
-                pAutoTempEntry.release();
+            // last property is digest, which is inserted later if we didn't have
+            // a magic header
+            aPropSet.realloc(PKG_SIZE_ENCR_MNFST);
 
-                sal_Int32 nLength;
-                uno::Sequence < sal_Int8 > aSeq (n_ConstBufferSize);
-                do
-                {
-                    nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
-                    rZipOut.write(aSeq, 0, nLength);
-                }
-                while ( nLength == n_ConstBufferSize );
+            aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
+            aPropSet[PKG_MNFST_INIVECTOR].Value <<= rInfo.pStream->getInitialisationVector();
+            aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
+            aPropSet[PKG_MNFST_SALT].Value <<= rInfo.pStream->getSalt();
+            aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
+            aPropSet[PKG_MNFST_ITERATION].Value <<= rInfo.pStream->getIterationCount ();
 
-                rZipOut.closeEntry();
-            }
-            catch ( ZipException& )
-            {
-                bSuccess = false;
-            }
-            catch ( IOException& )
-            {
-                bSuccess = false;
-            }
+            // Need to store the uncompressed size in the manifest
+            OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
+            aPropSet[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
+            aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
 
-            if ( bToBeEncrypted )
+            if ( bRawStream || bTransportOwnEncrStreamAsRaw )
             {
                 ::rtl::Reference< EncryptionData > xEncData = rInfo.pStream->GetEncryptionData();
                 if ( !xEncData.is() )
@@ -629,53 +533,184 @@ bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo
                 aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
                 aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
                 aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
-
-                rInfo.pStream->SetIsEncrypted ( true );
             }
         }
+    }
 
-        if( bSuccess )
+    // If the entry is already stored in the zip file in the format we
+    // 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 ) ) ) ) )
+    {
+        // 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 ( !rInfo.pStream->IsPackageMember() )
+            xStream = rInfo.pStream->getRawData();
+            if ( !xStream.is() )
             {
-                rInfo.pStream->CloseOwnStreamIfAny();
-                rInfo.pStream->SetPackageMember ( true );
+                // Make sure that we actually _got_ a new one !
+                bSuccess = false;
+                return bSuccess;
             }
+        }
 
+        try
+        {
             if ( bRawStream )
+                xStream->skipBytes( rInfo.pStream->GetMagicalHackPos() );
+
+            rZipOut.putNextEntry ( *pTempEntry, rInfo.pStream, false );
+            // the entry is provided to the ZipOutputStream that will delete it
+            pAutoTempEntry.release();
+
+            uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
+            sal_Int32 nLength;
+
+            do
+            {
+                nLength = xStream->readBytes( aSeq, n_ConstBufferSize );
+                rZipOut.rawWrite(aSeq, 0, nLength);
+            }
+            while ( nLength == n_ConstBufferSize );
+
+            rZipOut.rawCloseEntry();
+        }
+        catch ( ZipException& )
+        {
+            bSuccess = false;
+        }
+        catch ( IOException& )
+        {
+            bSuccess = false;
+        }
+    }
+    else
+    {
+        // This stream is defenitly not a raw stream
+
+        // If nonseekable access is used the stream should be at the beginning and
+        // is useless after the storing. Thus if the storing fails the package should
+        // be thrown away ( as actually it is done currently )!
+        // To allow to reuse the package after the error, the optimization must be removed!
+
+        // 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() )
+        {
+            xStream = rInfo.pStream->getInputStream();
+            if ( !xStream.is() )
             {
-                // the raw stream was integrated and now behaves
-                // as usual encrypted stream
-                rInfo.pStream->SetToBeEncrypted( true );
+                // Make sure that we actually _got_ a new one !
+                bSuccess = false;
+                return bSuccess;
             }
+        }
+
+        if ( bToBeCompressed )
+        {
+            pTempEntry->nMethod = DEFLATED;
+            pTempEntry->nCrc = -1;
+            pTempEntry->nCompressedSize = pTempEntry->nSize = -1;
+        }
 
-            // Then copy it back afterwards...
-            ZipPackageFolder::copyZipEntry ( rInfo.pStream->aEntry, *pTempEntry );
+        try
+        {
+            rZipOut.putNextEntry ( *pTempEntry, rInfo.pStream, bToBeEncrypted);
+            // the entry is provided to the ZipOutputStream that will delete it
+            pAutoTempEntry.release();
 
-            // Remove hacky bit from entry flags
-            if ( rInfo.pStream->aEntry.nFlag & ( 1 << 4 ) )
+            sal_Int32 nLength;
+            uno::Sequence < sal_Int8 > aSeq (n_ConstBufferSize);
+            do
             {
-                rInfo.pStream->aEntry.nFlag &= ~( 1 << 4 );
-                rInfo.pStream->aEntry.nMethod = STORED;
+                nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
+                rZipOut.write(aSeq, 0, nLength);
             }
+            while ( nLength == n_ConstBufferSize );
 
-            // TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving )
-            if ( rInfo.pStream->IsEncrypted() )
-                rInfo.pStream->setSize( nOwnStreamOrigSize );
+            rZipOut.closeEntry();
+        }
+        catch ( ZipException& )
+        {
+            bSuccess = false;
+        }
+        catch ( IOException& )
+        {
+            bSuccess = false;
+        }
 
-            rInfo.pStream->aEntry.nOffset *= -1;
+        if ( bToBeEncrypted )
+        {
+            ::rtl::Reference< EncryptionData > xEncData = rInfo.pStream->GetEncryptionData();
+            if ( !xEncData.is() )
+                throw uno::RuntimeException();
+
+            aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
+            aPropSet[PKG_MNFST_DIGEST].Value <<= rInfo.pStream->getDigest();
+            aPropSet[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
+            aPropSet[PKG_MNFST_ENCALG].Value <<= xEncData->m_nEncAlg;
+            aPropSet[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
+            aPropSet[PKG_MNFST_STARTALG].Value <<= xEncData->m_nStartKeyGenID;
+            aPropSet[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
+            aPropSet[PKG_MNFST_DIGESTALG].Value <<= xEncData->m_nCheckAlg;
+            aPropSet[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
+            aPropSet[PKG_MNFST_DERKEYSIZE].Value <<= xEncData->m_nDerivedKeySize;
+
+            rInfo.pStream->SetIsEncrypted ( true );
         }
     }
 
+    if( bSuccess )
+    {
+        if ( !rInfo.pStream->IsPackageMember() )
+        {
+            rInfo.pStream->CloseOwnStreamIfAny();
+            rInfo.pStream->SetPackageMember ( true );
+        }
+
+        if ( bRawStream )
+        {
+            // the raw stream was integrated and now behaves
+            // as usual encrypted stream
+            rInfo.pStream->SetToBeEncrypted( true );
+        }
+
+        // Then copy it back afterwards...
+        ZipPackageFolder::copyZipEntry ( rInfo.pStream->aEntry, *pTempEntry );
+
+        // Remove hacky bit from entry flags
+        if ( rInfo.pStream->aEntry.nFlag & ( 1 << 4 ) )
+        {
+            rInfo.pStream->aEntry.nFlag &= ~( 1 << 4 );
+            rInfo.pStream->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 );
+
+        rInfo.pStream->aEntry.nOffset *= -1;
+    }
+
     // folder can have a mediatype only in package format
     if ( aPropSet.getLength()
-      && ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
+      && ( nFormat == embed::StorageFormats::PACKAGE || ( nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
         rManList.push_back( aPropSet );
 
     return bSuccess;
 }
 
-void ZipPackageFolder::saveContents( OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool &rRandomPool ) const
+void ZipPackageFolder::saveContents(
+        const OUString &rPath,
+        std::vector < uno::Sequence < PropertyValue > > &rManList,
+        ZipOutputStream & rZipOut,
+        const uno::Sequence < sal_Int8 >& rEncryptionKey,
+        const rtlRandomPool &rRandomPool ) const
     throw( uno::RuntimeException )
 {
     bool bWritingFailed = false;
@@ -708,12 +743,13 @@ void ZipPackageFolder::saveContents( OUString &rPath, std::vector < uno::Sequenc
     OUString aMimeTypeStreamName("mimetype");
     if ( m_nFormat == embed::StorageFormats::ZIP && rPath.isEmpty() )
     {
-        // let the "mimtype" stream in root folder be stored as the first stream if it is zip format
+        // let the "mimetype" stream in root folder be stored as the first stream if it is zip format
         ContentHash::const_iterator aIter = maContents.find ( aMimeTypeStreamName );
         if ( aIter != maContents.end() && !(*aIter).second->bFolder )
         {
             bMimeTypeStreamStored = true;
-            bWritingFailed = !saveChild( (*aIter).first, *(*aIter).second, rPath, rManList, rZipOut, rEncryptionKey, rRandomPool );
+            bWritingFailed = !ZipPackageStream_saveChild(
+                *aIter->second, rPath + aIter->first, rManList, rZipOut, rEncryptionKey, rRandomPool, m_nFormat );
         }
     }
 
@@ -725,7 +761,18 @@ void ZipPackageFolder::saveContents( OUString &rPath, std::vector < uno::Sequenc
         const ContentInfo &rInfo = *(*aCI).second;
 
         if ( !bMimeTypeStreamStored || !rShortName.equals( aMimeTypeStreamName ) )
-            bWritingFailed = !saveChild( rShortName, rInfo, rPath, rManList, rZipOut, rEncryptionKey, rRandomPool );
+        {
+            if (rInfo.bFolder)
+            {
+                bWritingFailed = !ZipPackageFolder_saveChild(
+                    rInfo, rPath + rShortName, rManList, rZipOut, rEncryptionKey, rRandomPool, m_nFormat );
+            }
+            else
+            {
+                bWritingFailed = !ZipPackageStream_saveChild(
+                    rInfo, rPath + rShortName, rManList, rZipOut, rEncryptionKey, rRandomPool, m_nFormat );
+            }
+        }
     }
 
     if( bWritingFailed )
commit 04ebf437087c0a849dacf4816f0f2ee45799f840
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Oct 7 14:44:53 2014 +0200

    package: ZipOutputStream: prefix members
    
    Change-Id: I9cc21ba87484560ec0db5424800dd67f80e00540

diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index f2f9ce1..a8d106b 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -20,7 +20,6 @@
 #define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
 
 #include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/xml/crypto/XCipherContext.hpp>
 #include <com/sun/star/xml/crypto/XDigestContext.hpp>
@@ -33,32 +32,28 @@
 
 struct ZipEntry;
 class ZipPackageStream;
-namespace rtl
-{
-    template < class T > class Reference;
-}
 
 class ZipOutputStream
 {
 protected:
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
-    ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream;
+    ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > m_xStream;
 
-    ::std::vector < ZipEntry * >            aZipList;
+    ::std::vector < ZipEntry * > m_aZipList;
 
     ::com::sun::star::uno::Sequence< sal_Int8 > m_aDeflateBuffer;
 
-    OUString     sComment;
-    ZipUtils::Deflater  aDeflater;
+    OUString            m_sComment;
+    ZipUtils::Deflater  m_aDeflater;
 
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > m_xDigestContext;
 
-    CRC32               aCRC;
-    ByteChucker         aChucker;
-    ZipEntry            *pCurrentEntry;
-    sal_Int16           nMethod, nLevel, mnDigested;
-    bool            bFinished, bEncryptCurrentEntry;
+    CRC32               m_aCRC;
+    ByteChucker         m_aChucker;
+    ZipEntry            *m_pCurrentEntry;
+    sal_Int16           m_nMethod, m_nLevel, m_nDigested;
+    bool                m_bFinished, m_bEncryptCurrentEntry;
     ZipPackageStream*   m_pCurrentStream;
 
 public:
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index cd4f9e7..0a64d09 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -33,8 +33,6 @@
 using namespace com::sun::star;
 using namespace com::sun::star::io;
 using namespace com::sun::star::uno;
-using namespace com::sun::star::packages;
-using namespace com::sun::star::packages::zip;
 using namespace com::sun::star::packages::zip::ZipConstants;
 
 /** This class is used to write Zip files
@@ -42,35 +40,35 @@ using namespace com::sun::star::packages::zip::ZipConstants;
 ZipOutputStream::ZipOutputStream( const uno::Reference< uno::XComponentContext >& rxContext,
                                   const uno::Reference < XOutputStream > &xOStream )
 : m_xContext( rxContext )
-, xStream(xOStream)
+, m_xStream(xOStream)
 , m_aDeflateBuffer(n_ConstBufferSize)
-, aDeflater(DEFAULT_COMPRESSION, true)
-, aChucker(xOStream)
-, pCurrentEntry(NULL)
-, nMethod(DEFLATED)
-, nLevel(0)
-, mnDigested(0)
-, bFinished(false)
-, bEncryptCurrentEntry(false)
+, m_aDeflater(DEFAULT_COMPRESSION, true)
+, m_aChucker(xOStream)
+, m_pCurrentEntry(NULL)
+, m_nMethod(DEFLATED)
+, m_nLevel(0)
+, m_nDigested(0)
+, m_bFinished(false)
+, m_bEncryptCurrentEntry(false)
 , m_pCurrentStream(NULL)
 {
 }
 
 ZipOutputStream::~ZipOutputStream( void )
 {
-    for (sal_Int32 i = 0, nEnd = aZipList.size(); i < nEnd; i++)
-        delete aZipList[i];
+    for (sal_Int32 i = 0, nEnd = m_aZipList.size(); i < nEnd; i++)
+        delete m_aZipList[i];
 }
 
 void SAL_CALL ZipOutputStream::setMethod( sal_Int32 nNewMethod )
     throw(RuntimeException)
 {
-    nMethod = static_cast < sal_Int16 > (nNewMethod);
+    m_nMethod = static_cast < sal_Int16 > (nNewMethod);
 }
 void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel )
     throw(RuntimeException)
 {
-    aDeflater.setLevel( nNewLevel);
+    m_aDeflater.setLevel( nNewLevel);
 }
 
 void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
@@ -78,12 +76,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
                         bool bEncrypt)
     throw(IOException, RuntimeException)
 {
-    if (pCurrentEntry != NULL)
+    if (m_pCurrentEntry != NULL)
         closeEntry();
     if (rEntry.nTime == -1)
         rEntry.nTime = getCurrentDosTime();
     if (rEntry.nMethod == -1)
-        rEntry.nMethod = nMethod;
+        rEntry.nMethod = m_nMethod;
     rEntry.nVersion = 20;
     rEntry.nFlag = 1 << 11;
     if (rEntry.nSize == -1 || rEntry.nCompressedSize == -1 ||
@@ -95,61 +93,61 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
 
     if (bEncrypt)
     {
-        bEncryptCurrentEntry = true;
+        m_bEncryptCurrentEntry = true;
 
         m_xCipherContext = ZipFile::StaticGetCipher( m_xContext, pStream->GetEncryptionData(), true );
         m_xDigestContext = ZipFile::StaticGetDigestContextForChecksum( m_xContext, pStream->GetEncryptionData() );
-        mnDigested = 0;
+        m_nDigested = 0;
         rEntry.nFlag |= 1 << 4;
         m_pCurrentStream = pStream;
     }
     sal_Int32 nLOCLength = writeLOC(rEntry);
-    rEntry.nOffset = aChucker.GetPosition() - nLOCLength;
-    aZipList.push_back( &rEntry );
-    pCurrentEntry = &rEntry;
+    rEntry.nOffset = m_aChucker.GetPosition() - nLOCLength;
+    m_aZipList.push_back( &rEntry );
+    m_pCurrentEntry = &rEntry;
 }
 
 void SAL_CALL ZipOutputStream::closeEntry(  )
     throw(IOException, RuntimeException)
 {
-    ZipEntry *pEntry = pCurrentEntry;
+    ZipEntry *pEntry = m_pCurrentEntry;
     if (pEntry)
     {
         switch (pEntry->nMethod)
         {
             case DEFLATED:
-                aDeflater.finish();
-                while (!aDeflater.finished())
+                m_aDeflater.finish();
+                while (!m_aDeflater.finished())
                     doDeflate();
                 if ((pEntry->nFlag & 8) == 0)
                 {
-                    if (pEntry->nSize != aDeflater.getTotalIn())
+                    if (pEntry->nSize != m_aDeflater.getTotalIn())
                     {
                         OSL_FAIL("Invalid entry size");
                     }
-                    if (pEntry->nCompressedSize != aDeflater.getTotalOut())
+                    if (pEntry->nCompressedSize != m_aDeflater.getTotalOut())
                     {
                         // Different compression strategies make the merit of this
                         // test somewhat dubious
-                        pEntry->nCompressedSize = aDeflater.getTotalOut();
+                        pEntry->nCompressedSize = m_aDeflater.getTotalOut();
                     }
-                    if (pEntry->nCrc != aCRC.getValue())
+                    if (pEntry->nCrc != m_aCRC.getValue())
                     {
                         OSL_FAIL("Invalid entry CRC-32");
                     }
                 }
                 else
                 {
-                    if ( !bEncryptCurrentEntry )
+                    if ( !m_bEncryptCurrentEntry )
                     {
-                        pEntry->nSize = aDeflater.getTotalIn();
-                        pEntry->nCompressedSize = aDeflater.getTotalOut();
+                        pEntry->nSize = m_aDeflater.getTotalIn();
+                        pEntry->nCompressedSize = m_aDeflater.getTotalOut();
                     }
-                    pEntry->nCrc = aCRC.getValue();
+                    pEntry->nCrc = m_aCRC.getValue();
                     writeEXT(*pEntry);
                 }
-                aDeflater.reset();
-                aCRC.reset();
+                m_aDeflater.reset();
+                m_aCRC.reset();
                 break;
             case STORED:
                 if (!((pEntry->nFlag & 8) == 0))
@@ -160,9 +158,9 @@ void SAL_CALL ZipOutputStream::closeEntry(  )
                 break;
         }
 
-        if (bEncryptCurrentEntry)
+        if (m_bEncryptCurrentEntry)
         {
-            bEncryptCurrentEntry = false;
+            m_bEncryptCurrentEntry = false;
 
             m_xCipherContext.clear();
 
@@ -176,7 +174,7 @@ void SAL_CALL ZipOutputStream::closeEntry(  )
             if ( m_pCurrentStream )
                 m_pCurrentStream->setDigest( aDigestSeq );
         }
-        pCurrentEntry = NULL;
+        m_pCurrentEntry = NULL;
         m_pCurrentStream = NULL;
     }
 }
@@ -184,22 +182,22 @@ void SAL_CALL ZipOutputStream::closeEntry(  )
 void SAL_CALL ZipOutputStream::write( const Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
     throw(IOException, RuntimeException)
 {
-    switch (pCurrentEntry->nMethod)
+    switch (m_pCurrentEntry->nMethod)
     {
         case DEFLATED:
-            if (!aDeflater.finished())
+            if (!m_aDeflater.finished())
             {
-                aDeflater.setInputSegment(rBuffer, nNewOffset, nNewLength);
-                 while (!aDeflater.needsInput())
+                m_aDeflater.setInputSegment(rBuffer, nNewOffset, nNewLength);
+                 while (!m_aDeflater.needsInput())
                     doDeflate();
-                if (!bEncryptCurrentEntry)
-                    aCRC.updateSegment(rBuffer, nNewOffset, nNewLength);
+                if (!m_bEncryptCurrentEntry)
+                    m_aCRC.updateSegment(rBuffer, nNewOffset, nNewLength);
             }
             break;
         case STORED:
             {
                 Sequence < sal_Int8 > aTmpBuffer ( rBuffer.getConstArray(), nNewLength );
-                aChucker.WriteBytes( aTmpBuffer );
+                m_aChucker.WriteBytes( aTmpBuffer );
             }
             break;
     }
@@ -209,84 +207,84 @@ void SAL_CALL ZipOutputStream::rawWrite( Sequence< sal_Int8 >& rBuffer, sal_Int3
     throw(IOException, RuntimeException)
 {
     Sequence < sal_Int8 > aTmpBuffer ( rBuffer.getConstArray(), nNewLength );
-    aChucker.WriteBytes( aTmpBuffer );
+    m_aChucker.WriteBytes( aTmpBuffer );
 }
 
 void SAL_CALL ZipOutputStream::rawCloseEntry(  )
     throw(IOException, RuntimeException)
 {
-    if ( pCurrentEntry->nMethod == DEFLATED && ( pCurrentEntry->nFlag & 8 ) )
-        writeEXT(*pCurrentEntry);
-    pCurrentEntry = NULL;
+    if ( m_pCurrentEntry->nMethod == DEFLATED && ( m_pCurrentEntry->nFlag & 8 ) )
+        writeEXT(*m_pCurrentEntry);
+    m_pCurrentEntry = NULL;
 }
 
 void SAL_CALL ZipOutputStream::finish(  )
     throw(IOException, RuntimeException)
 {
-    if (bFinished)
+    if (m_bFinished)
         return;
 
-    if (pCurrentEntry != NULL)
+    if (m_pCurrentEntry != NULL)
         closeEntry();
 
-    if (aZipList.size() < 1)
+    if (m_aZipList.size() < 1)
         OSL_FAIL("Zip file must have at least one entry!\n");
 
-    sal_Int32 nOffset= static_cast < sal_Int32 > (aChucker.GetPosition());
-    for (sal_Int32 i =0, nEnd = aZipList.size(); i < nEnd; i++)
-        writeCEN( *aZipList[i] );
-    writeEND( nOffset, static_cast < sal_Int32 > (aChucker.GetPosition()) - nOffset);
-    bFinished = true;
-    xStream->flush();
+    sal_Int32 nOffset= static_cast < sal_Int32 > (m_aChucker.GetPosition());
+    for (sal_Int32 i =0, nEnd = m_aZipList.size(); i < nEnd; i++)
+        writeCEN( *m_aZipList[i] );
+    writeEND( nOffset, static_cast < sal_Int32 > (m_aChucker.GetPosition()) - nOffset);
+    m_bFinished = true;
+    m_xStream->flush();
 }
 
 void ZipOutputStream::doDeflate()
 {
-    sal_Int32 nLength = aDeflater.doDeflateSegment(m_aDeflateBuffer, 0, m_aDeflateBuffer.getLength());
+    sal_Int32 nLength = m_aDeflater.doDeflateSegment(m_aDeflateBuffer, 0, m_aDeflateBuffer.getLength());
 
     if ( nLength > 0 )
     {
         uno::Sequence< sal_Int8 > aTmpBuffer( m_aDeflateBuffer.getConstArray(), nLength );
-        if ( bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
+        if ( m_bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
         {
             // Need to update our digest before encryption...
-            sal_Int32 nDiff = n_ConstDigestLength - mnDigested;
+            sal_Int32 nDiff = n_ConstDigestLength - m_nDigested;
             if ( nDiff )
             {
                 sal_Int32 nEat = ::std::min( nLength, nDiff );
                 uno::Sequence< sal_Int8 > aTmpSeq( aTmpBuffer.getConstArray(), nEat );
                 m_xDigestContext->updateDigest( aTmpSeq );
-                mnDigested = mnDigested + static_cast< sal_Int16 >( nEat );
+                m_nDigested = m_nDigested + static_cast< sal_Int16 >( nEat );
             }
 
             // FIXME64: uno::Sequence not 64bit safe.
             uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->convertWithCipherContext( aTmpBuffer );
 
-            aChucker.WriteBytes( aEncryptionBuffer );
+            m_aChucker.WriteBytes( aEncryptionBuffer );
 
             // the sizes as well as checksum for encrypted streams is calculated here
-            pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
-            pCurrentEntry->nSize = pCurrentEntry->nCompressedSize;
-            aCRC.update( aEncryptionBuffer );
+            m_pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
+            m_pCurrentEntry->nSize = m_pCurrentEntry->nCompressedSize;
+            m_aCRC.update( aEncryptionBuffer );
         }
         else
         {
-            aChucker.WriteBytes ( aTmpBuffer );
+            m_aChucker.WriteBytes ( aTmpBuffer );
         }
     }
 
-    if ( aDeflater.finished() && bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
+    if ( m_aDeflater.finished() && m_bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
     {
         // FIXME64: sequence not 64bit safe.
         uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->finalizeCipherContextAndDispose();
         if ( aEncryptionBuffer.getLength() )
         {
-            aChucker.WriteBytes( aEncryptionBuffer );
+            m_aChucker.WriteBytes( aEncryptionBuffer );
 
             // the sizes as well as checksum for encrypted streams is calculated hier
-            pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
-            pCurrentEntry->nSize = pCurrentEntry->nCompressedSize;
-            aCRC.update( aEncryptionBuffer );
+            m_pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
+            m_pCurrentEntry->nSize = m_pCurrentEntry->nCompressedSize;
+            m_aCRC.update( aEncryptionBuffer );
         }
     }
 }
@@ -294,14 +292,14 @@ void ZipOutputStream::doDeflate()
 void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
     throw(IOException, RuntimeException)
 {
-    aChucker << ENDSIG;
-    aChucker << static_cast < sal_Int16 > ( 0 );
-    aChucker << static_cast < sal_Int16 > ( 0 );
-    aChucker << static_cast < sal_Int16 > ( aZipList.size() );
-    aChucker << static_cast < sal_Int16 > ( aZipList.size() );
-    aChucker << nLength;
-    aChucker << nOffset;
-    aChucker << static_cast < sal_Int16 > ( 0 );
+    m_aChucker << ENDSIG;
+    m_aChucker << static_cast < sal_Int16 > ( 0 );
+    m_aChucker << static_cast < sal_Int16 > ( 0 );
+    m_aChucker << static_cast < sal_Int16 > ( m_aZipList.size() );
+    m_aChucker << static_cast < sal_Int16 > ( m_aZipList.size() );
+    m_aChucker << nLength;
+    m_aChucker << nOffset;
+    m_aChucker << static_cast < sal_Int16 > ( 0 );
 }
 
 static sal_uInt32 getTruncated( sal_Int64 nNum, bool *pIsTruncated )
@@ -324,35 +322,35 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
     OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 );
     sal_Int16 nNameLength       = static_cast < sal_Int16 > ( sUTF8Name.getLength() );
 
-    aChucker << CENSIG;
-    aChucker << rEntry.nVersion;
-    aChucker << rEntry.nVersion;
+    m_aChucker << CENSIG;
+    m_aChucker << rEntry.nVersion;
+    m_aChucker << rEntry.nVersion;
     if (rEntry.nFlag & (1 << 4) )
     {
         // If it's an encrypted entry, we pretend its stored plain text
         ZipEntry *pEntry = const_cast < ZipEntry * > ( &rEntry );
         pEntry->nFlag &= ~(1 <<4 );
-        aChucker << rEntry.nFlag;
-        aChucker << static_cast < sal_Int16 > ( STORED );
+        m_aChucker << rEntry.nFlag;
+        m_aChucker << static_cast < sal_Int16 > ( STORED );
     }
     else
     {
-        aChucker << rEntry.nFlag;
-        aChucker << rEntry.nMethod;
+        m_aChucker << rEntry.nFlag;
+        m_aChucker << rEntry.nMethod;
     }
     bool bWrite64Header = false;
 
-    aChucker << static_cast < sal_uInt32> ( rEntry.nTime );
-    aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
-    aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
-    aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
-    aChucker << nNameLength;
-    aChucker << static_cast < sal_Int16> (0);
-    aChucker << static_cast < sal_Int16> (0);
-    aChucker << static_cast < sal_Int16> (0);
-    aChucker << static_cast < sal_Int16> (0);
-    aChucker << static_cast < sal_Int32> (0);
-    aChucker << getTruncated( rEntry.nOffset, &bWrite64Header );
+    m_aChucker << static_cast < sal_uInt32> ( rEntry.nTime );
+    m_aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
+    m_aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
+    m_aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
+    m_aChucker << nNameLength;
+    m_aChucker << static_cast < sal_Int16> (0);
+    m_aChucker << static_cast < sal_Int16> (0);
+    m_aChucker << static_cast < sal_Int16> (0);
+    m_aChucker << static_cast < sal_Int16> (0);
+    m_aChucker << static_cast < sal_Int32> (0);
+    m_aChucker << getTruncated( rEntry.nOffset, &bWrite64Header );
 
     if( bWrite64Header )
     {
@@ -363,17 +361,17 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
     }
 
     Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() );
-    aChucker.WriteBytes( aSequence );
+    m_aChucker.WriteBytes( aSequence );
 }
 void ZipOutputStream::writeEXT( const ZipEntry &rEntry )
     throw(IOException, RuntimeException)
 {
     bool bWrite64Header = false;
 
-    aChucker << EXTSIG;
-    aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
-    aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
-    aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
+    m_aChucker << EXTSIG;
+    m_aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
+    m_aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
+    m_aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
 
     if( bWrite64Header )
     {
@@ -393,40 +391,40 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
     OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 );
     sal_Int16 nNameLength       = static_cast < sal_Int16 > ( sUTF8Name.getLength() );
 
-    aChucker << LOCSIG;
-    aChucker << rEntry.nVersion;
+    m_aChucker << LOCSIG;
+    m_aChucker << rEntry.nVersion;
 
     if (rEntry.nFlag & (1 << 4) )
     {
         // If it's an encrypted entry, we pretend its stored plain text
         sal_Int16 nTmpFlag = rEntry.nFlag;
         nTmpFlag &= ~(1 <<4 );
-        aChucker << nTmpFlag;
-        aChucker << static_cast < sal_Int16 > ( STORED );
+        m_aChucker << nTmpFlag;
+        m_aChucker << static_cast < sal_Int16 > ( STORED );
     }
     else
     {
-        aChucker << rEntry.nFlag;
-        aChucker << rEntry.nMethod;
+        m_aChucker << rEntry.nFlag;
+        m_aChucker << rEntry.nMethod;
     }
 
     bool bWrite64Header = false;
 
-    aChucker << static_cast < sal_uInt32 > (rEntry.nTime);
+    m_aChucker << static_cast < sal_uInt32 > (rEntry.nTime);
     if ((rEntry.nFlag & 8) == 8 )
     {
-        aChucker << static_cast < sal_Int32 > (0);
-        aChucker << static_cast < sal_Int32 > (0);
-        aChucker << static_cast < sal_Int32 > (0);
+        m_aChucker << static_cast < sal_Int32 > (0);
+        m_aChucker << static_cast < sal_Int32 > (0);
+        m_aChucker << static_cast < sal_Int32 > (0);
     }
     else
     {
-        aChucker << static_cast < sal_uInt32 > (rEntry.nCrc);
-        aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
-        aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
+        m_aChucker << static_cast < sal_uInt32 > (rEntry.nCrc);
+        m_aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
+        m_aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
     }
-    aChucker << nNameLength;
-    aChucker << static_cast < sal_Int16 > (0);
+    m_aChucker << nNameLength;
+    m_aChucker << static_cast < sal_Int16 > (0);
 
     if( bWrite64Header )
     {
@@ -437,7 +435,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
     }
 
     Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() );
-    aChucker.WriteBytes( aSequence );
+    m_aChucker.WriteBytes( aSequence );
 
     return LOCHDR + nNameLength;
 }
commit 3d8f059802c209dbd0cfddc454198fce24c876b5
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Oct 7 13:56:26 2014 +0200

    package: Add some 'const' and prefix members
    
    Change-Id: Id177c99ba8b91586cf61457ab2ef084af9c7f490

diff --git a/package/inc/ZipPackageEntry.hxx b/package/inc/ZipPackageEntry.hxx
index c8cf1fa..cfe1895 100644
--- a/package/inc/ZipPackageEntry.hxx
+++ b/package/inc/ZipPackageEntry.hxx
@@ -44,24 +44,24 @@ protected:
     bool mbIsFolder:1;
     bool mbAllowRemoveOnInsert:1;
     // com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xParent;
-    OUString     sMediaType;
-    ZipPackageFolder * pParent;
+    OUString msMediaType;
+    ZipPackageFolder* mpParent;
 public:
     ZipEntry aEntry;
     ZipPackageEntry ( bool bNewFolder = false );
     virtual ~ZipPackageEntry( void );
 
-    OUString & GetMediaType () { return sMediaType; }
-    void SetMediaType ( const OUString & sNewType) { sMediaType = sNewType; }
+    const OUString& GetMediaType () const { return msMediaType; }
+    void SetMediaType ( const OUString & sNewType) { msMediaType = sNewType; }
     void doSetParent ( ZipPackageFolder * pNewParent, bool bInsert );
     bool IsFolder ( ) { return mbIsFolder; }
-    ZipPackageFolder* GetParent ( ) { return pParent; }
+    const ZipPackageFolder* GetParent () const { return mpParent; }
     void SetFolder ( bool bSetFolder ) { mbIsFolder = bSetFolder; }
 
     void clearParent ( void )
     {
         // xParent.clear();
-        pParent = NULL;
+        mpParent = NULL;
     }
     // XNamed
     virtual OUString SAL_CALL getName(  )
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index b885e3b..81eddd7 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -60,7 +60,7 @@ public:
                       bool bAllowRemoveOnInsert );
     virtual ~ZipPackageFolder();
 
-    OUString& GetVersion() { return m_sVersion; }
+    const OUString& GetVersion() const { return m_sVersion; }
     void SetVersion( const OUString& aVersion ) { m_sVersion = aVersion; }
 
     bool LookForUnexpectedODF12Streams( const OUString& aPath );
@@ -79,10 +79,10 @@ public:
     void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
     void setRemoveOnInsertMode_Impl( bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
 
-    bool saveChild(const OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool & rRandomPool);
+    bool saveChild(const OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool & rRandomPool) const;
 
     // Recursive functions
-    void  saveContents(OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool)
+    void  saveContents(OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool) const
         throw(::com::sun::star::uno::RuntimeException);
     void  releaseUpwardRef();
 
diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx
index 91b2e94..860f717 100644
--- a/package/source/zippackage/ZipPackageEntry.cxx
+++ b/package/source/zippackage/ZipPackageEntry.cxx
@@ -43,14 +43,14 @@ using namespace com::sun::star::packages::zip::ZipConstants;
 ZipPackageEntry::ZipPackageEntry ( bool bNewFolder )
 : mbIsFolder ( bNewFolder )
 , mbAllowRemoveOnInsert( true )
-, pParent ( NULL )
+, mpParent ( NULL )
 {
 }
 
 ZipPackageEntry::~ZipPackageEntry()
 {
     // When the entry is destroyed it must be already disconnected from the parent
-    OSL_ENSURE( !pParent, "The parent must be disconnected already! Memory corruption is possible!\n" );
+    OSL_ENSURE( !mpParent, "The parent must be disconnected already! Memory corruption is possible!\n" );
 }
 
 // XChild
@@ -62,8 +62,8 @@ OUString SAL_CALL ZipPackageEntry::getName(  )
 void SAL_CALL ZipPackageEntry::setName( const OUString& aName )
     throw(RuntimeException, std::exception)
 {
-    if ( pParent && !msName.isEmpty() && pParent->hasByName ( msName ) )
-        pParent->removeByName ( msName );
+    if ( mpParent && !msName.isEmpty() && mpParent->hasByName ( msName ) )
+        mpParent->removeByName ( msName );
 
     // unfortunately no other exception than RuntimeException can be thrown here
     // usually the package is used through storage implementation, the problem should be detected there
@@ -72,20 +72,20 @@ void SAL_CALL ZipPackageEntry::setName( const OUString& aName )
 
     msName = aName;
 
-    if ( pParent )
-        pParent->doInsertByName ( this, false );
+    if ( mpParent )
+        mpParent->doInsertByName ( this, false );
 }
 uno::Reference< XInterface > SAL_CALL ZipPackageEntry::getParent(  )
         throw(RuntimeException, std::exception)
 {
     // return uno::Reference< XInterface >( xParent, UNO_QUERY );
-    return uno::Reference< XInterface >( static_cast< ::cppu::OWeakObject* >( pParent ), UNO_QUERY );
+    return uno::Reference< XInterface >( static_cast< ::cppu::OWeakObject* >( mpParent ), UNO_QUERY );
 }
 
 void ZipPackageEntry::doSetParent ( ZipPackageFolder * pNewParent, bool bInsert )
 {
-    // xParent = pParent = pNewParent;
-    pParent = pNewParent;
+    // xParent = mpParent = pNewParent;
+    mpParent = pNewParent;
     if ( bInsert && !msName.isEmpty() && !pNewParent->hasByName ( msName ) )
         pNewParent->doInsertByName ( this, false );
 }
@@ -100,10 +100,10 @@ void SAL_CALL ZipPackageEntry::setParent( const uno::Reference< XInterface >& xN
 
     ZipPackageFolder *pNewParent = reinterpret_cast < ZipPackageFolder * > ( nTest );
 
-    if ( pNewParent != pParent )
+    if ( pNewParent != mpParent )
     {
-        if ( pParent && !msName.isEmpty() && pParent->hasByName ( msName ) && mbAllowRemoveOnInsert )
-            pParent->removeByName( msName );
+        if ( mpParent && !msName.isEmpty() && mpParent->hasByName ( msName ) && mbAllowRemoveOnInsert )
+            mpParent->removeByName( msName );
         doSetParent ( pNewParent, true );
     }
 }
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index ce01b92..9855dc1 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -294,7 +294,7 @@ static void ImplSetStoredData( ZipEntry & rEntry, uno::Reference< XInputStream>
     rEntry.nCrc = aCRC32.getValue();
 }
 
-bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo &rInfo, OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool &rRandomPool)
+bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo &rInfo, OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool &rRandomPool) const
 {
     bool bSuccess = true;
 
@@ -675,7 +675,7 @@ bool ZipPackageFolder::saveChild( const OUString &rShortName, const ContentInfo
     return bSuccess;
 }
 
-void ZipPackageFolder::saveContents( OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool &rRandomPool )
+void ZipPackageFolder::saveContents( OUString &rPath, std::vector < uno::Sequence < PropertyValue > > &rManList, ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool &rRandomPool ) const
     throw( uno::RuntimeException )
 {
     bool bWritingFailed = false;
@@ -709,7 +709,7 @@ void ZipPackageFolder::saveContents( OUString &rPath, std::vector < uno::Sequenc
     if ( m_nFormat == embed::StorageFormats::ZIP && rPath.isEmpty() )
     {
         // let the "mimtype" stream in root folder be stored as the first stream if it is zip format
-        ContentHash::iterator aIter = maContents.find ( aMimeTypeStreamName );
+        ContentHash::const_iterator aIter = maContents.find ( aMimeTypeStreamName );
         if ( aIter != maContents.end() && !(*aIter).second->bFolder )
         {
             bMimeTypeStreamStored = true;
@@ -779,7 +779,7 @@ void SAL_CALL ZipPackageFolder::setPropertyValue( const OUString& aPropertyName,
         // if ( m_nFormat != embed::StorageFormats::PACKAGE )
         //  throw UnknownPropertyException(THROW_WHERE );
 
-        aValue >>= sMediaType;
+        aValue >>= msMediaType;
     }
     else if ( aPropertyName == "Version" )
         aValue >>= m_sVersion;
@@ -797,7 +797,7 @@ uno::Any SAL_CALL ZipPackageFolder::getPropertyValue( const OUString& PropertyNa
         // if ( m_nFormat != embed::StorageFormats::PACKAGE )
         //  throw UnknownPropertyException(THROW_WHERE );
 
-        return uno::makeAny ( sMediaType );
+        return uno::makeAny ( msMediaType );
     }
     else if ( PropertyName == "Version" )
         return uno::makeAny( m_sVersion );
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 1c827c4..fee38a6 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -298,7 +298,7 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
             throw RuntimeException(THROW_WHERE );
 
         // copy all the properties of this stream to the new stream
-        xNewPSProps->setPropertyValue("MediaType", makeAny( sMediaType ) );
+        xNewPSProps->setPropertyValue("MediaType", makeAny( msMediaType ) );
         xNewPSProps->setPropertyValue("Compressed", makeAny( bToBeCompressed ) );
         if ( bToBeEncrypted )
         {
@@ -406,7 +406,7 @@ bool ZipPackageStream::ParsePackageRawStream()
                     m_nImportedDerivedKeySize = nDerivedKeySize;
                     m_nImportedStartKeyAlgorithm = nStartKeyGenID;
                     m_nMagicalHackSize = nMagHackSize;
-                    sMediaType = aMediaType;
+                    msMediaType = aMediaType;
 
                     bOk = true;
                 }
@@ -600,7 +600,7 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream()
         if ( !bIsEncrypted || !GetEncryptionData().is() )
             throw packages::NoEncryptionException(THROW_WHERE );
 
-        return rZipPackage.getZipFile().getWrappedRawStream( aEntry, GetEncryptionData(), sMediaType, rZipPackage.GetSharedMutexRef() );
+        return rZipPackage.getZipFile().getWrappedRawStream( aEntry, GetEncryptionData(), msMediaType, rZipPackage.GetSharedMutexRef() );
     }
     else if ( GetOwnSeekStream().is() )
     {
@@ -703,12 +703,12 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName,
         if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE && rZipPackage.getFormat() != embed::StorageFormats::OFOPXML )
             throw beans::PropertyVetoException(THROW_WHERE );
 
-        if ( aValue >>= sMediaType )
+        if ( aValue >>= msMediaType )
         {
-            if ( !sMediaType.isEmpty() )
+            if ( !msMediaType.isEmpty() )
             {
-                if ( sMediaType.indexOf ( "text" ) != -1
-                 || sMediaType == "application/vnd.sun.star.oleobject" )
+                if ( msMediaType.indexOf ( "text" ) != -1
+                 || msMediaType == "application/vnd.sun.star.oleobject" )
                     bToBeCompressed = true;
                 else if ( !m_bCompressedIsSetFromOutside )
                     bToBeCompressed = false;
@@ -859,7 +859,7 @@ Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName )
     Any aAny;
     if ( PropertyName == "MediaType" )
     {
-        aAny <<= sMediaType;
+        aAny <<= msMediaType;
         return aAny;
     }
     else if ( PropertyName == "Size" )
commit 9a25d12534f91c13400a63e265fb5aa14c6aca66
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Sep 30 13:40:06 2014 +0200

    This was OString already; use it that way
    
    Change-Id: Ia2268ce8a1e2111adb609c515e5bfa824afa66ce

diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index fbce18a..4466623 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -225,7 +225,7 @@ namespace sax_fastparser {
     void FastSaxSerializer::writeFastAttributeList( const Reference< XFastAttributeList >& Attribs )
     {
 #ifdef DBG_UTIL
-        ::std::set<OUString> DebugAttributes;
+        ::std::set<OString> DebugAttributes;
 #endif
         Sequence< Attribute > aAttrSeq = Attribs->getUnknownAttributes();
         const Attribute *pAttr = aAttrSeq.getConstArray();
@@ -258,10 +258,9 @@ namespace sax_fastparser {
 
 #ifdef DBG_UTIL
             // Well-formedness constraint: Unique Att Spec
-            OUString const name(OStringToOUString(getId(nToken),
-                                                  RTL_TEXTENCODING_UTF8));
-            assert(DebugAttributes.find(name) == DebugAttributes.end());
-            DebugAttributes.insert(name);
+            OString const nameId(getId(nToken));
+            assert(DebugAttributes.find(nameId) == DebugAttributes.end());
+            DebugAttributes.insert(nameId);
 #endif
 
             writeBytes(toUnoSequence(maEqualSignAndQuote));
commit 86de557ea2e9ab393909f66b9b2906573a2f9ef1
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Sep 24 12:46:49 2014 +0200

    Unused PowerPointExport::mpMasterFSArray member
    
    Change-Id: I02b9c31146396a39a624fbb869a5880b176e0f9e

diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index 0197b97..aa59d0c 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -141,7 +141,6 @@ private:
 
     LayoutInfo mLayoutInfo[EPP_LAYOUT_SIZE];
     std::vector< ::sax_fastparser::FSHelperPtr > mpSlidesFSArray;
-    std::vector< ::sax_fastparser::FSHelperPtr > mpMasterFSArray;
     sal_Int32 mnLayoutFileIdMax;
 
     sal_uInt32 mnSlideIdMax;
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index d00f4d8..caf46c6 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1555,9 +1555,6 @@ void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPr
                       .appendAscii( ".xml" )
                       .makeStringAndClear(),
                       "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" );
-    if( mpMasterFSArray.size() < mnMasterPages )
-        mpMasterFSArray.resize( mnMasterPages );
-    mpMasterFSArray[ nPageNum ] = pFS;
 
     // write theme per master
     WriteTheme( nPageNum );


More information about the Libreoffice-commits mailing list