sfx2/source/doc/objstor.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
New commits: commit f49d74edf76097d014ed891d0025cb2e9b197c5a Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Fri Apr 26 23:20:31 2024 +0200 Commit: Julien Nabet <serval2...@yahoo.fr> CommitDate: Sun Apr 28 11:39:38 2024 +0200 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 <serval2...@yahoo.fr> 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);