summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2021-01-20 10:52:26 +0100
committerLászló Németh <nemeth@numbertext.org>2021-02-04 13:45:13 +0100
commit54302a574a98d6fc071472f1fa64adaf70864a26 (patch)
tree97cba0bd1d47495e1b35630eb5a689cf401d2ffa /sw/source/uibase/shells
parentec33be1d135c1523b4d872eb2f86c515f0419509 (diff)
tdf#138512 sw: fix crash on textbox alignment
Regression from 3347d71b23595919e167bd49932675e77cbbdbbb (sw: fix text position at textbox alignment) has been fixed by this commit. Hopefully there won't not be newer regressions. Please note the crash only occur on GTK vcl backend so, the py-test only with that case will show the problem. In the other case there were no crash. Change-Id: I3280547a6195e240e5b33e0d0931fb60d4d19fff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109669 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/uibase/shells')
-rw-r--r--sw/source/uibase/shells/drwbassh.cxx38
1 files changed, 30 insertions, 8 deletions
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index f901f32cc15d..b73dccb6036d 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -443,8 +443,7 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
if ( bAlignPossible )
{
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
- if (rMarkList.GetMarkCount() == 1
- && !SwTextBoxHelper::hasTextFrame(rMarkList.GetMark(0)->GetMarkedSdrObj()))
+ if (rMarkList.GetMarkCount() == 1)
{
sal_Int16 nHorizOrient = -1, nVertOrient = -1;
@@ -472,13 +471,16 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
break;
}
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SwFrameFormat* pFrameFormat = FindFrameFormat(pObj);
+ SwFrameFormat* pTextBox
+ = SwTextBoxHelper::getOtherTextBoxFormat(pFrameFormat, RES_DRAWFRMFMT);
+
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 );
+ aHOrient.SetHoriOrient(nHorizOrient);
pFrameFormat->SetFormatAttr(aHOrient);
pSh->EndAction();
}
@@ -486,14 +488,34 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
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 );
+ aVOrient.SetVertOrient(nVertOrient);
pFrameFormat->SetFormatAttr(aVOrient);
pSh->EndAction();
}
+ if (pTextBox)
+ {
+ Point nShapePos(pFrameFormat->GetHoriOrient().GetPos(),
+ pFrameFormat->GetVertOrient().GetPos());
+ Point nOffset(
+ SwTextBoxHelper::getTextRectangle(pFrameFormat, false).TopLeft());
+
+ if (nHorizOrient != -1)
+ {
+ SwFormatHoriOrient aNewHOri(pTextBox->GetHoriOrient());
+ aNewHOri.SetPos(nShapePos.X() + nOffset.X());
+ pTextBox->SetFormatAttr(aNewHOri);
+ }
+
+ if (nVertOrient != -1)
+ {
+ SwFormatVertOrient aNewVOri(pTextBox->GetVertOrient());
+ aNewVOri.SetPos(nShapePos.Y() + nOffset.Y());
+ pTextBox->SetFormatAttr(aNewVOri);
+ }
+ }
+
break;
}