[Libreoffice-commits] core.git: 2 commits - opencl/source package/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 3 10:40:19 UTC 2020


 opencl/source/OpenCLZone.cxx                |   24 
 package/source/manifest/ManifestImport.cxx  |  252 ++++----
 package/source/xstor/owriteablestream.cxx   |  316 +++++-----
 package/source/xstor/xstorage.cxx           |  534 ++++++++---------
 package/source/zipapi/XUnbufferedStream.cxx |   34 -
 package/source/zipapi/ZipOutputEntry.cxx    |   44 -
 package/source/zippackage/ZipPackage.cxx    |  876 ++++++++++++++--------------
 7 files changed, 1041 insertions(+), 1039 deletions(-)

New commits:
commit 7bf522852570b562757818ae0cef379e2408bc7b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 3 10:49:37 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 3 12:39:54 2020 +0200

    loplugin:flatten in package
    
    Change-Id: I4d81c7c1d241e51565d7cbc6549ac586136f0c86
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91616
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx
index 0841c7be402c..952309ca82ec 100644
--- a/package/source/manifest/ManifestImport.cxx
+++ b/package/source/manifest/ManifestImport.cxx
@@ -215,94 +215,97 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs)
     // to import the initialisation vector, salt and iteration count used
     nDerivedKeySize = 0;
     OUString aString = rConvertedAttribs[gsChecksumTypeAttribute];
-    if ( !bIgnoreEncryptData ) {
-        if ( aString == gsSHA1_1k_Name || aString == gsSHA1_1k_URL ) {
-            aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty;
-            aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA1_1K;
-        } else if ( aString == gsSHA256_1k_URL ) {
-            aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty;
-            aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA256_1K;
-        } else
-            bIgnoreEncryptData = true;
+    if ( bIgnoreEncryptData )
+        return;
 
-        if ( !bIgnoreEncryptData ) {
-            aString = rConvertedAttribs[gsChecksumAttribute];
-            uno::Sequence < sal_Int8 > aDecodeBuffer;
-            ::comphelper::Base64::decode(aDecodeBuffer, aString);
-            aSequence[PKG_MNFST_DIGEST].Name = gsDigestProperty;
-            aSequence[PKG_MNFST_DIGEST].Value <<= aDecodeBuffer;
-        }
+    if ( aString == gsSHA1_1k_Name || aString == gsSHA1_1k_URL ) {
+        aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty;
+        aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA1_1K;
+    } else if ( aString == gsSHA256_1k_URL ) {
+        aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty;
+        aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA256_1K;
+    } else
+        bIgnoreEncryptData = true;
+
+    if ( !bIgnoreEncryptData ) {
+        aString = rConvertedAttribs[gsChecksumAttribute];
+        uno::Sequence < sal_Int8 > aDecodeBuffer;
+        ::comphelper::Base64::decode(aDecodeBuffer, aString);
+        aSequence[PKG_MNFST_DIGEST].Name = gsDigestProperty;
+        aSequence[PKG_MNFST_DIGEST].Value <<= aDecodeBuffer;
     }
 }
 
 void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs)
 {
-    if ( !bIgnoreEncryptData ) {
-        OUString aString = rConvertedAttribs[gsAlgorithmNameAttribute];
-        if ( aString == gsBlowfish_Name || aString == gsBlowfish_URL ) {
-            aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
-            aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8;
-        } else if ( aString == gsAES256_URL ) {
-            aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
-            aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
-            OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 32, "Unexpected derived key length!" );
-            nDerivedKeySize = 32;
-        } else if ( aString == gsAES192_URL ) {
-            aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
-            aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
-            OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 24, "Unexpected derived key length!" );
-            nDerivedKeySize = 24;
-        } else if ( aString == gsAES128_URL ) {
-            aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
-            aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
-            OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 16, "Unexpected derived key length!" );
-            nDerivedKeySize = 16;
-        } else
-            bIgnoreEncryptData = true;
+    if ( bIgnoreEncryptData )
+        return;
 
-        if ( !bIgnoreEncryptData ) {
-            aString = rConvertedAttribs[gsInitialisationVectorAttribute];
-            uno::Sequence < sal_Int8 > aDecodeBuffer;
-            ::comphelper::Base64::decode(aDecodeBuffer, aString);
-            aSequence[PKG_MNFST_INIVECTOR].Name = gsInitialisationVectorProperty;
-            aSequence[PKG_MNFST_INIVECTOR].Value <<= aDecodeBuffer;
-        }
+    OUString aString = rConvertedAttribs[gsAlgorithmNameAttribute];
+    if ( aString == gsBlowfish_Name || aString == gsBlowfish_URL ) {
+        aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
+        aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8;
+    } else if ( aString == gsAES256_URL ) {
+        aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
+        aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
+        OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 32, "Unexpected derived key length!" );
+        nDerivedKeySize = 32;
+    } else if ( aString == gsAES192_URL ) {
+        aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
+        aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
+        OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 24, "Unexpected derived key length!" );
+        nDerivedKeySize = 24;
+    } else if ( aString == gsAES128_URL ) {
+        aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
+        aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
+        OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 16, "Unexpected derived key length!" );
+        nDerivedKeySize = 16;
+    } else
+        bIgnoreEncryptData = true;
+
+    if ( !bIgnoreEncryptData ) {
+        aString = rConvertedAttribs[gsInitialisationVectorAttribute];
+        uno::Sequence < sal_Int8 > aDecodeBuffer;
+        ::comphelper::Base64::decode(aDecodeBuffer, aString);
+        aSequence[PKG_MNFST_INIVECTOR].Name = gsInitialisationVectorProperty;
+        aSequence[PKG_MNFST_INIVECTOR].Value <<= aDecodeBuffer;
     }
 }
 
 void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs)
 {
-    if ( !bIgnoreEncryptData ) {
-        OUString aString = rConvertedAttribs[gsKeyDerivationNameAttribute];
-        if ( aString == gsPBKDF2_Name || aString == gsPBKDF2_URL ) {
-            aString = rConvertedAttribs[gsSaltAttribute];
-            uno::Sequence < sal_Int8 > aDecodeBuffer;
-            ::comphelper::Base64::decode(aDecodeBuffer, aString);
-            aSequence[PKG_MNFST_SALT].Name = gsSaltProperty;
-            aSequence[PKG_MNFST_SALT].Value <<= aDecodeBuffer;
-
-            aString = rConvertedAttribs[gsIterationCountAttribute];
-            aSequence[PKG_MNFST_ITERATION].Name = gsIterationCountProperty;
-            aSequence[PKG_MNFST_ITERATION].Value <<= aString.toInt32();
-
-            aString = rConvertedAttribs[gsKeySizeAttribute];
-            if ( aString.getLength() ) {
-                sal_Int32 nKey = aString.toInt32();
-                OSL_ENSURE( !nDerivedKeySize || nKey == nDerivedKeySize , "Provided derived key length differs from the expected one!" );
-                nDerivedKeySize = nKey;
-            } else if ( !nDerivedKeySize )
-                nDerivedKeySize = 16;
-            else if ( nDerivedKeySize != 16 )
-                OSL_ENSURE( false, "Default derived key length differs from the expected one!" );
-
-            aSequence[PKG_MNFST_DERKEYSIZE].Name = gsDerivedKeySizeProperty;
-            aSequence[PKG_MNFST_DERKEYSIZE].Value <<= nDerivedKeySize;
-        } else if ( bPgpEncryption ) {
-            if ( aString != "PGP" )
-                bIgnoreEncryptData = true;
-        } else
+    if ( bIgnoreEncryptData )
+        return;
+
+    OUString aString = rConvertedAttribs[gsKeyDerivationNameAttribute];
+    if ( aString == gsPBKDF2_Name || aString == gsPBKDF2_URL ) {
+        aString = rConvertedAttribs[gsSaltAttribute];
+        uno::Sequence < sal_Int8 > aDecodeBuffer;
+        ::comphelper::Base64::decode(aDecodeBuffer, aString);
+        aSequence[PKG_MNFST_SALT].Name = gsSaltProperty;
+        aSequence[PKG_MNFST_SALT].Value <<= aDecodeBuffer;
+
+        aString = rConvertedAttribs[gsIterationCountAttribute];
+        aSequence[PKG_MNFST_ITERATION].Name = gsIterationCountProperty;
+        aSequence[PKG_MNFST_ITERATION].Value <<= aString.toInt32();
+
+        aString = rConvertedAttribs[gsKeySizeAttribute];
+        if ( aString.getLength() ) {
+            sal_Int32 nKey = aString.toInt32();
+            OSL_ENSURE( !nDerivedKeySize || nKey == nDerivedKeySize , "Provided derived key length differs from the expected one!" );
+            nDerivedKeySize = nKey;
+        } else if ( !nDerivedKeySize )
+            nDerivedKeySize = 16;
+        else if ( nDerivedKeySize != 16 )
+            OSL_ENSURE( false, "Default derived key length differs from the expected one!" );
+
+        aSequence[PKG_MNFST_DERKEYSIZE].Name = gsDerivedKeySizeProperty;
+        aSequence[PKG_MNFST_DERKEYSIZE].Value <<= nDerivedKeySize;
+    } else if ( bPgpEncryption ) {
+        if ( aString != "PGP" )
             bIgnoreEncryptData = true;
-    }
+    } else
+        bIgnoreEncryptData = true;
 }
 
 void ManifestImport::doStartKeyAlg(StringHashMap &rConvertedAttribs)
@@ -449,62 +452,61 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName )
     assert(nLevel >= 1);
 
     OUString aConvertedName = ConvertName( aName );
-    if ( !aStack.empty() && aStack.rbegin()->m_aConvertedName == aConvertedName ) {
-        if ( aConvertedName == gsFileEntryElement && aStack.back().m_bValid ) {
-            // root folder gets KeyInfo entry if any, for PGP encryption
-            if (!bIgnoreEncryptData && !aKeys.empty() && aSequence[PKG_MNFST_FULLPATH].Value.get<OUString>() == "/" )
-            {
-                aSequence[PKG_SIZE_NOENCR_MNFST].Name = "KeyInfo";
-                aSequence[PKG_SIZE_NOENCR_MNFST].Value <<= comphelper::containerToSequence(aKeys);
-            }
-            aSequence.erase(std::remove_if(aSequence.begin(), aSequence.end(),
-                                           isEmpty), aSequence.end());
+    if ( !(!aStack.empty() && aStack.rbegin()->m_aConvertedName == aConvertedName) )        return;
+
+    if ( aConvertedName == gsFileEntryElement && aStack.back().m_bValid ) {
+        // root folder gets KeyInfo entry if any, for PGP encryption
+        if (!bIgnoreEncryptData && !aKeys.empty() && aSequence[PKG_MNFST_FULLPATH].Value.get<OUString>() == "/" )
+        {
+            aSequence[PKG_SIZE_NOENCR_MNFST].Name = "KeyInfo";
+            aSequence[PKG_SIZE_NOENCR_MNFST].Value <<= comphelper::containerToSequence(aKeys);
+        }
+        aSequence.erase(std::remove_if(aSequence.begin(), aSequence.end(),
+                                       isEmpty), aSequence.end());
 
-            bIgnoreEncryptData = false;
-            rManVector.push_back ( comphelper::containerToSequence(aSequence) );
+        bIgnoreEncryptData = false;
+        rManVector.push_back ( comphelper::containerToSequence(aSequence) );
 
-            aSequence.clear();
-        }
-        else if ( (aConvertedName == gsEncryptedKeyElement
-                   || aConvertedName == gsEncryptedKeyElement13)
-                  && aStack.back().m_bValid ) {
-            if ( !bIgnoreEncryptData )
-            {
-                aKeys.push_back( comphelper::containerToSequence(aKeyInfoSequence) );
-                bPgpEncryption = true;
-            }
-            aKeyInfoSequence.clear();
+        aSequence.clear();
+    }
+    else if ( (aConvertedName == gsEncryptedKeyElement
+               || aConvertedName == gsEncryptedKeyElement13)
+              && aStack.back().m_bValid ) {
+        if ( !bIgnoreEncryptData )
+        {
+            aKeys.push_back( comphelper::containerToSequence(aKeyInfoSequence) );
+            bPgpEncryption = true;
         }
+        aKeyInfoSequence.clear();
+    }
 
-        // end element handling for elements with cdata
-        switch (nLevel) {
-            case 5: {
-                if (aConvertedName == gsCipherValueElement) //loext:CipherValue
-                    doEncryptedCipherValue();
-                else if (aConvertedName == gsCipherValueElement13) //manifest:CipherValue
-                    doEncryptedCipherValue();
-                else if (aConvertedName == gsPgpKeyIDElement13)   //manifest:PGPKeyID
-                    doEncryptedKeyId();
-                else if (aConvertedName == gsPGPKeyPacketElement13) //manifest:PGPKeyPacket
-                    doEncryptedKeyPacket();
-                else
-                    aStack.back().m_bValid = false;
-                break;
-            }
-            case 6: {
-                if (aConvertedName == gsPgpKeyIDElement)   //loext:PGPKeyID
-                    doEncryptedKeyId();
-                else if (aConvertedName == gsPGPKeyPacketElement) //loext:PGPKeyPacket
-                    doEncryptedKeyPacket();
-                else
-                    aStack.back().m_bValid = false;
-                break;
-            }
+    // end element handling for elements with cdata
+    switch (nLevel) {
+        case 5: {
+            if (aConvertedName == gsCipherValueElement) //loext:CipherValue
+                doEncryptedCipherValue();
+            else if (aConvertedName == gsCipherValueElement13) //manifest:CipherValue
+                doEncryptedCipherValue();
+            else if (aConvertedName == gsPgpKeyIDElement13)   //manifest:PGPKeyID
+                doEncryptedKeyId();
+            else if (aConvertedName == gsPGPKeyPacketElement13) //manifest:PGPKeyPacket
+                doEncryptedKeyPacket();
+            else
+                aStack.back().m_bValid = false;
+            break;
+        }
+        case 6: {
+            if (aConvertedName == gsPgpKeyIDElement)   //loext:PGPKeyID
+                doEncryptedKeyId();
+            else if (aConvertedName == gsPGPKeyPacketElement) //loext:PGPKeyPacket
+                doEncryptedKeyPacket();
+            else
+                aStack.back().m_bValid = false;
+            break;
         }
-
-        aStack.pop_back();
-        return;
     }
+
+    aStack.pop_back();
 }
 
 void SAL_CALL ManifestImport::characters( const OUString& aChars )
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index e01108b59d91..ac97214b7a1e 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -306,29 +306,29 @@ OWriteStream_Impl::~OWriteStream_Impl()
 
 void OWriteStream_Impl::CleanCacheStream()
 {
-    if ( m_xCacheStream.is() )
-    {
-        try
-        {
-            uno::Reference< io::XInputStream > xInputCache = m_xCacheStream->getInputStream();
-            if ( xInputCache.is() )
-                xInputCache->closeInput();
-        }
-        catch( const uno::Exception& )
-        {}
+    if ( !m_xCacheStream.is() )
+        return;
 
-        try
-        {
-            uno::Reference< io::XOutputStream > xOutputCache = m_xCacheStream->getOutputStream();
-            if ( xOutputCache.is() )
-                xOutputCache->closeOutput();
-        }
-        catch( const uno::Exception& )
-        {}
+    try
+    {
+        uno::Reference< io::XInputStream > xInputCache = m_xCacheStream->getInputStream();
+        if ( xInputCache.is() )
+            xInputCache->closeInput();
+    }
+    catch( const uno::Exception& )
+    {}
 
-        m_xCacheStream.clear();
-        m_xCacheSeek.clear();
+    try
+    {
+        uno::Reference< io::XOutputStream > xOutputCache = m_xCacheStream->getOutputStream();
+        if ( xOutputCache.is() )
+            xOutputCache->closeOutput();
     }
+    catch( const uno::Exception& )
+    {}
+
+    m_xCacheStream.clear();
+    m_xCacheSeek.clear();
 }
 
 void OWriteStream_Impl::InsertIntoPackageFolder( const OUString& aName,
@@ -475,19 +475,19 @@ void OWriteStream_Impl::DisposeWrappers()
     }
     m_pParent = nullptr;
 
-    if ( !m_aInputStreamsVector.empty() )
+    if ( m_aInputStreamsVector.empty() )
+        return;
+
+    for ( auto& pStream : m_aInputStreamsVector )
     {
-        for ( auto& pStream : m_aInputStreamsVector )
+        if ( pStream )
         {
-            if ( pStream )
-            {
-                pStream->InternalDispose();
-                pStream = nullptr;
-            }
+            pStream->InternalDispose();
+            pStream = nullptr;
         }
-
-        m_aInputStreamsVector.clear();
     }
+
+    m_aInputStreamsVector.clear();
 }
 
 OUString const & OWriteStream_Impl::GetFilledTempFileIfNo( const uno::Reference< io::XInputStream >& xStream )
@@ -897,25 +897,25 @@ void OWriteStream_Impl::Revert()
     m_bHasCachedEncryptionData = false;
     m_aEncryptionData.clear();
 
-    if ( m_nStorageType == embed::StorageFormats::OFOPXML )
+    if ( m_nStorageType != embed::StorageFormats::OFOPXML )
+        return;
+
+    // currently the relations storage is changed only on commit
+    m_xNewRelInfoStream.clear();
+    m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
+    if ( m_xOrigRelInfoStream.is() )
     {
-        // currently the relations storage is changed only on commit
-        m_xNewRelInfoStream.clear();
-        m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
-        if ( m_xOrigRelInfoStream.is() )
-        {
-            // the original stream is still here, that means that it was not parsed
-            m_aOrigRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
-            m_nRelInfoStatus = RELINFO_NO_INIT;
-        }
+        // the original stream is still here, that means that it was not parsed
+        m_aOrigRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
+        m_nRelInfoStatus = RELINFO_NO_INIT;
+    }
+    else
+    {
+        // the original stream was already parsed
+        if ( !m_bOrigRelInfoBroken )
+            m_nRelInfoStatus = RELINFO_READ;
         else
-        {
-            // the original stream was already parsed
-            if ( !m_bOrigRelInfoBroken )
-                m_nRelInfoStatus = RELINFO_READ;
-            else
-                m_nRelInfoStatus = RELINFO_BROKEN;
-        }
+            m_nRelInfoStatus = RELINFO_BROKEN;
     }
 }
 
@@ -1501,95 +1501,95 @@ void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStora
     // at this point of time the old stream must be already cleaned
     OSL_ENSURE( m_nStorageType == embed::StorageFormats::OFOPXML, "The method should be used only with OFOPXML format!" );
 
-    if ( m_nStorageType == embed::StorageFormats::OFOPXML )
-    {
-        OSL_ENSURE( !aOrigStreamName.isEmpty() && !aNewStreamName.isEmpty() && xRelStorage.is(),
-                    "Wrong relation persistence information is provided!" );
-
-        if ( !xRelStorage.is() || aOrigStreamName.isEmpty() || aNewStreamName.isEmpty() )
-            throw uno::RuntimeException();
-
-        if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN )
-            throw io::IOException(); // TODO:
+    if ( m_nStorageType != embed::StorageFormats::OFOPXML )
+        return;
 
-        OUString aOrigRelStreamName = aOrigStreamName + ".rels";
-        OUString aNewRelStreamName = aNewStreamName + ".rels";
+    OSL_ENSURE( !aOrigStreamName.isEmpty() && !aNewStreamName.isEmpty() && xRelStorage.is(),
+                "Wrong relation persistence information is provided!" );
 
-        bool bRenamed = aOrigRelStreamName != aNewRelStreamName;
-        if ( m_nRelInfoStatus == RELINFO_CHANGED
-          || m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
-          || m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
-        {
-            if ( bRenamed && xRelStorage->hasByName( aOrigRelStreamName ) )
-                xRelStorage->removeElement( aOrigRelStreamName );
-
-            if ( m_nRelInfoStatus == RELINFO_CHANGED )
-            {
-                if ( m_aNewRelInfo.hasElements() )
-                {
-                    uno::Reference< io::XStream > xRelsStream =
-                        xRelStorage->openStreamElement( aNewRelStreamName,
-                                                          embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
+    if ( !xRelStorage.is() || aOrigStreamName.isEmpty() || aNewStreamName.isEmpty() )
+        throw uno::RuntimeException();
 
-                    uno::Reference< io::XOutputStream > xOutStream = xRelsStream->getOutputStream();
-                    if ( !xOutStream.is() )
-                        throw uno::RuntimeException();
+    if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN )
+        throw io::IOException(); // TODO:
 
-                    ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence( xOutStream, m_aNewRelInfo, m_xContext );
+    OUString aOrigRelStreamName = aOrigStreamName + ".rels";
+    OUString aNewRelStreamName = aNewStreamName + ".rels";
 
-                    // set the mediatype
-                    uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
-                    xPropSet->setPropertyValue(
-                        "MediaType",
-                        uno::makeAny( OUString("application/vnd.openxmlformats-package.relationships+xml" ) ) );
+    bool bRenamed = aOrigRelStreamName != aNewRelStreamName;
+    if ( m_nRelInfoStatus == RELINFO_CHANGED
+      || m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
+      || m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
+    {
+        if ( bRenamed && xRelStorage->hasByName( aOrigRelStreamName ) )
+            xRelStorage->removeElement( aOrigRelStreamName );
 
-                    m_nRelInfoStatus = RELINFO_READ;
-                }
-            }
-            else if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
-                      || m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
+        if ( m_nRelInfoStatus == RELINFO_CHANGED )
+        {
+            if ( m_aNewRelInfo.hasElements() )
             {
                 uno::Reference< io::XStream > xRelsStream =
                     xRelStorage->openStreamElement( aNewRelStreamName,
-                                                        embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
+                                                      embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
 
-                uno::Reference< io::XOutputStream > xOutputStream = xRelsStream->getOutputStream();
-                if ( !xOutputStream.is() )
+                uno::Reference< io::XOutputStream > xOutStream = xRelsStream->getOutputStream();
+                if ( !xOutStream.is() )
                     throw uno::RuntimeException();
 
-                uno::Reference< io::XSeekable > xSeek( m_xNewRelInfoStream, uno::UNO_QUERY_THROW );
-                xSeek->seek( 0 );
-                ::comphelper::OStorageHelper::CopyInputToOutput( m_xNewRelInfoStream, xOutputStream );
-                xSeek->seek( 0 );
+                ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence( xOutStream, m_aNewRelInfo, m_xContext );
 
                 // set the mediatype
                 uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
-                xPropSet->setPropertyValue("MediaType",
+                xPropSet->setPropertyValue(
+                    "MediaType",
                     uno::makeAny( OUString("application/vnd.openxmlformats-package.relationships+xml" ) ) );
 
-                if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
-                    m_nRelInfoStatus = RELINFO_NO_INIT;
-                else
-                {
-                    // the information is already parsed and the stream is stored, no need in temporary stream any more
-                    m_xNewRelInfoStream.clear();
-                    m_nRelInfoStatus = RELINFO_READ;
-                }
+                m_nRelInfoStatus = RELINFO_READ;
             }
-
-            // the original stream makes no sense after this step
-            m_xOrigRelInfoStream = m_xNewRelInfoStream;
-            m_aOrigRelInfo = m_aNewRelInfo;
-            m_bOrigRelInfoBroken = false;
-            m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
-            m_xNewRelInfoStream.clear();
         }
-        else
+        else if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
+                  || m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
         {
-            // the stream is not changed but it might be renamed
-            if ( bRenamed && xRelStorage->hasByName( aOrigRelStreamName ) )
-                xRelStorage->renameElement( aOrigRelStreamName, aNewRelStreamName );
+            uno::Reference< io::XStream > xRelsStream =
+                xRelStorage->openStreamElement( aNewRelStreamName,
+                                                    embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
+
+            uno::Reference< io::XOutputStream > xOutputStream = xRelsStream->getOutputStream();
+            if ( !xOutputStream.is() )
+                throw uno::RuntimeException();
+
+            uno::Reference< io::XSeekable > xSeek( m_xNewRelInfoStream, uno::UNO_QUERY_THROW );
+            xSeek->seek( 0 );
+            ::comphelper::OStorageHelper::CopyInputToOutput( m_xNewRelInfoStream, xOutputStream );
+            xSeek->seek( 0 );
+
+            // set the mediatype
+            uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
+            xPropSet->setPropertyValue("MediaType",
+                uno::makeAny( OUString("application/vnd.openxmlformats-package.relationships+xml" ) ) );
+
+            if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
+                m_nRelInfoStatus = RELINFO_NO_INIT;
+            else
+            {
+                // the information is already parsed and the stream is stored, no need in temporary stream any more
+                m_xNewRelInfoStream.clear();
+                m_nRelInfoStatus = RELINFO_READ;
+            }
         }
+
+        // the original stream makes no sense after this step
+        m_xOrigRelInfoStream = m_xNewRelInfoStream;
+        m_aOrigRelInfo = m_aNewRelInfo;
+        m_bOrigRelInfoBroken = false;
+        m_aNewRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
+        m_xNewRelInfoStream.clear();
+    }
+    else
+    {
+        // the stream is not changed but it might be renamed
+        if ( bRenamed && xRelStorage->hasByName( aOrigRelStreamName ) )
+            xRelStorage->renameElement( aOrigRelStreamName, aNewRelStreamName );
     }
 }
 
@@ -1673,20 +1673,20 @@ void OWriteStream::CheckInitOnDemand()
         throw lang::DisposedException();
     }
 
-    if ( m_bInitOnDemand )
+    if ( !m_bInitOnDemand )
+        return;
+
+    SAL_INFO( "package.xstor", "package (mv76033) OWriteStream::CheckInitOnDemand, initializing" );
+    uno::Reference< io::XStream > xStream = m_pImpl->GetTempFileAsStream();
+    if ( xStream.is() )
     {
-        SAL_INFO( "package.xstor", "package (mv76033) OWriteStream::CheckInitOnDemand, initializing" );
-        uno::Reference< io::XStream > xStream = m_pImpl->GetTempFileAsStream();
-        if ( xStream.is() )
-        {
-            m_xInStream.set( xStream->getInputStream(), uno::UNO_SET_THROW );
-            m_xOutStream.set( xStream->getOutputStream(), uno::UNO_SET_THROW );
-            m_xSeekable.set( xStream, uno::UNO_QUERY_THROW );
-            m_xSeekable->seek( m_nInitPosition );
+        m_xInStream.set( xStream->getInputStream(), uno::UNO_SET_THROW );
+        m_xOutStream.set( xStream->getOutputStream(), uno::UNO_SET_THROW );
+        m_xSeekable.set( xStream, uno::UNO_QUERY_THROW );
+        m_xSeekable->seek( m_nInitPosition );
 
-            m_nInitPosition = 0;
-            m_bInitOnDemand = false;
-        }
+        m_nInitPosition = 0;
+        m_bInitOnDemand = false;
     }
 }
 
@@ -2178,18 +2178,18 @@ void OWriteStream::CloseOutput_Impl()
     m_xOutStream->closeOutput();
     m_xOutStream.clear();
 
-    if ( !m_bInitOnDemand )
-    {
-        // after the stream is disposed it can be committed
-        // so transport correct size property
-        if ( !m_xSeekable.is() )
-            throw uno::RuntimeException();
+    if ( m_bInitOnDemand )
+        return;
 
-        for ( auto& rProp : m_pImpl->m_aProps )
-        {
-            if ( rProp.Name == "Size" )
-                rProp.Value <<= m_xSeekable->getLength();
-        }
+    // after the stream is disposed it can be committed
+    // so transport correct size property
+    if ( !m_xSeekable.is() )
+        throw uno::RuntimeException();
+
+    for ( auto& rProp : m_pImpl->m_aProps )
+    {
+        if ( rProp.Name == "Size" )
+            rProp.Value <<= m_xSeekable->getLength();
     }
 }
 
@@ -3021,29 +3021,29 @@ void OWriteStream::BroadcastTransaction( sal_Int8 nMessage )
     ::cppu::OInterfaceContainerHelper* pContainer =
             m_pData->m_aListenersContainer.getContainer(
                 cppu::UnoType<embed::XTransactionListener>::get());
-    if ( pContainer )
+    if ( !pContainer )
+           return;
+
+    ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
+    while ( pIterator.hasMoreElements( ) )
     {
-           ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
-           while ( pIterator.hasMoreElements( ) )
-           {
-            OSL_ENSURE( nMessage >= 1 && nMessage <= 4, "Wrong internal notification code is used!" );
+        OSL_ENSURE( nMessage >= 1 && nMessage <= 4, "Wrong internal notification code is used!" );
 
-            switch( nMessage )
-            {
-                case STOR_MESS_PRECOMMIT:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preCommit( aSource );
-                    break;
-                case STOR_MESS_COMMITTED:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->commited( aSource );
-                    break;
-                case STOR_MESS_PREREVERT:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preRevert( aSource );
-                    break;
-                case STOR_MESS_REVERTED:
-                       static_cast< embed::XTransactionListener*>( pIterator.next( ) )->reverted( aSource );
-                    break;
-            }
-           }
+        switch( nMessage )
+        {
+            case STOR_MESS_PRECOMMIT:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preCommit( aSource );
+                break;
+            case STOR_MESS_COMMITTED:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->commited( aSource );
+                break;
+            case STOR_MESS_PREREVERT:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preRevert( aSource );
+                break;
+            case STOR_MESS_REVERTED:
+                   static_cast< embed::XTransactionListener*>( pIterator.next( ) )->reverted( aSource );
+                break;
+        }
     }
 }
 void SAL_CALL OWriteStream::commit()
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index f5afff414feb..507f8b8ef257 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -496,24 +496,24 @@ bool OStorage_Impl::HasChildren()
 
 void OStorage_Impl::GetStorageProperties()
 {
-    if ( m_nStorageType == embed::StorageFormats::PACKAGE )
-    {
-        uno::Reference< beans::XPropertySet > xProps( m_xPackageFolder, uno::UNO_QUERY_THROW );
+    if ( m_nStorageType != embed::StorageFormats::PACKAGE )
+        return;
 
-        if ( !m_bControlMediaType )
-        {
-            uno::Reference< beans::XPropertySet > xPackageProps( m_xPackage, uno::UNO_QUERY_THROW );
-            xPackageProps->getPropertyValue( MEDIATYPE_FALLBACK_USED_PROPERTY ) >>= m_bMTFallbackUsed;
+    uno::Reference< beans::XPropertySet > xProps( m_xPackageFolder, uno::UNO_QUERY_THROW );
 
-            xProps->getPropertyValue( "MediaType" ) >>= m_aMediaType;
-            m_bControlMediaType = true;
-        }
+    if ( !m_bControlMediaType )
+    {
+        uno::Reference< beans::XPropertySet > xPackageProps( m_xPackage, uno::UNO_QUERY_THROW );
+        xPackageProps->getPropertyValue( MEDIATYPE_FALLBACK_USED_PROPERTY ) >>= m_bMTFallbackUsed;
 
-        if ( !m_bControlVersion )
-        {
-            xProps->getPropertyValue( "Version" ) >>= m_aVersion;
-            m_bControlVersion = true;
-        }
+        xProps->getPropertyValue( "MediaType" ) >>= m_aMediaType;
+        m_bControlMediaType = true;
+    }
+
+    if ( !m_bControlVersion )
+    {
+        xProps->getPropertyValue( "Version" ) >>= m_aVersion;
+        m_bControlVersion = true;
     }
 
     // the properties of OFOPXML will be handled directly
@@ -1477,20 +1477,20 @@ void OStorage_Impl::OpenSubStream( SotElement_Impl* pElement )
 
     ::osl::MutexGuard aGuard( m_xMutex->GetMutex() );
 
-    if (!pElement->m_xStream)
-    {
-        SAL_WARN_IF( pElement->m_bIsInserted, "package.xstor", "Inserted element must be created already!" );
+    if (pElement->m_xStream)
+        return;
 
-        uno::Reference< lang::XUnoTunnel > xTunnel;
-        m_xPackageFolder->getByName( pElement->m_aOriginalName ) >>= xTunnel;
-        if ( !xTunnel.is() )
-            throw container::NoSuchElementException( THROW_WHERE );
+    SAL_WARN_IF( pElement->m_bIsInserted, "package.xstor", "Inserted element must be created already!" );
 
-        uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY_THROW );
+    uno::Reference< lang::XUnoTunnel > xTunnel;
+    m_xPackageFolder->getByName( pElement->m_aOriginalName ) >>= xTunnel;
+    if ( !xTunnel.is() )
+        throw container::NoSuchElementException( THROW_WHERE );
 
-        // the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction
-        pElement->m_xStream.reset(new OWriteStream_Impl(this, xPackageSubStream, m_xPackage, m_xContext, false, m_nStorageType, false, GetRelInfoStreamForName(pElement->m_aOriginalName)));
-    }
+    uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY_THROW );
+
+    // the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction
+    pElement->m_xStream.reset(new OWriteStream_Impl(this, xPackageSubStream, m_xPackage, m_xContext, false, m_nStorageType, false, GetRelInfoStreamForName(pElement->m_aOriginalName)));
 }
 
 uno::Sequence< OUString > OStorage_Impl::GetElementNames()
@@ -1603,25 +1603,25 @@ void OStorage_Impl::CreateRelStorage()
     if ( m_nStorageType != embed::StorageFormats::OFOPXML )
         return;
 
-    if ( !m_xRelStorage.is() )
+    if ( m_xRelStorage.is() )
+        return;
+
+    if ( !m_pRelStorElement )
     {
-        if ( !m_pRelStorElement )
-        {
-            m_pRelStorElement = new SotElement_Impl( "_rels", true, true );
-            m_pRelStorElement->m_xStorage = CreateNewStorageImpl(embed::ElementModes::WRITE);
-            if (m_pRelStorElement->m_xStorage)
-                m_pRelStorElement->m_xStorage->m_pParent = nullptr; // the relation storage is completely controlled by parent
-        }
+        m_pRelStorElement = new SotElement_Impl( "_rels", true, true );
+        m_pRelStorElement->m_xStorage = CreateNewStorageImpl(embed::ElementModes::WRITE);
+        if (m_pRelStorElement->m_xStorage)
+            m_pRelStorElement->m_xStorage->m_pParent = nullptr; // the relation storage is completely controlled by parent
+    }
 
-        if (!m_pRelStorElement->m_xStorage)
-            OpenSubStorage( m_pRelStorElement, embed::ElementModes::WRITE );
+    if (!m_pRelStorElement->m_xStorage)
+        OpenSubStorage( m_pRelStorElement, embed::ElementModes::WRITE );
 
-        if (!m_pRelStorElement->m_xStorage)
-            throw uno::RuntimeException( THROW_WHERE );
+    if (!m_pRelStorElement->m_xStorage)
+        throw uno::RuntimeException( THROW_WHERE );
 
-        OStorage* pResultStorage = new OStorage(m_pRelStorElement->m_xStorage.get(), false);
-        m_xRelStorage.set( static_cast<embed::XStorage*>(pResultStorage) );
-    }
+    OStorage* pResultStorage = new OStorage(m_pRelStorElement->m_xStorage.get(), false);
+    m_xRelStorage.set( static_cast<embed::XStorage*>(pResultStorage) );
 }
 
 void OStorage_Impl::CommitStreamRelInfo( const OUString &rName, SotElement_Impl const * pStreamElement )
