summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-01-21 12:42:08 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-01-26 10:27:42 +0100
commitbb0b878b9d8a63e43c5063b65b1b2381621a18f6 (patch)
treebbbbf5232a6e60dcb176923c58eb44cd2aebc2e6
parent167412ce5e10f2e84ac960eb99bf9ce87df03050 (diff)
LOK: move postMouseEvent to Document
Change-Id: I5d2d2d05fc0f55d98a1e7a1591b4d66fd93ad353
-rw-r--r--desktop/source/lib/init.cxx42
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h10
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx24
-rw-r--r--include/vcl/ITiledRenderable.hxx7
-rw-r--r--libreofficekit/source/gtk/lokdocview.c4
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx12
-rw-r--r--sw/source/uibase/inc/edtwin.hxx3
7 files changed, 60 insertions, 42 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e8f98aa82330..154a8f5ae630 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -203,6 +203,10 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis);
static void doc_registerCallback(LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
void* pData);
+static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -230,6 +234,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
m_pDocumentClass->registerCallback = doc_registerCallback;
+ m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
gDocumentClass = m_pDocumentClass;
}
@@ -253,7 +258,6 @@ static int lo_initialize (LibreOfficeKit* pThis, const ch
static LibreOfficeKitDocument* lo_documentLoad (LibreOfficeKit* pThis, const char* pURL);
static char * lo_getError (LibreOfficeKit* pThis);
static void lo_postKeyEvent (LibreOfficeKit* pThis, int nType, int nCode);
-static void lo_postMouseEvent (LibreOfficeKit* pThis, int nType, int nX, int nY);
struct LibLibreOffice_Impl : public _LibreOfficeKit
@@ -273,7 +277,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
m_pOfficeClass->documentLoad = lo_documentLoad;
m_pOfficeClass->getError = lo_getError;
m_pOfficeClass->postKeyEvent = lo_postKeyEvent;
- m_pOfficeClass->postMouseEvent = lo_postMouseEvent;
gOfficeClass = m_pOfficeClass;
}
@@ -644,6 +647,19 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
pDoc->registerCallback(pCallback, pData);
}
+static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+
+ pDoc->postMouseEvent(nType, nX, nY);
+}
+
+
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
@@ -672,28 +688,6 @@ static void lo_postKeyEvent(LibreOfficeKit* /*pThis*/, int nType, int nCode)
#endif
}
-static void lo_postMouseEvent(LibreOfficeKit* /*pThis*/, int nType, int nX, int nY)
-{
-#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
- if (SalFrame *pFocus = SvpSalFrame::GetFocusFrame())
- {
- MouseEvent aEvent = MouseEvent(Point(nX, nY), 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
- switch (nType)
- {
- case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
- Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pFocus->GetWindow(), &aEvent);
- break;
- case LOK_MOUSEEVENT_MOUSEBUTTONUP:
- Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONUP, pFocus->GetWindow(), &aEvent);
- break;
- default:
- assert(false);
- break;
- }
- }
-#endif
-}
-
static void force_c_locale(void)
{
// force locale (and resource files loaded) to en-US
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 397d435f9c76..991fae43ce98 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -100,7 +100,6 @@ struct _LibreOfficeKitClass
LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit* pThis, const char* pURL);
char* (*getError) (LibreOfficeKit* pThis);
void (*postKeyEvent) (LibreOfficeKit* pThis, int nType, int nCode);
- void (*postMouseEvent)(LibreOfficeKit* pThis, int nType, int nX, int nY);
};
#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
@@ -165,9 +164,12 @@ struct _LibreOfficeKitDocumentClass
void (*registerCallback) (LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
void* pData);
- void (*postKeyEvent) (LibreOfficeKitDocument* pThis,
- int nType,
- int nCode);
+
+ /// @see lok::Document::postMouseEvent
+ void (*postMouseEvent)(LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index bd3ce554b632..f3b3e8830ef0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -104,6 +104,18 @@ public:
{
mpDoc->pClass->registerCallback(mpDoc, pCallback, pData);
}
+
+ /**
+ * Posts a mouse event to the document.
+ *
+ * @param nType Event type, like down, move or up.
+ * @param nX horizontal position in document coordinates
+ * @param nY vertical position in document coordinates
+ */
+ inline void postMouseEvent(int nType, int nX, int nY)
+ {
+ mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY);
+ }
#endif // LOK_USE_UNSTABLE_API
};
@@ -146,18 +158,6 @@ public:
{
mpThis->pClass->postKeyEvent(mpThis, nType, nCode);
}
-
- /**
- * Posts a mouse event to the focused frame.
- *
- * @param nType Event type, like down, move or up.
- * @param nX horizontal position
- * @param nY vertical position
- */
- inline void postMouseEvent(int nType, int nX, int nY)
- {
- mpThis->pClass->postMouseEvent(mpThis, nType, nX, nY);
- }
};
inline Office* lok_cpp_init(const char* pInstallPath)
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 15630c140a0c..871161152476 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -96,6 +96,13 @@ public:
* @param pData is private data of the client that will be sent back when the callback is invoked
*/
virtual void registerCallback(LibreOfficeKitCallback /*pCallback*/, void* /*pData*/) { }
+
+ /**
+ * Posts a mouse event on the document.
+ *
+ * @see lok::Document::postMouseEvent().
+ */
+ virtual void postMouseEvent(int /*nType*/, int /*nX*/, int /*nY*/) { }
};
} // namespace vcl
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 972acab4e10c..bb2444cb1c31 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -45,10 +45,10 @@ void lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView*
switch (pEvent->type)
{
case GDK_BUTTON_PRESS:
- pDocView->pOffice->pClass->postMouseEvent(pDocView->pOffice, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
break;
case GDK_BUTTON_RELEASE:
- pDocView->pOffice->pClass->postMouseEvent(pDocView->pOffice, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
+ pDocView->pDocument->pClass->postMouseEvent(pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
break;
default:
break;
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 7001bf040ae6..fef9d4d83c08 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6250,4 +6250,16 @@ void SwEditWin::LogicInvalidate(const vcl::Region* pRegion)
m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
+void SwEditWin::LogicMouseMove(const MouseEvent& rMouseEvent)
+{
+}
+
+void SwEditWin::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+}
+
+void SwEditWin::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 3866dbf723ef..c28ad6e7bb26 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -302,6 +302,9 @@ public:
* @param pRegion If 0, that means the whole area, otherwise the area in logic coordinates.
*/
void LogicInvalidate(const vcl::Region* pRegion) SAL_OVERRIDE;
+ void LogicMouseMove(const MouseEvent& rMouseEvent);
+ void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+ void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
};
#endif