[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - android/Bootstrap android/experimental desktop/source include/LibreOfficeKit include/vcl libreofficekit/source sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Feb 5 05:57:55 PST 2015
android/Bootstrap/src/org/libreoffice/kit/Document.java | 3 +
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 2 -
desktop/source/lib/init.cxx | 7 ++-
desktop/source/lib/lokandroid.cxx | 4 +-
include/LibreOfficeKit/LibreOfficeKit.h | 3 +
include/LibreOfficeKit/LibreOfficeKit.hxx | 5 +-
include/LibreOfficeKit/LibreOfficeKitGtk.h | 4 ++
include/vcl/ITiledRenderable.hxx | 2 -
libreofficekit/source/gtk/lokdocview.c | 18 ++++++++--
sw/inc/unotxdoc.hxx | 2 -
sw/source/uibase/uno/unotxdoc.cxx | 4 +-
11 files changed, 38 insertions(+), 16 deletions(-)
New commits:
commit bf8b2db014a38a1d366c338fe95475df630b586c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Feb 5 14:19:35 2015 +0100
lok::Document::postMouseEvent(): allow double-click
Change-Id: Idaddd28d906e7508d4d2c5aab916b06fbe021beb
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 6966d29..cb798b5 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -103,8 +103,9 @@ public class Document {
* @param type - mouse event type
* @param x - x coordinate
* @param y - y coordinate
+ * @param count - number of events
*/
- public native void postMouseEvent(int type, int x, int y);
+ public native void postMouseEvent(int type, int x, int y, int count);
/**
* Callback to retrieve messages from LOK
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 20fce27..78af14b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -316,7 +316,7 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
int x = (int) pixelToTwip(inDocument.x, mDPI);
int y = (int) pixelToTwip(inDocument.y, mDPI);
- mDocument.postMouseEvent(type, x, y);
+ mDocument.postMouseEvent(type, x, y, 1);
}
@Override
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 154a8f5a..bfe224f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -206,7 +206,8 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
int nType,
int nX,
- int nY);
+ int nY,
+ int nCount);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -647,7 +648,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
pDoc->registerCallback(pCallback, pData);
}
-static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
+static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount)
{
ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
@@ -656,7 +657,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
return;
}
- pDoc->postMouseEvent(nType, nX, nY);
+ pDoc->postMouseEvent(nType, nX, nY, nCount);
}
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 9ea5107..d253cfe 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -278,10 +278,10 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs
}
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postMouseEvent
- (JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y)
+ (JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y, jint count)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
- pDocument->pClass->postMouseEvent(pDocument, type, x, y);
+ pDocument->pClass->postMouseEvent(pDocument, type, x, y, count);
}
/* DirectBufferAllocator */
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index d3b80cd..c76e56b 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -175,7 +175,8 @@ struct _LibreOfficeKitDocumentClass
void (*postMouseEvent)(LibreOfficeKitDocument* pThis,
int nType,
int nX,
- int nY);
+ int nY,
+ int nCount);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f3b3e88..ac315ae 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -111,10 +111,11 @@ public:
* @param nType Event type, like down, move or up.
* @param nX horizontal position in document coordinates
* @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)
+ inline void postMouseEvent(int nType, int nX, int nY, int nCount)
{
- mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY);
+ mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount);
}
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index ea9c9de..fd57139 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -47,6 +47,10 @@ struct _LOKDocView
GdkRectangle m_aVisibleCursor;
/// Cursor is visible or hidden (for blinking).
gboolean m_bCursorVisible;
+ /// Time of the last button press.
+ guint32 m_nLastButtonPressTime;
+ /// Time of the last button release.
+ guint32 m_nLastButtonReleaseTime;
};
struct _LOKDocViewClass
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index b231e98..9edd7a1 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -106,7 +106,7 @@ public:
*
* @see lok::Document::postMouseEvent().
*/
- virtual void postMouseEvent(int /*nType*/, int /*nX*/, int /*nY*/) { }
+ virtual void postMouseEvent(int /*nType*/, int /*nX*/, int /*nY*/, int /*nCount*/) { }
};
} // namespace vcl
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 40fe474..1df8c5c 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -47,11 +47,23 @@ void lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView*
switch (pEvent->type)
{
case GDK_BUTTON_PRESS:
- pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ {
+ int nCount = 1;
+ if ((pEvent->time - pDocView->m_nLastButtonPressTime) < 250)
+ nCount++;
+ pDocView->m_nLastButtonPressTime = pEvent->time;
+ pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y), nCount);
break;
+ }
case GDK_BUTTON_RELEASE:
- pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ {
+ int nCount = 1;
+ if ((pEvent->time - pDocView->m_nLastButtonReleaseTime) < 250)
+ nCount++;
+ pDocView->m_nLastButtonReleaseTime = pEvent->time;
+ pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y), nCount);
break;
+ }
default:
break;
}
@@ -113,6 +125,8 @@ static void lok_docview_init( LOKDocView* pDocView )
pDocView->m_bEdit = FALSE;
memset(&pDocView->m_aVisibleCursor, 0, sizeof(pDocView->m_aVisibleCursor));
pDocView->m_bCursorVisible = FALSE;
+ pDocView->m_nLastButtonPressTime = 0;
+ pDocView->m_nLastButtonReleaseTime = 0;
gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 2d5161e..894a127 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -414,7 +414,7 @@ public:
*/
virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::postMouseEvent().
- virtual void postMouseEvent(int nType, int nX, int nY) SAL_OVERRIDE;
+ virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index e0de39b..70abbac 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3173,12 +3173,12 @@ void SwXTextDocument::registerCallback(LibreOfficeKitCallback pCallback, void* p
pViewShell->registerLibreOfficeKitCallback(pCallback, pData);
}
-void SwXTextDocument::postMouseEvent(int nType, int nX, int nY)
+void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
{
SolarMutexGuard aGuard;
SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
- MouseEvent aEvent(Point(nX, nY), 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
+ MouseEvent aEvent(Point(nX, nY), nCount, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
switch (nType)
{
More information about the Libreoffice-commits
mailing list