[Libreoffice-commits] core.git: Branch 'feature/cib_contract3756' - 689 commits - accessibility/inc accessibility/IwyuFilter_accessibility.yaml accessibility/source android/Bootstrap android/source avmedia/source basctl/inc basctl/source basegfx/source basic/inc basic/source bin/find-can-be-private-symbols.py bin/lo-xlate-lang bin/update_pch bridges/inc bridges/source canvas/IwyuFilter_canvas.yaml canvas/source chart2/inc chart2/qa chart2/source chart2/uiconfig codemaker/source comphelper/inc comphelper/qa comphelper/source compilerplugins/clang compilerplugins/Makefile-clang.mk config_host/config_folders.h.in configmgr/inc configmgr/source configure.ac connectivity/inc connectivity/source cppcanvas/inc cppcanvas/IwyuFilter_cppcanvas.yaml cppcanvas/qa cppcanvas/source cppuhelper/inc cppu/source cui/inc cui/qa cui/source cui/uiconfig dbaccess/inc dbaccess/source desktop/inc desktop/source desktop/uiconfig dictionaries distro-configs/Jenkins download.lst drawinglayer/inc editeng/inc editeng/source embeddedobj/source embedserv/source emfio/inc extensions/source external/boost external/breakpad external/expat external/firebird external/glm external/harfbuzz external/icu external/lcms2 external/libfreehand external/libstaroffice external/libwps external/libxml2 external/lpsolve external/redland extras/source filter/source filter/uiconfig forms/inc forms/source formula/source fpicker/inc fpicker/IwyuFilter_fpicker.yaml fpicker/Library_fps_office.mk fpicker/qa fpicker/source fpicker/uiconfig fpicker/UIConfig_fps.mk framework/inc framework/Library_fwk.mk framework/source .gitreview helpcompiler/source helpcontent2 hwpfilter/inc hwpfilter/source i18nlangtag/source i18npool/qa i18npool/source i18nutil/source icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_svg icon-themes/colibre icon-themes/colibre_svg icon-themes/elementary icon-themes/elementary_svg icon-themes/sifr icon-themes/sifr_dark icon-themes/sifr_svg idlc/source idl/source include/avmedia include/basegfx inclu de/basic include/codemaker include/comphelper include/connectivity include/cui include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/framework include/jvmaccess include/linguistic include/o3tl include/oox include/rtl include/sal include/sax include/sfx2 include/sot include/svl include/svtools include/svx include/toolkit include/tools include/ucbhelper include/unoidl include/unotools include/vbahelper include/vcl include/xmloff include/xmlreader ios/LibreOfficeLight io/source jvmfwk/plugins libreofficekit/qa libreofficekit/source linguistic/source lotuswordpro/inc lotuswordpro/source odk/examples odk/settings offapi/com offapi/UnoApi_offapi.mk officecfg/registry oox/inc oox/source oox/util opencl/source package/inc package/qa package/source qadevOOo/objdsc qadevOOo/runner readlicense_oo/docs readlicense_oo/license README.md registry/source reportdesign/inc reportdesign/source RepositoryExternal.mk sal/osl sal/qa sal/rtl sal/util sax/qa sax/sourc e scaddins/source sc/CppunitTest_sc_screenshots.mk sc/CppunitTest_sc_styleobj.mk sc/inc sc/Library_sc.mk sc/Module_sc.mk sc/qa scripting/source sc/source sc/uiconfig sd/CppunitTest_sd_uimpress.mk sdext/inc sdext/source sd/inc sd/Library_sd.mk sd/qa sd/sdi sd/source sd/uiconfig sfx2/inc sfx2/source sfx2/uiconfig shell/source slideshow/inc slideshow/source solenv/bin solenv/clang-format solenv/gbuild solenv/sanitizers solenv/vs soltools/cpp soltools/mkdepend sot/inc sot/source starmath/inc starmath/source starmath/uiconfig stoc/source stoc/test store/source svgio/inc svl/inc svl/qa svl/source svtools/CppunitTest_svtools_dialogs_test.mk svtools/inc svtools/Library_svt.mk svtools/qa svtools/source svx/inc svx/qa svx/sdi svx/source svx/uiconfig sw/CppunitTest_sw_ooxmlexport14.mk sw/inc sw/Module_sw.mk sw/qa sw/sdi sw/source sw/uiconfig test/source toolkit/source tools/inc tools/source translations ucb/IwyuFilter_ucb.yaml ucb/qa ucb/source unoidl/source unotools/inc unotools/source unoxml /inc unoxml/source uui/inc uui/source vbahelper/inc vcl/headless vcl/inc vcl/IwyuFilter_vcl.yaml vcl/Library_vcl.mk vcl/Module_vcl.mk vcl/opengl vcl/osx vcl/qa vcl/README.lifecycle vcl/source vcl/uiconfig vcl/unx vcl/win vcl/workben winaccessibility/source writerfilter/inc writerfilter/source writerperfect/uiconfig xmlhelp/source xmloff/inc xmloff/source xmloff/util xmlscript/inc xmlscript/IwyuFilter_xmlscript.yaml xmlscript/source xmlsecurity/inc xmlsecurity/qa xmlsecurity/source

