Kaydet (Commit) 1a72dbb3 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

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: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst 1c2e55dc
......@@ -2704,22 +2704,7 @@ void SwFEShell::SetObjAttr( const SfxItemSet& rSet )
bool SwFEShell::IsAlignPossible() const
{
const size_t nCnt = IsObjSelected();
if ( 0 < nCnt )
{
bool bRet = true;
if ( nCnt == 1 )
{
SdrObject *pO = Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
SwDrawContact *pC = static_cast<SwDrawContact*>(GetUserCall(pO));
OSL_ENSURE( pC, "No SwDrawContact!");
//only as character bound drawings can be aligned
bRet = pC && pC->GetFormat()->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR;
}
if ( bRet )
return Imp()->GetDrawView()->IsAlignPossible();
}
return false;
return Imp()->GetDrawView()->IsAlignPossible();
}
// temporary fix till SS of JOE is available
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment