diff options
author | codewithvk <vivek.javiya@collabora.com> | 2024-11-01 19:28:51 +0530 |
---|---|---|
committer | vivek javiya <vivek.javiya@collabora.com> | 2024-11-07 08:27:11 +0100 |
commit | d72dcbc4fcb7458955d8071f49d1a877a7d1d1a6 (patch) | |
tree | be0b107ecef981c64751e91850fba720f80de035 /sw | |
parent | 8d5d06da8d01d46ede24bfc8e2789830493a5a7d (diff) |
sw: add .uno:DeleteContentControl command
This command removes formatting for content controls such as rich text, checkbox, dropdown, picture, and date controls. It deletes only the content control formatting, not the actual content of the section.
Here are some todos:
- Add test case for delete
- undo/redo for this uno command
Change-Id: Ib1b3b62ff7d62fd971472eff49a58c5afd786dc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175927
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 5d4ae3db293b0f9c46cbc09d0391806e1ed7b362)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176067
Tested-by: Jenkins
Reviewed-by: vivek javiya <vivek.javiya@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 14 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 21 | ||||
-rw-r--r-- | sw/uiconfig/sglobal/popupmenu/text.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/sweb/popupmenu/text.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swform/popupmenu/text.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swreport/popupmenu/text.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/popupmenu/text.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swxform/popupmenu/text.xml | 1 |
10 files changed, 48 insertions, 0 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 395bf663deec..02d06446328b 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -334,6 +334,7 @@ class SwUINumRuleItem; #define FN_DELETE_BOOKMARKS (FN_INSERT2 + 39) #define FN_DELETE_FIELDS (FN_INSERT2 + 40) #define FN_DELETE_SECTIONS (FN_INSERT2 + 41) +#define FN_DELETE_CONTENT_CONTROL (FN_INSERT2 + 42) /* Delete content control formatting */ // Region: Format #define FN_AUTOFORMAT_APPLY (FN_FORMAT + 1 ) /* apply autoformat options */ diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index d5e25007ef13..b0dd57ed8b3a 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1885,6 +1885,12 @@ interface BaseText DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + FN_DELETE_CONTENT_CONTROL + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] + FN_DELETE_FIELDS [ ExecMethod = Execute ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index ec808db28b46..0bc5e6e58952 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -2651,6 +2651,20 @@ SfxVoidItem DeleteSections FN_DELETE_SECTIONS GroupId = SfxGroupId::Controls; ] +SfxVoidItem DeleteContentControl FN_DELETE_CONTENT_CONTROL + +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + GroupId = SfxGroupId::Controls; +] + SfxVoidItem DeleteFields FN_DELETE_FIELDS (SfxStringItem TypeName FN_PARAM_1, SfxStringItem NamePrefix FN_PARAM_2) [ diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 8942e812fd29..0376bef49da9 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -70,6 +70,8 @@ #include <swdtflvr.hxx> #include <swundo.hxx> #include <reffld.hxx> +#include <textcontentcontrol.hxx> +#include <txatbase.hxx> #include <docsh.hxx> #include <inputwin.hxx> #include <chrdlgmodes.hxx> @@ -81,6 +83,7 @@ #include <strings.hrc> #include <txatbase.hxx> #include <paratr.hxx> +#include <ndtxt.hxx> #include <vcl/svapp.hxx> #include <sfx2/app.hxx> #include <breakit.hxx> @@ -532,6 +535,18 @@ void DeleteSections(SfxRequest& rReq, SwWrtShell& rWrtSh) } } +void DeleteContentControl( SwWrtShell& rWrtSh ) +{ + SwTextContentControl* pTextContentControl = rWrtSh.CursorInsideContentControl(); + if (pTextContentControl) { + const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl(); + const std::shared_ptr<SwContentControl>& pContentControl = rFormatContentControl.GetContentControl(); + pContentControl->SetReadWrite(true); + pTextContentControl->Delete(true); + } +} + + void UpdateBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh) { if (rWrtSh.getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS)) @@ -1341,6 +1356,11 @@ void SwTextShell::Execute(SfxRequest &rReq) DeleteSections(rReq, rWrtSh); break; } + case FN_DELETE_CONTENT_CONTROL: + { + DeleteContentControl( rWrtSh ); + break; + } case FN_SET_REMINDER: { // collect and sort navigator reminder names @@ -3878,6 +3898,7 @@ void SwTextShell::GetState( SfxItemSet &rSet ) rSet.Put(SfxBoolItem(nWhich, bProtected)); } break; + case FN_DELETE_CONTENT_CONTROL: case FN_CONTENT_CONTROL_PROPERTIES: { if (!GetShell().CursorInsideContentControl()) diff --git a/sw/uiconfig/sglobal/popupmenu/text.xml b/sw/uiconfig/sglobal/popupmenu/text.xml index 7170b7db12aa..209510f5fe6c 100644 --- a/sw/uiconfig/sglobal/popupmenu/text.xml +++ b/sw/uiconfig/sglobal/popupmenu/text.xml @@ -24,6 +24,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:FieldDialog"/> <menu:menuitem menu:id=".uno:ContentControlProperties"/> + <menu:menuitem menu:id=".uno:DeleteContentControl"/> <menu:menuitem menu:id=".uno:EditFootnote"/> <menu:menuitem menu:id=".uno:IndexEntryDialog"/> <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/> diff --git a/sw/uiconfig/sweb/popupmenu/text.xml b/sw/uiconfig/sweb/popupmenu/text.xml index 7170b7db12aa..209510f5fe6c 100644 --- a/sw/uiconfig/sweb/popupmenu/text.xml +++ b/sw/uiconfig/sweb/popupmenu/text.xml @@ -24,6 +24,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:FieldDialog"/> <menu:menuitem menu:id=".uno:ContentControlProperties"/> + <menu:menuitem menu:id=".uno:DeleteContentControl"/> <menu:menuitem menu:id=".uno:EditFootnote"/> <menu:menuitem menu:id=".uno:IndexEntryDialog"/> <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/> diff --git a/sw/uiconfig/swform/popupmenu/text.xml b/sw/uiconfig/swform/popupmenu/text.xml index 7170b7db12aa..209510f5fe6c 100644 --- a/sw/uiconfig/swform/popupmenu/text.xml +++ b/sw/uiconfig/swform/popupmenu/text.xml @@ -24,6 +24,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:FieldDialog"/> <menu:menuitem menu:id=".uno:ContentControlProperties"/> + <menu:menuitem menu:id=".uno:DeleteContentControl"/> <menu:menuitem menu:id=".uno:EditFootnote"/> <menu:menuitem menu:id=".uno:IndexEntryDialog"/> <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/> diff --git a/sw/uiconfig/swreport/popupmenu/text.xml b/sw/uiconfig/swreport/popupmenu/text.xml index 4b31d6d34f7d..e99e2653a3a1 100644 --- a/sw/uiconfig/swreport/popupmenu/text.xml +++ b/sw/uiconfig/swreport/popupmenu/text.xml @@ -29,6 +29,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:FieldDialog"/> <menu:menuitem menu:id=".uno:ContentControlProperties"/> + <menu:menuitem menu:id=".uno:DeleteContentControl"/> <menu:menuitem menu:id=".uno:EditFootnote"/> <menu:menuitem menu:id=".uno:IndexEntryDialog"/> <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/> diff --git a/sw/uiconfig/swriter/popupmenu/text.xml b/sw/uiconfig/swriter/popupmenu/text.xml index 4c68f99524f2..e9a559e43db4 100644 --- a/sw/uiconfig/swriter/popupmenu/text.xml +++ b/sw/uiconfig/swriter/popupmenu/text.xml @@ -27,6 +27,7 @@ <menu:menuitem menu:id=".uno:UpdateSelectedField"/> <menu:menuitem menu:id=".uno:FieldDialog"/> <menu:menuitem menu:id=".uno:ContentControlProperties"/> + <menu:menuitem menu:id=".uno:DeleteContentControl"/> <menu:menuitem menu:id=".uno:EditFootnote"/> <menu:menuitem menu:id=".uno:IndexEntryDialog"/> <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/> diff --git a/sw/uiconfig/swxform/popupmenu/text.xml b/sw/uiconfig/swxform/popupmenu/text.xml index 199f69eac465..004b2f3717f2 100644 --- a/sw/uiconfig/swxform/popupmenu/text.xml +++ b/sw/uiconfig/swxform/popupmenu/text.xml @@ -24,6 +24,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:FieldDialog"/> <menu:menuitem menu:id=".uno:ContentControlProperties"/> + <menu:menuitem menu:id=".uno:DeleteContentControl"/> <menu:menuitem menu:id=".uno:EditFootnote"/> <menu:menuitem menu:id=".uno:IndexEntryDialog"/> <menu:menuitem menu:id=".uno:AuthoritiesEntryDialog"/> |