[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Dec 20 14:17:00 UTC 2018
sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 24 ++++++++++
sw/source/core/crsr/pam.cxx | 12 ++++-
writerfilter/source/dmapper/PropertyMap.cxx | 1
4 files changed, 35 insertions(+), 2 deletions(-)
New commits:
commit 0898595532d1e3f498c259b6dfee462249b00667
Author: Serge Krot <Serge.Krot at cib.de>
AuthorDate: Mon Dec 17 17:07:23 2018 +0100
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu Dec 20 15:16:34 2018 +0100
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 at CIB.de>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt b/sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt
new file mode 100644
index 000000000000..217c8c38a409
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf122201_editUnprotectedText.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 4a7118cf56cd..8a98934dd484 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;
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index d0b4bc8c0d6e..7c1c29b1ebd2 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -699,7 +699,6 @@ void SectionPropertyMap::ApplyProtectionProperties( uno::Reference< beans::XProp
if ( xSection.is() )
xSection->setPropertyValue( getPropertyName(PROP_IS_PROTECTED), uno::makeAny(bIsProtected) );
}
- Erase(PROP_IS_PROTECTED);
}
catch ( uno::Exception& )
{
More information about the Libreoffice-commits
mailing list