summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-02 08:43:19 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-02 12:54:27 +0200
commit02a5bd2e6c4eee50cbd8cb4ed009731c409711a5 (patch)
tree1a9e8ac3ca2ddd2d2bf0b54521bb695139fc137d /sw/source/uibase
parentb294a94861289c322a26edb6b83f0d329575639d (diff)
sw content controls, checkbox: add insert UI
- extend SwWrtShell::InsertContentControl() to be able to create multiple content control types - a new checkbox content control's content is always a non-checked checkbox - expose this as a new .uno:InsertCheckboxContentControl uno command - add this new command to the bottom of the form menu -- now that we have two types of content controls, have that in a sub-menu Change-Id: I058659600b3face69b89262feb0979fff32521c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133685 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/inc/wrtsh.hxx3
-rw-r--r--sw/source/uibase/shells/textsh.cxx8
-rw-r--r--sw/source/uibase/uiview/view.cxx2
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx31
4 files changed, 35 insertions, 9 deletions
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 37d82557ac03..a80f42c8315a 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -55,6 +55,7 @@ class SwFieldMgr;
class SfxRequest;
enum class SwLineBreakClear;
class SwContentControl;
+enum class SwContentControlType;
namespace i18nutil {
struct SearchOptions2;
@@ -316,7 +317,7 @@ typedef bool (SwWrtShell::*FNSimpleMove)();
void InsertPageBreak(const OUString *pPageDesc = nullptr, const ::std::optional<sal_uInt16>& rPgNum = std::nullopt);
void InsertLineBreak(std::optional<SwLineBreakClear> oClear = std::nullopt);
void InsertColumnBreak();
- void InsertContentControl();
+ void InsertContentControl(SwContentControlType eType);
void InsertFootnote(const OUString &, bool bEndNote = false, bool bEdit = true );
void SplitNode( bool bAutoFormat = false );
bool CanInsert();
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index 667f7503bcea..280e667eaf2c 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -91,6 +91,7 @@ using namespace ::com::sun::star;
#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <IDocumentUndoRedo.hxx>
+#include <formatcontentcontrol.hxx>
SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell)
@@ -219,7 +220,12 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
break;
case FN_INSERT_CONTENT_CONTROL:
- rSh.InsertContentControl();
+ rSh.InsertContentControl(SwContentControlType::RICH_TEXT);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_CHECKBOX_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::CHECKBOX);
rReq.Done();
break;
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 8aa7e37b06bb..4efcfc677a7c 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -592,7 +592,7 @@ void SwView::CheckReadonlyState()
SID_CHARMAP, SID_EMOJI_CONTROL, FN_INSERT_SOFT_HYPHEN,
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_BREAK_DLG, FN_INSERT_CONTENT_CONTROL, FN_INSERT_CHECKBOX_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 daabc4002575..a0cd400b5145 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1012,7 +1012,7 @@ void SwWrtShell::InsertColumnBreak()
EndUndo(SwUndoId::UI_INSERT_COLUMN_BREAK);
}
-void SwWrtShell::InsertContentControl()
+void SwWrtShell::InsertContentControl(SwContentControlType eType)
{
if (!lcl_IsAllowed(this))
{
@@ -1026,13 +1026,32 @@ void SwWrtShell::InsertContentControl()
}
auto pContentControl = std::make_shared<SwContentControl>(nullptr);
- pContentControl->SetShowingPlaceHolder(true);
- if (!HasSelection())
+ OUString aPlaceholder;
+ switch (eType)
{
- OUString aPlaceholder = SwResId(STR_CONTENT_CONTROL_PLACEHOLDER);
- Insert(aPlaceholder);
- Left(CRSR_SKIP_CHARS, /*bSelect=*/true, aPlaceholder.getLength(), /*bBasicCall=*/false);
+ case SwContentControlType::RICH_TEXT:
+ {
+ pContentControl->SetShowingPlaceHolder(true);
+ if (!HasSelection())
+ {
+ aPlaceholder = SwResId(STR_CONTENT_CONTROL_PLACEHOLDER);
+ }
+ break;
+ }
+ case SwContentControlType::CHECKBOX:
+ {
+ pContentControl->SetCheckbox(true);
+ // Ballot Box with X
+ pContentControl->SetCheckedState(u"\u2612");
+ // Ballot Box
+ pContentControl->SetUncheckedState(OUString(u"\u2610"));
+ aPlaceholder = u"\u2610";
+ break;
+ }
}
+ Insert(aPlaceholder);
+ Left(CRSR_SKIP_CHARS, /*bSelect=*/true, aPlaceholder.getLength(),
+ /*bBasicCall=*/false);
SwFormatContentControl aContentControl(pContentControl, RES_TXTATR_CONTENTCONTROL);
SetAttrItem(aContentControl);
}