From d5eeca9bf3811b8c83d497dab5edb3ee2ba79a84 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Wed, 10 Feb 2021 07:21:30 +0100 Subject: fontwork: center in online in writer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid unnecessary position change Change-Id: I338b9a28653569e1b7c19ba3a1f590363fb2f94c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110664 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112164 Tested-by: Jenkins Reviewed-by: Szymon Kłos --- sw/source/uibase/uiview/viewdraw.cxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 680d7ba788e7..80c42872c29b 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -162,18 +162,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 ); -- cgit v1.2.3