[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit include/vcl libreofficekit/Library_libreofficekitgtk.mk libreofficekit/source sc/inc sc/source sd/source sw/inc sw/source

Mihai Varga mihai.varga at collabora.com
Mon Oct 5 05:03:25 PDT 2015


 desktop/source/lib/init.cxx                 |    8 ++-
 include/LibreOfficeKit/LibreOfficeKit.h     |    4 +
 include/LibreOfficeKit/LibreOfficeKit.hxx   |    4 -
 include/vcl/ITiledRenderable.hxx            |    2 
 libreofficekit/Library_libreofficekitgtk.mk |    4 +
 libreofficekit/source/gtk/lokdocview.cxx    |   57 +++++++++++++++++++++++++++-
 libreofficekit/source/gtk/tilebuffer.hxx    |    4 +
 sc/inc/docuno.hxx                           |    3 -
 sc/source/ui/unoobj/docuno.cxx              |    5 +-
 sd/source/ui/inc/unomodel.hxx               |    3 -
 sd/source/ui/unoidl/unomodel.cxx            |    5 +-
 sw/inc/unotxdoc.hxx                         |    3 -
 sw/source/uibase/uno/unotxdoc.cxx           |    4 -
 13 files changed, 88 insertions(+), 18 deletions(-)

New commits:
commit c90c08a65c480a1012182979d5e9218f17a2ba2e
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Sun Oct 4 19:40:13 2015 +0300

    LOK: added the button type and key modifier to postMouseEvent()
    
    To get a better functionality we need to know the button type (left,
    right, middle). We also need the key modifier (ctrl, alt, shift) for
    actions such as ctrl+click (to open a link) or shift+click to select
    
    Change-Id: Iaccb93b276f8a6870dd41cc5132dbb85d2bbf71b

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7eb54d3..8fe6295 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -230,7 +230,9 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
                                 int nType,
                                 int nX,
                                 int nY,
-                                int nCount);
+                                int nCount,
+                                int nButtons,
+                                int nModifier);
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
                                const char* pCommand,
                                const char* pArguments);
@@ -925,7 +927,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* /*pThis*/, const char* pC
     }
 }
 
-static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount)
+static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     ITiledRenderable* pDoc = getTiledRenderable(pThis);
     if (!pDoc)
@@ -934,7 +936,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
         return;
     }
 
-    pDoc->postMouseEvent(nType, nX, nY, nCount);
+    pDoc->postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier);
 }
 
 static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index d83dd49..83dcc98 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -137,7 +137,9 @@ struct _LibreOfficeKitDocumentClass
                             int nType,
                             int nX,
                             int nY,
-                            int nCount);
+                            int nCount,
+                            int nButtons,
+                            int nModifier);
 
     /// @see lok::Document::postUnoCommand
     void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index acdfa27..72231ad 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -192,9 +192,9 @@ public:
      * @param nY vertical position in document coordinates
      * @param nCount number of clicks: 1 for single click, 2 for double click
      */
-    inline void postMouseEvent(int nType, int nX, int nY, int nCount)
+    inline void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
     {
-        mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount);
+        mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount, nButtons, nModifier);
     }
 
     /**
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index fd336f6..c294d20 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -112,7 +112,7 @@ public:
      *
      * @see lok::Document::postMouseEvent().
      */
