Kaydet (Commit) 08985955 authored tarafından Serge Krot's avatar Serge Krot Kaydeden (comit) Thorsten Behrens

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: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst df1adbec
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
#include <string> #include <string>
#include <config_features.h> #include <config_features.h>
#include <unocrsr.hxx>
#include <ndtxt.hxx>
class Test : public SwModelTestBase class Test : public SwModelTestBase
{ {
...@@ -1031,6 +1033,28 @@ DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx") ...@@ -1031,6 +1033,28 @@ DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx")
CPPUNIT_ASSERT(xBookmarksByName->hasByName("permission-for-group:267014232:everyone")); 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") DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt")
{ {
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
......
...@@ -601,6 +601,16 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const ...@@ -601,6 +601,16 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const
{ {
bRet = true; bRet = true;
} }
else
{
const SwSectionNode* pParentSectionNd = pNd->FindSectionNode();
if ( pParentSectionNd != nullptr
&& ( pParentSectionNd->GetSection().IsProtectFlag()
|| ( bFormView && !pParentSectionNd->GetSection().IsEditInReadonlyFlag()) ) )
{
bRet = true;
}
}
} }
if ( !bRet if ( !bRet
...@@ -708,7 +718,7 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const ...@@ -708,7 +718,7 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const
// touches fields, or fully encloses it), then don't disable editing // touches fields, or fully encloses it), then don't disable editing
bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) ); 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 // Form protection case
bRet = ( pA == nullptr ) || ( pB == nullptr ) || bAtStartA || bAtStartB; bRet = ( pA == nullptr ) || ( pB == nullptr ) || bAtStartA || bAtStartB;
......
...@@ -699,7 +699,6 @@ void SectionPropertyMap::ApplyProtectionProperties( uno::Reference< beans::XProp ...@@ -699,7 +699,6 @@ void SectionPropertyMap::ApplyProtectionProperties( uno::Reference< beans::XProp
if ( xSection.is() ) if ( xSection.is() )
xSection->setPropertyValue( getPropertyName(PROP_IS_PROTECTED), uno::makeAny(bIsProtected) ); xSection->setPropertyValue( getPropertyName(PROP_IS_PROTECTED), uno::makeAny(bIsProtected) );
} }
Erase(PROP_IS_PROTECTED);
} }
catch ( uno::Exception& ) catch ( uno::Exception& )
{ {
......
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