diff options
author | Serge Krot <Serge.Krot@cib.de> | 2018-12-17 17:07:23 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-12-20 19:24:56 +0100 |
commit | 63ec2e8d07dff652a68c9dc96859c4c61f26b9df (patch) | |
tree | 3f2c4d7078c7a18ef922b45f023a566c97a1748e | |
parent | 99273001ca7b4dfa98d881ef6ed46cbcad1af8c9 (diff) |
tdf#122201 sw: DOCX: allow editing of unprotected areas in protected doc
Change-Id: I5fb590745b733e2bfb934d946276857b65caf680
Reviewed-on: https://gerrit.libreoffice.org/65278
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/65501
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt | bin | 0 -> 7104 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/crsr/pam.cxx | 12 |
3 files changed, 35 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt b/sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt Binary files differnew file mode 100644 index 000000000000..217c8c38a409 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 9840bbc9fde7..268805695c08 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -51,6 +51,8 @@ #include <string> #include <config_features.h> +#include <unocrsr.hxx> +#include <ndtxt.hxx> class Test : public SwModelTestBase { @@ -1031,6 +1033,28 @@ DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx") CPPUNIT_ASSERT(xBookmarksByName->hasByName("permission-for-group:267014232:everyone")); } +DECLARE_OOXMLEXPORT_TEST(tdf122201_editUnprotectedText, "tdf122201_editUnprotectedText.odt") +{ + // get the document + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDoc); + + // get two different nodes + SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent()); + SwNodeIndex aDocStart(*aDocEnd.GetNode().StartOfSectionNode(), 3); + + // check protected area + SwPaM aPaMPortected(aDocStart); + CPPUNIT_ASSERT(aPaMPortected.HasReadonlySel(false)); + + // check unprotected area + SwPaM aPaMUnprotected(aDocEnd); + CPPUNIT_ASSERT(!aPaMUnprotected.HasReadonlySel(false)); +} + DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt") { if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 3583e0d2794c..0d888149e6d0 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -601,6 +601,16 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const { bRet = true; } + else + { + const SwSectionNode* pParentSectionNd = pNd->FindSectionNode(); + if ( pParentSectionNd != nullptr + && ( pParentSectionNd->GetSection().IsProtectFlag() + || ( bFormView && !pParentSectionNd->GetSection().IsEditInReadonlyFlag()) ) ) + { + bRet = true; + } + } } if ( !bRet @@ -708,7 +718,7 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const // touches fields, or fully encloses it), then don't disable editing bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) ); } - if( !bRet && pDoc->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM ) ) + if( !bRet && pDoc->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM ) && (pA || pB) ) { // Form protection case bRet = ( pA == nullptr ) || ( pB == nullptr ) || bAtStartA || bAtStartB; |