From 19ef5a93dca235a7c7a8761d7daa79418798cdd3 Mon Sep 17 00:00:00 2001 From: Katarina Behrens Date: Fri, 24 Jan 2020 17:05:53 +0100 Subject: Add ProtectBookmarksAndFields per-document option Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87360 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit a5cd4d39f09c3658c2b7cfff4ab6a74449d4f0c0) Change-Id: I8dac403ddea59026b5f52c132c8accc1bd0ada92 --- sw/inc/IDocumentSettingAccess.hxx | 1 + sw/source/core/doc/DocumentSettingManager.cxx | 6 +++++- sw/source/core/inc/DocumentSettingManager.hxx | 1 + sw/source/uibase/uno/SwXDocumentSettings.cxx | 19 ++++++++++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 5b093bc0d08a..4728f2cb09a0 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -106,6 +106,7 @@ enum class DocumentSettingId APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, CONTINUOUS_ENDNOTES, HEADER_SPACING_BELOW_LAST_PARA, + PROTECT_BOOKMARKS_AND_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 726db3242647..bf77758254f5 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -93,7 +93,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mApplyParagraphMarkFormatToNumbering(false), mbLastBrowseMode( false ), mbDisableOffPagePositioning ( false ), - mbHeaderSpacingBelowLastPara(false) + mbHeaderSpacingBelowLastPara(false), + mbProtectBookmarksAndFields( false ) // COMPATIBILITY FLAGS END { @@ -225,6 +226,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const return mbContinuousEndnotes; case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA: return mbHeaderSpacingBelowLastPara; + case DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS: return mbProtectBookmarksAndFields; default: OSL_FAIL("Invalid setting id"); } @@ -469,6 +471,8 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo break; case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA: mbHeaderSpacingBelowLastPara = value; + case DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS: + mbProtectBookmarksAndFields = 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 5a19e930f664..86129ea8e73d 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -164,6 +164,7 @@ class DocumentSettingManager : bool mbEmptyDbFieldHidesPara; bool mbContinuousEndnotes = false; bool mbHeaderSpacingBelowLastPara; + bool mbProtectBookmarksAndFields; public: diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 1c437e021f93..15f0319d5003 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -147,6 +147,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_EMPTY_DB_FIELD_HIDES_PARA, HANDLE_CONTINUOUS_ENDNOTES, HANDLE_HEADER_SPACING_BELOW_LAST_PARA, + HANDLE_PROTECT_BOOKMARKS_AND_FIELDS, }; static MasterPropertySetInfo * lcl_createSettingsInfo() @@ -235,7 +236,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() { OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType::get(), 0 }, { OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType::get(), 0 }, { OUString("HeaderSpacingBelowLastPara"), HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType::get(), 0 }, - + { OUString("ProtectBookmarksAndFields"), HANDLE_PROTECT_BOOKMARKS_AND_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 @@ -956,6 +957,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf } } break; + case HANDLE_PROTECT_BOOKMARKS_AND_FIELDS: + { + bool bTmp; + if (rValue >>= bTmp) + { + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS, + bTmp); + } + } + break; case HANDLE_HEADER_SPACING_BELOW_LAST_PARA: { bool bTmp; @@ -1444,6 +1455,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA); } break; + case HANDLE_PROTECT_BOOKMARKS_AND_FIELDS: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get( + DocumentSettingId::PROTECT_BOOKMARKS_AND_FIELDS); + } + break; default: throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); } -- cgit