android/Bootstrap/src/org/libreoffice/kit/Document.java | 8 + android/Bootstrap/src/org/libreoffice/kit/Office.java | 8 - android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 6 - desktop/source/lib/init.cxx | 45 +++++----- desktop/source/lib/lokandroid.cxx | 14 +-- include/LibreOfficeKit/LibreOfficeKit.h | 8 + include/LibreOfficeKit/LibreOfficeKit.hxx | 26 ++--- libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 4 8 files changed, 61 insertions(+), 58 deletions(-)
New commits: commit 36293a5d1db27ee022a7d00536f1d389417b17ce Author: Miklos Vajna <[email protected]> Date: Fri Feb 27 15:38:30 2015 +0100 LOK: move Office::postKeyEvent to Document The implementation still sends them to the currently active VCL frame, not to the given document, though. Change-Id: I6fa2decdea3f949c55287e802cb3373c85664207 diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java index f410693..c692099 100644 --- a/android/Bootstrap/src/org/libreoffice/kit/Document.java +++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java @@ -107,6 +107,14 @@ public class Document { public native void initializeForRendering(); /** + * Post a key event to LibreOffice. + * @param type - type of key event + * @param charCode - the Unicode character generated by this event or 0. + * @param keyCode - the integer code representing the key of the event (non-zero for control keys). + */ + public native void postKeyEvent(int type, int charCode, int keyCode); + + /** * Post a mouse event to LOK * @param type - mouse event type * @param x - x coordinate diff --git a/android/Bootstrap/src/org/libreoffice/kit/Office.java b/android/Bootstrap/src/org/libreoffice/kit/Office.java index 8bd780b..86eda5c 100644 --- a/android/Bootstrap/src/org/libreoffice/kit/Office.java +++ b/android/Bootstrap/src/org/libreoffice/kit/Office.java @@ -34,14 +34,6 @@ public class Office { return document; } - /** - * Post a key event to LibreOffice. - * @param type - type of key event - * @param charCode - the Unicode character generated by this event or 0. - * @param keyCode - the integer code representing the key of the event (non-zero for control keys). - */ - public native void postKeyEvent(int type, int charCode, int keyCode); - public native void destroy(); public native void destroyAndExit(); } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index c2d59e0..7a90382 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -313,12 +313,12 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback String keyString = keyEvent.getCharacters(); for (int i = 0; i < keyString.length(); i++) { int codePoint = keyString.codePointAt(i); - mOffice.postKeyEvent(Office.KEY_PRESS, codePoint, getKeyCode(keyEvent)); + mDocument.postKeyEvent(Office.KEY_PRESS, codePoint, getKeyCode(keyEvent)); } } else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { - mOffice.postKeyEvent(Office.KEY_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent)); + mDocument.postKeyEvent(Office.KEY_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent)); } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) { - mOffice.postKeyEvent(Office.KEY_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent)); + mDocument.postKeyEvent(Office.KEY_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent)); } } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4aea3d0..0c2f4a9 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_postKeyEvent(LibreOfficeKitDocument* pThis, + int nType, + int nCharCode, + int nKeyCode); static void doc_postMouseEvent (LibreOfficeKitDocument* pThis, int nType, int nX, @@ -239,6 +243,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument m_pDocumentClass->getDocumentSize = doc_getDocumentSize; m_pDocumentClass->initializeForRendering = doc_initializeForRendering; m_pDocumentClass->registerCallback = doc_registerCallback; + m_pDocumentClass->postKeyEvent = doc_postKeyEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent; m_pDocumentClass->setTextSelection = doc_setTextSelection; @@ -266,7 +271,6 @@ static char * lo_getError (LibreOfficeKit* pThis); static LibreOfficeKitDocument* lo_documentLoadWithOptions (LibreOfficeKit* pThis, const char* pURL, const char* pOptions); -static void lo_postKeyEvent (LibreOfficeKit* pThis, int nType, int nCharCode, int nKeyCode); struct LibLibreOffice_Impl : public _LibreOfficeKit @@ -286,7 +290,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit m_pOfficeClass->documentLoad = lo_documentLoad; m_pOfficeClass->getError = lo_getError; m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions; - m_pOfficeClass->postKeyEvent = lo_postKeyEvent; gOfficeClass = m_pOfficeClass; } @@ -693,6 +696,25 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, pDoc->registerCallback(pCallback, pData); } +static void doc_postKeyEvent(LibreOfficeKitDocument* /*pThis*/, int nType, int nCharCode, int nKeyCode) +{ +#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS) + if (SalFrame *pFocus = SvpSalFrame::GetFocusFrame()) + { + KeyEvent aEvent(nCharCode, nKeyCode, 0); + switch (nType) + { + case LOK_KEYEVENT_KEYINPUT: + Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent); + break; + case LOK_KEYEVENT_KEYUP: + Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent); + break; + } + } +#endif +} + static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX, int nY, int nCount) { ITiledRenderable* pDoc = getTiledRenderable(pThis); @@ -726,25 +748,6 @@ static char* lo_getError (LibreOfficeKit *pThis) return pMemory; } -static void lo_postKeyEvent(LibreOfficeKit* /*pThis*/, int nType, int nCharCode, int nKeyCode) -{ -#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS) - if (SalFrame *pFocus = SvpSalFrame::GetFocusFrame()) - { - KeyEvent aEvent(nCharCode, nKeyCode, 0); - switch (nType) - { - case LOK_KEYEVENT_KEYINPUT: - Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent); - break; - case LOK_KEYEVENT_KEYUP: - Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent); - break; - } - } -#endif -} - static void force_c_locale(void) { // force locale (and resource files loaded) to en-US diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx index a4f7297..528ffe1 100644 --- a/desktop/source/lib/lokandroid.cxx +++ b/desktop/source/lib/lokandroid.cxx @@ -75,13 +75,6 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_destroyAn _exit(0); } -extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_postKeyEvent - (JNIEnv* pEnv, jobject aObject, jint nType, jint nCharCode, jint nKeyCode) -{ - LibreOfficeKit* pLibreOfficeKit = getHandle<LibreOfficeKit>(pEnv, aObject); - pLibreOfficeKit->pClass->postKeyEvent(pLibreOfficeKit, nType, nCharCode, nKeyCode); -} - namespace { @@ -277,6 +270,13 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs return result; } +extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postKeyEvent + (JNIEnv* pEnv, jobject aObject, jint nType, jint nCharCode, jint nKeyCode) +{ + LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject); + pDocument->pClass->postKeyEvent(pDocument, nType, nCharCode, nKeyCode); +} + extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postMouseEvent (JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y, jint count) { diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index f8a62b2..ea9846a 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -49,9 +49,6 @@ struct _LibreOfficeKitClass LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis, const char* pURL, const char* pOptions); -#ifdef LOK_USE_UNSTABLE_API - void (*postKeyEvent) (LibreOfficeKit* pThis, int nType, int nCharCode, int nKeyCode); -#endif // LOK_USE_UNSTABLE_API }; #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize) @@ -125,6 +122,11 @@ struct _LibreOfficeKitDocumentClass LibreOfficeKitCallback pCallback, void* pData); + /// @see lok::Document::postKeyEvent + void (*postKeyEvent)(LibreOfficeKitDocument* pThis, + int nType, + int nCharCode, + int nKeyCode); /// @see lok::Document::postMouseEvent void (*postMouseEvent)(LibreOfficeKitDocument* pThis, int nType, diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index f8d6e19..a442382 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -106,6 +106,18 @@ public: } /** + * Posts a keyboard event to the focused frame. + * + * @param nType Event type, like press or release. + * @param nCharCode contains the Unicode character generated by this event or 0 + * @param nKeyCode contains the integer code representing the key of the event (non-zero for control keys) + */ + inline void postKeyEvent(int nType, int nCharCode, int nKeyCode) + { + mpDoc->pClass->postKeyEvent(mpDoc, nType, nCharCode, nKeyCode); + } + + /** * Posts a mouse event to the document. * * @param nType Event type, like down, move or up. @@ -167,20 +179,6 @@ public: { return mpThis->pClass->getError(mpThis); } - -#ifdef LOK_USE_UNSTABLE_API - /** - * Posts a keyboard event to the focused frame. - * - * @param nType Event type, like press or release. - * @param nCharCode contains the Unicode character generated by this event or 0 - * @param nKeyCode contains the integer code representing the key of the event (non-zero for control keys) - */ - inline void postKeyEvent(int nType, int nCharCode, int nKeyCode) - { - mpThis->pClass->postKeyEvent(mpThis, nType, nCharCode, nKeyCode); - } -#endif // LOK_USE_UNSTABLE_API }; inline Office* lok_cpp_init(const char* pInstallPath) diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index c840c8c..cfa108e 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -186,9 +186,9 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD nKeyCode |= KEY_SHIFT; if (pEvent->type == GDK_KEY_RELEASE) - pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode); + pLOKDocView->pDocument->pClass->postKeyEvent(pLOKDocView->pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode); else - pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode); + pLOKDocView->pDocument->pClass->postKeyEvent(pLOKDocView->pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode); } // GtkComboBox requires gtk 2.24 or later _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
