diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-02-13 09:21:41 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-04-07 16:06:44 +0200 |
commit | 0307f178617c0c80e332860319772545ae24e24e (patch) | |
tree | 77f691bea98a06cb0a7a6536783cd1f18a0e3c36 | |
parent | 9b72b97dda21f3f787dfeb65344342366196e6fd (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>
(cherry picked from commit 087d9191ab642e4b00afb71571d83ffe04589769)
Without the WriterCommands string/UI changes.
Change-Id: I8f8a88bf7624438923b5f611549c703e304763b5
Conflicts:
officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
sw/inc/cmdid.h
sw/sdi/_textsh.sdi
sw/sdi/swriter.sdi
sw/source/uibase/shells/textsh1.cxx
-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 fccfd6c87bb9..769f40aca04f 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -271,6 +271,8 @@ #define FN_INSERT_MULTI_TOX (FN_INSERT2 + 20) /* insert any TOX */ #define FN_INSERT_AUTH_ENTRY_DLG (FN_INSERT2 + 21) /* insert entry for table of authorities*/ +#define FN_PROTECT_FIELDS (FN_INSERT2 + 26) + // Region: Format #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */ #define FN_AUTOFORMAT_AUTO (FN_FORMAT + 2 ) /* apply autoformat during user input */ diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index e9c35b2d24dd..453e48dd1b49 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1676,5 +1676,11 @@ interface BaseText DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; // e.g. disable for read-only documents ] + FN_PROTECT_FIELDS + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] + } //ende interface text diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 19aa9dfeae05..c89731d924f7 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7650,3 +7650,21 @@ SfxBoolItem ShowInlineTooltips FN_SHOW_INLINETOOLTIPS ToolBoxConfig = TRUE, GroupId = SfxGroupId::View; ] + +SfxBoolItem ProtectFields FN_PROTECT_FIELDS + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = TRUE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Controls; +] diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index f19ff11b9af8..1de455d6b0f4 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1391,6 +1391,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; default: OSL_ENSURE(false, "wrong dispatcher"); return; @@ -1930,6 +1940,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(); } |