sw/qa/extras/ww8export/data/fdo53985.doc |binary sw/qa/extras/ww8export/ww8export3.cxx | 23 +++++++++++++++++++++++ sw/source/filter/ww8/ww8par.cxx | 8 -------- 3 files changed, 23 insertions(+), 8 deletions(-)
New commits: commit 3e2e49074a59abbc9733e0c6e6914f902dd81664 Author: Justin Luth <[email protected]> AuthorDate: Thu Oct 18 08:47:58 2018 +0300 Commit: Justin Luth <[email protected]> CommitDate: Fri Oct 19 05:44:03 2018 +0200 ww8import: always protect document if set Just because some sections are unprotected doesn't mean that the document should not open in forms mode. MSWord 2016 opens it in "forms view" mode which also doesn't allow editing those unrestricted settings. Only when choosing the "Edit Document" view are the unprotected sections editable - similar to LO turning off the Compatibility: Protect Forms flag. Unfortunately, the "I want to address this" comment was from 2011, so obviously his temporarly solution became more permanent that expected. If this patch now blocks someone from being able to edit a document (because now only the forms components of the document are editable) they can remove the forms protection by going to tools - options - LibreOffice Writer - compatability - and disable Protect Form. patch developed to support tdf#120499 and depends on the patch for tdf#37778. Change-Id: I86e26095ade6b2cf0ab8ea8fc941a92fa672a2f7 Reviewed-on: https://gerrit.libreoffice.org/61901 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> diff --git a/sw/qa/extras/ww8export/data/fdo53985.doc b/sw/qa/extras/ww8export/data/fdo53985.doc new file mode 100644 index 000000000000..0c8f278dcf58 Binary files /dev/null and b/sw/qa/extras/ww8export/data/fdo53985.doc differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 8d0475975eb4..84f9e2f2d6cf 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -9,6 +9,7 @@ #include <swmodeltestbase.hxx> +#include <IDocumentSettingAccess.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/text/XTextFramesSupplier.hpp> @@ -44,6 +45,28 @@ DECLARE_WW8EXPORT_TEST(testTdf37778_readonlySection, "tdf37778_readonlySection.d CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of Sections", sal_Int32(0), xSections->getCount()); } +DECLARE_WW8EXPORT_TEST(testFdo53985, "fdo53985.doc") +{ + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTables->getCount()); // Only 4 tables were imported. + + 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); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xSections->getCount()); // The first paragraph wasn't counted as a section. + + uno::Reference<beans::XPropertySet> xSect(xSections->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section1 is protected", true, getProperty<bool>(xSect, "IsProtected")); + xSect.set(xSections->getByIndex(3), uno::UNO_QUERY); +if ( !mbExported ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section4 is protected", false, getProperty<bool>(xSect, "IsProtected")); +} + DECLARE_WW8EXPORT_TEST(testTdf120225_textControlCrossRef, "tdf120225_textControlCrossRef.doc") { uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 2cd0cd918c59..db8f3cac3c08 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4459,8 +4459,6 @@ SwFormatPageDesc wwSectionManager::SetSwFormatPageDesc(mySegIter const &rIter, void wwSectionManager::InsertSegments() { - const SvtFilterOptions& rOpt = SvtFilterOptions::Get(); - bool bUseEnhFields = rOpt.IsUseEnhancedFields(); mySegIter aEnd = maSegments.end(); mySegIter aStart = maSegments.begin(); for (mySegIter aIter = aStart; aIter != aEnd; ++aIter) @@ -4490,12 +4488,6 @@ void wwSectionManager::InsertSegments() || aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight ) bInsertPageDesc = true; bool bProtected = SectionIsProtected(*aIter); // do we really need this ?? I guess I have a different logic in editshell which disables this... - if (bUseEnhFields && mrReader.m_xWDop->fProtEnabled && aIter->IsNotProtected()) - { - // here we have the special case that the whole document is protected, with the exception of this section. - // I want to address this when I do the section rework, so for the moment we disable the overall protection then... - mrReader.m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_FORM, false ); - } if (bInsertPageDesc) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
