diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2018-03-08 21:07:40 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-05-22 12:03:57 +0200 |
commit | 6644d7a356e280e5a2557c9c095c777d3c61f26f (patch) | |
tree | 5539b95a0b87a4529b8fe451bae69a8866cbafc1 /sd | |
parent | be0476362b876bba573d3ec61fa01da5208a3952 (diff) |
sd lok: Enable mapmode in case of lok to calculate center
This reverts the solution in 9fee132c18b658c9ea9fb1114c1fefa56b57532a.
Also, calculate center using the new function for chart, image, and text
shape insertion.
Reviewed-on: https://gerrit.libreoffice.org/51343
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
(cherry picked from commit 1990fc47bb561fcb9f98cbdcb7f986b93a54b876)
Change-Id: I3386cf65d28d6537409a9e27e870c195d689ef50
Reviewed-on: https://gerrit.libreoffice.org/51531
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 21 | ||||
-rw-r--r-- | sd/source/ui/inc/View.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/inc/Window.hxx | 1 | ||||
-rw-r--r-- | sd/source/ui/view/sdview2.cxx | 13 | ||||
-rw-r--r-- | sd/source/ui/view/sdwindow.cxx | 14 |
5 files changed, 20 insertions, 31 deletions
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index f91f0663ff81..0b854ba27458 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -67,7 +67,6 @@ #include <sfx2/opengrf.hxx> #include <sfx2/viewfrm.hxx> #include <svx/charthelper.hxx> -#include <comphelper/lok.hxx> #include "app.hrc" #include "sdresid.hxx" @@ -171,20 +170,7 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq ) bSelectionReplaced = true; } - Point aPos; - // For LOK, set position to center of the page - if (comphelper::LibreOfficeKit::isActive()) - aPos = Rectangle(aPos, mpView->GetSdrPageView()->GetPage()->GetSize()).Center(); - else - { - Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() ); - aPos = aRect.Center(); - bool bMapModeWasEnabled(mpWindow->IsMapModeEnabled()); - mpWindow->EnableMapMode(/*true*/); - aPos = mpWindow->PixelToLogic(aPos); - mpWindow->EnableMapMode(bMapModeWasEnabled); - } - + Point aPos = mpWindow->GetVisibleCenter(); SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, nullptr); if(pGrafObj && bAsLink ) @@ -381,10 +367,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq ) aSize = OutputDevice::LogicToLogic(aSize, aUnit, MapUnit::Map100thMM); } - Point aPos; - Rectangle aWinRect(aPos, mpWindow->GetOutputSizePixel() ); - aPos = aWinRect.Center(); - aPos = mpWindow->PixelToLogic(aPos); + Point aPos = mpWindow->GetVisibleCenter(); aPos.X() -= aSize.Width() / 2; aPos.Y() -= aSize.Height() / 2; aRect = Rectangle(aPos, aSize); diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx index b88c780dfad7..607034ac9952 100644 --- a/sd/source/ui/inc/View.hxx +++ b/sd/source/ui/inc/View.hxx @@ -91,7 +91,7 @@ public: void SelectAll(); void DoCut(vcl::Window* pWindow=nullptr); void DoCopy(vcl::Window* pWindow=nullptr); - void DoPaste(vcl::Window* pWindow=nullptr); + void DoPaste(::sd::Window* pWindow=nullptr); virtual void DoConnect(SdrOle2Obj* pOleObj) override; virtual bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr = false); void StartDrag( const Point& rStartPos, vcl::Window* pWindow ); diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx index a91a71ea70d3..9031409164a5 100644 --- a/sd/source/ui/inc/Window.hxx +++ b/sd/source/ui/inc/Window.hxx @@ -131,6 +131,7 @@ public: void SetVisibleXY(double fX, double fY); double GetVisibleWidth(); double GetVisibleHeight(); + Point GetVisibleCenter(); double GetScrlLineWidth(); double GetScrlLineHeight(); double GetScrlPageWidth(); diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index 6b7427f55fad..57f18dcc6881 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -265,7 +265,7 @@ void View::DoCopy (vcl::Window* pWindow) } } -void View::DoPaste (vcl::Window* pWindow) +void View::DoPaste (::sd::Window* pWindow) { TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewSh->GetActiveWindow() ) ); if( !aDataHelper.GetTransferable().is() ) @@ -316,17 +316,8 @@ void View::DoPaste (vcl::Window* pWindow) } else { - Point aPos; sal_Int8 nDnDAction = DND_ACTION_COPY; - - if( pWindow ) - { - if (comphelper::LibreOfficeKit::isActive()) - aPos = Rectangle(aPos, GetSdrPageView()->GetPage()->GetSize()).Center(); - else - aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() ); - } - + Point aPos = pWindow->GetVisibleCenter(); DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpDocSh->GetViewShell() ); if (pDrViewSh != nullptr) diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx index 7472695ee728..59fe3c2b85a2 100644 --- a/sd/source/ui/view/sdwindow.cxx +++ b/sd/source/ui/view/sdwindow.cxx @@ -685,6 +685,20 @@ double Window::GetVisibleHeight() return ((double) aWinSize.Height() / maViewSize.Height()); } +Point Window::GetVisibleCenter() +{ + Point aPos; + aPos = Rectangle(aPos, GetOutputSizePixel()).Center(); + + // For LOK + bool bMapModeWasEnabled(IsMapModeEnabled()); + EnableMapMode(/*true*/); + aPos = PixelToLogic(aPos); + EnableMapMode(bMapModeWasEnabled); + + return aPos; +} + /** * @returns width of a scroll column in proportion to the width of the whole * working area. |