[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - svx/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 20 10:23:54 UTC 2021


 svx/source/tbxctrls/fontworkgallery.cxx |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 29c15be71f8c12e1116ef80d515fe3f734cd183f
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Jan 20 10:02:53 2021 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Jan 20 11:23:15 2021 +0100

    Don't insert fontwork outside view
    
    Change-Id: Ib518cc6c70e2595cc191cd353b628729fd220de7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109665
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

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);
 


More information about the Libreoffice-commits mailing list