summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx5
-rw-r--r--sd/source/ui/inc/ViewShellBase.hxx4
-rw-r--r--sd/source/ui/inc/unomodel.hxx2
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx11
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx46
-rw-r--r--sw/inc/view.hxx2
-rw-r--r--sw/source/uibase/uiview/view.cxx9
-rw-r--r--sw/source/uibase/uiview/viewdraw.cxx14
10 files changed, 79 insertions, 18 deletions
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index e9863fd99a03..dedef69a65b9 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -383,6 +383,8 @@ public:
bool isLOKTablet() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::TABLET; }
/// Check if the lok client is running on a mobile device.
bool isLOKMobilePhone() const { return maLOKDeviceFormFactor == LOKDeviceFormFactor::MOBILE; }
+
+ virtual tools::Rectangle getLOKVisibleArea() const { return tools::Rectangle(); }
};
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index cffc7cf1bb3c..60cd3d4848ea 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -402,6 +402,8 @@ public:
void InitFormEditData();
void ClearFormEditData();
ScFormEditData* GetFormEditData() { return mpFormEditData.get(); }
+
+ virtual tools::Rectangle getLOKVisibleArea() const override;
};
#endif
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index ee279ceec064..66da8b55e6d0 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1829,4 +1829,9 @@ ScNavigatorSettings* ScTabViewShell::GetNavigatorSettings()
return pNavSettings.get();
}
+tools::Rectangle ScTabViewShell::getLOKVisibleArea() const
+{
+ return GetViewData().getLOKVisibleArea();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx
index 4e4871186d3c..44dd9d25dfa5 100644
--- a/sd/source/ui/inc/ViewShellBase.hxx
+++ b/sd/source/ui/inc/ViewShellBase.hxx
@@ -217,6 +217,9 @@ public:
/// See SfxViewShell::NotifyCursor().
void NotifyCursor(SfxViewShell* pViewShell) const override;
+ void setLOKVisibleArea(const ::tools::Rectangle& rArea) { maLOKVisibleArea = rArea; }
+ virtual ::tools::Rectangle getLOKVisibleArea() const override { return maLOKVisibleArea; }
+
protected:
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
@@ -228,6 +231,7 @@ private:
std::unique_ptr<Implementation> mpImpl;
DrawDocShell* mpDocShell;
SdDrawDocument* mpDocument;
+ ::tools::Rectangle maLOKVisibleArea;
/** Determine from the properties of the document shell the initial type
of the view shell in the center pane. We use this method to avoid
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index b320abda4912..08629b074b5b 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -255,6 +255,8 @@ public:
virtual void setGraphicSelection(int nType, int nX, int nY) override;
/// @see lok::Document::resetSelection().
virtual void resetSelection() override;
+ /// @see vcl::ITiledRenderable::setClientVisibleArea().
+ virtual void setClientVisibleArea(const tools::Rectangle& rRectangle) override;
/// @see vcl::ITiledRenderable::setClipboard().
virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
/// @see vcl::ITiledRenderable::isMimeTypeSupported().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 17d07ec02cef..69c2a94dd946 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2615,6 +2615,17 @@ void SdXImpressDocument::resetSelection()
pSdrView->UnmarkAll();
}
+void SdXImpressDocument::setClientVisibleArea(const ::tools::Rectangle& rRectangle)
+{
+ SolarMutexGuard aGuard;
+
+ DrawViewShell* pViewShell = GetViewShell();
+ if (!pViewShell)
+ return;
+
+ pViewShell->GetViewShellBase().setLOKVisibleArea(rRectangle);
+}
+
void SdXImpressDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
{
SolarMutexGuard aGuard;
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)
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 1ce11c33bda6..6c42497efeb6 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -674,6 +674,8 @@ public:
void SetOldFrameCat(const OUString& sStr);
const OUString& GetOldDrwCat();
void SetOldDrwCat(const OUString& sStr);
+
+ virtual tools::Rectangle getLOKVisibleArea() const override;
};
inline long SwView::GetXScroll() const
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 296140abbae7..b06fa1a38457 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1880,6 +1880,15 @@ void SwView::AddTransferable(SwTransferable& rTransferable)
GetViewImpl()->AddTransferable(rTransferable);
}
+tools::Rectangle SwView::getLOKVisibleArea() const
+{
+ SwViewShell* pVwSh = GetWrtShellPtr();
+ if (pVwSh)
+ return pVwSh->getLOKVisibleArea();
+ else
+ return tools::Rectangle();
+}
+
namespace sw {
void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb)
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index cb06e3797264..233d1cfcff95 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -166,10 +166,9 @@ void SwView::ExecDraw(SfxRequest& rReq)
if ( pObj )
{
Size aDocSize( m_pWrtShell->GetDocSize() );
- const SwRect& rVisArea = m_pWrtShell->VisArea();
+ const SwRect& rVisArea = comphelper::LibreOfficeKit::isActive() ?
+ m_pWrtShell->getLOKVisibleArea() : m_pWrtShell->VisArea();
Point aPos( rVisArea.Center() );
- Size aSize;
- Size aPrefSize( pObj->GetSnapRect().GetSize() );
if( rVisArea.Width() > aDocSize.Width())
aPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
@@ -177,10 +176,11 @@ void SwView::ExecDraw(SfxRequest& rReq)
if(rVisArea.Height() > aDocSize.Height())
aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
- if( aPrefSize.Width() && aPrefSize.Height() )
- aSize = rWin2.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
- else
- aSize = Size( 2835, 2835 );
+ 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) );
m_pWrtShell->EnterStdMode();
m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );