From 078cb36ccfdc448259113fa961ac83ed1e17ceb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20N=C3=A9meth?= Date: Wed, 20 Jun 2018 16:28:13 +0200 Subject: [PATCH] tdf#107690 Initial support of Mark as Final property of MSO Don't save modified documents with property _MarkAsFinal=True silently to avoid to get unintended warning messages in MSO. Show read-only info bar for documents with custom document property _MarkAsFinal=True, similar to MSO. This improves interoperability a lot, because this is a basic document protection of MSO, recommended on its UI. Change-Id: Ie279c0670090d075103384cfa44ff1c2a2898216 --- sfx2/source/doc/objstor.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9bc418f..fd71e18 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -828,6 +828,35 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed ) xDocProps->setSubject(aValue); } } + + // tdf#107690 LibreOffice could save silently documents with the + // user-defined property _MarkAsFinal=true, resulting an interoperability + // problem: unintented read-only warning info bar in MSO. To avoid that + // and showing the warning of the original document also in LO, when + // _MarkAsFinal=true is defined, we call SetReadOnlyUI(), showing also an + // infobar for removing easily this read-only protection (this is the use + // case of the heavily used MSO custom property "_MarkAsFinal"), and + // change _MarkAsFinal to false immediately. + // + // TODO: Implement MarkAsFinal LO setting or use LoadReadonly for it + // (but that doesn't show infobar in LibreOffice 6.1, only Edit->Edit mode + // is available to remove the read-only protection), and move this fix + // in a better place. + uno::Reference xPropertyContainer = xDocProps->getUserDefinedProperties(); + if (xPropertyContainer.is()) + { + uno::Reference xPropertySet(xPropertyContainer, uno::UNO_QUERY); + if (xPropertySet.is()) + { + aAny = xPropertySet->getPropertyValue("_MarkAsFinal"); + if (aAny.has() && aAny.get()) + { + SetReadOnlyUI(); + xPropertySet->setPropertyValue("_MarkAsFinal", Any( false )); + } + } + + } } } catch( Exception& ) -- 2.7.4