diff options
author | Justin Luth <justin.luth@collabora.com> | 2020-03-10 21:38:50 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-03-25 09:17:34 +0100 |
commit | b2471b8ab62abaa7f0c2c8342b4fa61c18f013c6 (patch) | |
tree | b7f1ac45add0b037160acf590ceaf3531a7c1fd0 /sw | |
parent | d3e1ada45439937e0836696963b9d30ad5447b2c (diff) |
tdf#106843 docxexport: don't write double docProtect
regression from LO 6.4
commit 2756ed9317e3474003c11ffe7d1e2f087c1412bf
Change-Id: Iaf32974c7282d11bcd9572ed75cf1233ad3f0008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90321
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/sectionprot2.odt | bin | 0 -> 8568 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 30 |
3 files changed, 29 insertions, 15 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/sectionprot2.odt b/sw/qa/extras/ooxmlexport/data/sectionprot2.odt Binary files differnew file mode 100644 index 000000000000..8f4a283f847a --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/sectionprot2.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 2ba06ce0982e..7eb17d725845 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -992,6 +992,20 @@ DECLARE_OOXMLEXPORT_TEST(testSectionProtection, "sectionprot.odt") CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", false, getProperty<bool>(xSect, "IsProtected")); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testSectionProtection2, "sectionprot2.odt") +{ + if (xmlDocPtr pXmlSettings = parseExport("word/settings.xml")) + { + assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement", "true"); + assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "forms"); + } + + uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, getProperty<bool>(xSect, "IsProtected")); +} + DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx") { // check document permission settings for the whole document diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index a74292d27e54..9aa7a8a2a083 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1230,12 +1230,13 @@ void DocxExport::WriteSettings() // we have document protection from input DOCX file // and in the case of change tracking protection, we didn't modify it - - sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList); - if (!bIsProtectionTrackChanges || bHasDummyRedlineProtectionKey) + hasProtectionProperties = !bIsProtectionTrackChanges || bHasDummyRedlineProtectionKey; + if ( hasProtectionProperties ) + { + sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList); pFS->singleElementNS(XML_w, XML_documentProtection, xAttributeList); + } - hasProtectionProperties = true; } } else if (rProp.Name == "HyphenationZone") @@ -1259,10 +1260,10 @@ void DocxExport::WriteSettings() WriteDocVars(pFS); - // Protect form - // Section-specific write protection if (! hasProtectionProperties) { + // Protect form - highest priority + // Section-specific write protection if (m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM) || m_pSections->DocumentIsProtected()) { @@ -1272,16 +1273,15 @@ void DocxExport::WriteSettings() FSNS(XML_w, XML_edit), "forms", FSNS(XML_w, XML_enforcement), "true"); } - } - - // Protect Change Tracking - if ( bHasRedlineProtectionKey && !bHasDummyRedlineProtectionKey ) - { - // we have change tracking protection from Writer or from input ODT file + // Protect Change Tracking - next priority + else if ( bHasRedlineProtectionKey && !bHasDummyRedlineProtectionKey ) + { + // we have change tracking protection from Writer or from input ODT file - pFS->singleElementNS(XML_w, XML_documentProtection, - FSNS(XML_w, XML_edit), "trackedChanges", - FSNS(XML_w, XML_enforcement), "1"); + pFS->singleElementNS(XML_w, XML_documentProtection, + FSNS(XML_w, XML_edit), "trackedChanges", + FSNS(XML_w, XML_enforcement), "1"); + } } // finish settings.xml |