diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2021-10-06 10:19:05 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-10-13 14:45:30 +0200 |
commit | 5697e09b3e726a38b58ce31ac0c3a97e7871c74a (patch) | |
tree | 996ff2c6c68898347615680f062f600879418e0a /oox/source/ppt | |
parent | a3416ed058884a1fcaae0659ff6e71f5a7dff8d0 (diff) |
tdf#144943 PPTX import: fix permission for editing
The passwords for editing in PPTX documents
created with PowerPoint weren't asked and verified.
Change-Id: I62eb4fd68aac6422c1221a639f4815459ab556c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123130
Tested-by: Jenkins
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox/source/ppt')
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 9aabd45d18af..95eb5fdb53c0 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp> #include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -598,6 +599,81 @@ void PresentationFragmentHandler::finalizeImport() return new CustomShowListContext( *this, maCustomShowList ); case PPT_TOKEN( defaultTextStyle ): return new TextListStyleContext( *this, *mpTextListStyle ); + case PPT_TOKEN( modifyVerifier ): + OUString sAlgorithmClass = rAttribs.getString(XML_cryptAlgorithmClass, OUString()); + OUString sAlgorithmType = rAttribs.getString(XML_cryptAlgorithmType, OUString()); + sal_Int32 nAlgorithmSid = rAttribs.getInteger(XML_cryptAlgorithmSid, 0); + sal_Int32 nSpinCount = rAttribs.getInteger(XML_spinCount, 0); + OUString sSalt = rAttribs.getString(XML_saltData, OUString()); + OUString sHash = rAttribs.getString(XML_hashData, OUString()); + if (sAlgorithmClass == "hash" && sAlgorithmType == "typeAny" && nAlgorithmSid != 0 + && !sSalt.isEmpty() && !sHash.isEmpty()) + { + OUString sAlgorithmName; + switch (nAlgorithmSid) + { + case 1: + sAlgorithmName = "MD2"; + break; + case 2: + sAlgorithmName = "MD4"; + break; + case 3: + sAlgorithmName = "MD5"; + break; + case 4: + sAlgorithmName = "SHA-1"; + break; + case 5: + sAlgorithmName = "MAC"; + break; + case 6: + sAlgorithmName = "RIPEMD"; + break; + case 7: + sAlgorithmName = "RIPEMD-160"; + break; + case 9: + sAlgorithmName = "HMAC"; + break; + case 12: + sAlgorithmName = "SHA-256"; + break; + case 13: + sAlgorithmName = "SHA-384"; + break; + case 14: + sAlgorithmName = "SHA-512"; + break; + default:; // 8, 10, 11, any other value: Undefined. + } + + if (!sAlgorithmName.isEmpty()) + { + uno::Sequence<beans::PropertyValue> aResult; + aResult.realloc(4); + aResult[0].Name = "algorithm-name"; + aResult[0].Value <<= sAlgorithmName; + aResult[1].Name = "salt"; + aResult[1].Value <<= sSalt; + aResult[2].Name = "iteration-count"; + aResult[2].Value <<= nSpinCount; + aResult[3].Name = "hash"; + aResult[3].Value <<= sHash; + try + { + uno::Reference<beans::XPropertySet> xDocSettings( + getFilter().getModelFactory()->createInstance( + "com.sun.star.document.Settings"), + uno::UNO_QUERY); + xDocSettings->setPropertyValue("ModifyPasswordInfo", uno::makeAny(aResult)); + } + catch (const uno::Exception&) + { + } + } + } + return this; } return this; } |