tdf#123912 ww8 export: re-protect implicit section
Sections should retain their protected on/off status
regardless of the value of PROTECT_FORM. However, if there
ARE no sections, then the implicit section should use the
document settings. The same is true for the pseudo -1 section
which I believe can only be the last section (the fragment
of the implicit section that follows the last real section).
This is basically a revert of LO 6.2 commit
fa667b6dc410f3af57ef436cc117352c829f95e7, restoring
the previous behaviour in the case of the implicit section.
Change-Id: If0b473445e0add017504a3cb61b63116f92be5ce
Reviewed-on: https://gerrit.libreoffice.org/69957
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123912_protectedForm.odt b/sw/qa/extras/ooxmlexport/data/tdf123912_protectedForm.odt
new file mode 100755
index 0000000..34e8746
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123912_protectedForm.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 01e13fe..6ca09581 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -16,6 +16,7 @@
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <IDocumentSettingAccess.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
@@ -70,6 +71,21 @@
CPPUNIT_ASSERT_EQUAL_MESSAGE("Section Left Margin", sal_Int32(2540), getProperty<sal_Int32>(xSect, "SectionLeftMargin"));
}
DECLARE_OOXMLEXPORT_TEST(tdf123912_protectedForm, "tdf123912_protectedForm.odt")
{
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Compatibility: Protect form", true,
pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ) );
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);
if ( xSect.is() )
CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", true, getProperty<bool>(xSect, "IsProtected"));
}
DECLARE_OOXMLEXPORT_TEST(testDateControl, "empty-date-control.odt")
{
// Check that we did not lost the date control
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index eb0cd1d..f7bc513 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1526,7 +1526,11 @@
AttrOutput().SectFootnoteEndnotePr();
// forms
AttrOutput().SectionFormProtection( rSepInfo.IsProtected() );
bool bFormProtection = rSepInfo.IsProtected();
// use document settings when SepInfo has no protect settings (last section fragment or no sections at all)
if ( !rSepInfo.pSectionFormat || (reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) == rSepInfo.pSectionFormat) )
bFormProtection |= m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM );
AttrOutput().SectionFormProtection( bFormProtection );
// line numbers
const SwLineNumberInfo& rLnNumInfo = m_pDoc->GetLineNumberInfo();