[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 2 commits - include/vcl sd/source vcl/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Feb 24 05:33:24 PST 2015


 include/vcl/window.hxx           |    2 ++
 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 ++++++++++++++++++++++++++++++++
 vcl/source/window/mouse.cxx      |    9 +++++++++
 6 files changed, 74 insertions(+)

New commits:
commit f19759645bbe1cde7023ab6136f9ed76bf2ee126
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 24 14:30:41 2015 +0100

    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

diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index b4bd333..710c722 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 768e4f6..64080e7 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 ff9115a..054e8f2 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 0581a7c..0056af8 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())
commit a14673d338b37bb41743536beb1de34a70cafa57
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 24 14:00:28 2015 +0100

    Add vcl::Window::SetLastMousePos()
    
    This is needed, as e.g. sd::FuText::DoExecute() queries the mouse
    position from VCL, which won't be correct in case the mouse event is
    generated by a LOK client, not by VCL. So add a method that makes it
    possible to set the position before MouseButton*() starts.
    
    Change-Id: I1e24ffb2a4a866c9cac89367907ffaec336ad1f6

diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index b329f45..a6309d6 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1013,6 +1013,8 @@ public:
     void                                SetPointerPosPixel( const Point& rPos );
     Point                               GetPointerPosPixel();
     Point                               GetLastPointerPosPixel();
+    /// Similar to SetPointerPosPixel(), but sets the frame data's last mouse position instead.
+    void                                SetLastMousePos(const Point& rPos);
     void                                ShowPointer( bool bVisible );
     void                                EnterWait();
     void                                LeaveWait();
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index cc1c032..25de8d3 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -532,6 +532,15 @@ void Window::SetPointerPosPixel( const Point& rPos )
     mpWindowImpl->mpFrame->SetPointerPos( aPos.X(), aPos.Y() );
 }
 
+void Window::SetLastMousePos(const Point& rPos)
+{
+    // Do this conversion, so when GetPointerPosPixel() calls
+    // ImplFrameToOutput(), we get back the original position.
+    Point aPos = ImplOutputToFrame(rPos);
+    mpWindowImpl->mpFrameData->mnLastMouseX = aPos.X();
+    mpWindowImpl->mpFrameData->mnLastMouseY = aPos.Y();
+}
+
 Point Window::GetPointerPosPixel()
 {
 


More information about the Libreoffice-commits mailing list