summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/guisaveas.cxx
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-11-22 14:30:43 +0100
commit122468bf97f1ea456274991103a13489b8d5df58 (patch)
treee384460fc1dc1f566c8f9ecc93f7488e7649488e /sfx2/source/doc/guisaveas.cxx
parent252655333ed773585e12378fa3987bb34f38fa38 (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>
Diffstat (limited to 'sfx2/source/doc/guisaveas.cxx')
-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 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() );