diff options
-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 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SettingsTable.cxx | 3 |
4 files changed, 32 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 cb4b0ad2e3e7..87795d6ba6c6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -1064,6 +1064,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 d025d6b712ec..7fed578100d1 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1142,12 +1142,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") @@ -1161,10 +1162,10 @@ void DocxExport::WriteSettings() } } - // 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()) { @@ -1174,16 +1175,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 diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 7852547945e7..58399cf0a151 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -357,6 +357,9 @@ void SettingsTable::lcl_attribute(Id nName, Value & val) break; case NS_ooxml::LN_CT_DocProtect_edit: // 92037 m_pImpl->m_DocumentProtection.m_nEdit = nIntValue; + // multiple DocProtect_edits should not exist. If they do, last one wins + m_pImpl->m_bRedlineProtection = false; + m_pImpl->m_bProtectForm = false; switch (nIntValue) { case NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges: |