summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-01-26 16:35:10 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-03-09 09:55:04 +0100
commit878e8fe7ffeada3d6154fe4750079deb38e1ce94 (patch)
tree54b9c53745581ded7a0b1b5ef7a9788b589742a2 /svx
parent067b22aeff5ff256be393dc2aa14acdf0300427a (diff)
fontwork: insert in the center of LOK view
Change-Id: Iabde4ee927546b0e396c4fbd6d0099fa82240166 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109968 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112163 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx49
1 files changed, 39 insertions, 10 deletions
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index bfcde08d09c8..7acaac50b15c 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -20,16 +20,19 @@
#include <com/sun/star/text/WritingMode.hpp>
+#include <comphelper/lok.hxx>
+
#include <vcl/toolbox.hxx>
#include <vcl/virdev.hxx>
+#include <sfx2/viewsh.hxx>
+
#include <svl/itempool.hxx>
#include <svtools/toolbarmenu.hxx>
#include <svtools/popupwindowcontroller.hxx>
#include <svx/fmmodel.hxx>
-#include <svx/dialmgr.hxx>
#include <svx/strings.hrc>
#include <svx/svdpage.hxx>
#include <svx/svdobj.hxx>
@@ -38,6 +41,8 @@
#include <svx/gallery.hxx>
#include <svx/fontworkgallery.hxx>
+#include <tools/UnitConversion.hxx>
+
#include <algorithm>
#include <memory>
@@ -193,17 +198,41 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
// pNewObject->SetPage(nullptr);
tools::Rectangle aObjRect( pNewObject->GetLogicRect() );
- tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), pOutDev->GetOutputSizePixel()));
- Point aPagePos = aVisArea.Center();
- bool bIsInsertedObjectSmallerThanVisibleArea =
- aVisArea.GetSize().getHeight() > aObjRect.GetSize().getHeight() &&
- aVisArea.GetSize().getWidth() > aObjRect.GetSize().getWidth();
- if (bIsInsertedObjectSmallerThanVisibleArea)
+ Point aPagePos;
+ Size aFontworkSize = aObjRect.GetSize();
+
+ if (comphelper::LibreOfficeKit::isActive())
{
- aPagePos.AdjustX( -(aObjRect.GetWidth() / 2) );
- aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) );
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+
+ aPagePos = pViewShell->getLOKVisibleArea().Center();
+
+ aPagePos.setX(convertTwipToMm100(aPagePos.X()));
+ aPagePos.setY(convertTwipToMm100(aPagePos.Y()));
+
+ sal_Int32 nLOKViewWidth = 0.8 * convertTwipToMm100(pViewShell->getLOKVisibleArea().getWidth());
+ if (aFontworkSize.getWidth() > nLOKViewWidth)
+ {
+ double fScale = static_cast<double>(aFontworkSize.getWidth()) / nLOKViewWidth;
+ aFontworkSize.setWidth(aFontworkSize.getWidth() / fScale);
+ aFontworkSize.setHeight(aFontworkSize.getHeight() / fScale);
+ }
}
- tools::Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
+ else
+ {
+ Size aSize = pOutDev->GetOutputSizePixel();
+ tools::Rectangle aPixelVisRect(Point(0,0), aSize);
+ tools::Rectangle aVisArea = pOutDev->PixelToLogic(aPixelVisRect);
+
+ aPagePos = aVisArea.Center();
+ }
+
+ if (aPagePos.getX() > aFontworkSize.getWidth() / 2)
+ aPagePos.AdjustX( -(aFontworkSize.getWidth() / 2) );
+ if (aPagePos.getY() > aFontworkSize.getHeight() / 2)
+ aPagePos.AdjustY( -(aFontworkSize.getHeight() / 2) );
+
+ tools::Rectangle aNewObjectRectangle(aPagePos, aFontworkSize);
pNewObject->SetLogicRect(aNewObjectRectangle);
if (bUseSpecialCalcMode)