From 249b10c22f4a35672a7388d34b2ded1b76054dac Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 31 Jan 2020 17:11:09 +0100 Subject: sw: split into 2 settings ProtectBookmarks and ProtectFields On second thought, let's have 2 settings because there might be some use-case for protecting one but not the other. Change-Id: If8442b64adeeed80b25c8b69f607f2d4993786e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87777 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/inc/IDocumentSettingAccess.hxx | 3 ++- sw/source/core/doc/DocumentSettingManager.cxx | 13 ++++++++---- sw/source/core/inc/DocumentSettingManager.hxx | 3 ++- sw/source/uibase/uno/SwXDocumentSettings.cxx | 30 +++++++++++++++++++++------ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 39ca9a52c87b..b5d46aee3b1f 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -103,7 +103,8 @@ enum class DocumentSettingId EMBED_SYSTEM_FONTS, APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, CONTINUOUS_ENDNOTES, - PROTECT_BOOKMARKS_AND_FIELDS, + PROTECT_BOOKMARKS, + PROTECT_FIELDS, }; /** Provides access to settings of a document diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index 2b1330201e5b..c9270116cb51 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -94,7 +94,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mApplyParagraphMarkFormatToNumbering(false), mbLastBrowseMode( false ), mbDisableOffPagePositioning ( false ), - mbProtectBookmarksAndFields( false ) + mbProtectBookmarks(false), + mbProtectFields(false) // COMPATIBILITY FLAGS END { @@ -219,7 +220,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const case DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING: return mbDisableOffPagePositioning; case DocumentSettingId::EMPTY_DB_FIELD_HIDES_PARA: return mbEmptyDbFieldHidesPara; case DocumentSettingId::CONTINUOUS_ENDNOTES: return mbContinuousEndnotes; - case DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS: return mbProtectBookmarksAndFields; + case DocumentSettingId::PROTECT_BOOKMARKS: return mbProtectBookmarks; + case DocumentSettingId::PROTECT_FIELDS: return mbProtectFields; default: OSL_FAIL("Invalid setting id"); } @@ -455,8 +457,11 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo case DocumentSettingId::CONTINUOUS_ENDNOTES: mbContinuousEndnotes = value; break; - case DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS: - mbProtectBookmarksAndFields = value; + case DocumentSettingId::PROTECT_BOOKMARKS: + mbProtectBookmarks = value; + break; + case DocumentSettingId::PROTECT_FIELDS: + mbProtectFields = value; break; default: OSL_FAIL("Invalid setting id"); diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index 9ed267e70669..2ea1a2583e54 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -162,7 +162,8 @@ class DocumentSettingManager : bool mbDisableOffPagePositioning; // tdf#112443 bool mbEmptyDbFieldHidesPara; bool mbContinuousEndnotes = false; - bool mbProtectBookmarksAndFields; + bool mbProtectBookmarks; + bool mbProtectFields; public: diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 238c7d8dd7c7..7284b0313274 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -140,7 +140,8 @@ enum SwDocumentSettingsPropertyHandles HANDLE_DISABLE_OFF_PAGE_POSITIONING, HANDLE_EMPTY_DB_FIELD_HIDES_PARA, HANDLE_CONTINUOUS_ENDNOTES, - HANDLE_PROTECT_BOOKMARKS_AND_FIELDS, + HANDLE_PROTECT_BOOKMARKS, + HANDLE_PROTECT_FIELDS, }; } @@ -228,7 +229,8 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() { OUString("DisableOffPagePositioning"), HANDLE_DISABLE_OFF_PAGE_POSITIONING, cppu::UnoType::get(), 0}, { OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType::get(), 0 }, { OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType::get(), 0 }, - { OUString("ProtectBookmarksAndFields"), HANDLE_PROTECT_BOOKMARKS_AND_FIELDS, cppu::UnoType::get(), 0 }, + { OUString("ProtectBookmarks"), HANDLE_PROTECT_BOOKMARKS, cppu::UnoType::get(), 0 }, + { OUString("ProtectFields"), HANDLE_PROTECT_FIELDS, cppu::UnoType::get(), 0 }, /* * As OS said, we don't have a view when we need to set this, so I have to * find another solution before adding them to this property set - MTG @@ -937,12 +939,22 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf } } break; - case HANDLE_PROTECT_BOOKMARKS_AND_FIELDS: + case HANDLE_PROTECT_BOOKMARKS: { bool bTmp; if (rValue >>= bTmp) { - mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS, + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_BOOKMARKS, + bTmp); + } + } + break; + case HANDLE_PROTECT_FIELDS: + { + bool bTmp; + if (rValue >>= bTmp) + { + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_FIELDS, bTmp); } } @@ -1409,10 +1421,16 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::CONTINUOUS_ENDNOTES); } break; - case HANDLE_PROTECT_BOOKMARKS_AND_FIELDS: + case HANDLE_PROTECT_BOOKMARKS: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get( + DocumentSettingId::PROTECT_BOOKMARKS); + } + break; + case HANDLE_PROTECT_FIELDS: { rValue <<= mpDoc->getIDocumentSettingAccess().get( - DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS); + DocumentSettingId::PROTECT_FIELDS); } break; default: -- cgit