Serge Krot (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 1 00:07:46 UTC 2019


Rebased ref, commits from common ancestor:
commit ada416ed7c3aed8f02b9cefe5882e3b75a783c53
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Fri Oct 18 17:40:11 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Nov 1 01:06:06 2019 +0100

    Toolbar: Added usage of ImageControl as toolbar control
    
    Change-Id: I2536a505650b6e4c98e79f749c3b237518cc995d
    Reviewed-on: https://gerrit.libreoffice.org/81064
    Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>

diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index 5d59402c2be5..1fe75ccab4b7 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -132,6 +132,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
     framework/source/uielement/controlmenucontroller \
     framework/source/uielement/dropdownboxtoolbarcontroller \
     framework/source/uielement/edittoolbarcontroller \
+    framework/source/uielement/FixedImageToolbarController \
     framework/source/uielement/FixedTextToolbarController \
     framework/source/uielement/genericstatusbarcontroller \
     framework/source/uielement/generictoolbarcontroller \
diff --git a/framework/inc/uielement/FixedImageToolbarController.hxx b/framework/inc/uielement/FixedImageToolbarController.hxx
new file mode 100755
index 000000000000..54afb9ee29fe
--- /dev/null
+++ b/framework/inc/uielement/FixedImageToolbarController.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDIMAGETOOLBARCONTROLLER_HXX
+#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDIMAGETOOLBARCONTROLLER_HXX
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/frame/ControlCommand.hpp>
+
+#include <uielement/complextoolbarcontroller.hxx>
+
+class ToolBox;
+class ImageControl;
+
+namespace framework
+{
+class FixedImageToolbarController : public ComplexToolbarController
+{
+public:
+    FixedImageToolbarController(const css::uno::Reference<css::uno::XComponentContext>& rxContext,
+                                const css::uno::Reference<css::frame::XFrame>& rFrame,
+                                ToolBox* pToolBar, sal_uInt16 nID, const OUString& aCommand);
+
+    // XComponent
+    virtual void SAL_CALL dispose() override;
+
+    void CheckAndUpdateImages();
+
+protected:
+    virtual void executeControlCommand(const css::frame::ControlCommand& rControlCommand) override;
+
+protected:
+    DECL_LINK(MiscOptionsChanged, LinkParamNone*, void);
+
+private:
+    VclPtr<ImageControl> m_pFixedImageControl;
+    sal_Int16 m_eSymbolSize;
+};
+}
+
+#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDIMAGETOOLBARCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx
index cfe236f8328a..bb41a2bece60 100644
--- a/framework/inc/uielement/toolbarmerger.hxx
+++ b/framework/inc/uielement/toolbarmerger.hxx
@@ -27,6 +27,7 @@
 #include <uielement/spinfieldtoolbarcontroller.hxx>
 #include <uielement/edittoolbarcontroller.hxx>
 #include <uielement/dropdownboxtoolbarcontroller.hxx>
+#include <uielement/FixedImageToolbarController.hxx>
 #include <uielement/FixedTextToolbarController.hxx>
 #include <uielement/commandinfo.hxx>
 
diff --git a/framework/source/uielement/FixedImageToolbarController.cxx b/framework/source/uielement/FixedImageToolbarController.cxx
new file mode 100755
index 000000000000..6f9a1a53c3c0
--- /dev/null
+++ b/framework/source/uielement/FixedImageToolbarController.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <uielement/FixedImageToolbarController.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <vcl/window.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/imgctrl.hxx>
+#include <svtools/miscopt.hxx>
+#include <svtools/imgdef.hxx>
+#include <framework/sfxhelperfunctions.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+
+namespace framework
+{
+FixedImageToolbarController::FixedImageToolbarController(
+    const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame,
+    ToolBox* pToolbar, sal_uInt16 nID, const OUString& aCommand)
+    : ComplexToolbarController(rxContext, rFrame, pToolbar, nID, aCommand)
+    , m_eSymbolSize(SvtMiscOptions().GetCurrentSymbolsSize())
+{
+    m_pFixedImageControl = VclPtr<ImageControl>::Create(m_pToolbar, 0);
+    m_pToolbar->SetItemWindow(m_nID, m_pFixedImageControl);
+
+    bool bBigImages(SvtMiscOptions().AreCurrentSymbolsLarge());
+
+    Image aImage = AddonsOptions().GetImageFromURL(aCommand, bBigImages, true);
+    m_pFixedImageControl->SetImage(aImage);
+    m_pFixedImageControl->SetSizePixel(m_pFixedImageControl->GetOptimalSize());
+
+    SvtMiscOptions().AddListenerLink(LINK(this, FixedImageToolbarController, MiscOptionsChanged));
+}
+
+void SAL_CALL FixedImageToolbarController::dispose()
+{
+    SolarMutexGuard aSolarMutexGuard;
+    SvtMiscOptions().RemoveListenerLink(
+        LINK(this, FixedImageToolbarController, MiscOptionsChanged));
+    m_pToolbar->SetItemWindow(m_nID, nullptr);
+    m_pFixedImageControl.disposeAndClear();
+    ComplexToolbarController::dispose();
+}
+
+void FixedImageToolbarController::executeControlCommand(const css::frame::ControlCommand&)
+{
+    SolarMutexGuard aSolarMutexGuard;
+}
+
+void FixedImageToolbarController::CheckAndUpdateImages()
+{
+    SolarMutexGuard aSolarMutexGuard;
+
+    SvtMiscOptions aMiscOptions;
+    const sal_Int16 eNewSymbolSize = aMiscOptions.GetCurrentSymbolsSize();
+
+    if (m_eSymbolSize != eNewSymbolSize)
+    {
+        m_eSymbolSize = eNewSymbolSize;
+
+        // Refresh images if requested
+        auto aSize(m_pFixedImageControl->GetOptimalSize());
+        if (m_eSymbolSize == SFX_SYMBOLS_SIZE_LARGE)
+        {
+            aSize.setWidth(26);
+            aSize.setHeight(26);
+        }
+        else if (m_eSymbolSize == SFX_SYMBOLS_SIZE_32)
+        {
+            aSize.setWidth(32);
+            aSize.setHeight(32);
+        }
+        else
+        {
+            aSize.setWidth(16);
+            aSize.setHeight(16);
+        }
+        m_pFixedImageControl->SetSizePixel(aSize);
+    }
+}
+
+IMPL_LINK_NOARG(FixedImageToolbarController, MiscOptionsChanged, LinkParamNone*, void)
+{
+    CheckAndUpdateImages();
+}
+
+} // namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index 22a9169ce73e..b2496cf7a2ca 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -50,6 +50,7 @@ static const char TOOLBARCONTROLLER_IMGBUTTON[]   = "ImageButton";
 static const char TOOLBARCONTROLLER_DROPDOWNBOX[] = "Dropdownbox";
 static const char TOOLBARCONTROLLER_DROPDOWNBTN[] = "DropdownButton";
 static const char TOOLBARCONTROLLER_TOGGLEDDBTN[] = "ToggleDropdownButton";
+static const char TOOLBARCONTROLLER_FIXEDIMAGE[]  = "FixedImage";
 static const char TOOLBARCONTROLLER_FIXEDTEXT[]   = "FixedText";
 
 static const char   TOOLBOXITEM_SEPARATOR_STR[]   = "private:separator";
@@ -606,6 +607,8 @@ void ToolBarMerger::RemoveItems(
     else if ( rControlType == TOOLBARCONTROLLER_DROPDOWNBTN )
         pResult = new ToggleButtonToolbarController( rxContext, xFrame, pToolbar, nId,
                                                      ToggleButtonToolbarController::Style::DropDownButton, rCommandURL );
+    else if ( rControlType == TOOLBARCONTROLLER_FIXEDIMAGE )
+        pResult = new FixedImageToolbarController( rxContext, xFrame, pToolbar, nId, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_FIXEDTEXT )
         pResult = new FixedTextToolbarController( rxContext, xFrame, pToolbar, nId, rCommandURL );
     else if ( rControlType == TOOLBARCONTROLLER_TOGGLEDDBTN )
commit 8ccdc053b5147e23dc312d315f085ff5789a696a
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Oct 17 11:09:21 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Nov 1 01:06:05 2019 +0100

    oox: fixed build error, more consts
    
    Change-Id: I06b9885ca304c30d6160f43558b309539d4202c0

diff --git a/include/oox/crypto/DocumentEncryption.hxx b/include/oox/crypto/DocumentEncryption.hxx
index d33450a3b791..c99cadc972f4 100644
--- a/include/oox/crypto/DocumentEncryption.hxx
+++ b/include/oox/crypto/DocumentEncryption.hxx
@@ -33,14 +33,14 @@ private:
     css::uno::Reference< css::io::XStream > mxDocumentStream;
     oox::ole::OleStorage& mrOleStorage;
     css::uno::Reference< css::packages::XPackageEncryption > mxPackageEncryption;
-    css::uno::Sequence< css::beans::NamedValue >& mMediaEncData;
+    const css::uno::Sequence< css::beans::NamedValue >& mMediaEncData;
     css::uno::Reference< css::uno::XComponentContext > mxContext;
 
 public:
     DocumentEncryption(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
         css::uno::Reference< css::io::XStream > const & xDocumentStream,
         oox::ole::OleStorage& rOleStorage,
-        css::uno::Sequence< css::beans::NamedValue >& rMediaEncData);
+        const css::uno::Sequence< css::beans::NamedValue >& rMediaEncData);
 
     bool encrypt();
 
diff --git a/oox/source/crypto/DocumentEncryption.cxx b/oox/source/crypto/DocumentEncryption.cxx
index 2f0457911aed..70b7f2a3a4e9 100644
--- a/oox/source/crypto/DocumentEncryption.cxx
+++ b/oox/source/crypto/DocumentEncryption.cxx
@@ -28,7 +28,7 @@ using namespace css::beans;
 DocumentEncryption::DocumentEncryption(const Reference< XComponentContext >& rxContext,
                                        Reference<XStream> const & xDocumentStream,
                                        oox::ole::OleStorage& rOleStorage,
-                                       Sequence<NamedValue>& rMediaEncData)
+                                       const Sequence<NamedValue>& rMediaEncData)
     : mxContext(rxContext)
     , mxDocumentStream(xDocumentStream)
     , mrOleStorage(rOleStorage)
commit f05ae476c0ad4312cf270460b51550fa3c040dc0
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: Fri Nov 1 01:06:04 2019 +0100

    .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 299ebd3f9aac720d4b7b9e3d40504dc581f8df6f
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: Fri Nov 1 00:43:07 2019 +0100

    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 b700abb829ee..4347715a15ab 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 24cfa8afd294..9e386d8c5964 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 f162bd5dfa92..ae58f9a88e97 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2764,11 +2764,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 dea78688c9d2d8d21f62db2d87bba0cb0c7c06e2
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: Fri Nov 1 00:43:07 2019 +0100

    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 8e046dd186743276bdea67883ef1a48f2d0b5f45
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: Fri Nov 1 00:43:06 2019 +0100

    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 1d85a5535b88..d82a2aacf641 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 a951bfeef26d..41a6591b0f04 100644
--- a/include/oox/crypto/Standard2007Engine.hxx
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -37,6 +37,8 @@ class OOX_DLLPUBLIC Standard2007Engine final : public cppu::WeakImplHelper<css::
     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 5e4a46b061b715068bbc6ec963dffad118fd8607
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: Fri Nov 1 00:43:06 2019 +0100

    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 7c7be3ad824a4a82680dfa4cf28e33ec1d46dda1
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: Fri Nov 1 00:43:06 2019 +0100

    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 db2cd082b751..1d85a5535b88 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 3a969f68e888..a951bfeef26d 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 c9e295e1838b34f3f8031d814172bff456319293
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: Fri Nov 1 00:43:06 2019 +0100

    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 8dacdd0ab625..db2cd082b751 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 dff03a5ea228..3a969f68e888 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 049bdbf3a3722649ce79a1a895728be1e37676d7
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: Fri Nov 1 00:43:05 2019 +0100

    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 128d5ced20d6..bab2427a3617 100644
--- a/offapi/com/sun/star/frame/XModel2.idl
+++ b/offapi/com/sun/star/frame/XModel2.idl
@@ -146,7 +146,7 @@ interface XModel2 : com::sun::star::frame::XModel
                 <li>com::sun::star::document::MediaDescriptor::LockExport</li>
                 <li>com::sun::star::document::MediaDescriptor::LockPrint</li>
                 <li>com::sun::star::document::MediaDescriptor::LockSave</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 395672aaae97..7cc810cdca80 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1094,6 +1094,10 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
             rArg.Value >>= bValue;
             pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_SAVE, bValue));
         }
+        else if (rArg.Name == "EncryptionData")
+        {
+            pMedium->GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, rArg.Value));
+        }
         else
         {
             throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name,
commit 54c1c2f42a8a7261dc2b53828079524b8ba0f444
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Oct 4 11:23:30 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Nov 1 00:41:32 2019 +0100

    IRM encryption implmentation is moved out of core
    
    Change-Id: I2e83bfaf9e8190fe4839e2d39fcc9325305e4dda

diff --git a/include/oox/crypto/IRMEngine.hxx b/include/oox/crypto/IRMEngine.hxx
deleted file mode 100644
index c8ae7b125d86..000000000000
--- a/include/oox/crypto/IRMEngine.hxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#ifndef INCLUDED_OOX_CRYPTO_IRMENGINE_HXX
-#define INCLUDED_OOX_CRYPTO_IRMENGINE_HXX
-
-#include <oox/dllapi.h>
-#include <com/sun/star/packages/XPackageEncryption.hpp>
-#include <rtl/ustring.hxx>
-#include <sal/types.h>
-
-namespace oox
-{
-namespace core
-{
-struct OOX_DLLPUBLIC IRMEncryptionInfo
-{
-    OString license;
-    bool bCanRead;
-};
-
-class OOX_DLLPUBLIC IRMEngine : public cppu::WeakImplHelper<css::packages::XPackageEncryption>
-{
-    IRMEncryptionInfo mInfo;
-    css::uno::Reference<css::uno::XComponentContext> mxContext;
-
-    css::uno::Reference<css::io::XInputStream>
-    getStream(const css::uno::Sequence<css::beans::NamedValue>& rStreams,
-              const OUString sStreamName);
-
-public:
-    IRMEngine(const css::uno::Reference<css::uno::XComponentContext>& rxContext);
-
-    // 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,
-                     css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
-
-    sal_Bool checkDataIntegrity() override;
-
-    // Encryption
-
-    css::uno::Sequence<css::beans::NamedValue> writeEncryptionInfo() override;
-
-    void 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;
-
-    css::uno::Sequence<css::beans::NamedValue>
-    createEncryptionData(const OUString& rPassword) override;
-};
-
-} // namespace core
-} // namespace oox
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index b54b9283cba5..cc235b87e360 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -16,19 +16,8 @@ $(eval $(call gb_Library_use_custom_headers,oox,oox/generated))
 $(eval $(call gb_Library_set_include,oox,\
     $$(INCLUDE) \
     -I$(SRCDIR)/oox/inc \
-	-I"C:\Program Files\Active Directory Rights Management Services SDK 2.1\inc"\
 ))
 
-$(eval $(call gb_Library_add_libs,oox,\
-	msipc_s.lib \
-	msipc.lib \
-))
-
-$(eval $(call gb_Library_add_ldflags,oox,\
-	-LIBPATH:"C:\Program Files\Active Directory Rights Management Services SDK 2.1\lib\x64"\
-))
-
-
 ifeq ($(COM)-$(OS)-$(CPUNAME),GCC-LINUX-IA64)
 # at least Debian Linux ia64 fails at compile time on
 # link libooxlo.so which is apparently too large
@@ -109,7 +98,6 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
     oox/source/core/relationshandler \
     oox/source/core/xmlfilterbase \
     oox/source/crypto/AgileEngine \
-    oox/source/crypto/IRMEngine \
     oox/source/crypto/CryptTools \
     oox/source/crypto/DocumentEncryption \
     oox/source/crypto/DocumentDecryption \
diff --git a/oox/source/crypto/IRMEngine.cxx b/oox/source/crypto/IRMEngine.cxx
deleted file mode 100644
index 95135722ee08..000000000000
--- a/oox/source/crypto/IRMEngine.cxx
+++ /dev/null
@@ -1,447 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#include <oox/crypto/IRMEngine.hxx>
-
-#include <oox/helper/binaryinputstream.hxx>
-#include <oox/helper/binaryoutputstream.hxx>
-
-#include <sax/tools/converter.hxx>
-
-#include <comphelper/hash.hxx>
-#include <comphelper/docpasswordhelper.hxx>
-#include <comphelper/random.hxx>
-#include <comphelper/processfactory.hxx>
-#include <comphelper/base64.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/sequenceashashmap.hxx>
-
-#include <filter/msfilter/mscodec.hxx>
-#include <tools/stream.hxx>
-#include <tools/XmlWriter.hxx>
-
-#include <com/sun/star/io/XSeekable.hpp>
-#include <com/sun/star/io/XStream.hpp>
-#include <com/sun/star/io/SequenceInputStream.hpp>
-#include <com/sun/star/io/XSequenceOutputStream.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XFastParser.hpp>
-#include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
-#include <com/sun/star/xml/sax/FastParser.hpp>
-#include <com/sun/star/xml/sax/FastToken.hpp>
-
-#include <msipc.h>
-
-using namespace css;
-using namespace css::beans;
-using namespace css::io;
-using namespace css::lang;
-using namespace css::uno;
-using namespace css::xml::sax;
-using namespace css::xml;
-
-namespace oox
-{
-namespace core
-{
-extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
-com_sun_star_comp_oox_crypto_DRMEncryptedDataSpace_get_implementation(
-    XComponentContext* pCtx, Sequence<Any> const& /*arguments*/)
-{
-    return cppu::acquire(new IRMEngine(pCtx /*, arguments*/));
-}
-
-IRMEngine::IRMEngine(const Reference<XComponentContext>& rxContext)
-    : mxContext(rxContext)
-{
-}
-
-sal_Bool IRMEngine::checkDataIntegrity() { return true; }
-
-sal_Bool IRMEngine::decrypt(const Reference<XInputStream>& rxInputStream,
-                            Reference<XOutputStream>& rxOutputStream)
-{
-    BinaryXInputStream aInputStream(rxInputStream, true);
-    BinaryXOutputStream aOutputStream(rxOutputStream, true);
-
-    aInputStream.readInt64(); // Skip stream size
-
-    HRESULT hr = IpcInitialize();
-    if (FAILED(hr) && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED))
-    {
-        // ERROR_ALREADY_INITIALIZED not an error
-        // TODO: some reaction?
-        return false;
-    }
-
-    // Get decryption key
-    IPC_BUFFER licenseBuffer;
-    IPC_KEY_HANDLE key;
-    licenseBuffer.pvBuffer = (void*)mInfo.license.getStr();
-    licenseBuffer.cbBuffer = mInfo.license.getLength();
-    hr = IpcGetKey(&licenseBuffer, 0, NULL, NULL, &key);
-    if (FAILED(hr))
-    {
-        // TODO: some reaction?
-        return false;
-    }
-
-    // Read rights
-    BOOL value;
-    hr = IpcAccessCheck(key, IPC_GENERIC_READ, &value);
-    if (FAILED(hr))
-    {
-        // TODO: some reaction?
-        return false;
-    }
-    mInfo.bCanRead = value;
-
-    // Get size of decrypt block
-    DWORD* blockSize;
-    hr = IpcGetKeyProperty(key, IPC_KI_BLOCK_SIZE, nullptr, (LPVOID*)&blockSize);
-    if (FAILED(hr))
-    {
-        // TODO: some reaction?
-        return false;
-    }
-
-    char* pEncryptedBuffer = new char[*blockSize];
-    char* pDecryptedBuffer = new char[*blockSize];
-    int blockNo = 0;
-    bool lastBlock = false;
-
-    do
-    {
-        sal_uInt32 readBytes = aInputStream.readArray(pEncryptedBuffer, *blockSize);
-        lastBlock = readBytes != *blockSize;
-        DWORD bytes = 0;
-        hr = IpcDecrypt(key, blockNo, lastBlock, (PBYTE)pEncryptedBuffer, *blockSize,
-                        (PBYTE)pDecryptedBuffer, *blockSize, &bytes);
-
-        if (FAILED(hr))
-        {
-            // TODO: some reaction?
-            return false;
-        }
-
-        aOutputStream.writeArray(pDecryptedBuffer, bytes);
-
-        blockNo++;
-    } while (!lastBlock);
-
-    delete[] pEncryptedBuffer;
-    delete[] pDecryptedBuffer;
-
-    rxOutputStream->flush();
-
-    return true;
-}
-
-uno::Sequence<beans::NamedValue> IRMEngine::createEncryptionData(const OUString& /*rPassword*/)
-{
-    css::uno::Sequence<sal_uInt8> seq;
-    seq.realloc(mInfo.license.getLength());
-    memcpy(seq.getArray(), mInfo.license.getStr(), mInfo.license.getLength());
-
-    comphelper::SequenceAsHashMap aEncryptionData;
-    aEncryptionData["LicenseKey"] <<= seq;
-    aEncryptionData["CryptoType"] <<= OUString("DRMEncryptedDataSpace");
-    aEncryptionData["OOXPassword"] <<= OUString("1");
-
-    return aEncryptionData.getAsConstNamedValueList();
-}
-
-uno::Reference<io::XInputStream> IRMEngine::getStream(const Sequence<NamedValue>& rStreams,
-                                                      const OUString sStreamName)
-{
-    for (const auto& aStream : rStreams)
-    {
-        if (aStream.Name == sStreamName)
-        {
-            css::uno::Sequence<sal_Int8> aSeq;
-            aStream.Value >>= aSeq;
-            Reference<XInputStream> aStream(
-                io::SequenceInputStream::createStreamFromSequence(mxContext, aSeq),
-                UNO_QUERY_THROW);
-            return aStream;
-        }
-    }
-    return nullptr;
-}
-
-sal_Bool IRMEngine::readEncryptionInfo(const uno::Sequence<beans::NamedValue>& aStreams)
-{
-    // Read TransformInfo storage for IRM ECMA documents (MS-OFFCRYPTO 2.2.4)
-    uno::Reference<io::XInputStream> xTransformInfoStream
-        = getStream(aStreams, "\006DataSpaces/TransformInfo/DRMEncryptedTransform/\006Primary");
-    SAL_WARN_IF(!xTransformInfoStream.is(), "oox", "TransormInfo stream is missing!");
-    BinaryXInputStream aBinaryStream(xTransformInfoStream, true);
-
-    // MS-OFFCRYPTO 2.1.8: TransformInfoHeader
-    aBinaryStream.readuInt32(); // TransformLength
-    aBinaryStream.readuInt32(); // TransformType
-    // TransformId
-    sal_uInt32 aStringLength = aBinaryStream.readuInt32();
-    OUString sTransformId = aBinaryStream.readUnicodeArray(aStringLength / 2);
-    aBinaryStream.skip((4 - (aStringLength & 3)) & 3); // Skip padding
-
-    // TransformName
-    aStringLength = aBinaryStream.readuInt32();
-    OUString sTransformName = aBinaryStream.readUnicodeArray(aStringLength / 2);
-    aBinaryStream.skip((4 - (aStringLength & 3)) & 3); // Skip padding
-
-    aBinaryStream.readuInt32(); // ReaderVersion
-    aBinaryStream.readuInt32(); // UpdaterVersion
-    aBinaryStream.readuInt32(); // WriterVersion
-
-    // MS-OFFCRYPTO 2.2.5: ExtensibilityHeader
-    aBinaryStream.readuInt32(); // ExtensibilityHeader
-
-    // MS-OFFCRYPTO 2.2.6: XrMLLicense
-    aStringLength = aBinaryStream.readuInt32();
-    mInfo.license = aBinaryStream.readCharArray(aStringLength);
-
-    if (mInfo.license.getLength()
-        && static_cast<sal_uChar>(mInfo.license[0]) != 0x0ef) // BOM is missing?
-    {
-        mInfo.license = "\x0ef\x0bb\x0bf" + mInfo.license;
-    }
-
-    // TODO: CHECK info data
-
-    return true;
-}
-
-sal_Bool IRMEngine::setupEncryption(const Sequence<NamedValue>& rMediaEncData)
-{
-    for (int i = 0; i < rMediaEncData.getLength(); i++)
-    {
-        if (rMediaEncData[i].Name == "LicenseKey")
-        {
-            css::uno::Sequence<sal_uInt8> seq;
-            rMediaEncData[i].Value >>= seq;
-            mInfo.license = OString(reinterpret_cast<sal_Char*>(seq.getArray()), seq.getLength());
-        }
-    }
-
-    return true;
-}
-
-Sequence<NamedValue> IRMEngine::writeEncryptionInfo()
-{
-    // Write 0x6DataSpaces/DataSpaceMap
-    Reference<XOutputStream> xDataSpaceMap(
-        mxContext->getServiceManager()->createInstanceWithContext(
-            "com.sun.star.io.SequenceOutputStream", mxContext),
-        UNO_QUERY);
-    BinaryXOutputStream aDataSpaceMapStream(xDataSpaceMap, false);
-
-    aDataSpaceMapStream.WriteInt32(8); // Header length
-    aDataSpaceMapStream.WriteInt32(1); // Entries count
-
-    // DataSpaceMapEntry (MS-OFFCRYPTO 2.1.6.1)
-    OUString sDataSpaceName("DRMEncryptedDataSpace");
-    OUString sReferenceComponent("EncryptedPackage");
-
-    aDataSpaceMapStream.WriteInt32(0x60); // Length
-    aDataSpaceMapStream.WriteInt32(1); // References count
-    aDataSpaceMapStream.WriteInt32(0); // References component type
-
-    aDataSpaceMapStream.WriteInt32(sReferenceComponent.getLength() * 2);
-    aDataSpaceMapStream.writeUnicodeArray(sReferenceComponent);
-    for (int i = 0; i < sReferenceComponent.getLength() * 2 % 4; i++) // Padding
-    {
-        aDataSpaceMapStream.writeValue<sal_Char>(0);
-    }
-
-    aDataSpaceMapStream.WriteInt32(sDataSpaceName.getLength() * 2);
-    aDataSpaceMapStream.writeUnicodeArray(sDataSpaceName);
-    for (int i = 0; i < sDataSpaceName.getLength() * 2 % 4; i++) // Padding
-    {
-        aDataSpaceMapStream.writeValue<sal_Char>(0);
-    }
-
-    aDataSpaceMapStream.close();
-    xDataSpaceMap->flush();
-
-    // Write 0x6DataSpaces/Version
-    Reference<XOutputStream> xVersion(mxContext->getServiceManager()->createInstanceWithContext(
-                                          "com.sun.star.io.SequenceOutputStream", mxContext),
-                                      UNO_QUERY);
-    BinaryXOutputStream aVersionStream(xVersion, false);
-
-    OUString sFeatureIdentifier("Microsoft.Container.DataSpaces");
-    aVersionStream.WriteInt32(sFeatureIdentifier.getLength() * 2);
-    aVersionStream.writeUnicodeArray(sFeatureIdentifier);
-    for (int i = 0; i < sFeatureIdentifier.getLength() * 2 % 4; i++) // Padding
-    {
-        aVersionStream.writeValue<sal_Char>(0);
-    }
-
-    aVersionStream.WriteInt32(1); // Reader version
-    aVersionStream.WriteInt32(1); // Updater version
-    aVersionStream.WriteInt32(1); // Writer version
-
-    aVersionStream.close();
-    xVersion->flush();
-
-    // Write 0x6DataSpaces/DataSpaceInfo/[dataspacename]
-    Reference<XOutputStream> xDataSpaceInfo(
-        mxContext->getServiceManager()->createInstanceWithContext(
-            "com.sun.star.io.SequenceOutputStream", mxContext),
-        UNO_QUERY);
-    BinaryXOutputStream aDataSpaceInfoStream(xDataSpaceInfo, false);
-
-    aDataSpaceInfoStream.WriteInt32(0x08); // Header length
-    aDataSpaceInfoStream.WriteInt32(1); // Entries count
-
-    OUString sTransformName("DRMEncryptedTransform");
-    aDataSpaceInfoStream.WriteInt32(sTransformName.getLength() * 2);
-    aDataSpaceInfoStream.writeUnicodeArray(sTransformName);
-    for (int i = 0; i < sTransformName.getLength() * 2 % 4; i++) // Padding
-    {
-        aDataSpaceInfoStream.writeValue<sal_Char>(0);
-    }
-
-    aDataSpaceInfoStream.close();
-    xDataSpaceInfo->flush();
-
-    // Write 0x6DataSpaces/TransformInfo/[transformname]
-    Reference<XOutputStream> xTransformInfo(
-        mxContext->getServiceManager()->createInstanceWithContext(
-            "com.sun.star.io.SequenceOutputStream", mxContext),
-        UNO_QUERY);
-    BinaryXOutputStream aTransformInfoStream(xTransformInfo, false);
-    OUString sTransformId("{C73DFACD-061F-43B0-8B64-0C620D2A8B50}");
-
-    // MS-OFFCRYPTO 2.1.8: TransformInfoHeader
-    sal_uInt32 nLength
-        = sTransformId.getLength() * 2 + ((4 - (sTransformId.getLength() & 3)) & 3) + 10;
-    aTransformInfoStream.WriteInt32(nLength); // TransformLength, will be written later
-    aTransformInfoStream.WriteInt32(1); // TransformType
-
-    // TransformId
-    aTransformInfoStream.WriteInt32(sTransformId.getLength() * 2);
-    aTransformInfoStream.writeUnicodeArray(sTransformId);
-    for (int i = 0; i < sTransformId.getLength() * 2 % 4; i++) // Padding
-    {
-        aTransformInfoStream.writeValue<sal_Char>(0);
-    }
-
-    // TransformName
-    OUString sTransformInfoName("Microsoft.Metadata.DRMTransform");
-    aTransformInfoStream.WriteInt32(sTransformInfoName.getLength() * 2);
-    aTransformInfoStream.writeUnicodeArray(sTransformInfoName);
-    for (int i = 0; i < sTransformInfoName.getLength() * 2 % 4; i++) // Padding
-    {
-        aTransformInfoStream.writeValue<sal_Char>(0);
-    }
-
-    aTransformInfoStream.WriteInt32(1); // ReaderVersion
-    aTransformInfoStream.WriteInt32(1); // UpdateVersion
-    aTransformInfoStream.WriteInt32(1); // WriterVersion
-
-    aTransformInfoStream.WriteInt32(4); // Extensibility Header
-
-    aTransformInfoStream.WriteInt32(mInfo.license.getLength() - 3); // LicenseLength - BOM
-    aTransformInfoStream.writeArray<sal_Char>(mInfo.license.getStr() + 3,
-                                              mInfo.license.getLength() - 3);
-    aTransformInfoStream.writeValue<sal_Char>(0);
-
-    aTransformInfoStream.close();
-    xTransformInfo->flush();
-
-    // Store all streams into sequence and return back
-    comphelper::SequenceAsHashMap aStreams;
-
-    Reference<XSequenceOutputStream> xDataSpaceMapSequence(xDataSpaceMap, UNO_QUERY);
-    aStreams["\006DataSpaces/DataSpaceMap"] <<= xDataSpaceMapSequence->getWrittenBytes();
-
-    Reference<XSequenceOutputStream> xVersionSequence(xVersion, UNO_QUERY);
-    aStreams["\006DataSpaces/Version"] <<= xVersionSequence->getWrittenBytes();
-
-    OUString sStreamName = "\006DataSpaces/DataSpaceInfo/" + sDataSpaceName;
-    Reference<XSequenceOutputStream> xDataSpaceInfoSequence(xDataSpaceInfo, UNO_QUERY);
-    aStreams[sStreamName] <<= xDataSpaceInfoSequence->getWrittenBytes();
-
-    sStreamName = "\006DataSpaces/TransformInfo/" + sTransformName + "/\006Primary";
-    Reference<XSequenceOutputStream> xTransformInfoSequence(xTransformInfo, UNO_QUERY);
-    aStreams[sStreamName] <<= xTransformInfoSequence->getWrittenBytes();
-
-    return aStreams.getAsConstNamedValueList();
-}
-
-void IRMEngine::encrypt(const Reference<XInputStream>& rxInputStream,
-                        Reference<XOutputStream>& rxOutputStream)
-{
-    HRESULT hr = IpcInitialize();
-
-    if (FAILED(hr) && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED))
-    {
-        // ERROR_ALREADY_INITIALIZED not an error
-        // TODO: some reaction?
-    }
-
-    BinaryXInputStream aInputStream(rxInputStream, false);
-    BinaryXOutputStream aOutputStream(rxOutputStream, false);
-    aOutputStream.WriteInt64(aInputStream.size()); // Stream size
-
-    // Get decryption key
-    IPC_BUFFER licenseBuffer;
-    IPC_KEY_HANDLE key;
-    licenseBuffer.pvBuffer = (void*)mInfo.license.getStr();
-    licenseBuffer.cbBuffer = mInfo.license.getLength();
-    hr = IpcGetKey(&licenseBuffer, 0, NULL, NULL, &key);
-    if (FAILED(hr))
-    {
-        // TODO: some reaction?
-    }
-
-    // Get size of encrypt block
-    DWORD* blockSize;
-    hr = IpcGetKeyProperty(key, IPC_KI_BLOCK_SIZE, nullptr, (LPVOID*)&blockSize);
-    if (FAILED(hr))
-    {
-        // TODO: some reaction?
-    }
-
-    char* pEncryptedBuffer = new char[*blockSize];
-    char* pDecryptedBuffer = new char[*blockSize];
-    int blockNo = 0;
-    bool lastBlock = false;
-
-    do
-    {
-        sal_uInt32 readBytes = aInputStream.readArray(pDecryptedBuffer, *blockSize);
-        lastBlock = readBytes != *blockSize;
-        DWORD bytes = 0;
-        hr = IpcEncrypt(key, blockNo, lastBlock, (PBYTE)pDecryptedBuffer, *blockSize,
-                        (PBYTE)pEncryptedBuffer, *blockSize, &bytes);
-
-        if (FAILED(hr))
-        {
-            // TODO: some reaction?
-        }
-
-        aOutputStream.writeArray(pEncryptedBuffer, bytes);
-
-        blockNo++;
-    } while (!lastBlock);
-
-    delete[] pEncryptedBuffer;
-    delete[] pDecryptedBuffer;
-}
-
-sal_Bool IRMEngine::generateEncryptionKey(const OUString& /*password*/) { return true; }
-
-} // namespace core
-} // namespace oox
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/util/oox.component b/oox/util/oox.component
index 0643a417bfa3..d7167545b2be 100644
--- a/oox/util/oox.component
+++ b/oox/util/oox.component
@@ -40,14 +40,6 @@
     constructor="com_sun_star_comp_oox_ShapeContextHandler_get_implementation">
     <service name="com.sun.star.xml.sax.FastShapeContextHandler"/>
   </implementation>
-  <implementation name="com.sun.star.comp.oox.crypto.DRMEncryptedDataSpace"
-    constructor="com_sun_star_comp_oox_crypto_DRMEncryptedDataSpace_get_implementation">
-    <service name="com.sun.star.packages.XPackageEncryption"/>
-  </implementation>
-  <implementation name="com.sun.star.comp.oox.crypto.DRMDataSpace"
-    constructor="com_sun_star_comp_oox_crypto_DRMDataSpace_get_implementation">
-    <service name="com.sun.star.packages.XPackageEncryption"/>
-  </implementation>
   <implementation name="com.sun.star.comp.oox.crypto.Standard2007Engine"
     constructor="com_sun_star_comp_oox_crypto_Standard2007_get_implementation">
     <service name="com.sun.star.packages.XPackageEncryption"/>
commit e7519eaed399bf966e4f20325a7573443b0784ff
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Sep 27 11:56:00 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Nov 1 00:41:31 2019 +0100

    msdoc crypto: move crypto engines to service
    
    New interface XPackageEncryption was created. All existing
    crypto engines are refactored to be implmentations of this interface.
    
    Change-Id: Id063aca1474f76a926a2e47eecd4c12ebe79650f

diff --git a/include/oox/crypto/AgileEngine.hxx b/include/oox/crypto/AgileEngine.hxx
index 2918384f9d2a..8dacdd0ab625 100644
--- a/include/oox/crypto/AgileEngine.hxx
+++ b/include/oox/crypto/AgileEngine.hxx
@@ -15,9 +15,9 @@
 
 #include <oox/dllapi.h>
 #include <oox/crypto/CryptTools.hxx>
