diff options
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu | 8 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 3 | ||||
-rw-r--r-- | sw/inc/formatcontentcontrol.hxx | 2 | ||||
-rw-r--r-- | sw/inc/strings.hrc | 1 | ||||
-rw-r--r-- | sw/qa/uibase/wrtsh/wrtsh.cxx | 23 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 17 | ||||
-rw-r--r-- | sw/source/core/crsr/dropdowncontentcontrolbutton.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/txtnode/attrcontentcontrol.cxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 13 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh3.cxx | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml | 3 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 2 |
16 files changed, 96 insertions, 5 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index b15b1ebb6a30..0e99196e6893 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -635,6 +635,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:InsertDropdownContentControl" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Insert Drop-Down List 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 6f3673b62811..38a965802806 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -210,10 +210,11 @@ #define FN_INSERT_LINEBREAK (FN_INSERT + 18) /* Newline */ #define FN_INSERT_FIELD_DATA_ONLY (FN_INSERT + 19) /* Field dialog for mail merge*/ -#define FN_INSERT_CONTENT_CONTROL (FN_INSERT + 20) /* Content control */ +#define FN_INSERT_CONTENT_CONTROL (FN_INSERT + 20) /* Rich text content control */ #define FN_INSERT_CHECKBOX_CONTENT_CONTROL (FN_INSERT + 21) /* Checkbox content control */ #define FN_INSERT_OBJECT_DLG (FN_INSERT + 22) /* Object */ #define FN_INSERT_PAGEBREAK (FN_INSERT + 23) /* Page break*/ +#define FN_INSERT_DROPDOWN_CONTENT_CONTROL (FN_INSERT + 24) /* Dropdown content control */ #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) diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index a7bf74681936..d544021cdd8b 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -83,6 +83,8 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const; + OUString ToString() const; + static void ItemsToAny(const std::vector<SwContentControlListItem>& rItems, css::uno::Any& rVal); diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 90a7f5b44d73..1c91a387b94b 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1421,6 +1421,7 @@ #define STR_WRAP_PANEL_CUSTOM_STR NC_("sidebarwrap|customlabel", "Custom") #define STR_CONTENT_CONTROL_PLACEHOLDER NC_("STR_CONTENT_CONTROL_PLACEHOLDER", "Click here to enter text") +#define STR_DROPDOWN_CONTENT_CONTROL_PLACEHOLDER NC_("STR_DROPDOWN_CONTENT_CONTROL_PLACEHOLDER", "Choose an item") #endif diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index 51a1bbb984fa..9e9cee69f9ee 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -216,6 +216,29 @@ CPPUNIT_TEST_FIXTURE(Test, testSelectDropdownContentControl) // i.e. the document text was unchanged instead of display text of the first list item. CPPUNIT_ASSERT_EQUAL(OUString("red"), pTextNode->GetExpandText(pWrtShell->GetLayout())); } + +CPPUNIT_TEST_FIXTURE(Test, testInsertDropdownContentControl) +{ + // Given an empty document: + SwDoc* pDoc = createSwDoc(); + + // When inserting a content control: + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST); + + // Then make sure that the matching text attribute is added to the document model: + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode(); + SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); + auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr); + auto& rFormatContentControl + = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr()); + SwContentControl* pContentControl = rFormatContentControl.GetContentControl(); + // Without the accompanying fix in place, this test would have failed: + // - Expected: 1 + // - Actual : 0 + // i.e. the inserted content control was a default (rich text) one, not a dropdown. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pContentControl->GetListItems().size()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index 8c76493bf36b..f9ec02b66f6d 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -284,6 +284,12 @@ interface BaseText StateMethod = NoState ; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + FN_INSERT_DROPDOWN_CONTENT_CONTROL // status(final|play) + [ + ExecMethod = ExecInsert ; + StateMethod = NoState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] FN_INSERT_COLUMN_BREAK // status(final|play) [ ExecMethod = ExecInsert ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 93d16693c296..aeae14479435 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -3066,6 +3066,23 @@ SfxVoidItem InsertCheckboxContentControl FN_INSERT_CHECKBOX_CONTENT_CONTROL GroupId = SfxGroupId::Insert; ] +SfxVoidItem InsertDropdownContentControl FN_INSERT_DROPDOWN_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 InsertMultiIndex FN_INSERT_MULTI_TOX () [ diff --git a/sw/source/core/crsr/dropdowncontentcontrolbutton.cxx b/sw/source/core/crsr/dropdowncontentcontrolbutton.cxx index b7113994c0c7..a1f73dc1b522 100644 --- a/sw/source/core/crsr/dropdowncontentcontrolbutton.cxx +++ b/sw/source/core/crsr/dropdowncontentcontrolbutton.cxx @@ -24,7 +24,9 @@ void SwDropDownContentControlButton::InitDropdown() std::vector<SwContentControlListItem> aListItems = m_rContentControl.GetListItems(); for (const auto& rListItem : aListItems) - m_xTreeView->append_text(rListItem.m_aDisplayText); + { + m_xTreeView->append_text(rListItem.ToString()); + } if (aListItems.empty()) { diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index 8704221a9a3b..fd98947e3458 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -246,6 +246,16 @@ void SwContentControlListItem::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterEndElement(pWriter); } +OUString SwContentControlListItem::ToString() const +{ + if (!m_aDisplayText.isEmpty()) + { + return m_aDisplayText; + } + + return m_aValue; +} + void SwContentControlListItem::ItemsToAny(const std::vector<SwContentControlListItem>& rItems, uno::Any& rVal) { diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index e8b05efb83b2..b7e25a137cef 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -229,6 +229,11 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) rReq.Done(); break; + case FN_INSERT_DROPDOWN_CONTENT_CONTROL: + rSh.InsertContentControl(SwContentControlType::DROP_DOWN_LIST); + rReq.Done(); + break; + case FN_INSERT_COLUMN_BREAK: rSh.InsertColumnBreak(); rReq.Done(); diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 2fe2ad061456..d26759e3ea4c 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -595,6 +595,7 @@ void SwView::CheckReadonlyState() FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_NNBSP, FN_INSERT_BREAK, FN_INSERT_LINEBREAK, FN_INSERT_COLUMN_BREAK, FN_INSERT_BREAK_DLG, FN_INSERT_CONTENT_CONTROL, FN_INSERT_CHECKBOX_CONTENT_CONTROL, + FN_INSERT_DROPDOWN_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/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 576ffdec5b5d..256115b8ddd4 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1025,7 +1025,6 @@ void SwWrtShell::InsertContentControl(SwContentControlType eType) switch (eType) { case SwContentControlType::RICH_TEXT: - case SwContentControlType::DROP_DOWN_LIST: { pContentControl->SetShowingPlaceHolder(true); if (!HasSelection()) @@ -1044,6 +1043,18 @@ void SwWrtShell::InsertContentControl(SwContentControlType eType) aPlaceholder = u"\u2610"; break; } + case SwContentControlType::DROP_DOWN_LIST: + { + pContentControl->SetShowingPlaceHolder(true); + if (!HasSelection()) + { + aPlaceholder = SwResId(STR_DROPDOWN_CONTENT_CONTROL_PLACEHOLDER); + } + SwContentControlListItem aListItem; + aListItem.m_aValue = aPlaceholder; + pContentControl->SetListItems({ aListItem }); + break; + } } if (aPlaceholder.getLength()) { diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx b/sw/source/uibase/wrtsh/wrtsh3.cxx index 573ea4a9752d..5225c7278357 100644 --- a/sw/source/uibase/wrtsh/wrtsh3.cxx +++ b/sw/source/uibase/wrtsh/wrtsh3.cxx @@ -132,7 +132,7 @@ bool SwWrtShell::GotoContentControl(const SwFormatContentControl& rContentContro size_t nSelectedListItem = *pContentControl->GetSelectedListItem(); LockView(/*bViewLocked=*/true); OUString aOldState = GetCursorDescr(); - OUString aNewState = pContentControl->GetListItems()[nSelectedListItem].m_aDisplayText; + OUString aNewState = pContentControl->GetListItems()[nSelectedListItem].ToString(); SwRewriter aRewriter; aRewriter.AddRule(UndoArg1, aOldState); aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS)); diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index e40052d1384a..c5d48d6375b3 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -714,6 +714,7 @@ <menu:menupopup> <menu:menuitem menu:id=".uno:InsertContentControl"/> <menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/> + <menu:menuitem menu:id=".uno:InsertDropdownContentControl"/> </menu:menupopup> </menu:menu> </menu:menupopup> diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml index 6be7228ded4d..83b8cd35d98a 100644 --- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml +++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml @@ -15,6 +15,9 @@ <menu:menuseparator/> <menu:menu menu:id=".uno:MSCompatContentControls"> <menu:menupopup> + <menu:menuitem menu:id=".uno:InsertContentControl"/> + <menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/> + <menu:menuitem menu:id=".uno:InsertDropdownContentControl"/> <menu:menuitem menu:id=".uno:DatePickerFormField"/> </menu:menupopup> </menu:menu> diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 4ffb14ad528b..4665df3e2f1f 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3920,7 +3920,7 @@ void XMLTextParagraphExport::ExportContentControl( comphelper::SequenceAsHashMap aMap(rListItem); auto it = aMap.find("DisplayText"); OUString aValue; - if (it != aMap.end() && (it->second >>= aValue)) + if (it != aMap.end() && (it->second >>= aValue) && !aValue.isEmpty()) { GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_DISPLAY_TEXT, aValue); } |