officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |    8 +++
 sw/inc/cmdid.h                                                      |    1 
 sw/qa/uibase/wrtsh/wrtsh.cxx                                        |   22 
++++++++++
 sw/sdi/_textsh.sdi                                                  |    6 ++
 sw/sdi/swriter.sdi                                                  |   17 
+++++++
 sw/source/uibase/shells/textsh.cxx                                  |    5 ++
 sw/source/uibase/uiview/view.cxx                                    |    1 
 sw/uiconfig/swriter/menubar/menubar.xml                             |    1 
 sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml               |    1 
 9 files changed, 62 insertions(+)

New commits:
commit f9751ba946c177f596ca86993535fdb3ceaac68c
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Sep 23 08:55:08 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Sep 26 08:19:21 2022 +0200

    sw content controls, combo box: add insert UI
    
    - expose the combo box case in SwWrtShell::InsertContentControl() as a
      new .uno:InsertComboBoxContentControl command
    
    - - add the new uno command to the default & MS-compatible menus
    
    (cherry picked from commit 49f1bf56ebfa3c96aa90835c1121eb827d713b9d)
    
    Change-Id: Ifb1a9cede8c219d956ce438119ee789a69507679
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140518
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index 330fd3c0bb9a..9247374da3f6 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -675,6 +675,14 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:InsertComboBoxContentControl" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Insert Combo Box Content Control</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:InsertObjectDialog" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Insert Other Objects</value>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 690a1b2a6688..56b05c4aacd1 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -222,6 +222,7 @@
 #define FN_POSTIT               (FN_INSERT + 29)    /* Insert/edit PostIt */
 #define FN_INSERT_TABLE         (FN_INSERT + 30)    /* Insert Table */
 #define FN_INSERT_STRING        (FN_INSERT+31)
+#define FN_INSERT_COMBO_BOX_CONTENT_CONTROL (FN_INSERT + 32) /* Combo box 
content control */
 #define FN_INSERT_FRAME_INTERACT (FN_INSERT + 33)   /* Insert interactive 
frame */
 #define FN_INSERT_FRAME         (FN_INSERT + 34)    /* Insert Frame */
 
diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx
index 510b96083ddb..cbc31237d893 100644
--- a/sw/qa/uibase/wrtsh/wrtsh.cxx
+++ b/sw/qa/uibase/wrtsh/wrtsh.cxx
@@ -388,6 +388,28 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertPlainTextContentControl)
     // handling for plain text content controls.
     CPPUNIT_ASSERT(pContentControl->GetPlainText());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertComboBoxContentControl)
+{
+    // Given an empty document:
+    SwDoc* pDoc = createSwDoc();
+
+    // When inserting a combo box content control:
+    dispatchCommand(mxComponent, ".uno:InsertComboBoxContentControl", {});
+
+    // Then make sure that the matching text attribute is added to the 
document model:
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode();
+    // Without the accompanying fix in place, this test would have failed, no 
content control was
+    // inserted.
+    SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, 
RES_TXTATR_CONTENTCONTROL);
+    CPPUNIT_ASSERT(pAttr);
+    auto pTextContentControl = 
static_txtattr_cast<SwTextContentControl*>(pAttr);
+    auto& rFormatContentControl
+        = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
+    std::shared_ptr<SwContentControl> pContentControl = 
rFormatContentControl.GetContentControl();
+    CPPUNIT_ASSERT(pContentControl->GetComboBox());
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 27e17a231332..e82a2fff3d88 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -308,6 +308,12 @@ interface BaseText
         StateMethod = NoState ;
         DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
     ]
+    FN_INSERT_COMBO_BOX_CONTENT_CONTROL  // status(final|play)
+    [
+        ExecMethod = ExecInsert ;
+        StateMethod = NoState ;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
     FN_CONTENT_CONTROL_PROPERTIES  // status(final|play)
     [
         ExecMethod = ExecInsert ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 4864da660acc..e34d663bf29b 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -3134,6 +3134,23 @@ SfxVoidItem InsertPlainTextContentControl 
FN_INSERT_PLAIN_TEXT_CONTENT_CONTROL
     GroupId = SfxGroupId::Insert;
 ]
 
+SfxVoidItem InsertComboBoxContentControl FN_INSERT_COMBO_BOX_CONTENT_CONTROL
+()
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Insert;
+]
+
 SfxVoidItem ContentControlProperties FN_CONTENT_CONTROL_PROPERTIES
 ()
 [
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index 5f34339c408e..d81c32245445 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -249,6 +249,11 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
         rReq.Done();
         break;
 
+    case FN_INSERT_COMBO_BOX_CONTENT_CONTROL:
+        rSh.InsertContentControl(SwContentControlType::COMBO_BOX);
+        rReq.Done();
+        break;
+
     case FN_CONTENT_CONTROL_PROPERTIES:
     {
         SwWrtShell& rWrtSh = GetShell();
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index f58abbab53d4..675becb47e61 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -597,6 +597,7 @@ void SwView::CheckReadonlyState()
             FN_INSERT_BREAK_DLG,        FN_INSERT_CONTENT_CONTROL,  
FN_INSERT_CHECKBOX_CONTENT_CONTROL,
             FN_INSERT_DROPDOWN_CONTENT_CONTROL, 
FN_INSERT_PICTURE_CONTENT_CONTROL,
             FN_INSERT_DATE_CONTENT_CONTROL, 
FN_INSERT_PLAIN_TEXT_CONTENT_CONTROL,
+            FN_INSERT_COMBO_BOX_CONTENT_CONTROL,
             FN_DELETE_SENT,             FN_DELETE_BACK_SENT,        
FN_DELETE_WORD,
             FN_DELETE_BACK_WORD,        FN_DELETE_LINE,             
FN_DELETE_BACK_LINE,
             FN_DELETE_PARA,             FN_DELETE_BACK_PARA,        
FN_DELETE_WHOLE_LINE,
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml 
b/sw/uiconfig/swriter/menubar/menubar.xml
index 9ce4053dc3c5..802afa9af2de 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -716,6 +716,7 @@
           <menu:menuitem menu:id=".uno:InsertPlainTextContentControl"/>
           <menu:menuitem menu:id=".uno:InsertPictureContentControl"/>
           <menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/>
+          <menu:menuitem menu:id=".uno:InsertComboBoxContentControl"/>
           <menu:menuitem menu:id=".uno:InsertDropdownContentControl"/>
           <menu:menuitem menu:id=".uno:InsertDateContentControl"/>
           <menu:menuitem menu:id=".uno:ContentControlProperties"/>
diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml 
b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
index 307a391ea00a..00a4b58ff94d 100644
--- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
+++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
@@ -19,6 +19,7 @@
           <menu:menuitem menu:id=".uno:InsertPlainTextContentControl"/>
           <menu:menuitem menu:id=".uno:InsertPictureContentControl"/>
           <menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/>
+          <menu:menuitem menu:id=".uno:InsertComboBoxContentControl"/>
           <menu:menuitem menu:id=".uno:InsertDropdownContentControl"/>
           <menu:menuitem menu:id=".uno:InsertDateContentControl"/>
           <menu:menuitem menu:id=".uno:ContentControlProperties"/>

Reply via email to