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

New commits:
commit d9afd58186543f556987d817622eae587cdf09a3
Author:     Serge Krot <serge.k...@cib.de>
AuthorDate: Fri Nov 15 19:30:36 2019 +0100
Commit:     Serge Krot (CIB) <serge.k...@cib.de>
CommitDate: Fri Nov 15 19:33:49 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.k...@cib.de>
    Tested-by: Serge Krot (CIB) <serge.k...@cib.de>

diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 6a9012f63c1f..508524b37220 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,36 @@ 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();
+        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())
+        {
+            aSupportedFilters = ";" + aSupportedFilters + ";";
+            const OUString aSearchToken = ";" + aFilterName + ";";
+            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() );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to