From b780822f5afbf8cd6c2a8c756251a7edf248f55e Mon Sep 17 00:00:00 2001 From: Miklos Vajna <vmiklos@collabora.co.uk> Date: Tue, 24 Feb 2015 14:30:41 +0100 Subject: Introduce SdXImpressDocument::postMouseEvent() override It's far from perfect, but the following use-case works: - open an empty document with a singe slide (only two placeholder shapes) - type a few characters (into the title shape), Esc to finish editing - click into the non-title placeholder - type + Esc -> characters appear in the non-title shape Change-Id: Idc97c1fbeda0fb3ac53769e78b7cd665d8aee67b --- sd/source/ui/inc/ViewShell.hxx | 5 +++++ sd/source/ui/inc/unomodel.hxx | 2 ++ sd/source/ui/unoidl/unomodel.cxx | 24 ++++++++++++++++++++++++ sd/source/ui/view/viewshel.cxx | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) (limited to 'sd') diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index b4bd3331a30e..710c72293f1a 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -443,6 +443,11 @@ public: SdPage* pPage, const sal_Int32 nInsertPosition = -1); + /// Same as MouseButtonDown(), but coordinates are in logic unit. + void LogicMouseButtonDown(const MouseEvent& rMouseEvent); + /// Same as MouseButtonUp(), but coordinates are in logic unit. + void LogicMouseButtonUp(const MouseEvent& rMouseEvent); + class Implementation; protected: diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 768e4f633f90..64080e7ad992 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -244,6 +244,8 @@ public: virtual void initializeForTiledRendering() SAL_OVERRIDE; /// @see vcl::ITiledRenderable::registerCallback(). virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE; + /// @see vcl::ITiledRenderable::postMouseEvent(). + virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE; // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index ff9115a08a32..054e8f20dc71 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2362,6 +2362,30 @@ void SdXImpressDocument::registerCallback(LibreOfficeKitCallback pCallback, void mpDoc->registerLibreOfficeKitCallback(pCallback, pData); } +void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount) +{ + SolarMutexGuard aGuard; + + DrawViewShell* pViewShell = GetViewShell(); + if (!pViewShell) + return; + + MouseEvent aEvent(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT); + + switch (nType) + { + case LOK_MOUSEEVENT_MOUSEBUTTONDOWN: + pViewShell->LogicMouseButtonDown(aEvent); + break; + case LOK_MOUSEEVENT_MOUSEBUTTONUP: + pViewShell->LogicMouseButtonUp(aEvent); + break; + default: + assert(false); + break; + } +} + uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable() { uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters); diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 0581a7cb4238..0056af821e18 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -502,6 +502,38 @@ void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) } } +void ViewShell::LogicMouseButtonDown(const MouseEvent& rMouseEvent) +{ + // When we're not doing tiled rendering, then positions must be passed as pixels. + assert(GetDoc()->isTiledRendering()); + + bool bMap = mpActiveWindow->IsMapModeEnabled(); + mpActiveWindow->EnableMapMode(false); + Point aPoint = mpActiveWindow->GetPointerPosPixel(); + mpActiveWindow->SetPointerPosPixel(rMouseEvent.GetPosPixel()); + + MouseButtonDown(rMouseEvent, 0); + + mpActiveWindow->SetPointerPosPixel(aPoint); + mpActiveWindow->EnableMapMode(bMap); +} + +void ViewShell::LogicMouseButtonUp(const MouseEvent& rMouseEvent) +{ + // When we're not doing tiled rendering, then positions must be passed as pixels. + assert(GetDoc()->isTiledRendering()); + + bool bMap = mpActiveWindow->IsMapModeEnabled(); + mpActiveWindow->EnableMapMode(false); + Point aPoint = mpActiveWindow->GetPointerPosPixel(); + mpActiveWindow->SetPointerPosPixel(rMouseEvent.GetPosPixel()); + + MouseButtonUp(rMouseEvent, 0); + + mpActiveWindow->SetPointerPosPixel(aPoint); + mpActiveWindow->EnableMapMode(bMap); +} + void ViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) { if (rMEvt.IsLeaveWindow()) -- cgit