summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-09-23 08:55:08 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-09-23 10:35:22 +0200
commit49f1bf56ebfa3c96aa90835c1121eb827d713b9d (patch)
treebf489697f6ad0621cbf906c7bcc95d6fa102d2c9
parentc3d488c201231a98ef13560dc8d070267d8d5e86 (diff)
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 Change-Id: Ifb1a9cede8c219d956ce438119ee789a69507679 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140468 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu8
-rw-r--r--sw/inc/cmdid.h1
-rw-r--r--sw/qa/uibase/wrtsh/wrtsh.cxx22
-rw-r--r--sw/sdi/_textsh.sdi6
-rw-r--r--sw/sdi/swriter.sdi17
-rw-r--r--sw/source/uibase/shells/textsh.cxx5
-rw-r--r--sw/source/uibase/uiview/view.cxx1
-rw-r--r--sw/uiconfig/swriter/menubar/menubar.xml1
-rw-r--r--sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml1
9 files changed, 62 insertions, 0 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index fa208dcd645d..bd7dff5b6cf6 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 f183108c071e..d98d72ce56b5 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -229,6 +229,7 @@ class SwUINumRuleItem;
#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 fb0d9d80d64a..e40f641e706a 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()->GetPointNode().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 f9788707eb84..3ef8211e33c7 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -314,6 +314,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 78f1d7cd74b0..044feca164f3 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -3152,6 +3152,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 2888dcc7912f..af047adc2d19 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 3635fed59652..b4159a79d1d1 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -622,6 +622,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 0159070b7699..c939aba5e989 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"/>