@@ -1674,92 +1674,92 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain
     if ( !xNewPackageFolder.is() )
         throw uno::RuntimeException( THROW_WHERE );
 
-    if ( m_nStorageType == embed::StorageFormats::OFOPXML )
-    {
-        if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN )
-            throw io::IOException( THROW_WHERE );
-
-        if (m_nRelInfoStatus == RELINFO_CHANGED)
-        {
-            if (m_aRelInfo.hasElements())
-            {
-                CreateRelStorage();
-
-                uno::Reference<io::XStream> xRelsStream = m_xRelStorage->openStreamElement(
-                    ".rels", embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE);
-
-                uno::Reference<io::XOutputStream> xOutStream = xRelsStream->getOutputStream();
-                if (!xOutStream.is())
-                    throw uno::RuntimeException(THROW_WHERE);
-
-                ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence(xOutStream, m_aRelInfo,
-                                                                        m_xContext);
+    if ( m_nStorageType != embed::StorageFormats::OFOPXML )
+        return;
 
-                // set the mediatype
-                uno::Reference<beans::XPropertySet> xPropSet(xRelsStream, uno::UNO_QUERY_THROW);
-                xPropSet->setPropertyValue(
-                    "MediaType", uno::makeAny(OUString(
-                                     "application/vnd.openxmlformats-package.relationships+xml")));
+    if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN )
+        throw io::IOException( THROW_WHERE );
 
-                m_nRelInfoStatus = RELINFO_READ;
-            }
-            else if (m_xRelStorage.is())
-                RemoveStreamRelInfo(OUString()); // remove own rel info
-        }
-        else if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
-                 || m_nRelInfoStatus == RELINFO_CHANGED_STREAM)
+    if (m_nRelInfoStatus == RELINFO_CHANGED)
+    {
+        if (m_aRelInfo.hasElements())
         {
             CreateRelStorage();
 
             uno::Reference<io::XStream> xRelsStream = m_xRelStorage->openStreamElement(
                 ".rels", embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE);
 
-            uno::Reference<io::XOutputStream> xOutputStream = xRelsStream->getOutputStream();
-            if (!xOutputStream.is())
+            uno::Reference<io::XOutputStream> xOutStream = xRelsStream->getOutputStream();
+            if (!xOutStream.is())
                 throw uno::RuntimeException(THROW_WHERE);
 
-            uno::Reference<io::XSeekable> xSeek(m_xNewRelInfoStream, uno::UNO_QUERY_THROW);
-            xSeek->seek(0);
-            ::comphelper::OStorageHelper::CopyInputToOutput(m_xNewRelInfoStream, xOutputStream);
+            ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence(xOutStream, m_aRelInfo,
+                                                                    m_xContext);
 
             // set the mediatype
             uno::Reference<beans::XPropertySet> xPropSet(xRelsStream, uno::UNO_QUERY_THROW);
             xPropSet->setPropertyValue(
-                "MediaType",
-                uno::makeAny(OUString("application/vnd.openxmlformats-package.relationships+xml")));
+                "MediaType", uno::makeAny(OUString(
+                                 "application/vnd.openxmlformats-package.relationships+xml")));
 
-            m_xNewRelInfoStream.clear();
-            if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM)
-            {
-                m_aRelInfo = uno::Sequence<uno::Sequence<beans::StringPair>>();
-                m_nRelInfoStatus = RELINFO_NO_INIT;
-            }
-            else
-                m_nRelInfoStatus = RELINFO_READ;
+            m_nRelInfoStatus = RELINFO_READ;
         }
+        else if (m_xRelStorage.is())
+            RemoveStreamRelInfo(OUString()); // remove own rel info
+    }
+    else if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
+             || m_nRelInfoStatus == RELINFO_CHANGED_STREAM)
+    {
+        CreateRelStorage();
 
-        if ( m_xRelStorage.is() )
-        {
-            if ( m_xRelStorage->hasElements() )
-            {
-                uno::Reference< embed::XTransactedObject > xTrans( m_xRelStorage, uno::UNO_QUERY_THROW );
-                xTrans->commit();
-            }
+        uno::Reference<io::XStream> xRelsStream = m_xRelStorage->openStreamElement(
+            ".rels", embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE);
 
-            if ( xNewPackageFolder.is() && xNewPackageFolder->hasByName( aRelsStorName ) )
-                xNewPackageFolder->removeByName( aRelsStorName );
+        uno::Reference<io::XOutputStream> xOutputStream = xRelsStream->getOutputStream();
+        if (!xOutputStream.is())
+            throw uno::RuntimeException(THROW_WHERE);
 
-            if ( !m_xRelStorage->hasElements() )
-            {
-                // the empty relations storage should not be created
-                delete m_pRelStorElement;
-                m_pRelStorElement = nullptr;
-                m_xRelStorage.clear();
-            }
-            else if ( m_pRelStorElement && m_pRelStorElement->m_xStorage && xNewPackageFolder.is() )
-                m_pRelStorElement->m_xStorage->InsertIntoPackageFolder( aRelsStorName, xNewPackageFolder );
+        uno::Reference<io::XSeekable> xSeek(m_xNewRelInfoStream, uno::UNO_QUERY_THROW);
+        xSeek->seek(0);
+        ::comphelper::OStorageHelper::CopyInputToOutput(m_xNewRelInfoStream, xOutputStream);
+
+        // set the mediatype
+        uno::Reference<beans::XPropertySet> xPropSet(xRelsStream, uno::UNO_QUERY_THROW);
+        xPropSet->setPropertyValue(
+            "MediaType",
+            uno::makeAny(OUString("application/vnd.openxmlformats-package.relationships+xml")));
+
+        m_xNewRelInfoStream.clear();
+        if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM)
+        {
+            m_aRelInfo = uno::Sequence<uno::Sequence<beans::StringPair>>();
+            m_nRelInfoStatus = RELINFO_NO_INIT;
         }
+        else
+            m_nRelInfoStatus = RELINFO_READ;
+    }
+
+    if ( !m_xRelStorage.is() )
+        return;
+
+    if ( m_xRelStorage->hasElements() )
+    {
+        uno::Reference< embed::XTransactedObject > xTrans( m_xRelStorage, uno::UNO_QUERY_THROW );
+        xTrans->commit();
+    }
+
+    if ( xNewPackageFolder.is() && xNewPackageFolder->hasByName( aRelsStorName ) )
+        xNewPackageFolder->removeByName( aRelsStorName );
+
+    if ( !m_xRelStorage->hasElements() )
+    {
+        // the empty relations storage should not be created
+        delete m_pRelStorElement;
+        m_pRelStorElement = nullptr;
+        m_xRelStorage.clear();
     }
+    else if ( m_pRelStorElement && m_pRelStorElement->m_xStorage && xNewPackageFolder.is() )
+        m_pRelStorElement->m_xStorage->InsertIntoPackageFolder( aRelsStorName, xNewPackageFolder );
 }
 
 // OStorage implementation
@@ -1963,29 +1963,29 @@ void OStorage::BroadcastTransaction( sal_Int8 nMessage )
     ::cppu::OInterfaceContainerHelper* pContainer =
             m_pData->m_aListenersContainer.getContainer(
                 cppu::UnoType<embed::XTransactionListener>::get());
-    if ( pContainer )
+    if ( !pContainer )
+           return;
+
+    ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
+    while ( pIterator.hasMoreElements( ) )
     {
-           ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
-           while ( pIterator.hasMoreElements( ) )
-           {
-            OSL_ENSURE( nMessage >= 1 && nMessage <= 4, "Wrong internal notification code is used!" );
+        OSL_ENSURE( nMessage >= 1 && nMessage <= 4, "Wrong internal notification code is used!" );
 
-            switch( nMessage )
-            {
-                case STOR_MESS_PRECOMMIT:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preCommit( aSource );
-                    break;
-                case STOR_MESS_COMMITTED:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->commited( aSource );
-                    break;
-                case STOR_MESS_PREREVERT:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preRevert( aSource );
-                    break;
-                case STOR_MESS_REVERTED:
-                       static_cast<embed::XTransactionListener*>( pIterator.next( ) )->reverted( aSource );
-                    break;
-            }
-           }
+        switch( nMessage )
+        {
+            case STOR_MESS_PRECOMMIT:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preCommit( aSource );
+                break;
+            case STOR_MESS_COMMITTED:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->commited( aSource );
+                break;
+            case STOR_MESS_PREREVERT:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->preRevert( aSource );
+                break;
+            case STOR_MESS_REVERTED:
+                   static_cast<embed::XTransactionListener*>( pIterator.next( ) )->reverted( aSource );
+                break;
+        }
     }
 }
 
@@ -4039,48 +4039,48 @@ void SAL_CALL OStorage::removeEncryption()
         throw uno::RuntimeException( THROW_WHERE ); // the interface must be visible only for package storage
 
     SAL_WARN_IF( !m_pData->m_bIsRoot, "package.xstor", "removeEncryption() method is not available for nonroot storages!" );
-    if ( m_pData->m_bIsRoot )
+    if ( !m_pData->m_bIsRoot )
+        return;
+
+    try {
+        m_pImpl->ReadContents();
+    }
+    catch ( const uno::RuntimeException& )
     {
-        try {
-            m_pImpl->ReadContents();
-        }
-        catch ( const uno::RuntimeException& )
-        {
-            TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
-            throw;
-        }
-        catch ( const uno::Exception& )
-        {
-            uno::Any aCaught( ::cppu::getCaughtException() );
-            SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
+        TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
+        throw;
+    }
+    catch ( const uno::Exception& )
+    {
+        uno::Any aCaught( ::cppu::getCaughtException() );
+        SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
 
-            throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
-                                                static_cast< OWeakObject* >( this ),
-                                                aCaught );
-        }
+        throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
+                                            static_cast< OWeakObject* >( this ),
+                                            aCaught );
+    }
 
-        // TODO: check if the password is valid
-        // update all streams that was encrypted with old password
+    // TODO: check if the password is valid
+    // update all streams that was encrypted with old password
 
-        uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
-        try
-        {
-            xPackPropSet->setPropertyValue( STORAGE_ENCRYPTION_KEYS_PROPERTY,
-                                            uno::makeAny( uno::Sequence< beans::NamedValue >() ) );
+    uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
+    try
+    {
+        xPackPropSet->setPropertyValue( STORAGE_ENCRYPTION_KEYS_PROPERTY,
+                                        uno::makeAny( uno::Sequence< beans::NamedValue >() ) );
 
-            m_pImpl->m_bHasCommonEncryptionData = false;
-            m_pImpl->m_aCommonEncryptionData.clear();
-        }
-        catch( const uno::RuntimeException& )
-        {
-            TOOLS_WARN_EXCEPTION( "package.xstor", "The call must not fail, it is pretty simple!" );
-            throw;
-        }
-        catch( const uno::Exception& )
-        {
-            TOOLS_WARN_EXCEPTION( "package.xstor", "The call must not fail, it is pretty simple!" );
-            throw io::IOException( THROW_WHERE );
-        }
+        m_pImpl->m_bHasCommonEncryptionData = false;
+        m_pImpl->m_aCommonEncryptionData.clear();
+    }
+    catch( const uno::RuntimeException& )
+    {
+        TOOLS_WARN_EXCEPTION( "package.xstor", "The call must not fail, it is pretty simple!" );
+        throw;
+    }
+    catch( const uno::Exception& )
+    {
+        TOOLS_WARN_EXCEPTION( "package.xstor", "The call must not fail, it is pretty simple!" );
+        throw io::IOException( THROW_WHERE );
     }
 }
 
@@ -4103,42 +4103,42 @@ void SAL_CALL OStorage::setEncryptionData( const uno::Sequence< beans::NamedValu
         throw uno::RuntimeException( THROW_WHERE "Unexpected empty encryption data!" );
 
     SAL_WARN_IF( !m_pData->m_bIsRoot, "package.xstor", "setEncryptionData() method is not available for nonroot storages!" );
-    if ( m_pData->m_bIsRoot )
+    if ( !m_pData->m_bIsRoot )
+        return;
+
+    try {
+        m_pImpl->ReadContents();
+    }
+    catch ( const uno::RuntimeException& )
     {
-        try {
-            m_pImpl->ReadContents();
-        }
-        catch ( const uno::RuntimeException& )
-        {
-            TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
-            throw;
-        }
-        catch ( const uno::Exception& )
-        {
-            uno::Any aCaught( ::cppu::getCaughtException() );
-            SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
+        TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
+        throw;
+    }
+    catch ( const uno::Exception& )
+    {
+        uno::Any aCaught( ::cppu::getCaughtException() );
+        SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
 
-            throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
-                                static_cast< OWeakObject* >( this ),
-                                aCaught );
-        }
+        throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
+                            static_cast< OWeakObject* >( this ),
+                            aCaught );
+    }
 
-        uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
-        try
-        {
-            ::comphelper::SequenceAsHashMap aEncryptionMap( aEncryptionData );
-            xPackPropSet->setPropertyValue( STORAGE_ENCRYPTION_KEYS_PROPERTY,
-                                            uno::makeAny( aEncryptionMap.getAsConstNamedValueList() ) );
+    uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
+    try
+    {
+        ::comphelper::SequenceAsHashMap aEncryptionMap( aEncryptionData );
+        xPackPropSet->setPropertyValue( STORAGE_ENCRYPTION_KEYS_PROPERTY,
+                                        uno::makeAny( aEncryptionMap.getAsConstNamedValueList() ) );
 
-            m_pImpl->m_bHasCommonEncryptionData = true;
-            m_pImpl->m_aCommonEncryptionData = aEncryptionMap;
-        }
-        catch( const uno::Exception& )
-        {
-            TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:" );
+        m_pImpl->m_bHasCommonEncryptionData = true;
+        m_pImpl->m_aCommonEncryptionData = aEncryptionMap;
+    }
+    catch( const uno::Exception& )
+    {
+        TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:" );
 
-            throw io::IOException( THROW_WHERE );
-        }
+        throw io::IOException( THROW_WHERE );
     }
 }
 
@@ -4168,46 +4168,46 @@ void SAL_CALL OStorage::setEncryptionAlgorithms( const uno::Sequence< beans::Nam
         throw uno::RuntimeException( THROW_WHERE "Unexpected empty encryption algorithms list!" );
 
     SAL_WARN_IF( !m_pData->m_bIsRoot, "package.xstor", "setEncryptionAlgorithms() method is not available for nonroot storages!" );
-    if ( m_pData->m_bIsRoot )
+    if ( !m_pData->m_bIsRoot )
+        return;
+
+    try {
+        m_pImpl->ReadContents();
+    }
+    catch ( const uno::RuntimeException& )
     {
-        try {
-            m_pImpl->ReadContents();
-        }
-        catch ( const uno::RuntimeException& )
-        {
-            TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
-            throw;
-        }
-        catch ( const uno::Exception& )
-        {
-            uno::Any aCaught( ::cppu::getCaughtException() );
-            SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
+        TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
+        throw;
+    }
+    catch ( const uno::Exception& )
+    {
+        uno::Any aCaught( ::cppu::getCaughtException() );
+        SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
 
-            throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
-                                                static_cast< OWeakObject* >( this ),
-                                                aCaught );
-        }
+        throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
+                                            static_cast< OWeakObject* >( this ),
+                                            aCaught );
+    }
 
-        uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
-        try
-        {
-            xPackPropSet->setPropertyValue( ENCRYPTION_ALGORITHMS_PROPERTY,
-                                            uno::makeAny( aAlgorithms ) );
-        }
-        catch ( const uno::RuntimeException& )
-        {
-            TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
-            throw;
-        }
-        catch( const uno::Exception& )
-        {
-            uno::Any aCaught( ::cppu::getCaughtException() );
-            SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
+    uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
+    try
+    {
+        xPackPropSet->setPropertyValue( ENCRYPTION_ALGORITHMS_PROPERTY,
+                                        uno::makeAny( aAlgorithms ) );
+    }
+    catch ( const uno::RuntimeException& )
+    {
+        TOOLS_INFO_EXCEPTION("package.xstor", "Rethrow:");
+        throw;
+    }
+    catch( const uno::Exception& )
+    {
+        uno::Any aCaught( ::cppu::getCaughtException() );
+        SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
 
-            throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
-                                                static_cast< OWeakObject* >( this ),
-                                                aCaught );
-        }
+        throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
+                                            static_cast< OWeakObject* >( this ),
+                                            aCaught );
     }
 }
 
@@ -4228,46 +4228,46 @@ void SAL_CALL OStorage::setGpgProperties( const uno::Sequence< uno::Sequence< be
         throw uno::RuntimeException( THROW_WHERE "Unexpected empty encryption algorithms list!" );
 
     SAL_WARN_IF( !m_pData->m_bIsRoot, "package.xstor", "setGpgProperties() method is not available for nonroot storages!" );
-    if ( m_pData->m_bIsRoot )
+    if ( !m_pData->m_bIsRoot )
+        return;
+
+    try {
+        m_pImpl->ReadContents();
+    }
+    catch ( const uno::RuntimeException& aRuntimeException )
     {
-        try {
-            m_pImpl->ReadContents();
-        }
-        catch ( const uno::RuntimeException& aRuntimeException )
-        {
-            SAL_INFO("package.xstor", "Rethrow: " << aRuntimeException.Message);
-            throw;
-        }
-        catch ( const uno::Exception& )
-        {
-            uno::Any aCaught( ::cppu::getCaughtException() );
-            SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
+        SAL_INFO("package.xstor", "Rethrow: " << aRuntimeException.Message);
+        throw;
+    }
+    catch ( const uno::Exception& )
+    {
+        uno::Any aCaught( ::cppu::getCaughtException() );
+        SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
 
-            throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
-                                                static_cast< OWeakObject* >( this ),
-                                                aCaught );
-        }
+        throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
+                                            static_cast< OWeakObject* >( this ),
+                                            aCaught );
+    }
 
-        uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
-        try
-        {
-            xPackPropSet->setPropertyValue( ENCRYPTION_GPG_PROPERTIES,
-                                            uno::makeAny( aProps ) );
-        }
-        catch ( const uno::RuntimeException& aRuntimeException )
-        {
-            SAL_INFO("package.xstor", "Rethrow: " << aRuntimeException.Message);
-            throw;
-        }
-        catch( const uno::Exception& )
-        {
-            uno::Any aCaught( ::cppu::getCaughtException() );
-            SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
+    uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
+    try
+    {
+        xPackPropSet->setPropertyValue( ENCRYPTION_GPG_PROPERTIES,
+                                        uno::makeAny( aProps ) );
+    }
+    catch ( const uno::RuntimeException& aRuntimeException )
+    {
+        SAL_INFO("package.xstor", "Rethrow: " << aRuntimeException.Message);
+        throw;
+    }
+    catch( const uno::Exception& )
+    {
+        uno::Any aCaught( ::cppu::getCaughtException() );
+        SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
 
-            throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
-                                                static_cast< OWeakObject* >( this ),
-                                                aCaught );
-        }
+        throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
+                                            static_cast< OWeakObject* >( this ),
+                                            aCaught );
     }
 }
 
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index a6e9c2d8b783..4539829f20f0 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -92,23 +92,23 @@ XUnbufferedStream::XUnbufferedStream(
         mnBlockSize = ( rData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 16 : 1 );
     }
 
-    if ( bHaveEncryptData && mbWrappedRaw && bIsEncrypted )
-    {
-        // if we have the data needed to decrypt it, but didn't want it decrypted (or
-        // we couldn't decrypt it due to wrong password), then we prepend this
-        // data to the stream
-
-        // Make a buffer big enough to hold both the header and the data itself
-        maHeader.realloc  ( n_ConstHeaderSize +
-                            rData->m_aInitVector.getLength() +
-                            rData->m_aSalt.getLength() +
-                            rData->m_aDigest.getLength() +
-                            aMediaType.getLength() * sizeof( sal_Unicode ) );
-        sal_Int8 * pHeader = maHeader.getArray();
-        ZipFile::StaticFillHeader( rData, rEntry.nSize, aMediaType, pHeader );
-        mnHeaderToRead = static_cast < sal_Int16 > ( maHeader.getLength() );
-        mnZipSize += mnHeaderToRead;
-    }
+    if ( !(bHaveEncryptData && mbWrappedRaw && bIsEncrypted) )
+        return;
+
+    // if we have the data needed to decrypt it, but didn't want it decrypted (or
+    // we couldn't decrypt it due to wrong password), then we prepend this
+    // data to the stream
+
+    // Make a buffer big enough to hold both the header and the data itself
+    maHeader.realloc  ( n_ConstHeaderSize +
+                        rData->m_aInitVector.getLength() +
+                        rData->m_aSalt.getLength() +
+                        rData->m_aDigest.getLength() +
+                        aMediaType.getLength() * sizeof( sal_Unicode ) );
+    sal_Int8 * pHeader = maHeader.getArray();
+    ZipFile::StaticFillHeader( rData, rEntry.nSize, aMediaType, pHeader );
+    mnHeaderToRead = static_cast < sal_Int16 > ( maHeader.getLength() );
+    mnZipSize += mnHeaderToRead;
 }
 
 // allows to read package raw stream
diff --git a/package/source/zipapi/ZipOutputEntry.cxx b/package/source/zipapi/ZipOutputEntry.cxx
index f08e687c43a4..c63dc1691136 100644
--- a/package/source/zipapi/ZipOutputEntry.cxx
+++ b/package/source/zipapi/ZipOutputEntry.cxx
@@ -99,20 +99,20 @@ void ZipOutputEntryBase::closeEntry()
     deflaterReset();
     m_aCRC.reset();
 
-    if (m_bEncryptCurrentEntry)
-    {
-        m_xCipherContext.clear();
+    if (!m_bEncryptCurrentEntry)
+        return;
 
-        uno::Sequence< sal_Int8 > aDigestSeq;
-        if ( m_xDigestContext.is() )
-        {
-            aDigestSeq = m_xDigestContext->finalizeDigestAndDispose();
-            m_xDigestContext.clear();
-        }
+    m_xCipherContext.clear();
 
-        if ( m_pCurrentStream )
-            m_pCurrentStream->setDigest( aDigestSeq );
+    uno::Sequence< sal_Int8 > aDigestSeq;
+    if ( m_xDigestContext.is() )
+    {
+        aDigestSeq = m_xDigestContext->finalizeDigestAndDispose();
+        m_xDigestContext.clear();
     }
+
+    if ( m_pCurrentStream )
+        m_pCurrentStream->setDigest( aDigestSeq );
 }
 
 void ZipOutputEntryBase::processDeflated( const uno::Sequence< sal_Int8 >& deflateBuffer, sal_Int32 nLength )
@@ -148,19 +148,19 @@ void ZipOutputEntryBase::processDeflated( const uno::Sequence< sal_Int8 >& defla
         }
     }
 
-    if ( isDeflaterFinished() && m_bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
+    if ( !(isDeflaterFinished() && m_bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is()) )
+        return;
+
+    // FIXME64: sequence not 64bit safe.
+    uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->finalizeCipherContextAndDispose();
+    if ( aEncryptionBuffer.hasElements() )
     {
-        // FIXME64: sequence not 64bit safe.
-        uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->finalizeCipherContextAndDispose();
-        if ( aEncryptionBuffer.hasElements() )
-        {
-            m_xOutStream->writeBytes( aEncryptionBuffer );
+        m_xOutStream->writeBytes( aEncryptionBuffer );
 
-            // the sizes as well as checksum for encrypted streams are calculated here
-            m_pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
-            m_pCurrentEntry->nSize = m_pCurrentEntry->nCompressedSize;
-            m_aCRC.update( aEncryptionBuffer );
-        }
+        // the sizes as well as checksum for encrypted streams are calculated here
+        m_pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
+        m_pCurrentEntry->nSize = m_pCurrentEntry->nCompressedSize;
+        m_aCRC.update( aEncryptionBuffer );
     }
 }
 
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 9f5d9f632cf7..c483b53c968a 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -169,352 +169,352 @@ bool ZipPackage::isLocalFile() const
 
 void ZipPackage::parseManifest()
 {
-    if ( m_nFormat == embed::StorageFormats::PACKAGE )
+    if ( m_nFormat != embed::StorageFormats::PACKAGE )
+        return;
+
+    bool bManifestParsed = false;
+    const OUString sMeta ("META-INF");
+    if ( m_xRootFolder->hasByName( sMeta ) )
     {
-        bool bManifestParsed = false;
-        const OUString sMeta ("META-INF");
-        if ( m_xRootFolder->hasByName( sMeta ) )
-        {
-            const OUString sManifest ("manifest.xml");
+        const OUString sManifest ("manifest.xml");
 
-            try {
-                uno::Reference< XUnoTunnel > xTunnel;
-                Any aAny = m_xRootFolder->getByName( sMeta );
+        try {
+            uno::Reference< XUnoTunnel > xTunnel;
+            Any aAny = m_xRootFolder->getByName( sMeta );
+            aAny >>= xTunnel;
+            uno::Reference< XNameContainer > xMetaInfFolder( xTunnel, UNO_QUERY );
+            if ( xMetaInfFolder.is() && xMetaInfFolder->hasByName( sManifest ) )
+            {
+                aAny = xMetaInfFolder->getByName( sManifest );
                 aAny >>= xTunnel;
-                uno::Reference< XNameContainer > xMetaInfFolder( xTunnel, UNO_QUERY );
-                if ( xMetaInfFolder.is() && xMetaInfFolder->hasByName( sManifest ) )
+                uno::Reference < XActiveDataSink > xSink ( xTunnel, UNO_QUERY );
+                if ( xSink.is() )
                 {
-                    aAny = xMetaInfFolder->getByName( sManifest );
-                    aAny >>= xTunnel;
-                    uno::Reference < XActiveDataSink > xSink ( xTunnel, UNO_QUERY );
-                    if ( xSink.is() )
+                    uno::Reference < XManifestReader > xReader = ManifestReader::create( m_xContext );
+
+                    const OUString sPropFullPath ("FullPath");
+                    const OUString sPropVersion ("Version");
+                    const OUString sPropMediaType ("MediaType");
+                    const OUString sPropInitialisationVector ("InitialisationVector");
+                    const OUString sPropSalt ("Salt");
+                    const OUString sPropIterationCount ("IterationCount");
+                    const OUString sPropSize ("Size");
+                    const OUString sPropDigest ("Digest");
+                    const OUString sPropDerivedKeySize ("DerivedKeySize");
+                    const OUString sPropDigestAlgorithm ("DigestAlgorithm");
+                    const OUString sPropEncryptionAlgorithm ("EncryptionAlgorithm");
+                    const OUString sPropStartKeyAlgorithm ("StartKeyAlgorithm");
+                    const OUString sKeyInfo ("KeyInfo");
+
+                    const uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence = xReader->readManifestSequence ( xSink->getInputStream() );
+                    ZipPackageStream *pStream = nullptr;
+                    ZipPackageFolder *pFolder = nullptr;
+                    const Any *pKeyInfo = nullptr;
+
+                    for ( const uno::Sequence<PropertyValue>& rSequence : aManifestSequence )
                     {
-                        uno::Reference < XManifestReader > xReader = ManifestReader::create( m_xContext );
-
-                        const OUString sPropFullPath ("FullPath");
-                        const OUString sPropVersion ("Version");
-                        const OUString sPropMediaType ("MediaType");
-                        const OUString sPropInitialisationVector ("InitialisationVector");
-                        const OUString sPropSalt ("Salt");
-                        const OUString sPropIterationCount ("IterationCount");
-                        const OUString sPropSize ("Size");
-                        const OUString sPropDigest ("Digest");
-                        const OUString sPropDerivedKeySize ("DerivedKeySize");
-                        const OUString sPropDigestAlgorithm ("DigestAlgorithm");
-                        const OUString sPropEncryptionAlgorithm ("EncryptionAlgorithm");
-                        const OUString sPropStartKeyAlgorithm ("StartKeyAlgorithm");
-                        const OUString sKeyInfo ("KeyInfo");
-
-                        const uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence = xReader->readManifestSequence ( xSink->getInputStream() );
-                        ZipPackageStream *pStream = nullptr;
-                        ZipPackageFolder *pFolder = nullptr;
-                        const Any *pKeyInfo = nullptr;
-
-                        for ( const uno::Sequence<PropertyValue>& rSequence : aManifestSequence )
+                        OUString sPath, sMediaType, sVersion;
+                        const Any *pSalt = nullptr, *pVector = nullptr, *pCount = nullptr, *pSize = nullptr, *pDigest = nullptr, *pDigestAlg = nullptr, *pEncryptionAlg = nullptr, *pStartKeyAlg = nullptr, *pDerivedKeySize = nullptr;
+                        for ( const PropertyValue& rValue : rSequence )
                         {
-                            OUString sPath, sMediaType, sVersion;
-                            const Any *pSalt = nullptr, *pVector = nullptr, *pCount = nullptr, *pSize = nullptr, *pDigest = nullptr, *pDigestAlg = nullptr, *pEncryptionAlg = nullptr, *pStartKeyAlg = nullptr, *pDerivedKeySize = nullptr;
-                            for ( const PropertyValue& rValue : rSequence )
+                            if ( rValue.Name == sPropFullPath )
+                                rValue.Value >>= sPath;
+                            else if ( rValue.Name == sPropVersion )
+                                rValue.Value >>= sVersion;
+                            else if ( rValue.Name == sPropMediaType )
+                                rValue.Value >>= sMediaType;
+                            else if ( rValue.Name == sPropSalt )
+                                pSalt = &( rValue.Value );
+                            else if ( rValue.Name == sPropInitialisationVector )
+                                pVector = &( rValue.Value );
+                            else if ( rValue.Name == sPropIterationCount )
+                                pCount = &( rValue.Value );
+                            else if ( rValue.Name == sPropSize )
+                                pSize = &( rValue.Value );
+                            else if ( rValue.Name == sPropDigest )
+                                pDigest = &( rValue.Value );
+                            else if ( rValue.Name == sPropDigestAlgorithm )
+                                pDigestAlg = &( rValue.Value );
+                            else if ( rValue.Name == sPropEncryptionAlgorithm )
+                                pEncryptionAlg = &( rValue.Value );
+                            else if ( rValue.Name == sPropStartKeyAlgorithm )
+                                pStartKeyAlg = &( rValue.Value );
+                            else if ( rValue.Name == sPropDerivedKeySize )
+                                pDerivedKeySize = &( rValue.Value );
+                            else if ( rValue.Name == sKeyInfo )
+                                pKeyInfo = &( rValue.Value );
+                        }
+
+                        if ( !sPath.isEmpty() && hasByHierarchicalName ( sPath ) )
+                        {
+                            aAny = getByHierarchicalName( sPath );
+                            uno::Reference < XUnoTunnel > xUnoTunnel;
+                            aAny >>= xUnoTunnel;
+                            sal_Int64 nTest=0;
+                            if ( (nTest = xUnoTunnel->getSomething( ZipPackageFolder::getUnoTunnelId() )) != 0 )
                             {
-                                if ( rValue.Name == sPropFullPath )
-                                    rValue.Value >>= sPath;
-                                else if ( rValue.Name == sPropVersion )
-                                    rValue.Value >>= sVersion;
-                                else if ( rValue.Name == sPropMediaType )
-                                    rValue.Value >>= sMediaType;
-                                else if ( rValue.Name == sPropSalt )
-                                    pSalt = &( rValue.Value );
-                                else if ( rValue.Name == sPropInitialisationVector )
-                                    pVector = &( rValue.Value );
-                                else if ( rValue.Name == sPropIterationCount )
-                                    pCount = &( rValue.Value );
-                                else if ( rValue.Name == sPropSize )
-                                    pSize = &( rValue.Value );
-                                else if ( rValue.Name == sPropDigest )
-                                    pDigest = &( rValue.Value );
-                                else if ( rValue.Name == sPropDigestAlgorithm )
-                                    pDigestAlg = &( rValue.Value );
-                                else if ( rValue.Name == sPropEncryptionAlgorithm )
-                                    pEncryptionAlg = &( rValue.Value );
-                                else if ( rValue.Name == sPropStartKeyAlgorithm )
-                                    pStartKeyAlg = &( rValue.Value );
-                                else if ( rValue.Name == sPropDerivedKeySize )
-                                    pDerivedKeySize = &( rValue.Value );
-                                else if ( rValue.Name == sKeyInfo )
-                                    pKeyInfo = &( rValue.Value );
+                                pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest );
+                                pFolder->SetMediaType ( sMediaType );
+                                pFolder->SetVersion ( sVersion );
                             }
-
-                            if ( !sPath.isEmpty() && hasByHierarchicalName ( sPath ) )
+                            else
                             {
-                                aAny = getByHierarchicalName( sPath );
-                                uno::Reference < XUnoTunnel > xUnoTunnel;
-                                aAny >>= xUnoTunnel;
-                                sal_Int64 nTest=0;
-                                if ( (nTest = xUnoTunnel->getSomething( ZipPackageFolder::getUnoTunnelId() )) != 0 )
-                                {
-                                    pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest );
-                                    pFolder->SetMediaType ( sMediaType );
-                                    pFolder->SetVersion ( sVersion );
-                                }
-                                else
-                                {
-                                    pStream = reinterpret_cast < ZipPackageStream* > ( xUnoTunnel->getSomething( ZipPackageStream::getUnoTunnelId() ));
-                                    pStream->SetMediaType ( sMediaType );
-                                    pStream->SetFromManifest( true );
+                                pStream = reinterpret_cast < ZipPackageStream* > ( xUnoTunnel->getSomething( ZipPackageStream::getUnoTunnelId() ));
+                                pStream->SetMediaType ( sMediaType );
+                                pStream->SetFromManifest( true );
 
-                                    if ( pKeyInfo && pVector && pSize && pDigest && pDigestAlg && pEncryptionAlg )
-                                    {
-                                        uno::Sequence < sal_Int8 > aSequence;
-                                        sal_Int64 nSize = 0;
-                                        sal_Int32 nDigestAlg = 0, nEncryptionAlg = 0;
+                                if ( pKeyInfo && pVector && pSize && pDigest && pDigestAlg && pEncryptionAlg )
+                                {
+                                    uno::Sequence < sal_Int8 > aSequence;
+                                    sal_Int64 nSize = 0;
+                                    sal_Int32 nDigestAlg = 0, nEncryptionAlg = 0;
 
-                                        pStream->SetToBeEncrypted ( true );
+                                    pStream->SetToBeEncrypted ( true );
 
-                                        *pVector >>= aSequence;
-                                        pStream->setInitialisationVector ( aSequence );
+                                    *pVector >>= aSequence;
+                                    pStream->setInitialisationVector ( aSequence );
 
-                                        *pSize >>= nSize;
-                                        pStream->setSize ( nSize );
+                                    *pSize >>= nSize;
+                                    pStream->setSize ( nSize );
 
-                                        *pDigest >>= aSequence;
-                                        pStream->setDigest ( aSequence );
+                                    *pDigest >>= aSequence;
+                                    pStream->setDigest ( aSequence );
 
-                                        *pDigestAlg >>= nDigestAlg;
-                                        pStream->SetImportedChecksumAlgorithm( nDigestAlg );
+                                    *pDigestAlg >>= nDigestAlg;
+                                    pStream->SetImportedChecksumAlgorithm( nDigestAlg );
 
-                                        *pEncryptionAlg >>= nEncryptionAlg;
-                                        pStream->SetImportedEncryptionAlgorithm( nEncryptionAlg );
+                                    *pEncryptionAlg >>= nEncryptionAlg;
+                                    pStream->SetImportedEncryptionAlgorithm( nEncryptionAlg );
 
-                                        *pKeyInfo >>= m_aGpgProps;
+                                    *pKeyInfo >>= m_aGpgProps;
 
-                                        pStream->SetToBeCompressed ( true );
-                                        pStream->SetToBeEncrypted ( true );
-                                        pStream->SetIsEncrypted ( true );
-                                        pStream->setIterationCount(0);
+                                    pStream->SetToBeCompressed ( true );
+                                    pStream->SetToBeEncrypted ( true );
+                                    pStream->SetIsEncrypted ( true );
+                                    pStream->setIterationCount(0);
 
-                                        // clamp to default SHA256 start key magic value,
-                                        // c.f. ZipPackageStream::GetEncryptionKey()
-                                        // trying to get key value from properties
-                                        const sal_Int32 nStartKeyAlg = xml::crypto::DigestID::SHA256;
-                                        pStream->SetImportedStartKeyAlgorithm( nStartKeyAlg );
+                                    // clamp to default SHA256 start key magic value,
+                                    // c.f. ZipPackageStream::GetEncryptionKey()
+                                    // trying to get key value from properties
+                                    const sal_Int32 nStartKeyAlg = xml::crypto::DigestID::SHA256;
+                                    pStream->SetImportedStartKeyAlgorithm( nStartKeyAlg );
 
-                                        if ( !m_bHasEncryptedEntries && pStream->getName() == "content.xml" )
-                                        {
-                                            m_bHasEncryptedEntries = true;
-                                            m_nChecksumDigestID = nDigestAlg;
-                                            m_nCommonEncryptionID = nEncryptionAlg;
-                                            m_nStartKeyGenerationID = nStartKeyAlg;
-                                        }
-                                    }
-                                    else if ( pSalt && pVector && pCount && pSize && pDigest && pDigestAlg && pEncryptionAlg )
+                                    if ( !m_bHasEncryptedEntries && pStream->getName() == "content.xml" )
                                     {
-                                        uno::Sequence < sal_Int8 > aSequence;
-                                        sal_Int64 nSize = 0;
-                                        sal_Int32 nCount = 0, nDigestAlg = 0, nEncryptionAlg = 0;
-                                        sal_Int32 nDerivedKeySize = 16, nStartKeyAlg = xml::crypto::DigestID::SHA1;
+                                        m_bHasEncryptedEntries = true;
+                                        m_nChecksumDigestID = nDigestAlg;
+                                        m_nCommonEncryptionID = nEncryptionAlg;
+                                        m_nStartKeyGenerationID = nStartKeyAlg;
+                                    }
+                                }
+                                else if ( pSalt && pVector && pCount && pSize && pDigest && pDigestAlg && pEncryptionAlg )
+                                {
+                                    uno::Sequence < sal_Int8 > aSequence;
+                                    sal_Int64 nSize = 0;
+                                    sal_Int32 nCount = 0, nDigestAlg = 0, nEncryptionAlg = 0;
+                                    sal_Int32 nDerivedKeySize = 16, nStartKeyAlg = xml::crypto::DigestID::SHA1;
 
-                                        pStream->SetToBeEncrypted ( true );
+                                    pStream->SetToBeEncrypted ( true );
 
-                                        *pSalt >>= aSequence;
-                                        pStream->setSalt ( aSequence );
+                                    *pSalt >>= aSequence;
+                                    pStream->setSalt ( aSequence );
 
-                                        *pVector >>= aSequence;
-                                        pStream->setInitialisationVector ( aSequence );
+                                    *pVector >>= aSequence;
+                                    pStream->setInitialisationVector ( aSequence );
 
-                                        *pCount >>= nCount;
-                                        pStream->setIterationCount ( nCount );
+                                    *pCount >>= nCount;
+                                    pStream->setIterationCount ( nCount );
 
-                                        *pSize >>= nSize;
-                                        pStream->setSize ( nSize );
+                                    *pSize >>= nSize;
+                                    pStream->setSize ( nSize );
 
-                                        *pDigest >>= aSequence;
-                                        pStream->setDigest ( aSequence );
+                                    *pDigest >>= aSequence;
+                                    pStream->setDigest ( aSequence );
 
-                                        *pDigestAlg >>= nDigestAlg;
-                                        pStream->SetImportedChecksumAlgorithm( nDigestAlg );
+                                    *pDigestAlg >>= nDigestAlg;
+                                    pStream->SetImportedChecksumAlgorithm( nDigestAlg );
 
-                                        *pEncryptionAlg >>= nEncryptionAlg;
-                                        pStream->SetImportedEncryptionAlgorithm( nEncryptionAlg );
+                                    *pEncryptionAlg >>= nEncryptionAlg;
+                                    pStream->SetImportedEncryptionAlgorithm( nEncryptionAlg );
 
-                                        if ( pDerivedKeySize )
-                                            *pDerivedKeySize >>= nDerivedKeySize;
-                                        pStream->SetImportedDerivedKeySize( nDerivedKeySize );
+                                    if ( pDerivedKeySize )
+                                        *pDerivedKeySize >>= nDerivedKeySize;
+                                    pStream->SetImportedDerivedKeySize( nDerivedKeySize );
 
-                                        if ( pStartKeyAlg )
-                                            *pStartKeyAlg >>= nStartKeyAlg;
-                                        pStream->SetImportedStartKeyAlgorithm( nStartKeyAlg );
+                                    if ( pStartKeyAlg )
+                                        *pStartKeyAlg >>= nStartKeyAlg;
+                                    pStream->SetImportedStartKeyAlgorithm( nStartKeyAlg );
 
-                                        pStream->SetToBeCompressed ( true );
-                                        pStream->SetToBeEncrypted ( true );
-                                        pStream->SetIsEncrypted ( true );
-                                        if ( !m_bHasEncryptedEntries && pStream->getName() == "content.xml" )
-                                        {
-                                            m_bHasEncryptedEntries = true;
-                                            m_nStartKeyGenerationID = nStartKeyAlg;
-                                            m_nChecksumDigestID = nDigestAlg;
-                                            m_nCommonEncryptionID = nEncryptionAlg;
-                                        }
+                                    pStream->SetToBeCompressed ( true );
+                                    pStream->SetToBeEncrypted ( true );
+                                    pStream->SetIsEncrypted ( true );
+                                    if ( !m_bHasEncryptedEntries && pStream->getName() == "content.xml" )
+                                    {
+                                        m_bHasEncryptedEntries = true;
+                                        m_nStartKeyGenerationID = nStartKeyAlg;
+                                        m_nChecksumDigestID = nDigestAlg;
+                                        m_nCommonEncryptionID = nEncryptionAlg;
                                     }
-                                    else
-                                        m_bHasNonEncryptedEntries = true;
                                 }
+                                else
+                                    m_bHasNonEncryptedEntries = true;
                             }
                         }
-
-                        bManifestParsed = true;
                     }
 
-                    // now hide the manifest.xml file from user
-                    xMetaInfFolder->removeByName( sManifest );
+                    bManifestParsed = true;
                 }
-            }
-            catch( Exception& )
-            {
-                if ( !m_bForceRecovery )
-                    throw;
+
+                // now hide the manifest.xml file from user
+                xMetaInfFolder->removeByName( sManifest );
             }
         }
+        catch( Exception& )
+        {
+            if ( !m_bForceRecovery )
+                throw;
+        }
+    }
 
-        if ( !bManifestParsed && !m_bForceRecovery )
-            throw ZipIOException(
-                THROW_WHERE "Could not parse manifest.xml" );
+    if ( !bManifestParsed && !m_bForceRecovery )
+        throw ZipIOException(
+            THROW_WHERE "Could not parse manifest.xml" );
 
-        const OUString sMimetype ("mimetype");
-        if ( m_xRootFolder->hasByName( sMimetype ) )
+    const OUString sMimetype ("mimetype");
+    if ( m_xRootFolder->hasByName( sMimetype ) )
+    {
+        // get mediatype from the "mimetype" stream
+        OUString aPackageMediatype;
+        uno::Reference< lang::XUnoTunnel > xMimeTypeTunnel;
+        m_xRootFolder->getByName( sMimetype ) >>= xMimeTypeTunnel;
+        uno::Reference < io::XActiveDataSink > xMimeSink( xMimeTypeTunnel, UNO_QUERY );
+        if ( xMimeSink.is() )
         {
-            // get mediatype from the "mimetype" stream
-            OUString aPackageMediatype;
-            uno::Reference< lang::XUnoTunnel > xMimeTypeTunnel;
-            m_xRootFolder->getByName( sMimetype ) >>= xMimeTypeTunnel;
-            uno::Reference < io::XActiveDataSink > xMimeSink( xMimeTypeTunnel, UNO_QUERY );
-            if ( xMimeSink.is() )
+            uno::Reference< io::XInputStream > xMimeInStream = xMimeSink->getInputStream();
+            if ( xMimeInStream.is() )
             {
-                uno::Reference< io::XInputStream > xMimeInStream = xMimeSink->getInputStream();
-                if ( xMimeInStream.is() )
-                {
-                    // Mediatypes longer than 1024 symbols should not appear here
-                    uno::Sequence< sal_Int8 > aData( 1024 );
-                    sal_Int32 nRead = xMimeInStream->readBytes( aData, 1024 );
-                    if ( nRead > aData.getLength() )
-                        nRead = aData.getLength();
-
-                    if ( nRead )
-                        aPackageMediatype = OUString( reinterpret_cast<char const *>(aData.getConstArray()), nRead, RTL_TEXTENCODING_ASCII_US );
-                }
+                // Mediatypes longer than 1024 symbols should not appear here
+                uno::Sequence< sal_Int8 > aData( 1024 );
+                sal_Int32 nRead = xMimeInStream->readBytes( aData, 1024 );
+                if ( nRead > aData.getLength() )
+                    nRead = aData.getLength();
+
+                if ( nRead )
+                    aPackageMediatype = OUString( reinterpret_cast<char const *>(aData.getConstArray()), nRead, RTL_TEXTENCODING_ASCII_US );
             }
+        }
 
-            if ( !bManifestParsed )
-            {
-                // the manifest.xml could not be successfully parsed, this is an inconsistent package
-                if ( aPackageMediatype.startsWith("application/vnd.") )
-                {
-                    // accept only types that look similar to own mediatypes
-                    m_xRootFolder->SetMediaType( aPackageMediatype );
-                    m_bMediaTypeFallbackUsed = true;
-                }
-            }
-            else if ( !m_bForceRecovery )
+        if ( !bManifestParsed )
+        {
+            // the manifest.xml could not be successfully parsed, this is an inconsistent package
+            if ( aPackageMediatype.startsWith("application/vnd.") )
             {
-                // the mimetype stream should contain the information from manifest.xml
-                if ( m_xRootFolder->GetMediaType() != aPackageMediatype )
-                    throw ZipIOException(
-                        THROW_WHERE
-                        "mimetype conflicts with manifest.xml, \""
-                        + m_xRootFolder->GetMediaType() + "\" vs. \""
-                        + aPackageMediatype + "\"" );
+                // accept only types that look similar to own mediatypes
+                m_xRootFolder->SetMediaType( aPackageMediatype );
+                m_bMediaTypeFallbackUsed = true;
             }
-
-            m_xRootFolder->removeByName( sMimetype );
         }
-
-        m_bInconsistent = m_xRootFolder->LookForUnexpectedODF12Streams( OUString() );
-
-        bool bODF12AndNewer = ( m_xRootFolder->GetVersion().compareTo( ODFVER_012_TEXT ) >= 0 );
-        if ( !m_bForceRecovery && bODF12AndNewer )
+        else if ( !m_bForceRecovery )
         {
-            if ( m_bInconsistent )
-            {
-                // this is an ODF1.2 document that contains streams not referred in the manifest.xml;
-                // in case of ODF1.2 documents without version in manifest.xml the property IsInconsistent
-                // should be checked later
+            // the mimetype stream should contain the information from manifest.xml
+            if ( m_xRootFolder->GetMediaType() != aPackageMediatype )
                 throw ZipIOException(
-                    THROW_WHERE "there are streams not referred in manifest.xml" );
-            }
-            // all the streams should be encrypted with the same StartKey in ODF1.2
-            // TODO/LATER: in future the exception should be thrown
-            // throw ZipIOException( THROW_WHERE "More than one Start Key Generation algorithm is specified!" );
+                    THROW_WHERE
+                    "mimetype conflicts with manifest.xml, \""
+                    + m_xRootFolder->GetMediaType() + "\" vs. \""
+                    + aPackageMediatype + "\"" );
         }
 
-        // in case it is a correct ODF1.2 document, the version must be set
-        // and the META-INF folder is reserved for package format
-        if ( bODF12AndNewer )
-            m_xRootFolder->removeByName( sMeta );
+        m_xRootFolder->removeByName( sMimetype );
     }
+
+    m_bInconsistent = m_xRootFolder->LookForUnexpectedODF12Streams( OUString() );
+
+    bool bODF12AndNewer = ( m_xRootFolder->GetVersion().compareTo( ODFVER_012_TEXT ) >= 0 );
+    if ( !m_bForceRecovery && bODF12AndNewer )
+    {
+        if ( m_bInconsistent )
+        {
+            // this is an ODF1.2 document that contains streams not referred in the manifest.xml;
+            // in case of ODF1.2 documents without version in manifest.xml the property IsInconsistent
+            // should be checked later
+            throw ZipIOException(
+                THROW_WHERE "there are streams not referred in manifest.xml" );
+        }
+        // all the streams should be encrypted with the same StartKey in ODF1.2
+        // TODO/LATER: in future the exception should be thrown
+        // throw ZipIOException( THROW_WHERE "More than one Start Key Generation algorithm is specified!" );
+    }
+
+    // in case it is a correct ODF1.2 document, the version must be set
+    // and the META-INF folder is reserved for package format
+    if ( bODF12AndNewer )
+        m_xRootFolder->removeByName( sMeta );
 }
 
 void ZipPackage::parseContentType()
 {
-    if ( m_nFormat == embed::StorageFormats::OFOPXML )
-    {
-        const OUString aContentTypes("[Content_Types].xml");
-        try {
-            // the content type must exist in OFOPXML format!
-            if ( !m_xRootFolder->hasByName( aContentTypes ) )
-                throw io::IOException(THROW_WHERE "Wrong format!" );
+    if ( m_nFormat != embed::StorageFormats::OFOPXML )
+        return;
 
-            uno::Reference< lang::XUnoTunnel > xTunnel;
-            uno::Any aAny = m_xRootFolder->getByName( aContentTypes );
-            aAny >>= xTunnel;
-            uno::Reference < io::XActiveDataSink > xSink( xTunnel, UNO_QUERY );
-            if ( xSink.is() )
+    const OUString aContentTypes("[Content_Types].xml");
+    try {
+        // the content type must exist in OFOPXML format!
+        if ( !m_xRootFolder->hasByName( aContentTypes ) )
+            throw io::IOException(THROW_WHERE "Wrong format!" );
+
+        uno::Reference< lang::XUnoTunnel > xTunnel;
+        uno::Any aAny = m_xRootFolder->getByName( aContentTypes );
+        aAny >>= xTunnel;
+        uno::Reference < io::XActiveDataSink > xSink( xTunnel, UNO_QUERY );
+        if ( xSink.is() )
+        {
+            uno::Reference< io::XInputStream > xInStream = xSink->getInputStream();
+            if ( xInStream.is() )
             {
-                uno::Reference< io::XInputStream > xInStream = xSink->getInputStream();
-                if ( xInStream.is() )
-                {
-                    // here aContentTypeInfo[0] - Defaults, and aContentTypeInfo[1] - Overrides
-                    const uno::Sequence< uno::Sequence< beans::StringPair > > aContentTypeInfo =
-                        ::comphelper::OFOPXMLHelper::ReadContentTypeSequence( xInStream, m_xContext );
+                // here aContentTypeInfo[0] - Defaults, and aContentTypeInfo[1] - Overrides
+                const uno::Sequence< uno::Sequence< beans::StringPair > > aContentTypeInfo =
+                    ::comphelper::OFOPXMLHelper::ReadContentTypeSequence( xInStream, m_xContext );
 
-                    if ( aContentTypeInfo.getLength() != 2 )
-                        throw io::IOException(THROW_WHERE );
+                if ( aContentTypeInfo.getLength() != 2 )
+                    throw io::IOException(THROW_WHERE );
 
-                    // set the implicit types first
-                    for ( const auto& rPair : aContentTypeInfo[0] )
-                        m_xRootFolder->setChildStreamsTypeByExtension( rPair );
+                // set the implicit types first
+                for ( const auto& rPair : aContentTypeInfo[0] )
+                    m_xRootFolder->setChildStreamsTypeByExtension( rPair );
 
-                    // now set the explicit types
-                    for ( const auto& rPair : aContentTypeInfo[1] )
-                    {
-                        OUString aPath;
-                        if ( rPair.First.toChar() == '/' )
-                            aPath = rPair.First.copy( 1 );
-                        else
-                            aPath = rPair.First;
+                // now set the explicit types
+                for ( const auto& rPair : aContentTypeInfo[1] )
+                {
+                    OUString aPath;
+                    if ( rPair.First.toChar() == '/' )
+                        aPath = rPair.First.copy( 1 );
+                    else
+                        aPath = rPair.First;
 
-                        if ( !aPath.isEmpty() && hasByHierarchicalName( aPath ) )
+                    if ( !aPath.isEmpty() && hasByHierarchicalName( aPath ) )
+                    {
+                        uno::Any aIterAny = getByHierarchicalName( aPath );
+                        uno::Reference < lang::XUnoTunnel > xIterTunnel;
+                        aIterAny >>= xIterTunnel;
+                        sal_Int64 nTest = xIterTunnel->getSomething( ZipPackageStream::getUnoTunnelId() );
+                        if ( nTest != 0 )
                         {
-                            uno::Any aIterAny = getByHierarchicalName( aPath );
-                            uno::Reference < lang::XUnoTunnel > xIterTunnel;
-                            aIterAny >>= xIterTunnel;
-                            sal_Int64 nTest = xIterTunnel->getSomething( ZipPackageStream::getUnoTunnelId() );
-                            if ( nTest != 0 )
-                            {
-                                // this is a package stream, in OFOPXML format only streams can have mediatype
-                                ZipPackageStream *pStream = reinterpret_cast < ZipPackageStream* > ( nTest );
-                                pStream->SetMediaType( rPair.Second );
-                            }

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list