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 <michael.stahl@cib.de>
This commit is contained in:
Michael Stahl 2020-01-31 17:11:09 +01:00 committed by Michael Stahl
parent a5cd4d39f0
commit 249b10c22f
4 changed files with 37 additions and 12 deletions

View file

@ -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

View file

@ -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");

View file

@ -162,7 +162,8 @@ class DocumentSettingManager :
bool mbDisableOffPagePositioning; // tdf#112443
bool mbEmptyDbFieldHidesPara;
bool mbContinuousEndnotes = false;
bool mbProtectBookmarksAndFields;
bool mbProtectBookmarks;
bool mbProtectFields;
public:

View file

@ -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<bool>::get(), 0},
{ OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType<bool>::get(), 0 },
{ OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType<bool>::get(), 0 },
{ OUString("ProtectBookmarksAndFields"), HANDLE_PROTECT_BOOKMARKS_AND_FIELDS, cppu::UnoType<bool>::get(), 0 },
{ OUString("ProtectBookmarks"), HANDLE_PROTECT_BOOKMARKS, cppu::UnoType<bool>::get(), 0 },
{ OUString("ProtectFields"), HANDLE_PROTECT_FIELDS, cppu::UnoType<bool>::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_AND_FIELDS);
DocumentSettingId::PROTECT_BOOKMARKS);
}
break;
case HANDLE_PROTECT_FIELDS:
{
rValue <<= mpDoc->getIDocumentSettingAccess().get(
DocumentSettingId::PROTECT_FIELDS);
}
break;
default: