diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-10 12:12:52 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-10 19:05:07 +0100 |
commit | 48f8790d27823c683e2ffa1d4e1d4055dcd7468c (patch) | |
tree | 5cfe54ed9384fb812a95e3d03bca121425c5c1e1 | |
parent | e61367ca3b4a5440b91d2c4d29c773a6d2fe598d (diff) |
sw: stop inheriting SwSectionData::m_bProtectFlag from parent section
This is actually no longer inherited by accident since commit
2e32f4ed5af16a68c97a50806a42ffa2d10f1d7a because it replaced the
SwSectionFormat::Modify()->ModifyBroadcast()->CallSwClientNotify()->CallSwClientNotify()
with a call to GetNotifier()->Broadcast(), and apparently SwSection
is a SwClient of SwSectionFormat but not a SvtListener.
But some consider the new behaviour useful, as previously there was no
way to un-protect a section inside an outer protected section at all,
while in this way every section can have its own independent protection
flag. (The m_bEditInReadonlyFlag is not used for this purpose, as it is
only for the case when the document was loaded ReadOnly.)
So make it more explicit by removing the SwSection inheritance code.
A similar change was made for hidden flag in commit
91b0024965908c692bea40f47c58ea9d1bf8a596
Change-Id: I29d3c84309a84267573950775f2a1c6353623724
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128221
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 840cc7883849a10eea11a02a743848238723a3de)
-rw-r--r-- | sw/inc/section.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/docnode/section.cxx | 23 |
2 files changed, 4 insertions, 21 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 0776afda4cf9..654371ab3587 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -74,7 +74,7 @@ private: /// may have different value than format attribute: /// format attr has value for this section, while flag is /// effectively ORed with parent sections! - bool m_bProtectFlag : 1; + bool m_bProtectFlag : 1; ///< protect flag is no longer inherited // Edit in readonly sections. bool m_bEditInReadonlyFlag : 1; diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index c974d37bb72d..76d54d27ce23 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -204,15 +204,11 @@ SwSection::SwSection( SetHidden(); } - m_Data.SetProtectFlag( pParentSect->IsProtectFlag() ); // edit in readonly sections m_Data.SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() ); } - if (!m_Data.IsProtectFlag()) - { - m_Data.SetProtectFlag( rFormat.GetProtect().IsContentProtected() ); - } + m_Data.SetProtectFlag( rFormat.GetProtect().IsContentProtected() ); if (!m_Data.IsEditInReadonlyFlag()) // edit in readonly sections { @@ -456,21 +452,8 @@ void SwSection::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) { bool bNewFlag = static_cast<const SvxProtectItem*>(pNew)->IsContentProtected(); - if( !bNewFlag ) - { - // Switching off: See if there is protection transferred - // by the Parents - const SwSection* pSect = this; - do { - if( pSect->IsProtect() ) - { - bNewFlag = true; - break; - } - pSect = pSect->GetParent(); - } while (pSect); - } - + // this used to inherit the flag from the parent, but then there is + // no way to turn it off in an inner section m_Data.SetProtectFlag( bNewFlag ); } return; |