sw: add UI for adding a textbox for a draw shape
Change-Id: Icc4ff083431635f1769dba5907f26e7dc6b08d02
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index c27ceb9..79f4dc6 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 cc9bc07..3417a74 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 c45619d..d181a0d 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 eb66d88..271ad17 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 4fa9b14..80090e0 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 cf7dba7..76d2538 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -32,6 +32,8 @@
#include <svx/fontworkbar.hxx>
#include <svx/tbxcustomshapes.hxx>
#include <uitool.hxx>
#include <dcontact.hxx>
#include <textboxhelper.hxx>
#include <wview.hxx>
#include <swmodule.hxx>
#include <swwait.hxx>
@@ -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();
}