android/Bootstrap/src/org/libreoffice/kit/Office.java | 2 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 25 ++++++++-- desktop/source/lib/init.cxx | 6 +- desktop/source/lib/lokandroid.cxx | 4 - include/LibreOfficeKit/LibreOfficeKit.h | 2 include/LibreOfficeKit/LibreOfficeKit.hxx | 7 +- libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 17 +++--- 7 files changed, 40 insertions(+), 23 deletions(-)
New commits: commit 516c0122c6fd5b68eb316b70b7e96a27d1c9653d Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Feb 17 10:33:47 2015 +0100 lok::Office::postKeyEvent: allow different char and key code editeng is not happy with non-zero char code for css::awt::Key::ESCAPE. Change-Id: If26923df7defb8a47766e9109835a8569067e578 diff --git a/android/Bootstrap/src/org/libreoffice/kit/Office.java b/android/Bootstrap/src/org/libreoffice/kit/Office.java index 25861c9..f344e21 100644 --- a/android/Bootstrap/src/org/libreoffice/kit/Office.java +++ b/android/Bootstrap/src/org/libreoffice/kit/Office.java @@ -39,7 +39,7 @@ public class Office { * @param type - type of key event * @param code - key event code */ - public native void postKeyEvent(int type, int code); + 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 71dd17c..8e7c4f6 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -287,6 +287,23 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback this.tileInvalidationCallback = tileInvalidationCallback; } + /** + * Returns the Unicode character generated by this event or 0. + */ + private int getCharCode(KeyEvent keyEvent) { + switch (keyEvent.getKeyCode()) + { + case KeyEvent.KEYCODE_DEL: + case KeyEvent.KEYCODE_ENTER: + return 0; + } + return keyEvent.getUnicodeChar(); + } + + /** + * Returns the integer code representing the key of the event (non-zero for + * control keys). + */ private int getKeyCode(KeyEvent keyEvent) { switch (keyEvent.getKeyCode()) { @@ -295,19 +312,17 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback case KeyEvent.KEYCODE_ENTER: return com.sun.star.awt.Key.RETURN; } - return keyEvent.getUnicodeChar(); + return 0; } @Override public void keyPress(KeyEvent keyEvent) { - int code = getKeyCode(keyEvent); - mOffice.postKeyEvent(Office.KEY_PRESS, code); + mOffice.postKeyEvent(Office.KEY_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent)); } @Override public void keyRelease(KeyEvent keyEvent) { - int code = getKeyCode(keyEvent); - mOffice.postKeyEvent(Office.KEY_RELEASE, code); + mOffice.postKeyEvent(Office.KEY_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent)); } private void mouseButton(int type, PointF inDocument) { diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d7ca143..bd3a80a 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -262,7 +262,7 @@ static void lo_destroy (LibreOfficeKit* pThis); static int lo_initialize (LibreOfficeKit* pThis, const char* pInstallPath); 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_postKeyEvent (LibreOfficeKit* pThis, int nType, int nCharCode, int nKeyCode); struct LibLibreOffice_Impl : public _LibreOfficeKit @@ -699,12 +699,12 @@ static char* lo_getError (LibreOfficeKit *pThis) return pMemory; } -static void lo_postKeyEvent(LibreOfficeKit* /*pThis*/, int nType, int nCode) +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(nCode, nCode, 0); + KeyEvent aEvent(nCharCode, nKeyCode, 0); switch (nType) { case LOK_KEYEVENT_KEYINPUT: diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx index 5403ea0..9ea1842 100644 --- a/desktop/source/lib/lokandroid.cxx +++ b/desktop/source/lib/lokandroid.cxx @@ -76,10 +76,10 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_destroyAn } extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_postKeyEvent - (JNIEnv* pEnv, jobject aObject, jint nType, jint nCode) + (JNIEnv* pEnv, jobject aObject, jint nType, jint nCharCode, jint nKeyCode) { LibreOfficeKit* pLibreOfficeKit = getHandle<LibreOfficeKit>(pEnv, aObject); - pLibreOfficeKit->pClass->postKeyEvent(pLibreOfficeKit, nType, nCode); + pLibreOfficeKit->pClass->postKeyEvent(pLibreOfficeKit, nType, nCharCode, nKeyCode); } namespace diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 9c5cca5..46346bc 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -143,7 +143,7 @@ struct _LibreOfficeKitClass void (*destroy) (LibreOfficeKit* pThis); LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit* pThis, const char* pURL); char* (*getError) (LibreOfficeKit* pThis); - void (*postKeyEvent) (LibreOfficeKit* pThis, int nType, int nCode); + void (*postKeyEvent) (LibreOfficeKit* pThis, int nType, int nCharCode, int nKeyCode); }; #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize) diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index ef365ce..6476e8f 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -165,11 +165,12 @@ public: * Posts a keyboard event to the focused frame. * * @param nType Event type, like press or release. - * @param nCode Code of the key. + * @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 nCode) + inline void postKeyEvent(int nType, int nCharCode, int nKeyCode) { - mpThis->pClass->postKeyEvent(mpThis, nType, nCode); + mpThis->pClass->postKeyEvent(mpThis, nType, nCharCode, nKeyCode); } }; diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index c2fc02b..fbaa97f 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -135,7 +135,8 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ ) static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/) { LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView); - int nCode = 0; + int nCharCode = 0; + int nKeyCode = 0; if (!pLOKDocView->m_bEdit) { @@ -146,25 +147,25 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD switch (pEvent->keyval) { case GDK_BackSpace: - nCode = com::sun::star::awt::Key::BACKSPACE; + nKeyCode = com::sun::star::awt::Key::BACKSPACE; break; case GDK_Return: - nCode = com::sun::star::awt::Key::RETURN; + nKeyCode = com::sun::star::awt::Key::RETURN; break; case GDK_Escape: - nCode = com::sun::star::awt::Key::ESCAPE; + nKeyCode = com::sun::star::awt::Key::ESCAPE; break; default: if (pEvent->keyval >= GDK_F1 && pEvent->keyval <= GDK_F26) - nCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_F1); + nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_F1); else - nCode = gdk_keyval_to_unicode(pEvent->keyval); + nCharCode = gdk_keyval_to_unicode(pEvent->keyval); } if (pEvent->type == GDK_KEY_RELEASE) - pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYUP, nCode); + pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode); else - pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYINPUT, nCode); + pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode); } // GtkComboBox requires gtk 2.24 or later _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits