diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-07-26 08:21:48 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-07-26 09:50:37 +0200 |
commit | 7748a0c437855133fb0a0ebadb60f5f083112f20 (patch) | |
tree | fe8dcb7298c75e8453497738dec1f35d02419197 | |
parent | bbda36c328ddb16d32bdc1c3443893076f09a307 (diff) |
sw content controls, plain text: add insert UI
- handle the plain text case in SwWrtShell::InsertContentControl()
- expose this as a new .uno:InsertPlainTextContentControl command
- add the new uno command to the default & MS-compatible menus
Change-Id: Ie6eb7271f2c1603fb92036e0067b1e6be70d93ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137447
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu | 8 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/qa/uibase/wrtsh/wrtsh.cxx | 21 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 17 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 4 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml | 1 |
10 files changed, 65 insertions, 1 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 7cbd50530d4c..fa208dcd645d 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -667,6 +667,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:InsertPlainTextContentControl" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Insert Plain Text 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 ec35e740b42f..f456dc2b13ea 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -225,6 +225,7 @@ class SwUINumRuleItem; #define FN_CONTENT_CONTROL_PROPERTIES (FN_INSERT + 25) /* Content control properties */ #define FN_INSERT_PICTURE_CONTENT_CONTROL (FN_INSERT + 26) /* Picture content control */ #define FN_INSERT_DATE_CONTENT_CONTROL (FN_INSERT + 27) /* Date content control */ +#define FN_INSERT_PLAIN_TEXT_CONTENT_CONTROL (FN_INSERT + 28) /* Plain text 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/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index 87537e887242..1caeb749906f 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -367,6 +367,27 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertDateContentControl) // handling for date content control. CPPUNIT_ASSERT(pContentControl->GetDate()); } + +CPPUNIT_TEST_FIXTURE(Test, testInsertPlainTextContentControl) +{ + // Given an empty document: + SwDoc* pDoc = createSwDoc(); + + // When inserting a plain text content control: + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::PLAIN_TEXT); + + // 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()); + std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl(); + // Without the accompanying fix in place, this test would have failed, there was no special + // handling for plain text content controls. + CPPUNIT_ASSERT(pContentControl->GetPlainText()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index fce2a4df9740..a508445f8dca 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -302,6 +302,12 @@ interface BaseText StateMethod = NoState ; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + FN_INSERT_PLAIN_TEXT_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 49fa8f2bb4e6..cd3304860374 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -3117,6 +3117,23 @@ SfxVoidItem InsertDateContentControl FN_INSERT_DATE_CONTENT_CONTROL GroupId = SfxGroupId::Insert; ] +SfxVoidItem InsertPlainTextContentControl FN_INSERT_PLAIN_TEXT_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 cb0ebc60b2ee..2888dcc7912f 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -244,6 +244,11 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) rReq.Done(); break; + case FN_INSERT_PLAIN_TEXT_CONTENT_CONTROL: + rSh.InsertContentControl(SwContentControlType::PLAIN_TEXT); + 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 23b3498d6b7c..0e83cf683692 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -594,7 +594,7 @@ void SwView::CheckReadonlyState() 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_INSERT_PICTURE_CONTENT_CONTROL, - FN_INSERT_DATE_CONTENT_CONTROL, + FN_INSERT_DATE_CONTENT_CONTROL, FN_INSERT_PLAIN_TEXT_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 05c0f86a9da8..7ca55ce26309 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1037,6 +1037,10 @@ void SwWrtShell::InsertContentControl(SwContentControlType eType) case SwContentControlType::PLAIN_TEXT: { pContentControl->SetShowingPlaceHolder(true); + if (eType == SwContentControlType::PLAIN_TEXT) + { + pContentControl->SetPlainText(true); + } if (!HasSelection()) { aPlaceholder = SwResId(STR_CONTENT_CONTROL_PLACEHOLDER); diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 12df19d9c32c..0159070b7699 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -713,6 +713,7 @@ <menu:menu menu:id=".uno:ContentControlsMenu"> <menu:menupopup> <menu:menuitem menu:id=".uno:InsertContentControl"/> + <menu:menuitem menu:id=".uno:InsertPlainTextContentControl"/> <menu:menuitem menu:id=".uno:InsertPictureContentControl"/> <menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/> <menu:menuitem menu:id=".uno:InsertDropdownContentControl"/> diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml index 1e66cd782a8f..307a391ea00a 100644 --- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml +++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml @@ -16,6 +16,7 @@ <menu:menu menu:id=".uno:MSCompatContentControls"> <menu:menupopup> <menu:menuitem menu:id=".uno:InsertContentControl"/> + <menu:menuitem menu:id=".uno:InsertPlainTextContentControl"/> <menu:menuitem menu:id=".uno:InsertPictureContentControl"/> <menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/> <menu:menuitem menu:id=".uno:InsertDropdownContentControl"/> |