summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-01-26 16:35:10 +0100
committerJan Holesovsky <kendy@collabora.com>2021-02-09 10:53:33 +0100
commit2555441f3f694af11d0d7b220b12ae25f43a6a5a (patch)
tree0ae994afe97d3553599dfadfbb6b213d1a5377cb /svx
parent2ca7964b50756b1e071c432b15eea7f079486f6c (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>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx46
1 files changed, 35 insertions, 11 deletions
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index e04978139236..afd2da9f8dfa 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -32,6 +32,9 @@
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include <comphelper/lok.hxx>
+#include <tools/UnitConversion.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/frmdiritem.hxx>
@@ -200,20 +203,41 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
// pNewObject->SetPage(nullptr);
tools::Rectangle aObjRect( pNewObject->GetLogicRect() );
- Size aSize = pOutDev->GetOutputSizePixel();
- tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), aSize));
-
- 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_uInt32 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);
+ }
}
+ 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, aObjRect.GetSize());
+ tools::Rectangle aNewObjectRectangle(aPagePos, aFontworkSize);
pNewObject->SetLogicRect(aNewObjectRectangle);
if (bUseSpecialCalcMode)