From 7f77b8a689f84a03495ac5911236b68f01ee7b24 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 19 Jun 2014 10:11:10 +0200 Subject: sw: add UI for adding a textbox for a draw shape Change-Id: Icc4ff083431635f1769dba5907f26e7dc6b08d02 --- sw/inc/cmdid.h | 1 + sw/inc/swcommands.h | 1 + sw/sdi/drawsh.sdi | 7 +++++++ sw/sdi/swriter.sdi | 24 ++++++++++++++++++++++++ sw/source/ui/app/mn.src | 6 ++++++ sw/source/uibase/shells/drawsh.cxx | 27 +++++++++++++++++++++++++++ 6 files changed, 66 insertions(+) diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index c27ceb9cd48c..79f4dc66c3ed 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -478,6 +478,7 @@ #define FN_EXPAND_GLOSSARY (FN_EXTRA + 28) /* expand text building blocks */ #define FN_CHANGE_PAGENUM (FN_EXTRA + 34) /* change page numbers*/ +#define FN_ADD_TEXT_BOX (FN_EXTRA + 35) /* add text box to draw shape */ // Region: Glossary diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h index cc9bc07d0f42..3417a74dc088 100644 --- a/sw/inc/swcommands.h +++ b/sw/inc/swcommands.h @@ -20,6 +20,7 @@ #define INCLUDED_SW_INC_SWCOMMANDS_H #define CMD_SID_CREATE_SW_DRAWVIEW ".uno:CreateSWDrawView" +#define CMD_FN_ADD_TEXT_BOX ".uno:AddTextBox" #define CMD_FN_FRAME_ALIGN_VERT_BOTTOM ".uno:AlignBottom" #define CMD_FN_FRAME_ALIGN_HORZ_CENTER ".uno:AlignHorizontalCenter" #define CMD_FN_FRAME_ALIGN_HORZ_LEFT ".uno:AlignLeft" diff --git a/sw/sdi/drawsh.sdi b/sw/sdi/drawsh.sdi index c45619d1c3e5..d181a0defc5a 100644 --- a/sw/sdi/drawsh.sdi +++ b/sw/sdi/drawsh.sdi @@ -508,5 +508,12 @@ shell SwDrawShell : SwDrawBaseShell [ ExecMethod = Execute ; ] + + FN_ADD_TEXT_BOX + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] } diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index eb66d884ce34..271ad17b3892 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -10079,3 +10079,27 @@ SvxLongLRSpaceItem SwPageLRMargin SID_ATTR_PAGE_LRSPACE ToolBoxConfig = FALSE, GroupId = GID_FORMAT; ] + +SfxVoidItem AddTextBox FN_ADD_TEXT_BOX +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_DRAWING; +] diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index 4fa9b14c52a9..80090e0e8229 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -1044,6 +1044,12 @@ Menu MN_DRAW_POPUPMENU MN_FRM_CAPTION_ITEM SEPARATOR ; MN_DRAW3 + MenuItem + { + Identifier = FN_ADD_TEXT_BOX; + HelpId = CMD_FN_ADD_TEXT_BOX; + Text [ en-US ] = "Add Text Box"; + }; }; }; diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index cf7dba779fc1..76d2538f7fd1 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -397,6 +399,16 @@ void SwDrawShell::Execute(SfxRequest &rReq) break; } + case FN_ADD_TEXT_BOX: + { + if (SdrObject* pObj = IsSingleFillableNonOLESelected()) + { + SwFrmFmt* pFrmFmt = ::FindFrmFmt(pObj); + if (pFrmFmt) + SwTextBoxHelper::create(pFrmFmt); + } + break; + } default: OSL_ENSURE(!this, "wrong dispatcher"); return; @@ -502,6 +514,21 @@ void SwDrawShell::GetState(SfxItemSet& rSet) break; } + case FN_ADD_TEXT_BOX: + { + bool bDisable = true; + if (SdrObject* pObj = IsSingleFillableNonOLESelected()) + { + SwFrmFmt* pFrmFmt = ::FindFrmFmt(pObj); + // Allow creating a TextBox only in case this is a draw format without a TextBox so far. + if (pFrmFmt && pFrmFmt->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::findTextBox(pFrmFmt)) + bDisable = false; + } + + if (bDisable) + rSet.DisableItem(nWhich); + break; + } } nWhich = aIter.NextWhich(); } -- cgit v1.2.3