[Libreoffice-commits] core.git: sfx2/source

Serge Krot (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 22 13:31:30 UTC 2019


 sfx2/source/doc/guisaveas.cxx |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

New commits:
commit 122468bf97f1ea456274991103a13489b8d5df58
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Fri Nov 15 19:30:36 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Nov 22 14:30:43 2019 +0100

    Warn user when output format does not support used encryption
    
    Change-Id: Id5614cb7647b465c3edb2485fcd4f621cfee42b2
    Reviewed-on: https://gerrit.libreoffice.org/82816
    Reviewed-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Tested-by: Serge Krot (CIB) <Serge.Krot at cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/82817
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 6a9012f63c1f..74a753d8da5c 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -724,6 +724,8 @@ sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName )
     ::comphelper::SequenceAsHashMap aDefFiltPropsHM = GetDocServiceDefaultFilterCheckFlags( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT, SfxFilterFlags::NONE );
     SfxFilterFlags nDefFiltFlags = static_cast<SfxFilterFlags>(aDefFiltPropsHM.getUnpackedValueOrDefault("Flags", sal_Int32(0) ));
 
+    bool bAsk = false;
+
     // if the old filter is not acceptable
     // and there is no default filter or it is not acceptable for requested parameters then proceed with saveAs
     if ( ( aFiltPropsHM.empty() || !( nFiltFlags & SfxFilterFlags::EXPORT ) )
@@ -740,6 +742,38 @@ sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName )
            && !aDefFiltPropsHM.empty()
            && ( nDefFiltFlags & SfxFilterFlags::EXPORT ) && !( nDefFiltFlags & SfxFilterFlags::INTERNAL ))
     {
+        bAsk = true;
+    }
+
+    // check if EncryptionData supports this output format
+    {
+        OUString aSupportedFilters;
+        const ::comphelper::SequenceAsHashMap& rDocumentProperties = GetDocProps();
+        const css::uno::Sequence<css::beans::NamedValue> aEncryptionData = rDocumentProperties.getUnpackedValueOrDefault("EncryptionData", css::uno::Sequence<css::beans::NamedValue>());
+        if (aEncryptionData != css::uno::Sequence<css::beans::NamedValue>())
+        {
+            for (const css::beans::NamedValue& aNamedValue : aEncryptionData)
+            {
+                if (aNamedValue.Name == "SupportedFilters")
+                {
+                    aNamedValue.Value >>= aSupportedFilters;
+                }
+            }
+        }
+
+        // if 'SupportedFilters' is empty assume that all filters are supported.
+        if (!aSupportedFilters.isEmpty())
+        {
+            const OUString aSelectedFilter = aFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString());
+
+            aSupportedFilters = ";" + aSupportedFilters + ";";
+            const OUString aSearchToken = ";" + aSelectedFilter + ";";
+            bAsk = (aSupportedFilters.indexOf(aSearchToken) < 0);
+        }
+    }
+
+    if (bAsk)
+    {
         // the default filter is acceptable and the old filter is alien one
         // so ask to make a saveAs operation
         const OUString aUIName = aFiltPropsHM.getUnpackedValueOrDefault("UIName", OUString() );


More information about the Libreoffice-commits mailing list