summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2024-04-26 23:20:31 +0200
committerJulien Nabet <serval2412@yahoo.fr>2024-04-28 11:39:38 +0200
commitf49d74edf76097d014ed891d0025cb2e9b197c5a (patch)
tree6fb32a798a36897925b01ae85486a47e41612806
parentd98e014cf6d4cea7ebd7898cbc9124f6fba07684 (diff)
tdf#160827: fix crash when retrieving _MarkAsFinal value (docx)
xPropertySet->getPropertyValue("_MarkAsFinal") can retrieve an Any containing a boolean or a string Change-Id: I1c8bafc12cdaf7fb98d3500507ba83b3e90f69cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166763 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--sfx2/source/doc/objstor.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 720e939e3885..441641d1c65c 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2741,7 +2741,13 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("_MarkAsFinal"))
{
- if (xPropertySet->getPropertyValue("_MarkAsFinal").get<bool>())
+ Any anyMarkAsFinal = xPropertySet->getPropertyValue("_MarkAsFinal");
+ const OUString strValueTypeName = anyMarkAsFinal.getValueTypeName();
+
+ if (
+ ( (strValueTypeName == "boolean") && (anyMarkAsFinal.get<bool>()) ) ||
+ ( (strValueTypeName == "string") && (anyMarkAsFinal.get<OUString>() == "true") )
+ )
{
uno::Reference< lang::XMultiServiceFactory > xFactory(GetModel(), uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > xSettings(xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);