summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-01-20 10:02:53 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-01-20 11:23:15 +0100
commit29c15be71f8c12e1116ef80d515fe3f734cd183f (patch)
treeac50d72675105d0777d82f075b4c4b04fcf089b8
parentabfc973318a7432e0b95c232cf6c9326408f51d0 (diff)
Don't insert fontwork outside view
Change-Id: Ib518cc6c70e2595cc191cd353b628729fd220de7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109665 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index edd3748400fb..e04978139236 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -200,10 +200,19 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
// pNewObject->SetPage(nullptr);
tools::Rectangle aObjRect( pNewObject->GetLogicRect() );
- tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), pOutDev->GetOutputSizePixel()));
+ Size aSize = pOutDev->GetOutputSizePixel();
+ tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), aSize));
+
Point aPagePos = aVisArea.Center();
- aPagePos.AdjustX( -(aObjRect.GetWidth() / 2) );
- aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) );
+ bool bIsInsertedObjectSmallerThanVisibleArea =
+ aVisArea.GetSize().getHeight() > aObjRect.GetSize().getHeight()
+ && aVisArea.GetSize().getWidth() > aObjRect.GetSize().getWidth();
+ if (bIsInsertedObjectSmallerThanVisibleArea)
+ {
+ aPagePos.AdjustX( -(aObjRect.GetWidth() / 2) );
+ aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) );
+ }
+
tools::Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
pNewObject->SetLogicRect(aNewObjectRectangle);