summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-10-18 08:47:58 +0300
committerAndras Timar <andras.timar@collabora.com>2018-10-20 22:58:26 +0200
commit7139f926dd933e9d6cda196fcfe7463c2dd11772 (patch)
treed4a8fc15132a641da56b11c83d8f19c1c5e10308 /sw
parent7583ad5383be14f7c589538da1b42dc1ad7e5954 (diff)
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 <justin_luth@sil.org> (cherry picked from commit 3e2e49074a59abbc9733e0c6e6914f902dd81664)
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ww8export/data/fdo53985.docbin0 -> 39936 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx23
-rw-r--r--sw/source/filter/ww8/ww8par.cxx8
3 files changed, 23 insertions, 8 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/fdo53985.doc
Binary files 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 b308c55f974b..a1dd150e18d3 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4442,8 +4442,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)
@@ -4473,12 +4471,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)
{