-    virtual void postMouseEvent(int nType, int nX, int nY, int nCount) = 0;
+    virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) = 0;
 
     /**
      * Sets the start or end of a text selection.
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk
index 71a77e9..7d25abf 100644
--- a/libreofficekit/Library_libreofficekitgtk.mk
+++ b/libreofficekit/Library_libreofficekitgtk.mk
@@ -16,6 +16,10 @@ $(eval $(call gb_Library_add_exception_objects,libreofficekitgtk,\
     libreofficekit/source/gtk/tilebuffer \
 ))
 
+$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
+    boost_headers \
+))
+
 $(eval $(call gb_Library_add_cxxflags,libreofficekitgtk,\
     $$(GTK3_CFLAGS) \
 ))
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 2270231..2d34e58 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -20,6 +20,7 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <LibreOfficeKit/LibreOfficeKitGtk.h>
 #include <rsc/rsc-vcl-shared-types.hxx>
+#include <vcl/event.hxx>
 
 #include "tilebuffer.hxx"
 
@@ -66,6 +67,10 @@ struct _LOKDocViewPrivate
     guint32 m_nLastButtonPressTime;
     /// Time of the last button release.
     guint32 m_nLastButtonReleaseTime;
+    /// Last pressed button (left, right, middle)
+    guint32 m_nLastButtonPressed;
+    /// Key modifier (ctrl, atl, shift)
+    guint32 m_nKeyModifier;
     /// Rectangles of the current text selection.
     std::vector<GdkRectangle> m_aTextSelectionRectangles;
     /// Position and size of the selection start (as if there would be a cursor caret there).
@@ -267,6 +272,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
         return FALSE;
     }
 
+    priv->m_nKeyModifier = 0;
     switch (pEvent->keyval)
     {
     case GDK_KEY_BackSpace:
@@ -296,6 +302,21 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
     case GDK_KEY_Right:
         nKeyCode = com::sun::star::awt::Key::RIGHT;
         break;
+    case GDK_KEY_Shift_L:
+    case GDK_KEY_Shift_R:
+        if (pEvent->type == GDK_KEY_PRESS)
+            priv->m_nKeyModifier |= KEY_SHIFT;
+        break;
+    case GDK_KEY_Control_L:
+    case GDK_KEY_Control_R:
+        if (pEvent->type == GDK_KEY_PRESS)
+            priv->m_nKeyModifier |= KEY_MOD1;
+        break;
+    case GDK_KEY_Alt_L:
+    case GDK_KEY_Alt_R:
+        if (pEvent->type == GDK_KEY_PRESS)
+            priv->m_nKeyModifier |= KEY_MOD2;
+        break;
     default:
         if (pEvent->keyval >= GDK_KEY_F1 && pEvent->keyval <= GDK_KEY_F26)
             nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_KEY_F1);
@@ -309,7 +330,6 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
     if (pEvent->state & GDK_SHIFT_MASK)
         nKeyCode |= KEY_SHIFT;
 
-
     if (pEvent->type == GDK_KEY_RELEASE)
     {
         GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
@@ -1060,6 +1080,20 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
         pLOEvent->m_nPostMouseEventX = pixelToTwip(pEvent->x, priv->m_fZoom);
         pLOEvent->m_nPostMouseEventY = pixelToTwip(pEvent->y, priv->m_fZoom);
         pLOEvent->m_nPostMouseEventCount = nCount;
+        switch (pEvent->button)
+        {
+        case 1:
+            pLOEvent->m_nPostMouseEventButton = MOUSE_LEFT;
+            break;
+        case 2:
+            pLOEvent->m_nPostMouseEventButton = MOUSE_MIDDLE;
+            break;
+        case 3:
+            pLOEvent->m_nPostMouseEventButton = MOUSE_RIGHT;
+            break;
+        }
+        pLOEvent->m_nPostMouseEventModifier = priv->m_nKeyModifier;
+        priv->m_nLastButtonPressed = pLOEvent->m_nPostMouseEventButton;
         g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
         g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
@@ -1078,6 +1112,20 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
         pLOEvent->m_nPostMouseEventX = pixelToTwip(pEvent->x, priv->m_fZoom);
         pLOEvent->m_nPostMouseEventY = pixelToTwip(pEvent->y, priv->m_fZoom);
         pLOEvent->m_nPostMouseEventCount = nCount;
+        switch (pEvent->button)
+        {
+        case 1:
+            pLOEvent->m_nPostMouseEventButton = MOUSE_LEFT;
+            break;
+        case 2:
+            pLOEvent->m_nPostMouseEventButton = MOUSE_MIDDLE;
+            break;
+        case 3:
+            pLOEvent->m_nPostMouseEventButton = MOUSE_RIGHT;
+            break;
+        }
+        pLOEvent->m_nPostMouseEventModifier = priv->m_nKeyModifier;
+        priv->m_nLastButtonPressed = pLOEvent->m_nPostMouseEventButton;
         g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
         g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
@@ -1182,6 +1230,9 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
     pLOEvent->m_nPostMouseEventX = pixelToTwip(pEvent->x, priv->m_fZoom);
     pLOEvent->m_nPostMouseEventY = pixelToTwip(pEvent->y, priv->m_fZoom);
     pLOEvent->m_nPostMouseEventCount = 1;
+    pLOEvent->m_nPostMouseEventButton = priv->m_nLastButtonPressed;
+    pLOEvent->m_nPostMouseEventModifier = priv->m_nKeyModifier;
+
     g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
 
     g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), NULL);
@@ -1218,7 +1269,9 @@ postMouseEventInThread(gpointer data)
                                               pLOEvent->m_nPostMouseEventType,
                                               pLOEvent->m_nPostMouseEventX,
                                               pLOEvent->m_nPostMouseEventY,
-                                              pLOEvent->m_nPostMouseEventCount);
+                                              pLOEvent->m_nPostMouseEventCount,
+                                              pLOEvent->m_nPostMouseEventButton,
+                                              pLOEvent->m_nPostMouseEventModifier);
 }
 
 static void
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
index 5a989fc..668a720 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -202,6 +202,8 @@ struct LOEvent
     int m_nPostMouseEventX;
     int m_nPostMouseEventY;
     int m_nPostMouseEventCount;
+    int m_nPostMouseEventButton;
+    int m_nPostMouseEventModifier;
     ///@}
 
     /// @name setGraphicSelection parameters
@@ -230,6 +232,8 @@ struct LOEvent
         , m_nPostMouseEventX(0)
         , m_nPostMouseEventY(0)
         , m_nPostMouseEventCount(0)
+        , m_nPostMouseEventButton(0)
+        , m_nPostMouseEventModifier(0)
         , m_nSetGraphicSelectionType(0)
         , m_nSetGraphicSelectionX(0)
         , m_nSetGraphicSelectionY(0)
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 34235a2..91358f6 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -51,6 +51,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/interfacecontainer.h>
 #include <svl/itemprop.hxx>
+#include <vcl/event.hxx>
 #include <vcl/ITiledRenderable.hxx>
 #include "drwlayer.hxx"
 
@@ -398,7 +399,7 @@ public:
     virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
 
     /// @see vcl::ITiledRenderable::postMouseEvent().
-    virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
+    virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons = MOUSE_LEFT, int nModifier = 0) SAL_OVERRIDE;
 
     /// @see vcl::ITiledRenderable::setTextSelection().
     virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index e1835bd..f9c7fde 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -591,7 +591,7 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     }
 }
 
-void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount)
+void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
@@ -607,7 +607,8 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount)
     pViewData->SetZoom(Fraction(1, 1), Fraction(1, 1), true);
 
     // Calc operates in pixels...
-    MouseEvent aEvent(Point(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
+    MouseEvent aEvent(Point(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()), nCount,
+            MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
     switch (nType)
     {
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 6aff89c..f3debf8 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -45,6 +45,7 @@
 #include <sfx2/sfxbasemodel.hxx>
 #include <svx/fmdmod.hxx>
 
+#include <vcl/event.hxx>
 #include <vcl/ITiledRenderable.hxx>
 
 #include <editeng/unoipset.hxx>
@@ -249,7 +250,7 @@ public:
     /// @see vcl::ITiledRenderable::postKeyEvent().
     virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::postMouseEvent().
-    virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
+    virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons = MOUSE_LEFT, int nModifier = 0) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::setTextSelection().
     virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::getTextSelection().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index b12a770..0d322ea 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2422,7 +2422,7 @@ void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     }
 }
 
-void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
+void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
@@ -2430,7 +2430,8 @@ void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
     if (!pViewShell)
         return;
 
-    MouseEvent aEvent(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
+    MouseEvent aEvent(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)), nCount,
+            MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
     switch (nType)
     {
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 1edefc4..7315aab 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -66,6 +66,7 @@
 #include <editeng/UnoForbiddenCharsTable.hxx>
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/implbase.hxx>
+#include <vcl/event.hxx>
 #include <vcl/ITiledRenderable.hxx>
 #include <com/sun/star/tiledrendering/XTiledRenderable.hpp>
 
@@ -419,7 +420,7 @@ public:
     /// @see vcl::ITiledRenderable::postKeyEvent().
     virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::postMouseEvent().
-    virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
+    virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons = MOUSE_LEFT, int nModifier = 0) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::setTextSelection().
     virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::getTextSelection().
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index b7f3d76..9a8128b 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3272,12 +3272,12 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     }
 }
 
-void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
+void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
 {
     SolarMutexGuard aGuard;
 
     SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
-    MouseEvent aEvent(Point(nX, nY), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
+    MouseEvent aEvent(Point(nX, nY), nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
     switch (nType)
     {


More information about the Libreoffice-commits mailing list