summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2019-11-15 19:30:36 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-12-04 13:42:23 +0100
commit1c7a4176f201ef04fb88413ff602031fdf6f03c4 (patch)
tree2f393181204a7625e4b13c3990534fdc78446b3d
parent8787fed1622a27e16401135936fc6c8730941087 (diff)
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@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de> Reviewed-on: https://gerrit.libreoffice.org/82817 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--sfx2/source/doc/guisaveas.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index e14ed2bb7404..2b2d439dc790 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -729,6 +729,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 ) )
@@ -745,6 +747,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() );