desktop/source/lib/init.cxx                                         |    1 
 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |   14 
++++++
 sfx2/source/control/unoctitm.cxx                                    |    1 
 sw/inc/cmdid.h                                                      |    1 
 sw/sdi/_textsh.sdi                                                  |    6 ++
 sw/sdi/swriter.sdi                                                  |   14 
++++++
 sw/source/uibase/shells/textsh1.cxx                                 |   21 
++++++++++
 sw/uiconfig/sglobal/popupmenu/text.xml                              |    1 
 sw/uiconfig/sweb/popupmenu/text.xml                                 |    1 
 sw/uiconfig/swform/popupmenu/text.xml                               |    1 
 sw/uiconfig/swreport/popupmenu/text.xml                             |    1 
 sw/uiconfig/swriter/popupmenu/text.xml                              |    1 
 sw/uiconfig/swxform/popupmenu/text.xml                              |    1 
 13 files changed, 64 insertions(+)

New commits:
commit d72dcbc4fcb7458955d8071f49d1a877a7d1d1a6
Author:     codewithvk <vivek.jav...@collabora.com>
AuthorDate: Fri Nov 1 19:28:51 2024 +0530
Commit:     vivek javiya <vivek.jav...@collabora.com>
CommitDate: Thu Nov 7 08:27:11 2024 +0100

    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 <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit 5d4ae3db293b0f9c46cbc09d0391806e1ed7b362)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176067
    Tested-by: Jenkins
    Reviewed-by: vivek javiya <vivek.jav...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7f804585813e..9400a9bc6ce9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4020,6 +4020,7 @@ static void doc_iniUnoCommands ()
         u".uno:Protect"_ustr,
         u".uno:UnsetCellsReadOnly"_ustr,
         u".uno:ContentControlProperties"_ustr,
+        u".uno:DeleteContentControl"_ustr,
         u".uno:InsertCheckboxContentControl"_ustr,
         u".uno:InsertContentControl"_ustr,
         u".uno:InsertDateContentControl"_ustr,
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index 3e378f8a8f3b..d75dd6c83946 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -567,6 +567,20 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:DeleteContentControl" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Delete Content Control</value>
+        </prop>
+        <prop oor:name="ContextLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Delete Content Control</value>
+        </prop>
+        <prop oor:name="PopupLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Delete Content Control</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:SetReminder" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Set Reminder</value>
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 30cf78a710f5..6fd2196f583a 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1333,6 +1333,7 @@ constexpr auto handlers = 
frozen::make_unordered_map<std::u16string_view, Payloa
     { u"Protect", EnabledPayload },
     { u"UnsetCellsReadOnly", EnabledPayload },
     { u"ContentControlProperties", EnabledPayload },
+    { u"DeleteContentControl", EnabledPayload },
     { u"InsertCheckboxContentControl", EnabledPayload },
     { u"InsertContentControl", EnabledPayload },
     { u"InsertDateContentControl", EnabledPayload },
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"/>

Reply via email to