summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-03-30 16:45:03 +0300
committerJustin Luth <justin_luth@sil.org>2019-03-30 19:28:34 +0100
commitd9a6eab15a747cf4c8a3d04f4b21fe1a1c3d0721 (patch)
tree563425bf609b99e6d85fb13b4be2a5d3d8b5a78d /sw
parenta16e16a3669dbe992c3073ae0ff4545830618c76 (diff)
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>
Diffstat (limited to 'sw')
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf123912_protectedForm.odtbin0 -> 9604 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx16
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx6
3 files changed, 21 insertions, 1 deletions
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 000000000000..34e87467ee3e
--- /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 01e13fee05c7..6ca09581d1b5 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 @@ DECLARE_OOXMLEXPORT_TEST(testendingSectionProps, "endingSectionProps.docx")
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 eb0cd1dc664d..f7bc5136e922 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1526,7 +1526,11 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
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();