diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-02-10 07:21:30 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2021-02-10 10:13:42 +0100 |
commit | acda15662abfad136d7fc0165f32fd25e775d728 (patch) | |
tree | 9ffee04ae43b5dcc8938035efa2ae0c3209bd787 | |
parent | 1363e7a09526c77a0119b86bd90a3b20686ca4ff (diff) |
fontwork: center in online in writer
Avoid unnecessary position change
Change-Id: I338b9a28653569e1b7c19ba3a1f590363fb2f94c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110664
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 233d1cfcff95..d5c2ff4284c7 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -169,18 +169,17 @@ void SwView::ExecDraw(SfxRequest& rReq) const SwRect& rVisArea = comphelper::LibreOfficeKit::isActive() ? m_pWrtShell->getLOKVisibleArea() : m_pWrtShell->VisArea(); Point aPos( rVisArea.Center() ); + tools::Rectangle aObjRect( pObj->GetLogicRect() ); - if( rVisArea.Width() > aDocSize.Width()) + if ( rVisArea.Width() > aDocSize.Width()) aPos.setX( aDocSize.Width() / 2 + rVisArea.Left() ); + else if (aPos.getX() > aObjRect.GetWidth() / 2) + aPos.AdjustX( -(aObjRect.GetWidth() / 2) ); - if(rVisArea.Height() > aDocSize.Height()) + if (rVisArea.Height() > aDocSize.Height()) aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() ); - - tools::Rectangle aObjRect( pObj->GetLogicRect() ); - if (aPos.getX() > aObjRect.GetWidth() / 2) - aPos.AdjustX( -(aObjRect.GetWidth() / 2) ); - if (aPos.getY() > aObjRect.GetHeight() / 2) - aPos.AdjustY( -(aObjRect.GetHeight() / 2) ); + else if (aPos.getY() > aObjRect.GetHeight() / 2) + aPos.AdjustY( -(aObjRect.GetHeight() / 2) ); m_pWrtShell->EnterStdMode(); m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos ); |