[Libreoffice-commits] core.git: Branch 'feature/cib_contract3756' - 11 commits - framework/inc framework/source .gitreview include/oox offapi/com oox/source package/source sfx2/source vcl/source

Serge Krot (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 16 19:21:59 UTC 2019


Rebased ref, commits from common ancestor:
commit d5f63b0c5e62c3dd173751b64ea6246282c31278
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Wed Oct 16 16:03:41 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:56 2019 +0200

    ToogleButton: add ability to set tooltip text for pop-up menu items
    
    Change-Id: Iacd5c97438782ffddc8a9196688e1d58abce9abe
    Reviewed-on: https://gerrit.libreoffice.org/80906
    Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>

diff --git a/framework/inc/uielement/togglebuttontoolbarcontroller.hxx b/framework/inc/uielement/togglebuttontoolbarcontroller.hxx
old mode 100644
new mode 100755
index 1550e554d59f..ae532858d25b
--- a/framework/inc/uielement/togglebuttontoolbarcontroller.hxx
+++ b/framework/inc/uielement/togglebuttontoolbarcontroller.hxx
@@ -36,6 +36,13 @@ class ToggleButtonToolbarController : public ComplexToolbarController
 
 {
     public:
+        class DropdownMenuItem
+        {
+        public:
+            OUString mLabel;
+            OUString mTipHelpText;
+        };
+
         enum class Style
         {
             DropDownButton,
@@ -64,7 +71,7 @@ class ToggleButtonToolbarController : public ComplexToolbarController
         DECL_LINK( MenuSelectHdl, Menu *, bool);
 
         OUString                m_aCurrentSelection;
-        std::vector< OUString > m_aDropdownMenuList;
+        std::vector< DropdownMenuItem > m_aDropdownMenuList;
 };
 
 }
diff --git a/framework/source/uielement/togglebuttontoolbarcontroller.cxx b/framework/source/uielement/togglebuttontoolbarcontroller.cxx
index 92818083c1f7..f884bb23e8cc 100755
--- a/framework/source/uielement/togglebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/togglebuttontoolbarcontroller.cxx
@@ -97,12 +97,15 @@ uno::Reference< awt::XWindow > SAL_CALL ToggleButtonToolbarController::createPop
     const sal_uInt32 nCount = m_aDropdownMenuList.size();
     for ( sal_uInt32 i = 0; i < nCount; i++ )
     {
-        OUString aLabel( m_aDropdownMenuList[i] );
-        aPopup->InsertItem( sal_uInt16( i+1 ), aLabel );
-        if ( aLabel == m_aCurrentSelection )
+        const OUString & rLabel = m_aDropdownMenuList[i].mLabel;
+        aPopup->InsertItem( sal_uInt16( i+1 ), rLabel );
+        if ( rLabel == m_aCurrentSelection )
             aPopup->CheckItem( sal_uInt16( i+1 ) );
         else
             aPopup->CheckItem( sal_uInt16( i+1 ), false );
+
+        if ( !m_aDropdownMenuList[i].mTipHelpText.isEmpty() )
+            aPopup->SetTipHelpText( sal_uInt16( i+1 ), m_aDropdownMenuList[i].mTipHelpText );
     }
 
     m_pToolbar->SetItemDown( m_nID, true );
@@ -125,10 +128,14 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
             {
                 Sequence< OUString > aList;
                 m_aDropdownMenuList.clear();
+                m_aCurrentSelection.clear();
 
                 rControlCommand.Arguments[i].Value >>= aList;
                 for ( sal_Int32 j = 0; j < aList.getLength(); j++ )
-                    m_aDropdownMenuList.push_back( aList[j] );
+                {
+                    m_aDropdownMenuList.push_back( DropdownMenuItem() );
+                    m_aDropdownMenuList.back().mLabel = aList[j];
+                }
 
                 // send notification
                 uno::Sequence< beans::NamedValue > aInfo { { "List", css::uno::makeAny(aList) } };
@@ -153,7 +160,7 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
                      ( sal::static_int_cast< sal_uInt32 >(nPos)
                        < m_aDropdownMenuList.size() ) )
                 {
-                    m_aCurrentSelection = m_aDropdownMenuList[nPos];
+                    m_aCurrentSelection = m_aDropdownMenuList[nPos].mLabel;
 
                     // send notification
                     uno::Sequence< beans::NamedValue > aInfo { { "ItemChecked", css::uno::makeAny(nPos) } };
@@ -168,15 +175,26 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
     else if ( rControlCommand.Command == "AddEntry" )
     {
         OUString   aText;
+        OUString   aTipHelpText;
+
         for ( sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++ )
         {
             if ( rControlCommand.Arguments[i].Name == "Text" )
             {
-                if ( rControlCommand.Arguments[i].Value >>= aText )
-                    m_aDropdownMenuList.push_back( aText );
-                break;
+                rControlCommand.Arguments[i].Value >>= aText;
+            }
+            else if ( rControlCommand.Arguments[i].Name == "TipHelpText" )
+            {
+                rControlCommand.Arguments[i].Value >>= aTipHelpText;
             }
         }
+
+        if (!aText.isEmpty())
+        {
+            m_aDropdownMenuList.push_back( DropdownMenuItem() );
+            m_aDropdownMenuList.back().mLabel = aText;
+            m_aDropdownMenuList.back().mTipHelpText = aTipHelpText;
+        }
     }
     else if ( rControlCommand.Command == "InsertEntry" )
     {
@@ -198,9 +216,11 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
                 rControlCommand.Arguments[i].Value >>= aText;
         }
 
-        std::vector< OUString >::iterator aIter = m_aDropdownMenuList.begin();
+        std::vector< DropdownMenuItem >::iterator aIter = m_aDropdownMenuList.begin();
         aIter += nPos;
-        m_aDropdownMenuList.insert( aIter, aText );
+        aIter = m_aDropdownMenuList.insert(aIter, DropdownMenuItem());
+        if (aIter != m_aDropdownMenuList.end())
+            aIter->mLabel = aText;
     }
     else if ( rControlCommand.Command == "RemoveEntryPos" )
     {
@@ -232,7 +252,7 @@ void ToggleButtonToolbarController::executeControlCommand( const css::frame::Con
                     sal_Int32 nSize = sal_Int32( m_aDropdownMenuList.size() );
                     for ( sal_Int32 j = 0; j < nSize; j++ )
                     {
-                        if ( m_aDropdownMenuList[j] == aText )
+                        if ( m_aDropdownMenuList[j].mLabel == aText )
                         {
                             m_aDropdownMenuList.erase(m_aDropdownMenuList.begin() + j);
                             break;
@@ -256,7 +276,7 @@ IMPL_LINK( ToggleButtonToolbarController, MenuSelectHdl, Menu *, pMenu, bool )
     sal_uInt16 nItemId = pMenu->GetCurItemId();
     if ( nItemId > 0 && nItemId <= m_aDropdownMenuList.size() )
     {
-        m_aCurrentSelection = m_aDropdownMenuList[nItemId-1];
+        m_aCurrentSelection = m_aDropdownMenuList[nItemId-1].mLabel;
 
         execute( 0 );
     }
commit b6e65058f7880a1a8c0b9250fff158ff13ccca2c
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Tue Oct 15 13:04:49 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:55 2019 +0200

    Tooltips: Use HELPWINSTYLE_BALLOON when tooltip contains \n
    
    Change-Id: I33ef48b5a90338471d85a613ede73eada323381c
    Reviewed-on: https://gerrit.libreoffice.org/80825
    Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>

diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
old mode 100644
new mode 100755
index 035230c69235..ec0e1d0579fc
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -326,7 +326,7 @@ void HelpTextWindow::SetHelpText( const OUString& rHelpText )
 {
     maHelpText = rHelpText;
     ApplySettings(*this);
-    if ( mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < HELPTEXTMAXLEN)
+    if ( mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < HELPTEXTMAXLEN && maHelpText.indexOf('\n') < 0)
     {
         Size aSize;
         aSize.setHeight( GetTextHeight() );
@@ -384,7 +384,7 @@ void HelpTextWindow::Paint( vcl::RenderContext& rRenderContext, const tools::Rec
     }
 
     // paint text
-    if (mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < HELPTEXTMAXLEN)
+    if (mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < HELPTEXTMAXLEN && maHelpText.indexOf('\n') < 0)
     {
         if ( mnStyle & QuickHelpFlags::CtrlText )
             rRenderContext.DrawCtrlText(maTextRect.TopLeft(), maHelpText);
commit 1b19cb701928b7d862d97e710e74c43db8ffd273
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Mon Oct 14 10:37:45 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:55 2019 +0200

    .gitreview: Update default branch
    
    Change-Id: Ie7acdd15ee51f4d1e8d7a5b13ca107d64a360b61
    Reviewed-on: https://gerrit.libreoffice.org/80758
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/.gitreview b/.gitreview
index 199752b8b09e..0193cec971ff 100644
--- a/.gitreview
+++ b/.gitreview
@@ -3,5 +3,4 @@ host=gerrit.libreoffice.org
 port=29418
 project=core
 defaultremote=logerrit
-defaultbranch=master
-
+defaultbranch=feature/cib_contract3756
commit 17acde6b6f7d2618f833550777be18d5a77c63de
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Thu Oct 10 08:13:51 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:54 2019 +0200

    Add document-level option to lock down content extraction
    
    Setting this option will prevent copying/dragging any content from LO
    to another program or even another LO window.
    
    Change-Id: Ifbc032a4fa69ac1a17d4b500f5a30f5399d84ed7
    Reviewed-on: https://gerrit.libreoffice.org/80586
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    (cherry picked from commit 075f20a4b696f9e85d11dc977806e41a49e6de61)
    Reviewed-on: https://gerrit.libreoffice.org/80757
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/offapi/com/sun/star/frame/XModel2.idl b/offapi/com/sun/star/frame/XModel2.idl
index b3ae90358854..0a5944e0e6f0 100644
--- a/offapi/com/sun/star/frame/XModel2.idl
+++ b/offapi/com/sun/star/frame/XModel2.idl
@@ -144,6 +144,7 @@ interface XModel2 : com::sun::star::frame::XModel
                 <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsName</li>
                 <li>com::sun::star::document::MediaDescriptor::LockContentExtraction</li>
                 <li>com::sun::star::document::MediaDescriptor::EncryptionData</li>
+                <li>com::sun::star::document::MediaDescriptor::LockContentExtraction</li>
             </ul>
 
         @throws com::sun::star::lang::IllegalArgumentException When trying to set an unsupported property
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 175226190f6b..4516eba7d4c3 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1083,6 +1083,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
         {
             pMedium->GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, rArg.Value));
         }
+        else if (rArg.Name == "LockContentExtraction")
+        {
+            rArg.Value >>= bValue;
+            pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_CONTENT_EXTRACTION, bValue));
+        }
         else
         {
             throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name,
commit 734afc6debf9c2db1e32e2272428505c4a8045d6
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Mon Oct 14 00:01:52 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:53 2019 +0200

    temporary: do not clean up EncryptionData during SaveAs
    
    This clean up can ruin sensetive encryption details saving document
    in plain mode which is not expected.
    
    Relaization is not final and requires more atention.
    
    Change-Id: I46b757af81e68ad4781e83b1a0e0b6da3a5e13e1

diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 7b2e705e45e5..cf8df0b417cc 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1752,7 +1752,7 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
         if ( !( aValue >>= aKeys ) )
             throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 2 );
 
-        if ( aKeys.hasElements() )
+/*        if ( aKeys.hasElements() )
         {
             bool bHasSHA256 = false;
             bool bHasSHA1 = false;
@@ -1766,7 +1766,7 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
 
             if ( !bHasSHA256 && !bHasSHA1 )
                 throw IllegalArgumentException(THROW_WHERE "Expected keys are not provided!", uno::Reference< uno::XInterface >(), 2 );
-        }
+        }*/
 
         m_aStorageEncryptionKeys = aKeys;
         m_aEncryptionKey.realloc( 0 );
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 8dc5b8eecbd7..482fad092d09 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1415,7 +1415,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
         // the password will be set in case user decide so
         rpSet->ClearItem( SID_PASSWORDINTERACTION );
         rpSet->ClearItem( SID_PASSWORD );
-        rpSet->ClearItem( SID_ENCRYPTIONDATA );
+        //rpSet->ClearItem( SID_ENCRYPTIONDATA );
         rpSet->ClearItem( SID_RECOMMENDREADONLY );
         rpSet->ClearItem( SID_MODIFYPASSWORDINFO );
 
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 5e04a0c09c34..813a1e251674 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -810,10 +810,21 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 
 
                 bool bPreselectPassword = false;
-                const SfxUnoAnyItem* pOldEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
                 const SfxStringItem* pOldPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
-                if ( pOldEncryptionDataItem || pOldPasswordItem )
+                if (pOldPasswordItem)
+                {
                     bPreselectPassword = true;
+                }
+                else
+                {
+                    const SfxUnoAnyItem* pOldEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
+                    if (pOldEncryptionDataItem)
+                    {
+                        uno::Sequence< beans::NamedValue > aEncryptionData;
+                        pOldEncryptionDataItem->GetValue() >>= aEncryptionData;
+
+                    }
+                }
 
                 uno::Sequence< beans::PropertyValue > aDispatchArgs;
                 if ( rReq.GetArgs() )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 5dfcd6829df5..8975c32fe051 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2757,11 +2757,11 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString&
     std::unique_ptr<SfxAllItemSet> pMergedParams(new SfxAllItemSet( *pMedium->GetItemSet() ));
 
     // in "SaveAs" title and password will be cleared ( maybe the new itemset contains new values, otherwise they will be empty )
-    pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
+    //pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
     pMergedParams->ClearItem( SID_PASSWORD );
     // #i119366# - As the SID_ENCRYPTIONDATA and SID_PASSWORD are using for setting password together, we need to clear them both.
     // Also, ( maybe the new itemset contains new values, otherwise they will be empty )
-    pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
+//    pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
     pMergedParams->ClearItem( SID_DOCINFO_TITLE );
 
     pMergedParams->ClearItem( SID_INPUTSTREAM );
commit 8df8afe20cdb7338a46ef549bcbd353eb58f24ae
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Sun Oct 13 23:56:39 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:52 2019 +0200

    oox: init OLE container if any encryption data is present
    
    Some encryption methods could use other than "OOXPassword"
    values. So we could rely just on "EncryptionData" exists and
    it is not empty
    
    Change-Id: Iece53601282a1bd30b592c998c77185c9dcbbe7c

diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index b6e44b56b416..b52e6a0d9a28 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -882,13 +882,7 @@ Reference<XStream> XmlFilterBase::implGetOutputStream( MediaDescriptor& rMediaDe
                                         MediaDescriptor::PROP_ENCRYPTIONDATA(),
                                         Sequence< NamedValue >() );
 
-    OUString aPassword;
-    auto pProp = std::find_if(aMediaEncData.begin(), aMediaEncData.end(),
-        [](const NamedValue& rProp) { return rProp.Name == "OOXPassword"; });
-    if (pProp != aMediaEncData.end())
-        pProp->Value >>= aPassword;
-
-    if (aPassword.isEmpty())
+    if (aMediaEncData.getLength() == 0)
     {
         return FilterBase::implGetOutputStream( rMediaDescriptor );
     }
commit 71b0d1ed25066de7b5df27d278223c289f96365c
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Sun Oct 13 23:53:22 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:51 2019 +0200

    oox: XPackageEncryption interface simplification
    
    instead of two methods to write ecrypted data and encryption info
    just one is used.
    
    Change-Id: Ie31f363a0b76cfe5b67b15c1b98b0e556578b5c8

diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
index afef194e53e9..de3836ffdb19 100644
--- a/include/oox/crypto/AgileEngine.hxx
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -128,6 +128,9 @@ private:
     void setupEncryptionParameters(AgileEncryptionParameters const & rAgileEncryptionParameters);
     bool setupEncryptionKey(OUString const & rPassword);
 
+    css::uno::Sequence<sal_Int8> writeEncryptionInfo();
+    css::uno::Sequence<sal_Int8> writeEncryptedDocument(const css::uno::Reference<css::io::XInputStream>& rxInputStream);
+
 public:
     AgileEngine(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
 
@@ -143,10 +146,7 @@ public:
 
     // Encryption
 
-    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL writeEncryptionInfo() override;
-
-    virtual void SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
-                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
+    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream) override;
 
     virtual sal_Bool SAL_CALL setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx
index feaf6a3ada6f..50be627a86e7 100644
--- a/include/oox/crypto/Standard2007Engine.hxx
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -37,6 +37,8 @@ class OOX_DLLPUBLIC Standard2007Engine : public cppu::WeakImplHelper<css::packag
     bool calculateEncryptionKey(const OUString& rPassword);
 
     css::uno::Reference<css::io::XInputStream> getStream(const css::uno::Sequence<css::beans::NamedValue> & rStreams, const OUString sStreamName);
+    css::uno::Sequence<sal_Int8> writeEncryptionInfo();
+    css::uno::Sequence<sal_Int8> writeEncryptedDocument(const css::uno::Reference<css::io::XInputStream>& rxInputStream);
 
 public:
     Standard2007Engine(const css::uno::Reference<css::uno::XComponentContext>& rxContext);
@@ -53,10 +55,7 @@ public:
 
     // Encryption
 
-    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL writeEncryptionInfo() override;
-
-    virtual void SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
-                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
+    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream) override;
 
     virtual sal_Bool SAL_CALL setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
diff --git a/offapi/com/sun/star/packages/XPackageEncryption.idl b/offapi/com/sun/star/packages/XPackageEncryption.idl
index 298a089af6c7..0fba1d9c3ba7 100644
--- a/offapi/com/sun/star/packages/XPackageEncryption.idl
+++ b/offapi/com/sun/star/packages/XPackageEncryption.idl
@@ -52,11 +52,6 @@ interface XPackageEncryption: com::sun::star::uno::XInterface
     /**
         TODO
      */
-    sequence<com::sun::star::beans::NamedValue> writeEncryptionInfo();
-
-    /**
-        TODO
-     */
     sequence<com::sun::star::beans::NamedValue> createEncryptionData([in] string rPassword);
 
     /**
@@ -67,8 +62,7 @@ interface XPackageEncryption: com::sun::star::uno::XInterface
     /**
         TODO
      */
-    void encrypt([in] com::sun::star::io::XInputStream rxInputStream,
-                 [out] com::sun::star::io::XOutputStream rxOutputStream);
+    sequence<com::sun::star::beans::NamedValue> encrypt([in] com::sun::star::io::XInputStream rxInputStream);
 
     /**
         TODO
diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx
index 35104903d918..54dd841ef2bf 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -756,7 +756,7 @@ bool AgileEngine::setupEncryptionKey(OUString const & rPassword)
     return true;
 }
 
-css::uno::Sequence<css::beans::NamedValue> AgileEngine::writeEncryptionInfo()
+css::uno::Sequence<sal_Int8> AgileEngine::writeEncryptionInfo()
 {
     Reference<XOutputStream> aEncryptionInfoStream(
         mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.io.SequenceOutputStream", mxContext),
@@ -820,20 +820,19 @@ css::uno::Sequence<css::beans::NamedValue> AgileEngine::writeEncryptionInfo()
     rStream.close();
     aEncryptionInfoStream->flush();
 
-    // Store all streams into sequence and return back
-    comphelper::SequenceAsHashMap aStreams;
-
     Reference<XSequenceOutputStream> aEncryptionInfoSequenceStream(aEncryptionInfoStream, UNO_QUERY);
-    aStreams["EncryptionInfo"] <<= aEncryptionInfoSequenceStream->getWrittenBytes();
-    return aStreams.getAsConstNamedValueList();
+    return aEncryptionInfoSequenceStream->getWrittenBytes();
 }
 
-void AgileEngine::encrypt(const css::uno::Reference<css::io::XInputStream> &  rxInputStream,
-                          css::uno::Reference<css::io::XOutputStream> & rxOutputStream)
+css::uno::Sequence<sal_Int8> AgileEngine::writeEncryptedDocument(const css::uno::Reference<css::io::XInputStream>& rxInputStream)
 {
     CryptoHash aCryptoHash(mInfo.hmacKey, cryptoHashTypeFromString(mInfo.hashAlgorithm));
 
-    BinaryXOutputStream aBinaryOutputStream(rxOutputStream, false);
+    Reference<XOutputStream> aOutputStream(
+        mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.io.SequenceOutputStream", mxContext),
+        UNO_QUERY);
+    BinaryXOutputStream aBinaryOutputStream(aOutputStream, false);
+
     BinaryXInputStream aBinaryInputStream(rxInputStream, false);
     Reference<XSeekable> xSeekable(rxInputStream, UNO_QUERY);
     sal_uInt32 nLength = xSeekable->getLength();
@@ -890,6 +889,18 @@ void AgileEngine::encrypt(const css::uno::Reference<css::io::XInputStream> &  rx
     }
     mInfo.hmacHash = aCryptoHash.finalize();
     encryptHmacValue();
+
+    Reference<XSequenceOutputStream> aSequenceStream(aOutputStream, UNO_QUERY);
+    return aSequenceStream->getWrittenBytes();
+}
+
+
+css::uno::Sequence<css::beans::NamedValue> AgileEngine::encrypt(const css::uno::Reference<css::io::XInputStream> &  rxInputStream)
+{
+    comphelper::SequenceAsHashMap aStreams;
+    aStreams["EncryptedPackage"] <<= writeEncryptedDocument(rxInputStream);
+    aStreams["EncryptionInfo"] <<= writeEncryptionInfo();
+    return aStreams.getAsConstNamedValueList();
 }
 
 } // namespace core
diff --git a/oox/source/crypto/DocumentEncryption.cxx b/oox/source/crypto/DocumentEncryption.cxx
index 2dba0f035df5..2f0457911aed 100644
--- a/oox/source/crypto/DocumentEncryption.cxx
+++ b/oox/source/crypto/DocumentEncryption.cxx
@@ -78,12 +78,7 @@ bool DocumentEncryption::encrypt()
 
     mxPackageEncryption->setupEncryption(mMediaEncData);
 
-    Reference<XOutputStream> xOutputStream(mrOleStorage.openOutputStream("EncryptedPackage"), UNO_SET_THROW);
-    mxPackageEncryption->encrypt(xInputStream, xOutputStream);
-    xOutputStream->flush();
-    xOutputStream->closeOutput();
-
-    Sequence<NamedValue> aStreams = mxPackageEncryption->writeEncryptionInfo();
+    Sequence<NamedValue> aStreams = mxPackageEncryption->encrypt(xInputStream);
 
     for (const NamedValue & aStream : aStreams)
     {
diff --git a/oox/source/crypto/Standard2007Engine.cxx b/oox/source/crypto/Standard2007Engine.cxx
index 50f23e2cf491..9ddde339b1d5 100644
--- a/oox/source/crypto/Standard2007Engine.cxx
+++ b/oox/source/crypto/Standard2007Engine.cxx
@@ -257,7 +257,7 @@ sal_Bool Standard2007Engine::setupEncryption(const css::uno::Sequence<css::beans
     return true;
 }
 
-css::uno::Sequence<css::beans::NamedValue> Standard2007Engine::writeEncryptionInfo()
+css::uno::Sequence<sal_Int8> Standard2007Engine::writeEncryptionInfo()
 {
     Reference<XOutputStream> aEncryptionInfoStream(
         mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.io.SequenceOutputStream", mxContext),
@@ -283,21 +283,17 @@ css::uno::Sequence<css::beans::NamedValue> Standard2007Engine::writeEncryptionIn
     rStream.close();
     aEncryptionInfoStream->flush();
 
-    // Store all streams into sequence and return back
-    comphelper::SequenceAsHashMap aStreams;
-
     Reference<XSequenceOutputStream> aEncryptionInfoSequenceStream(aEncryptionInfoStream, UNO_QUERY);
-    aStreams["EncryptionInfo"] <<= aEncryptionInfoSequenceStream->getWrittenBytes();
-    return aStreams.getAsConstNamedValueList();
+    return aEncryptionInfoSequenceStream->getWrittenBytes();
 }
 
-void Standard2007Engine::encrypt(const css::uno::Reference<css::io::XInputStream> &  rxInputStream,
-                                 css::uno::Reference<css::io::XOutputStream> & rxOutputStream)
+css::uno::Sequence<sal_Int8> Standard2007Engine::writeEncryptedDocument(const css::uno::Reference<css::io::XInputStream> &  rxInputStream)
 {
-    if (mKey.empty())
-        return;
+    Reference<XOutputStream> aOutputStream(
+        mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.io.SequenceOutputStream", mxContext),
+        UNO_QUERY);
+    BinaryXOutputStream aBinaryOutputStream(aOutputStream, false);
 
-    BinaryXOutputStream aBinaryOutputStream(rxOutputStream, false);
     BinaryXInputStream aBinaryInputStream(rxInputStream, false);
     Reference<XSeekable> xSeekable(rxInputStream, UNO_QUERY);
 
@@ -321,6 +317,21 @@ void Standard2007Engine::encrypt(const css::uno::Reference<css::io::XInputStream
         outputLength = aEncryptor.update(outputBuffer, inputBuffer, inputLength);
         aBinaryOutputStream.writeMemory(outputBuffer.data(), outputLength);
     }
+
+    Reference<XSequenceOutputStream> aSequenceStream(aOutputStream, UNO_QUERY);
+    return aSequenceStream->getWrittenBytes();
+}
+
+css::uno::Sequence<css::beans::NamedValue> Standard2007Engine::encrypt(const css::uno::Reference<css::io::XInputStream> &  rxInputStream)
+{
+    if (mKey.empty())
+        return css::uno::Sequence<css::beans::NamedValue>();
+
+    comphelper::SequenceAsHashMap aStreams;
+
+    aStreams["EncryptedPackage"] <<= writeEncryptedDocument(rxInputStream);
+    aStreams["EncryptionInfo"] <<= writeEncryptionInfo();
+    return aStreams.getAsConstNamedValueList();
 }
 
 css::uno::Reference<css::io::XInputStream> Standard2007Engine::getStream(const css::uno::Sequence<css::beans::NamedValue> & rStreams, const OUString sStreamName)
commit 4f8cc6049adc42d7e92005b9911e98554179a781
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Sun Oct 13 21:29:24 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:50 2019 +0200

    oox: avoid control freeze on exception
    
    If exception happens somewhere in exportDocument() or later,
    document controls could be remain locked and later cause crash
    due to missing exception handler.
    
    To avoid this simple lock guard was implemented releasing controls
    even on exception.
    
    Change-Id: I1ce4e487833ddc4b1f1b708f3a7e10bb299ef354

diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index c99c77ba870f..ca57d3920a0c 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -110,6 +110,23 @@ DocumentOpenedGuard::~DocumentOpenedGuard()
         rUrlPool.maUrls.erase( maUrl );
 }
 
+class ControllerLockGuard
+{
+public:
+    explicit ControllerLockGuard(const Reference< XModel > & xModel)
+        : mxModel (xModel)
+    {
+        mxModel->lockControllers();
+    }
+
+    ~ControllerLockGuard()
+    {
+        mxModel->unlockControllers();
+    }
+private:
+    const Reference< XModel > & mxModel;
+};
+
 } // namespace
 
 /** Specifies whether this filter is an import or export filter. */
@@ -159,8 +176,6 @@ struct FilterBaseImpl
 
     /// @throws IllegalArgumentException
     void                setDocumentModel( const Reference< XComponent >& rxComponent );
-
-    void                initializeFilter();
 };
 
 FilterBaseImpl::FilterBaseImpl( const Reference< XComponentContext >& rxContext ) :
@@ -185,18 +200,6 @@ void FilterBaseImpl::setDocumentModel( const Reference< XComponent >& rxComponen
     }
 }
 
-void FilterBaseImpl::initializeFilter()
-{
-    try
-    {
-        // lock the model controllers
-        mxModel->lockControllers();
-    }
-    catch( Exception& )
-    {
-    }
-}
-
 FilterBase::FilterBase( const Reference< XComponentContext >& rxContext ) :
     mxImpl( new FilterBaseImpl( rxContext ) )
 {
@@ -472,7 +475,8 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDes
     DocumentOpenedGuard aOpenedGuard( mxImpl->maFileUrl );
     if( aOpenedGuard.isValid() || mxImpl->maFileUrl.isEmpty() )
     {
-        mxImpl->initializeFilter();
+        ControllerLockGuard aCtrlLockGuard(mxImpl->mxModel);
+
         switch( mxImpl->meDirection )
         {
             case FILTERDIRECTION_UNKNOWN:
@@ -492,7 +496,6 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDes
                 }
             break;
         }
-        mxImpl->mxModel->unlockControllers();
     }
     return bRet;
 }
commit ab63af866539ea59288e2e6f8fbb5d450f2295a3
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Oct 10 10:45:44 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:50 2019 +0200

    crypto: predefine classes for later usage in unittests
    
    Change-Id: I2835803eaa2670ca5cae5445049bbc95f303dd08

diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
index 39f8103a6a03..afef194e53e9 100644
--- a/include/oox/crypto/AgileEngine.hxx
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -24,6 +24,8 @@ namespace oox {
     class BinaryXOutputStream;
 }
 
+namespace com::sun::star::uno { class XComponentContext; }
+
 namespace oox {
 namespace core {
 
diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx
index e838d7b064d3..feaf6a3ada6f 100644
--- a/include/oox/crypto/Standard2007Engine.hxx
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -22,6 +22,8 @@ namespace oox {
     class BinaryXOutputStream;
 }
 
+namespace com::sun::star::uno { class XComponentContext; }
+
 namespace oox {
 namespace core {
 
commit 38df45fa38e779a6854f26a4f9b77e5a9d900e38
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Thu Oct 10 10:01:16 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:49 2019 +0200

    Fix compilation: SAL_CALL is missing in method declaration
    
    Change-Id: I4fc5e2de894a523d2a222ad9e7e04e1f1c01b9c5
    Reviewed-on: https://gerrit.libreoffice.org/80590
    Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>

diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
index 3a8b49e21de8..39f8103a6a03 100644
--- a/include/oox/crypto/AgileEngine.hxx
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -131,24 +131,24 @@ public:
 
     // Decryption
 
-    sal_Bool generateEncryptionKey(const OUString & rPassword) override;
-    sal_Bool readEncryptionInfo(const css::uno::Sequence<css::beans::NamedValue>& aStreams) override;
-    sal_Bool decrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+    virtual sal_Bool SAL_CALL generateEncryptionKey(const OUString & rPassword) override;
+    virtual sal_Bool SAL_CALL readEncryptionInfo(const css::uno::Sequence<css::beans::NamedValue>& aStreams) override;
+    virtual sal_Bool SAL_CALL decrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
                  css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
 
-    sal_Bool checkDataIntegrity() override;
+    virtual sal_Bool SAL_CALL checkDataIntegrity() override;
 
     // Encryption
 
-    css::uno::Sequence<css::beans::NamedValue> writeEncryptionInfo() override;
+    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL writeEncryptionInfo() override;
 
-    void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+    virtual void SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
                  css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    sal_Bool setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
+    virtual sal_Bool SAL_CALL setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
-    css::uno::Sequence<css::beans::NamedValue> createEncryptionData(const OUString& rPassword) override;
+    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL createEncryptionData(const OUString& rPassword) override;
 };
 
 } // namespace core
diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx
index d853f4e1a1af..e838d7b064d3 100644
--- a/include/oox/crypto/Standard2007Engine.hxx
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -41,24 +41,24 @@ public:
 
     // Decryption
 
-    sal_Bool generateEncryptionKey(const OUString & rPassword) override;
-    sal_Bool readEncryptionInfo(const css::uno::Sequence<css::beans::NamedValue>& aStreams) override;
-    sal_Bool decrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+    virtual sal_Bool SAL_CALL generateEncryptionKey(const OUString & rPassword) override;
+    virtual sal_Bool SAL_CALL readEncryptionInfo(const css::uno::Sequence<css::beans::NamedValue>& aStreams) override;
+    virtual sal_Bool SAL_CALL decrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
                  css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
 
-    sal_Bool checkDataIntegrity() override;
+    virtual sal_Bool SAL_CALL checkDataIntegrity() override;
 
     // Encryption
 
-    css::uno::Sequence<css::beans::NamedValue> writeEncryptionInfo() override;
+    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL writeEncryptionInfo() override;
 
-    void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+    virtual void SAL_CALL encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
                  css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    sal_Bool setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
+    virtual sal_Bool SAL_CALL setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
-    css::uno::Sequence<css::beans::NamedValue> createEncryptionData(const OUString& rPassword) override;
+    virtual css::uno::Sequence<css::beans::NamedValue> SAL_CALL createEncryptionData(const OUString& rPassword) override;
 };
 
 } // namespace core
commit e9c1e7648322fbba5ca3c652dd953e74a75e516b
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Tue Oct 8 11:46:05 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Oct 16 21:19:48 2019 +0200

    uno: XModel2->setArgs() now able to set "EncryptionData"
    
    setArgs is able to set only limited media descriptor parameters.
    Extending this list by one more.
    
    Change-Id: I179a1cfc2cdd7b04becba0d7dfe9740d920ae4ee
    Reviewed-on: https://gerrit.libreoffice.org/80432
    Reviewed-by: Vasily Melenchuk <vasily.melenchuk at cib.de>
    Tested-by: Vasily Melenchuk <vasily.melenchuk at cib.de>

diff --git a/offapi/com/sun/star/frame/XModel2.idl b/offapi/com/sun/star/frame/XModel2.idl
index c3a8d18a71b6..b3ae90358854 100644
--- a/offapi/com/sun/star/frame/XModel2.idl
+++ b/offapi/com/sun/star/frame/XModel2.idl
@@ -143,6 +143,7 @@ interface XModel2 : com::sun::star::frame::XModel
                 <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsDir</li>
                 <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsName</li>
                 <li>com::sun::star::document::MediaDescriptor::LockContentExtraction</li>
+                <li>com::sun::star::document::MediaDescriptor::EncryptionData</li>
             </ul>
 
         @throws com::sun::star::lang::IllegalArgumentException When trying to set an unsupported property
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index f4019db6b98d..175226190f6b 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1079,6 +1079,10 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
             rArg.Value >>= bValue;
             pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_CONTENT_EXTRACTION, bValue));
         }
+        else if (rArg.Name == "EncryptionData")
+        {
+            pMedium->GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, rArg.Value));
+        }
         else
         {
             throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name,


More information about the Libreoffice-commits mailing list