summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-03-10 19:18:41 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-03-19 12:20:54 +0100
commitbc898e2c2784e36ad4d4cdf6d962e39069d2c82d (patch)
treeca53c5c2d4104f867423a9d13bcf434c6a087038
parent34ea5c21a752364caef9727850ef34943ad5c752 (diff)
writerfilter: DocProtect_enforcement defaults to false
If enforcement is not specified, then it defaults to off. "If this attribute is omitted, then document protection settings shall not be enforced by applications." Since we cannot guarantee that NS_ooxml::LN_CT_DocProtect_enforcement will be called, handle checking the various protection statuses after the import has finished. The unit test previously had an explicit enforcement="0". Removing that was the only change I made. This patch was inspired by a code-review of LO 6.4's tdf#106843 and preparation for tdf#120852. Change-Id: I702f5173fd796eb8bda1ea610411f8297d8889b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90302 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/TextFrameRotation.docxbin30563 -> 25798 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport7.cxx5
-rw-r--r--writerfilter/source/dmapper/SettingsTable.cxx13
3 files changed, 7 insertions, 11 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/TextFrameRotation.docx b/sw/qa/extras/ooxmlexport/data/TextFrameRotation.docx
index fde69c5a7546..ac7c2236bf23 100644
--- a/sw/qa/extras/ooxmlexport/data/TextFrameRotation.docx
+++ b/sw/qa/extras/ooxmlexport/data/TextFrameRotation.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index a7f4b5e4eacf..d7c6d3ca64be 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -793,6 +793,11 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo80894, "TextFrameRotation.docx")
// Rotation value was not roundtripped for textframe.
assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:xfrm",
"rot","16200000");
+
+ // w:enforcement defaults to off if not explicitly specified, so DocProtect forms should not be enabled.
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("No protected sections", sal_Int32(0), xSections->getCount());
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo80895, "fdo80895.docx")
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 71bff9b68dab..824c627f436c 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -380,15 +380,6 @@ void SettingsTable::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_CT_DocProtect_enforcement: // 92039
m_pImpl->m_DocumentProtection.m_bEnforcement = (nIntValue != 0);
- switch (m_pImpl->m_DocumentProtection.m_nEdit)
- {
- case NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges:
- m_pImpl->m_bRedlineProtection = (nIntValue != 0);
- break;
- case NS_ooxml::LN_Value_doc_ST_DocProtect_forms:
- m_pImpl->m_bProtectForm = (nIntValue != 0);
- break;
- }
break;
case NS_ooxml::LN_CT_DocProtect_formatting: // 92038
m_pImpl->m_DocumentProtection.m_bFormatting = (nIntValue != 0);
@@ -664,7 +655,7 @@ bool SettingsTable::GetDoNotExpandShiftReturn() const
bool SettingsTable::GetProtectForm() const
{
- return m_pImpl->m_bProtectForm;
+ return m_pImpl->m_bProtectForm && m_pImpl->m_DocumentProtection.m_bEnforcement;
}
bool SettingsTable::GetNoHyphenateCaps() const
@@ -734,7 +725,7 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x
{
xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
// Password protected Record changes
- if ( m_pImpl->m_bRecordChanges && m_pImpl->m_bRedlineProtection )
+ if ( m_pImpl->m_bRecordChanges && m_pImpl->m_bRedlineProtection && m_pImpl->m_DocumentProtection.m_bEnforcement )
{
// use dummy protection key to forbid disabling of Record changes without a notice
// (extending the recent GrabBag support) TODO support password verification...