sw/qa/extras/ooxmlexport/data/tdf123912_protectedForm.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 16 ++++++++++++++ sw/source/filter/ww8/wrtw8sty.cxx | 6 ++++- 3 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit d9a6eab15a747cf4c8a3d04f4b21fe1a1c3d0721 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Mar 30 16:45:03 2019 +0300 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Sat Mar 30 19:28:34 2019 +0100 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_l...@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 000000000000..34e87467ee3e Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf123912_protectedForm.odt 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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits