tdf#106843 docxexport: don't write double docProtect
regression from LO 6.4
commit 2756ed9317
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>
This commit is contained in:
parent
d3e1ada454
commit
b2471b8ab6
4 changed files with 32 additions and 15 deletions
BIN
sw/qa/extras/ooxmlexport/data/sectionprot2.odt
Normal file
BIN
sw/qa/extras/ooxmlexport/data/sectionprot2.odt
Normal file
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
hasProtectionProperties = !bIsProtectionTrackChanges || bHasDummyRedlineProtectionKey;
|
||||
if ( hasProtectionProperties )
|
||||
{
|
||||
sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
|
||||
if (!bIsProtectionTrackChanges || bHasDummyRedlineProtectionKey)
|
||||
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,10 +1273,8 @@ void DocxExport::WriteSettings()
|
|||
FSNS(XML_w, XML_edit), "forms",
|
||||
FSNS(XML_w, XML_enforcement), "true");
|
||||
}
|
||||
}
|
||||
|
||||
// Protect Change Tracking
|
||||
if ( bHasRedlineProtectionKey && !bHasDummyRedlineProtectionKey )
|
||||
// Protect Change Tracking - next priority
|
||||
else if ( bHasRedlineProtectionKey && !bHasDummyRedlineProtectionKey )
|
||||
{
|
||||
// we have change tracking protection from Writer or from input ODT file
|
||||
|
||||
|
@ -1283,6 +1282,7 @@ void DocxExport::WriteSettings()
|
|||
FSNS(XML_w, XML_edit), "trackedChanges",
|
||||
FSNS(XML_w, XML_enforcement), "1");
|
||||
}
|
||||
}
|
||||
|
||||
// finish settings.xml
|
||||
pFS->endElementNS( XML_w, XML_settings );
|
||||
|
|
|
@ -365,6 +365,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:
|
||||
|
|
Loading…
Reference in a new issue