Kaydet (Commit) 3e2e4907 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Justin Luth

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: 's avatarJustin Luth <justin_luth@sil.org>
üst 6df13f86
This diff was suppressed by a .gitattributes entry.
......@@ -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);
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment