diff options
author | László Németh <nemeth@numbertext.org> | 2018-06-20 16:28:13 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-09-12 09:43:32 +0200 |
commit | 3d6ae0441a8eee97e0e5eeff491245055680b829 (patch) | |
tree | 7dce2ebfe8ab8ac8a28e76d71fb1726594f8c3cf /sfx2 | |
parent | 6685a3b6fb1e4e3c6e109904d0d20fcd00c3e470 (diff) |
tdf#107690 OOXML import/export of setting "Open as read-only"
Import custom document property _MarkAsFinal as LoadReadonly
setting, export LoadReadonly as _MarkAsFinal in DOCX, XLSX
and PPTX documents.
Before this fix, LibreOffice opened read-only OOXML documents
as editable, also saved and exported _MarkAsFinal=true silently,
resulting unintented read-only warning info bar in MSO.
This commit improves interoperability a lot, because this is a
basic document protection of MSO, recommended on its UI.
Note: LoadReadonly (on File->Properties...->Security, property
"Open file read-only") doesn't show "Edit read-only" info bar
from commit 630186ff4e0eba7317e542f8c3eca39ebd068721,
but it's still possible to switch on editing by Edit->Edit Mode.
MSO shows info bar for _MarkAsFinal. (There is an advantage to
hide the info bar in LibreOffice in a mixed environment,
to avoid overwriting of press-ready MSO files by LibreOffice.)
Note 2: Other differences of LoadReadonly in LO and _MarkAsFinal
in MSO: (1) Switching on editing doesn't remove the LoadReadonly
property automatically in LO. (2) Saving with LoadReadonly doesn't
switch off editing of the actual (still opened) document in LO.
Reviewed-on: https://gerrit.libreoffice.org/56180
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 9a5c56a9c4e04589b0a6bb710573922e459d9685)
Change-Id: Ie279c0670090d075103384cfa44ff1c2a2898216
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index dad9c424891c..ad0ffb937416 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2250,6 +2250,33 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, } } } + + // tdf#107690 import custom document property _MarkAsFinal as SecurityOptOpenReadonly + // (before this fix, LibreOffice opened read-only OOXML documents as editable, + // also saved and exported _MarkAsFinal=true silently, resulting unintented read-only + // warning info bar in MSO) + uno::Reference< document::XDocumentPropertiesSupplier > xPropSupplier(GetModel(), uno::UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> xDocProps = xPropSupplier->getDocumentProperties() ; + uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocProps->getUserDefinedProperties(); + if (xPropertyContainer.is()) + { + uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY); + if (xPropertySet.is()) + { + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("_MarkAsFinal")) + { + if (xPropertySet->getPropertyValue("_MarkAsFinal").get<bool>()) + { + uno::Reference< lang::XMultiServiceFactory > xFactory(GetModel(), uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xSettings(xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + xSettings->setPropertyValue("LoadReadonly", uno::makeAny(true)); + } + xPropertyContainer->removeProperty("_MarkAsFinal"); + } + } + } + return bRtn; } catch (const packages::zip::ZipIOException&) |