summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2018-09-17 21:06:05 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2018-09-19 20:24:46 +0200
commit1a72dbb390e9cf6e61b6503f3c575ba531d547d8 (patch)
treeb393e210ab5e91014e6e80a20e127f71801f8afb /sw/source/uibase/shells
parent1c2e55dc616d1f3c25b1b2c41402e28419f4b554 (diff)
tdf#90850 Enable align commands for a single shape in Writer
Similar to images and frames. Just exposes the existing position settings from the "Position and Size" dialog. Change-Id: Ifa7e91f695af74d5297412e5ffeb12286ec63767 Reviewed-on: https://gerrit.libreoffice.org/60649 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sw/source/uibase/shells')
-rw-r--r--sw/source/uibase/shells/drwbassh.cxx82
1 files changed, 49 insertions, 33 deletions
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index 10a2320a6f68..0ab94affdb5a 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -419,41 +419,57 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
if ( bAlignPossible )
{
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
- if( rMarkList.GetMarkCount() == 1 && bAlignPossible )
- { // Do not align objects to each other
- RndStdIds nAnchor = pSh->GetAnchorId();
- if (nAnchor == RndStdIds::FLY_AS_CHAR)
+ if ( rMarkList.GetMarkCount() == 1 )
+ {
+ sal_Int16 nHorizOrient = -1, nVertOrient = -1;
+
+ switch (nSlotId)
{
- sal_Int16 nVertOrient = -1;
+ case SID_OBJECT_ALIGN_LEFT:
+ nHorizOrient = text::HoriOrientation::LEFT;
+ break;
+ case SID_OBJECT_ALIGN_CENTER:
+ nHorizOrient = text::HoriOrientation::CENTER;
+ break;
+ case SID_OBJECT_ALIGN_RIGHT:
+ nHorizOrient = text::HoriOrientation::RIGHT;
+ break;
+ case SID_OBJECT_ALIGN_UP:
+ nVertOrient = text::VertOrientation::TOP;
+ break;
+ case SID_OBJECT_ALIGN_MIDDLE:
+ nVertOrient = text::VertOrientation::CENTER;
+ break;
+ case SID_OBJECT_ALIGN_DOWN:
+ nVertOrient = text::VertOrientation::BOTTOM;
+ break;
+ default:
+ break;
+ }
- switch (nSlotId)
- {
- case SID_OBJECT_ALIGN_UP:
- nVertOrient = text::VertOrientation::TOP;
- break;
- case SID_OBJECT_ALIGN_MIDDLE:
- nVertOrient = text::VertOrientation::CENTER;
- break;
- case SID_OBJECT_ALIGN_DOWN:
- nVertOrient = text::VertOrientation::BOTTOM;
- break;
- default:
- break;
- }
- if (nVertOrient != -1)
- {
- pSh->StartAction();
- SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
- SwFormatVertOrient aVOrient(pFrameFormat->GetFormatAttr(RES_VERT_ORIENT));
- aVOrient.SetVertOrient( nVertOrient );
- pFrameFormat->SetFormatAttr(aVOrient);
- pSh->EndAction();
- }
- break;
+ if (nHorizOrient != -1)
+ {
+ pSh->StartAction();
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
+ SwFormatHoriOrient aHOrient(pFrameFormat->GetFormatAttr(RES_HORI_ORIENT));
+ aHOrient.SetHoriOrient( nHorizOrient );
+ pFrameFormat->SetFormatAttr(aHOrient);
+ pSh->EndAction();
+ }
+
+ if (nVertOrient != -1)
+ {
+ pSh->StartAction();
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SwFrameFormat* pFrameFormat = FindFrameFormat( pObj );
+ SwFormatVertOrient aVOrient(pFrameFormat->GetFormatAttr(RES_VERT_ORIENT));
+ aVOrient.SetVertOrient( nVertOrient );
+ pFrameFormat->SetFormatAttr(aVOrient);
+ pSh->EndAction();
}
- if (nAnchor == RndStdIds::FLY_AT_PARA)
- break; // Do not align frames of an anchored paragraph
+
+ break;
}
pSh->StartAction();
@@ -654,7 +670,7 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet)
case SID_OBJECT_ALIGN:
if ( !rSh.IsAlignPossible() || bProtected )
rSet.DisableItem( nWhich );
- else
+ else if ( rSh.GetAnchorId() == RndStdIds::FLY_AS_CHAR )
{
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
//if only one object is selected it can only be vertically