-#include <oox/crypto/CryptoEngine.hxx>
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
+#include <com/sun/star/packages/XPackageEncryption.hpp>
 
 namespace oox {
     class BinaryXInputStream;
@@ -74,7 +74,7 @@ enum class AgileEncryptionPreset
     AES_256_SHA512,
 };
 
-class OOX_DLLPUBLIC AgileEngine final : public CryptoEngine
+class OOX_DLLPUBLIC AgileEngine final : public cppu::WeakImplHelper<css::packages::XPackageEncryption>
 {
 private:
     std::vector<sal_uInt8> mKey;
@@ -82,7 +82,7 @@ private:
     AgileEncryptionPreset meEncryptionPreset;
     css::uno::Reference< css::uno::XComponentContext > mxContext;
 
-    css::uno::Reference<css::io::XInputStream> getStream(css::uno::Sequence<css::beans::NamedValue> & rStreams, const OUString sStreamName);
+    css::uno::Reference<css::io::XInputStream> getStream(const css::uno::Sequence<css::beans::NamedValue> & rStreams, const OUString sStreamName);
 
     void calculateHashFinal(const OUString& rPassword, std::vector<sal_uInt8>& aHashFinal);
 
@@ -131,24 +131,24 @@ public:
 
     // Decryption
 
-    bool generateEncryptionKey(OUString const & rPassword) override;
-    bool readEncryptionInfo(css::uno::Sequence<css::beans::NamedValue> aStreams) override;
-    bool decrypt(BinaryXInputStream& aInputStream,
-                 BinaryXOutputStream& aOutputStream) override;
+    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,
+                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    bool checkDataIntegrity() override;
+
+    sal_Bool checkDataIntegrity() override;
 
     // Encryption
 
-    void writeEncryptionInfo(oox::ole::OleStorage& rOleStorage) override;
+    css::uno::Sequence<css::beans::NamedValue> writeEncryptionInfo() override;
 
-    void encrypt(css::uno::Reference<css::io::XInputStream>&  rxInputStream,
-                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream,
-                 sal_uInt32 nSize) override;
+    void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    bool setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
+    sal_Bool setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
-    virtual void createEncryptionData(comphelper::SequenceAsHashMap & aEncryptionData, const OUString rPassword) override;
+    css::uno::Sequence<css::beans::NamedValue> createEncryptionData(const OUString& rPassword) override;
 };
 
 } // namespace core
diff --git a/include/oox/crypto/CryptoEngine.hxx b/include/oox/crypto/CryptoEngine.hxx
deleted file mode 100644
index f985f2d7fb45..000000000000
--- a/include/oox/crypto/CryptoEngine.hxx
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#ifndef INCLUDED_OOX_CRYPTO_CRYPTOENGINE_HXX
-#define INCLUDED_OOX_CRYPTO_CRYPTOENGINE_HXX
-
-#include <vector>
-
-#include <rtl/ustring.hxx>
-#include <sal/types.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-
-namespace oox {
-    class BinaryXInputStream;
-    class BinaryXOutputStream;
-}
-
-namespace oox {
-namespace core {
-
-class CryptoEngine
-{
-public:
-    CryptoEngine()
-    {}
-
-    virtual ~CryptoEngine()
-    {}
-
-    // Decryption
-    virtual bool readEncryptionInfo(css::uno::Sequence<css::beans::NamedValue> aStreams) = 0;
-
-    virtual bool generateEncryptionKey(const OUString& rPassword) = 0;
-
-    virtual bool decrypt(
-                    BinaryXInputStream& aInputStream,
-                    BinaryXOutputStream& aOutputStream) = 0;
-
-    // Encryption
-    virtual void writeEncryptionInfo(oox::ole::OleStorage& rOleStorage) = 0;
-
-    virtual void createEncryptionData(comphelper::SequenceAsHashMap & aEncryptionData, const OUString rPassword) = 0;
-
-    virtual bool setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) = 0;
-
-    virtual void encrypt(css::uno::Reference<css::io::XInputStream> & rxInputStream,
-                         css::uno::Reference<css::io::XOutputStream> & rxOutputStream,
-                         sal_uInt32 nSize) = 0;
-
-    virtual bool checkDataIntegrity() = 0;
-};
-
-} // namespace core
-} // namespace oox
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/oox/crypto/DocumentDecryption.hxx b/include/oox/crypto/DocumentDecryption.hxx
index 248f33f61734..fdea2c25f9f7 100644
--- a/include/oox/crypto/DocumentDecryption.hxx
+++ b/include/oox/crypto/DocumentDecryption.hxx
@@ -17,7 +17,6 @@
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
-#include <oox/crypto/CryptoEngine.hxx>
 #include <rtl/ustring.hxx>
 
 namespace com { namespace sun { namespace star {
@@ -25,6 +24,7 @@ namespace com { namespace sun { namespace star {
     namespace io { class XInputStream; }
     namespace io { class XStream; }
     namespace uno { class XComponentContext; }
+    namespace packages { class XPackageEncryption; }
 } } }
 
 namespace oox { namespace ole { class OleStorage; } }
@@ -37,8 +37,7 @@ class OOX_DLLPUBLIC DocumentDecryption
 private:
     oox::ole::OleStorage&                      mrOleStorage;
     css::uno::Sequence<css::beans::NamedValue> maStreamsSequence;
-    std::unique_ptr<CryptoEngine>              mEngine;
-    OUString                                   msEngineName;
+    css::uno::Reference< css::packages::XPackageEncryption > mxPackageEncryption;
     css::uno::Reference< css::uno::XComponentContext > mxContext;
 
     void readStrongEncryptionInfo();
diff --git a/include/oox/crypto/DocumentEncryption.hxx b/include/oox/crypto/DocumentEncryption.hxx
index 9e9c013456ca..d33450a3b791 100644
--- a/include/oox/crypto/DocumentEncryption.hxx
+++ b/include/oox/crypto/DocumentEncryption.hxx
@@ -15,11 +15,11 @@
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
-#include <oox/crypto/CryptoEngine.hxx>
 #include <rtl/ustring.hxx>
 
 namespace com { namespace sun { namespace star {
     namespace io { class XStream; }
+    namespace packages { class XPackageEncryption; }
 } } }
 
 namespace oox { namespace ole { class OleStorage; } }
@@ -32,7 +32,7 @@ class OOX_DLLPUBLIC DocumentEncryption
 private:
     css::uno::Reference< css::io::XStream > mxDocumentStream;
     oox::ole::OleStorage& mrOleStorage;
-    std::unique_ptr<CryptoEngine>   mEngine;
+    css::uno::Reference< css::packages::XPackageEncryption > mxPackageEncryption;
     css::uno::Sequence< css::beans::NamedValue >& mMediaEncData;
     css::uno::Reference< css::uno::XComponentContext > mxContext;
 
diff --git a/include/oox/crypto/IRMEngine.hxx b/include/oox/crypto/IRMEngine.hxx
index 9bf610904a9d..c8ae7b125d86 100644
--- a/include/oox/crypto/IRMEngine.hxx
+++ b/include/oox/crypto/IRMEngine.hxx
@@ -12,19 +12,12 @@
 #define INCLUDED_OOX_CRYPTO_IRMENGINE_HXX
 
 #include <oox/dllapi.h>
-#include <oox/crypto/CryptoEngine.hxx>
-#include <filter/msfilter/mscodec.hxx>
+#include <com/sun/star/packages/XPackageEncryption.hpp>
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
 
 namespace oox
 {
-class BinaryXInputStream;
-class BinaryXOutputStream;
-}
-
-namespace oox
-{
 namespace core
 {
 struct OOX_DLLPUBLIC IRMEncryptionInfo
@@ -33,37 +26,40 @@ struct OOX_DLLPUBLIC IRMEncryptionInfo
     bool bCanRead;
 };
 
-class OOX_DLLPUBLIC IRMEngine : public CryptoEngine
+class OOX_DLLPUBLIC IRMEngine : public cppu::WeakImplHelper<css::packages::XPackageEncryption>
 {
     IRMEncryptionInfo mInfo;
     css::uno::Reference<css::uno::XComponentContext> mxContext;
 
     css::uno::Reference<css::io::XInputStream>
-    getStream(css::uno::Sequence<css::beans::NamedValue>& rStreams, const OUString sStreamName);
+    getStream(const css::uno::Sequence<css::beans::NamedValue>& rStreams,
+              const OUString sStreamName);
 
 public:
     IRMEngine(const css::uno::Reference<css::uno::XComponentContext>& rxContext);
 
-    bool readEncryptionInfo(css::uno::Sequence<css::beans::NamedValue> aStreams) override;
+    // Decryption
 
-    virtual bool generateEncryptionKey(OUString const& rPassword) override;
+    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,
+                     css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    virtual bool decrypt(BinaryXInputStream& aInputStream,
-                         BinaryXOutputStream& aOutputStream) override;
+    sal_Bool checkDataIntegrity() override;
 
-    bool checkDataIntegrity() override;
+    // Encryption
 
-    void encrypt(css::uno::Reference<css::io::XInputStream>& rxInputStream,
-                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream,
-                 sal_uInt32 nSize) override;
+    css::uno::Sequence<css::beans::NamedValue> writeEncryptionInfo() override;
 
-    virtual void writeEncryptionInfo(oox::ole::OleStorage& rOleStorage) override;
+    void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    virtual void createEncryptionData(comphelper::SequenceAsHashMap& aEncryptionData,
-                                      const OUString rPassword) override;
+    sal_Bool
+    setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
-    virtual bool
-    setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
+    css::uno::Sequence<css::beans::NamedValue>
+    createEncryptionData(const OUString& rPassword) override;
 };
 
 } // namespace core
diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx
index a7cb6554403b..dff03a5ea228 100644
--- a/include/oox/crypto/Standard2007Engine.hxx
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -12,7 +12,7 @@
 #define INCLUDED_OOX_CRYPTO_STANDARD2007ENGINE_HXX
 
 #include <oox/dllapi.h>
-#include <oox/crypto/CryptoEngine.hxx>
+#include <com/sun/star/packages/XPackageEncryption.hpp>
 #include <filter/msfilter/mscodec.hxx>
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
@@ -25,7 +25,7 @@ namespace oox {
 namespace oox {
 namespace core {
 
-class OOX_DLLPUBLIC Standard2007Engine final : public CryptoEngine
+class OOX_DLLPUBLIC Standard2007Engine final : public cppu::WeakImplHelper<css::packages::XPackageEncryption>
 {
     msfilter::StandardEncryptionInfo mInfo;
     std::vector<sal_uInt8> mKey;
@@ -34,31 +34,31 @@ class OOX_DLLPUBLIC Standard2007Engine final : public CryptoEngine
     bool generateVerifier();
     bool calculateEncryptionKey(const OUString& rPassword);
 
-    css::uno::Reference<css::io::XInputStream> getStream(css::uno::Sequence<css::beans::NamedValue> & rStreams, const OUString sStreamName);
+    css::uno::Reference<css::io::XInputStream> getStream(const css::uno::Sequence<css::beans::NamedValue> & rStreams, const OUString sStreamName);
 
 public:
     Standard2007Engine(const css::uno::Reference<css::uno::XComponentContext>& rxContext);
 
-    bool readEncryptionInfo(css::uno::Sequence<css::beans::NamedValue> aStreams) override;
+    // Decryption
 
-    virtual bool generateEncryptionKey(OUString const & rPassword) override;
+    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,
+                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    virtual bool decrypt(
-                    BinaryXInputStream& aInputStream,
-                    BinaryXOutputStream& aOutputStream) override;
 
-    bool checkDataIntegrity() override;
+    sal_Bool checkDataIntegrity() override;
 
-    void encrypt(css::uno::Reference<css::io::XInputStream>&  rxInputStream,
-                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream,
-                 sal_uInt32 nSize) override;
+    // Encryption
 
-    virtual void writeEncryptionInfo(oox::ole::OleStorage& rOleStorage) override;
+    css::uno::Sequence<css::beans::NamedValue> writeEncryptionInfo() override;
 
-    virtual void createEncryptionData(comphelper::SequenceAsHashMap & aEncryptionData, const OUString rPassword) override;
+    void encrypt(const css::uno::Reference<css::io::XInputStream>& rxInputStream,
+                 css::uno::Reference<css::io::XOutputStream>& rxOutputStream) override;
 
-    virtual bool setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
+    sal_Bool setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData) override;
 
+    css::uno::Sequence<css::beans::NamedValue> createEncryptionData(const OUString& rPassword) override;
 };
 
 } // namespace core
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 5fa55f8f191d..ad2ee805fd6d 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2930,6 +2930,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/packages,\
 	NoRawFormatException \
 	WrongPasswordException \
 	XDataSinkEncrSupport \
+	XPackageEncryption \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/packages/manifest,\
 	XManifestReader \
diff --git a/offapi/com/sun/star/packages/XPackageEncryption.idl b/offapi/com/sun/star/packages/XPackageEncryption.idl
new file mode 100644
index 000000000000..298a089af6c7
--- /dev/null
+++ b/offapi/com/sun/star/packages/XPackageEncryption.idl
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_packages_XPackageEncryption_idl__
+#define __com_sun_star_packages_XPackageEncryption_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+
+#include <com/sun/star/io/XInputStream.idl>
+#include <com/sun/star/io/XOutputStream.idl>
+
+
+module com {  module sun {  module star {  module packages {
+
+
+/**
+    TODO
+ */
+interface XPackageEncryption: com::sun::star::uno::XInterface
+{
+    /**
+        TODO
+     */
+    boolean readEncryptionInfo([in] sequence < com::sun::star::beans::NamedValue > rOleStreams);
+
+    /**
+        TODO
+     */
+    boolean generateEncryptionKey([in] string rPassword);
+
+    /**
+        TODO
+     */
+    boolean decrypt([in] com::sun::star::io::XInputStream rxInputStream,
+                    [out] com::sun::star::io::XOutputStream rxOutputStream);
+
+    /**
+        TODO
+     */
+    sequence<com::sun::star::beans::NamedValue> writeEncryptionInfo();
+
+    /**
+        TODO
+     */
+    sequence<com::sun::star::beans::NamedValue> createEncryptionData([in] string rPassword);
+
+    /**
+        TODO
+     */
+    boolean setupEncryption([in] sequence<com::sun::star::beans::NamedValue> rMediaEncData);
+
+    /**
+        TODO
+     */
+    void encrypt([in] com::sun::star::io::XInputStream rxInputStream,
+                 [out] com::sun::star::io::XOutputStream rxOutputStream);
+
+    /**
+        TODO
+     */
+    boolean checkDataIntegrity();
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx
index c3bd6e16378d..35104903d918 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/io/XStream.hpp>
 #include <com/sun/star/io/SequenceInputStream.hpp>
+#include <com/sun/star/io/XSequenceOutputStream.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/xml/sax/XFastParser.hpp>
 #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
@@ -47,6 +48,14 @@ using namespace css::xml;
 namespace oox {
 namespace core {
 
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+    com_sun_star_comp_oox_crypto_Agile_get_implementation(
+        XComponentContext* pCtx, Sequence<Any> const& /*arguments*/)
+{
+    return cppu::acquire(new AgileEngine(pCtx/*, arguments*/));
+}
+
+
 namespace {
 
 OUString stripNamespacePrefix(OUString const & rsInputName)
@@ -350,7 +359,7 @@ void AgileEngine::decryptEncryptionKey(OUString const & rPassword)
 }
 
 // TODO: Rename
-bool AgileEngine::generateEncryptionKey(OUString const & rPassword)
+sal_Bool AgileEngine::generateEncryptionKey(OUString const & rPassword)
 {
     bool bResult = decryptAndCheckVerifierHash(rPassword);
 
@@ -414,7 +423,7 @@ bool AgileEngine::decryptHmacValue()
     return true;
 }
 
-bool AgileEngine::checkDataIntegrity()
+sal_Bool AgileEngine::checkDataIntegrity()
 {
     bool bResult = (mInfo.hmacHash.size() == mInfo.hmacCalculatedHash.size() &&
                std::equal(mInfo.hmacHash.begin(), mInfo.hmacHash.end(), mInfo.hmacCalculatedHash.begin()));
@@ -422,11 +431,14 @@ bool AgileEngine::checkDataIntegrity()
     return bResult;
 }
 
-bool AgileEngine::decrypt(BinaryXInputStream& aInputStream,
-                          BinaryXOutputStream& aOutputStream)
+sal_Bool AgileEngine::decrypt(const css::uno::Reference<css::io::XInputStream>&  rxInputStream,
+    css::uno::Reference<css::io::XOutputStream>& rxOutputStream)
 {
     CryptoHash aCryptoHash(mInfo.hmacKey, cryptoHashTypeFromString(mInfo.hashAlgorithm));
 
+    BinaryXInputStream aInputStream(rxInputStream, true);
+    BinaryXOutputStream aOutputStream(rxOutputStream, true);
+
     sal_uInt32 totalSize = aInputStream.readuInt32(); // Document unencrypted size - 4 bytes
     // account for size in HMAC
     std::vector<sal_uInt8> aSizeBytes(sizeof(sal_uInt32));
@@ -484,10 +496,12 @@ bool AgileEngine::decrypt(BinaryXInputStream& aInputStream,
 
     mInfo.hmacCalculatedHash = aCryptoHash.finalize();
 
+    rxOutputStream->flush();
+
     return true;
 }
 
-uno::Reference<io::XInputStream> AgileEngine::getStream(Sequence<NamedValue> & rStreams, const OUString sStreamName)
+uno::Reference<io::XInputStream> AgileEngine::getStream(const Sequence<NamedValue> & rStreams, const OUString sStreamName)
 {
     for (const auto & aStream : rStreams)
     {
@@ -502,7 +516,7 @@ uno::Reference<io::XInputStream> AgileEngine::getStream(Sequence<NamedValue> & r
     return nullptr;
 }
 
-bool AgileEngine::readEncryptionInfo(Sequence<NamedValue> aStreams)
+sal_Bool AgileEngine::readEncryptionInfo(const Sequence<NamedValue>& aStreams)
 {
     uno::Reference<io::XInputStream> xEncryptionInfo = getStream(aStreams, "EncryptionInfo");
 
@@ -682,7 +696,7 @@ bool AgileEngine::encryptEncryptionKey(OUString const & rPassword)
     return true;
 }
 
-bool AgileEngine::setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rMediaEncData)
+sal_Bool AgileEngine::setupEncryption(const css::uno::Sequence<css::beans::NamedValue>& rMediaEncData)
 {
     if (meEncryptionPreset == AgileEncryptionPreset::AES_128_SHA1)
         setupEncryptionParameters({ 100000, 16, 128, 20, 16, OUString("AES"), OUString("ChainingModeCBC"), OUString("SHA1") });
@@ -692,7 +706,7 @@ bool AgileEngine::setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rM
     OUString sPassword;
     for (int i = 0; i < rMediaEncData.getLength(); i++)
     {
-        if (rMediaEncData[i].Name == "Password")
+        if (rMediaEncData[i].Name == "OOXPassword")
         {
             OUString sCryptoType;
             rMediaEncData[i].Value >>= sPassword;
@@ -702,9 +716,13 @@ bool AgileEngine::setupEncryption(css::uno::Sequence<css::beans::NamedValue>& rM
     return setupEncryptionKey(sPassword);
 }
 
-void AgileEngine::createEncryptionData(comphelper::SequenceAsHashMap & aEncryptionData, const OUString rPassword)
+uno::Sequence<beans::NamedValue> AgileEngine::createEncryptionData(const OUString & rPassword)
 {
+    comphelper::SequenceAsHashMap aEncryptionData;
     aEncryptionData["OOXPassword"] <<= rPassword;
+    aEncryptionData["CryptoType"] <<= OUString("AgileEngine");
+
+    return aEncryptionData.getAsConstNamedValueList();
 }
 
 void AgileEngine::setupEncryptionParameters(AgileEncryptionParameters const & rAgileEncryptionParameters)
@@ -738,10 +756,12 @@ bool AgileEngine::setupEncryptionKey(OUString const & rPassword)
     return true;
 }
 
-void AgileEngine::writeEncryptionInfo(oox::ole::OleStorage& rOleStorage)
+css::uno::Sequence<css::beans::NamedValue> AgileEngine::writeEncryptionInfo()
 {
-    Reference<XOutputStream> xEncryptionInfo(rOleStorage.openOutputStream("EncryptionInfo"), UNO_SET_THROW);
-    BinaryXOutputStream rStream(xEncryptionInfo, false);
+    Reference<XOutputStream> aEncryptionInfoStream(
+        mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.io.SequenceOutputStream", mxContext),
+        UNO_QUERY);
+    BinaryXOutputStream rStream(aEncryptionInfoStream, false);
 
     rStream.WriteUInt32(msfilter::VERSION_INFO_AGILE);
     rStream.WriteUInt32(msfilter::AGILE_ENCRYPTION_RESERVED);
@@ -798,21 +818,28 @@ void AgileEngine::writeEncryptionInfo(oox::ole::OleStorage& rOleStorage)
     rStream.writeMemory(aMemStream.GetData(), aMemStream.GetSize());
 
     rStream.close();
-    xEncryptionInfo->flush();
-    xEncryptionInfo->closeOutput();
+    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();
 }
 
-void AgileEngine::encrypt(css::uno::Reference<css::io::XInputStream> &  rxInputStream,
-                          css::uno::Reference<css::io::XOutputStream> & rxOutputStream,
-                          sal_uInt32 nSize)
+void AgileEngine::encrypt(const css::uno::Reference<css::io::XInputStream> &  rxInputStream,
+                          css::uno::Reference<css::io::XOutputStream> & rxOutputStream)
 {
     CryptoHash aCryptoHash(mInfo.hmacKey, cryptoHashTypeFromString(mInfo.hashAlgorithm));
 
     BinaryXOutputStream aBinaryOutputStream(rxOutputStream, false);
     BinaryXInputStream aBinaryInputStream(rxInputStream, false);
+    Reference<XSeekable> xSeekable(rxInputStream, UNO_QUERY);
+    sal_uInt32 nLength = xSeekable->getLength();
 
     std::vector<sal_uInt8> aSizeBytes(sizeof(sal_uInt32));
-    ByteOrderConverter::writeLittleEndian(aSizeBytes.data(), nSize);
+    ByteOrderConverter::writeLittleEndian(aSizeBytes.data(), nLength);
     aBinaryOutputStream.writeMemory(aSizeBytes.data(), aSizeBytes.size()); // size
     aCryptoHash.update(aSizeBytes, aSizeBytes.size());
 
diff --git a/oox/source/crypto/DocumentDecryption.cxx b/oox/source/crypto/DocumentDecryption.cxx
index 7d9427a5bb41..ea3ed1123532 100644
--- a/oox/source/crypto/DocumentDecryption.cxx
+++ b/oox/source/crypto/DocumentDecryption.cxx
@@ -14,14 +14,12 @@
 #include <cppuhelper/implbase.hxx>
 
 #include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/io/XStream.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
-#include <oox/crypto/AgileEngine.hxx>
-#include <oox/crypto/Standard2007Engine.hxx>
-#include <oox/crypto/IRMEngine.hxx>
-#include <oox/helper/binaryinputstream.hxx>
-#include <oox/helper/binaryoutputstream.hxx>
+#include <com/sun/star/packages/XPackageEncryption.hpp>
 #include <oox/ole/olestorage.hxx>
+#include <filter/msfilter/mscodec.hxx>
 
 namespace {
 
@@ -81,8 +79,8 @@ DocumentDecryption::DocumentDecryption(const css::uno::Reference< css::uno::XCom
 
 bool DocumentDecryption::generateEncryptionKey(const OUString& rPassword)
 {
-    if (mEngine)
-        return mEngine->generateEncryptionKey(rPassword);
+    if (mxPackageEncryption.is())
+        return mxPackageEncryption->generateEncryptionKey(rPassword);
     return false;
 }
 
@@ -93,16 +91,20 @@ void DocumentDecryption::readStrongEncryptionInfo()
     BinaryXInputStream aBinaryInputStream(xEncryptionInfo, true);
     sal_uInt32 aVersion = aBinaryInputStream.readuInt32();
 
+    uno::Sequence< uno::Any > aArguments;
+
     switch (aVersion)
     {
     case msfilter::VERSION_INFO_2007_FORMAT:
     case msfilter::VERSION_INFO_2007_FORMAT_SP2:
-        msEngineName = "Standard"; // Set encryption info format
-        mEngine.reset(new Standard2007Engine(mxContext));
+        mxPackageEncryption.set(
+            mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+                "com.sun.star.comp.oox.crypto.Standard2007Engine", aArguments, mxContext), css::uno::UNO_QUERY);
         break;
     case msfilter::VERSION_INFO_AGILE:
-        msEngineName = "Agile"; // Set encryption info format
-        mEngine.reset(new AgileEngine(mxContext));
+        mxPackageEncryption.set(
+            mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+                "com.sun.star.comp.oox.crypto.AgileEngine", aArguments, mxContext), css::uno::UNO_QUERY);
         break;
     default:
         break;
@@ -146,23 +148,15 @@ bool DocumentDecryption::readEncryptionInfo()
             aDataSpaceStream.skip((4 - (aDataSpaceNameLength & 3)) & 3);  // Skip padding
         }
 
-        if (sDataSpaceName == "DRMEncryptedDataSpace")
-        {
-            msEngineName = "IRM"; // Set encryption info format
-            mEngine.reset(new IRMEngine(mxContext));
-        }
-        else if (sDataSpaceName == "\011DRMDataSpace") // 0x09DRMDataSpace
-        {
-            // TODO: IRM binary file
-        }
-        else if (sDataSpaceName == "StrongEncryptionDataSpace")
+        uno::Sequence< uno::Any > aArguments;
+        mxPackageEncryption.set(
+            mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+                "com.sun.star.comp.oox.crypto." + sDataSpaceName, aArguments, mxContext), css::uno::UNO_QUERY);
+
+        if (!mxPackageEncryption.is() && sDataSpaceName == "StrongEncryptionDataSpace")
         {
             readStrongEncryptionInfo();
         }
-        else
-        {
-            SAL_WARN("oox", "Unknown dataspace - document will be not decrypted!");
-        }
     }
     else
     {
@@ -172,20 +166,21 @@ bool DocumentDecryption::readEncryptionInfo()
         readStrongEncryptionInfo();
     }
 
-    if (!mEngine)
+    if (!mxPackageEncryption.is())
+    {
+        // we do not know how to decrypt this document
         return false;
+    }
 
-    return mEngine->readEncryptionInfo(maStreamsSequence);
+    return mxPackageEncryption->readEncryptionInfo(maStreamsSequence);
 }
 
 uno::Sequence<beans::NamedValue> DocumentDecryption::createEncryptionData(const OUString& rPassword)
 {
-    comphelper::SequenceAsHashMap aEncryptionData;
+    if (!mxPackageEncryption.is())
+        return uno::Sequence<beans::NamedValue>();
 
-    aEncryptionData["CryptoType"] <<= msEngineName;
-    mEngine->createEncryptionData(aEncryptionData, rPassword);
-
-    return aEncryptionData.getAsConstNamedValueList();
+    return mxPackageEncryption->createEncryptionData(rPassword);
 }
 
 bool DocumentDecryption::decrypt(const uno::Reference<io::XStream>& xDocumentStream)
@@ -195,21 +190,22 @@ bool DocumentDecryption::decrypt(const uno::Reference<io::XStream>& xDocumentStr
     if (!mrOleStorage.isStorage())
         return false;
 
+    if (!mxPackageEncryption.is())
+        return false;
+
     // open the required input streams in the encrypted package
     uno::Reference<io::XInputStream> xEncryptedPackage = mrOleStorage.openInputStream("EncryptedPackage");
 
     // create temporary file for unencrypted package
     uno::Reference<io::XOutputStream> xDecryptedPackage = xDocumentStream->getOutputStream();
-    BinaryXOutputStream aDecryptedPackage(xDecryptedPackage, true);
-    BinaryXInputStream aEncryptedPackage(xEncryptedPackage, true);
 
-    bResult = mEngine->decrypt(aEncryptedPackage, aDecryptedPackage);
+    bResult = mxPackageEncryption->decrypt(xEncryptedPackage, xDecryptedPackage);
 
-    xDecryptedPackage->flush();
-    aDecryptedPackage.seekToStart();
+    css::uno::Reference<io::XSeekable> xSeekable(xDecryptedPackage, css::uno::UNO_QUERY);
+    xSeekable->seek(0);
 
     if (bResult)
-        return mEngine->checkDataIntegrity();
+        return mxPackageEncryption->checkDataIntegrity();
 
     return bResult;
 }
diff --git a/oox/source/crypto/DocumentEncryption.cxx b/oox/source/crypto/DocumentEncryption.cxx
index 8aac457c67d2..2dba0f035df5 100644
--- a/oox/source/crypto/DocumentEncryption.cxx
+++ b/oox/source/crypto/DocumentEncryption.cxx
@@ -9,16 +9,13 @@
  */
 
 #include <oox/crypto/DocumentEncryption.hxx>
-#include <oox/crypto/Standard2007Engine.hxx>
-#include <oox/crypto/IRMEngine.hxx>
 
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/io/XStream.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/packages/XPackageEncryption.hpp>
 
-#include <oox/helper/binaryinputstream.hxx>
-#include <oox/helper/binaryoutputstream.hxx>
 #include <oox/ole/olestorage.hxx>
 
 namespace oox {
@@ -26,11 +23,12 @@ namespace core {
 
 using namespace css::io;
 using namespace css::uno;
+using namespace css::beans;
 
-DocumentEncryption::DocumentEncryption(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+DocumentEncryption::DocumentEncryption(const Reference< XComponentContext >& rxContext,
                                        Reference<XStream> const & xDocumentStream,
                                        oox::ole::OleStorage& rOleStorage,
-                                       Sequence<css::beans::NamedValue>& rMediaEncData)
+                                       Sequence<NamedValue>& rMediaEncData)
     : mxContext(rxContext)
     , mxDocumentStream(xDocumentStream)
     , mrOleStorage(rOleStorage)
@@ -43,25 +41,28 @@ DocumentEncryption::DocumentEncryption(const css::uno::Reference< css::uno::XCom
         {
             OUString sCryptoType;
             rMediaEncData[i].Value >>= sCryptoType;
-            if (sCryptoType == "IRM")
-            {
-                mEngine.reset(new IRMEngine(mxContext));
-            }
-            else if (sCryptoType == "Standard" || sCryptoType == "Agile")
-            {
-                mEngine.reset(new Standard2007Engine(mxContext));
-            }
-            else
+
+            if (sCryptoType == "Standard")
+                sCryptoType = "Standard2007Engine";
+
+            Sequence<Any> aArguments;
+            mxPackageEncryption.set(
+                mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+                    "com.sun.star.comp.oox.crypto." + sCryptoType, aArguments, mxContext), css::uno::UNO_QUERY);
+
+            if (!mxPackageEncryption.is())
             {
                 SAL_WARN("oox", "Requested encryption method \"" << sCryptoType << "\" is not supported");
             }
+
+            break;
         }
     }
 }
 
 bool DocumentEncryption::encrypt()
 {
-    if (!mEngine)
+    if (!mxPackageEncryption.is())
         return false;
 
     Reference<XInputStream> xInputStream (mxDocumentStream->getInputStream(), UNO_SET_THROW);
@@ -70,20 +71,32 @@ bool DocumentEncryption::encrypt()
     if (!xSeekable.is())
         return false;
 
-    sal_uInt32 aLength = xSeekable->getLength(); // check length of the stream
     xSeekable->seek(0); // seek to begin of the document stream
 
     if (!mrOleStorage.isStorage())
         return false;
 
-    mEngine->setupEncryption(mMediaEncData);
+    mxPackageEncryption->setupEncryption(mMediaEncData);
 
     Reference<XOutputStream> xOutputStream(mrOleStorage.openOutputStream("EncryptedPackage"), UNO_SET_THROW);
-    mEngine->encrypt(xInputStream, xOutputStream, aLength);
+    mxPackageEncryption->encrypt(xInputStream, xOutputStream);
     xOutputStream->flush();
     xOutputStream->closeOutput();
 
-    mEngine->writeEncryptionInfo(mrOleStorage);
+    Sequence<NamedValue> aStreams = mxPackageEncryption->writeEncryptionInfo();
+
+    for (const NamedValue & aStream : aStreams)
+    {
+        Reference<XOutputStream> xOutputStream(mrOleStorage.openOutputStream(aStream.Name), UNO_SET_THROW);
+        BinaryXOutputStream aBinaryOutputStream(xOutputStream, true);
+
+        css::uno::Sequence<sal_Int8> aStreamSequence;
+        aStream.Value >>= aStreamSequence;
+
+        aBinaryOutputStream.writeData(aStreamSequence);
+
+        aBinaryOutputStream.close();
+    }
 
     return true;
 }
diff --git a/oox/source/crypto/IRMEngine.cxx b/oox/source/crypto/IRMEngine.cxx
index 1301a3b51279..95135722ee08 100644
--- a/oox/source/crypto/IRMEngine.cxx
+++ b/oox/source/crypto/IRMEngine.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/io/XStream.hpp>
 #include <com/sun/star/io/SequenceInputStream.hpp>
+#include <com/sun/star/io/XSequenceOutputStream.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/xml/sax/XFastParser.hpp>
 #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
@@ -50,15 +51,26 @@ namespace oox
 {
 namespace core
 {
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_comp_oox_crypto_DRMEncryptedDataSpace_get_implementation(
+    XComponentContext* pCtx, Sequence<Any> const& /*arguments*/)
+{
+    return cppu::acquire(new IRMEngine(pCtx /*, arguments*/));
+}
+
 IRMEngine::IRMEngine(const Reference<XComponentContext>& rxContext)
     : mxContext(rxContext)
 {
 }
 
-bool IRMEngine::checkDataIntegrity() { return true; }
+sal_Bool IRMEngine::checkDataIntegrity() { return true; }
 
-bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& aOutputStream)
+sal_Bool IRMEngine::decrypt(const Reference<XInputStream>& rxInputStream,
+                            Reference<XOutputStream>& rxOutputStream)
 {
+    BinaryXInputStream aInputStream(rxInputStream, true);
+    BinaryXOutputStream aOutputStream(rxOutputStream, true);
+
     aInputStream.readInt64(); // Skip stream size
 
     HRESULT hr = IpcInitialize();
@@ -66,6 +78,7 @@ bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& a
     {
         // ERROR_ALREADY_INITIALIZED not an error
         // TODO: some reaction?
+        return false;
     }
 
     // Get decryption key
@@ -77,6 +90,7 @@ bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& a
     if (FAILED(hr))
     {
         // TODO: some reaction?
+        return false;
     }
 
     // Read rights
@@ -85,6 +99,7 @@ bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& a
     if (FAILED(hr))
     {
         // TODO: some reaction?
+        return false;
     }
     mInfo.bCanRead = value;
 
@@ -94,6 +109,7 @@ bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& a
     if (FAILED(hr))
     {
         // TODO: some reaction?
+        return false;
     }
 
     char* pEncryptedBuffer = new char[*blockSize];
@@ -112,6 +128,7 @@ bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& a
         if (FAILED(hr))
         {
             // TODO: some reaction?
+            return false;
         }
 
         aOutputStream.writeArray(pDecryptedBuffer, bytes);
@@ -122,22 +139,26 @@ bool IRMEngine::decrypt(BinaryXInputStream& aInputStream, BinaryXOutputStream& a
     delete[] pEncryptedBuffer;
     delete[] pDecryptedBuffer;
 
+    rxOutputStream->flush();
+
     return true;
 }
 
-void IRMEngine::createEncryptionData(comphelper::SequenceAsHashMap& aEncryptionData,
-                                     const OUString rPassword)
+uno::Sequence<beans::NamedValue> IRMEngine::createEncryptionData(const OUString& /*rPassword*/)
 {
-    aEncryptionData["OOXPassword"] <<= rPassword;
-
     css::uno::Sequence<sal_uInt8> seq;
     seq.realloc(mInfo.license.getLength());
     memcpy(seq.getArray(), mInfo.license.getStr(), mInfo.license.getLength());
 
-    aEncryptionData["license"] <<= seq;
+    comphelper::SequenceAsHashMap aEncryptionData;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list