diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-02-13 09:21:41 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-02-13 14:49:15 +0100 |
commit | 087d9191ab642e4b00afb71571d83ffe04589769 (patch) | |
tree | 3fa92baee41752dc1805e61331c515a10d3d84f6 /sw | |
parent | ae7c689a803aa5e8f4b9ef4881fdd60b23e4b463 (diff) |
Add uno cmd to protect fields in a document
Change-Id: Ifb9f757111a6fcbb283d2350ed2ccd42de19d5df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88585
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/cmdid.h | 2 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 18 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 17 |
4 files changed, 43 insertions, 0 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 68f640199c0f..2dfb720bb854 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -284,6 +284,8 @@ // MSO content controls #define FN_INSERT_DATE_FORMFIELD (FN_INSERT2 + 25) +#define FN_PROTECT_FIELDS (FN_INSERT2 + 26) + // clipboard table content #define FN_PASTE_NESTED_TABLE (FN_INSERT2 + 30) /* instead of the cell-by-cell copy between source and target tables */ #define FN_TABLE_PASTE_ROW_BEFORE (FN_INSERT2 + 31) /* paste table as new table rows */ diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index b91292dea316..9bc92512435b 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1740,6 +1740,12 @@ interface BaseText StateMethod = StateField ; ] + FN_PROTECT_FIELDS + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] + SID_FM_CTL_PROPERTIES [ ExecMethod = Execute ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 524018f1b90c..dbc6196feeb1 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7917,6 +7917,24 @@ SfxVoidItem DatePickerFormField FN_INSERT_DATE_FORMFIELD GroupId = SfxGroupId::Controls; ] +SfxBoolItem ProtectFields FN_PROTECT_FIELDS + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = TRUE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Controls; +] + SfxUInt32Item TableRowHeight SID_ATTR_TABLE_ROW_HEIGHT [ diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index f8bd62cab79c..a6893e5f39e1 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1384,6 +1384,16 @@ void SwTextShell::Execute(SfxRequest &rReq) GetView().UpdateWordCount(this, nSlot); } break; + case FN_PROTECT_FIELDS: + { + IDocumentSettingAccess& rIDSA = rWrtSh.getIDocumentSettingAccess(); + rIDSA.set(DocumentSettingId::PROTECT_FIELDS, !rIDSA.get(DocumentSettingId::PROTECT_FIELDS)); + // Invalidate so that toggle state gets updated + SfxViewFrame* pViewFrame = GetView().GetViewFrame(); + pViewFrame->GetBindings().Invalidate(nSlot); + pViewFrame->GetBindings().Update(nSlot); + } + break; case SID_FM_CTL_PROPERTIES: { SwPosition aPos(*GetShell().GetCursor()->GetPoint()); @@ -2160,6 +2170,13 @@ void SwTextShell::GetState( SfxItemSet &rSet ) rSet.DisableItem(nWhich); break; } + case FN_PROTECT_FIELDS: + { + bool bProtected + = rSh.getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FIELDS); + rSet.Put(SfxBoolItem(nWhich, bProtected)); + } + break; } nWhich = aIter.NextWhich(); } |