sw/source/uibase/shells/drwbassh.cxx | 53 +++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 9 deletions(-)
New commits: commit 4a885a4da2e7baaa8c1827a1483b76894d3c0967 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Fri Feb 7 12:49:59 2020 +0530 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Feb 10 12:02:54 2020 +0100 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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits