diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2020-02-07 12:49:59 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-02-10 12:02:54 +0100 |
commit | 4a885a4da2e7baaa8c1827a1483b76894d3c0967 (patch) | |
tree | 1e0e4f8c187d6a9dd931b093c6ba75eb2b1f82e4 /sw | |
parent | 42ba6d0ebab69c5e307e8c2390f005eca8aaca1d (diff) |
Get the align states of draw-shapes in...
SwDrawBaseShell::GetState() so that the align buttons are informed
(in core desktop and online via statechange messages)
Change-Id: Ic69fb03bc98f39b1a6a389d50d3d6404fefd7f29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88159
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/shells/drwbassh.cxx | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx index 6f405026b071..21c6f9395a90 100644 --- a/sw/source/uibase/shells/drwbassh.cxx +++ b/sw/source/uibase/shells/drwbassh.cxx @@ -695,18 +695,53 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet) case SID_OBJECT_ALIGN_MIDDLE: case SID_OBJECT_ALIGN_DOWN: case SID_OBJECT_ALIGN: - if ( !rSh.IsAlignPossible() || bProtected ) - rSet.DisableItem( nWhich ); - else if ( rSh.GetAnchorId() == RndStdIds::FLY_AS_CHAR ) { + bool bDisableThis = false; + bool bDisableHoriz = false; + bool bHoriz = (nWhich == SID_OBJECT_ALIGN_LEFT || nWhich == SID_OBJECT_ALIGN_CENTER || + nWhich == SID_OBJECT_ALIGN_RIGHT); const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); - //if only one object is selected it can only be vertically - // aligned because it is character bound - if( rMarkList.GetMarkCount() == 1 ) + if ( !rSh.IsAlignPossible() || bProtected ) + { + bDisableThis = true; + rSet.DisableItem( nWhich ); + } + else if ( rSh.GetAnchorId() == RndStdIds::FLY_AS_CHAR ) { - rSet.DisableItem(SID_OBJECT_ALIGN_LEFT); - rSet.DisableItem(SID_OBJECT_ALIGN_CENTER); - rSet.DisableItem(SID_OBJECT_ALIGN_RIGHT); + //if only one object is selected it can only be vertically + // aligned because it is character bound + if( rMarkList.GetMarkCount() == 1 ) + { + bDisableHoriz = true; + rSet.DisableItem(SID_OBJECT_ALIGN_LEFT); + rSet.DisableItem(SID_OBJECT_ALIGN_CENTER); + rSet.DisableItem(SID_OBJECT_ALIGN_RIGHT); + } + } + + if (bHoriz && !bDisableThis && !bDisableHoriz && + rMarkList.GetMarkCount() == 1) + { + sal_Int16 nHoriOrient = -1; + switch(nWhich) + { + case SID_OBJECT_ALIGN_LEFT: + nHoriOrient = text::HoriOrientation::LEFT; + break; + case SID_OBJECT_ALIGN_CENTER: + nHoriOrient = text::HoriOrientation::CENTER; + break; + case SID_OBJECT_ALIGN_RIGHT: + nHoriOrient = text::HoriOrientation::RIGHT; + break; + default: + break; + } + + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SwFrameFormat* pFrameFormat = FindFrameFormat(pObj); + SwFormatHoriOrient aHOrient(pFrameFormat->GetFormatAttr(RES_HORI_ORIENT)); + rSet.Put(SfxBoolItem(nWhich, aHOrient.GetHoriOrient() == nHoriOrient)); } } break; |