summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitGtk.h3
-rw-r--r--libreofficekit/Executable_gtktiledviewer.mk2
-rw-r--r--libreofficekit/Library_libreofficekitgtk.mk1
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx67
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx69
5 files changed, 75 insertions, 67 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 1a5b932c75e1..bb8ae78ddbc9 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -68,6 +68,9 @@ gboolean lok_docview_get_edit (LOKDocView* pDocView);
/// Posts the .uno: command to the LibreOfficeKit.
void lok_docview_post_command (LOKDocView* pDocView, const char* pCommand);
+
+/// Posts a keyboard event to LibreOfficeKit.
+void lok_docview_post_key (GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData);
#ifdef __cplusplus
}
#endif
diff --git a/libreofficekit/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk
index d57500c8742f..47c6f96db08e 100644
--- a/libreofficekit/Executable_gtktiledviewer.mk
+++ b/libreofficekit/Executable_gtktiledviewer.mk
@@ -14,8 +14,6 @@ $(eval $(call gb_Executable_set_include,gtktiledviewer,\
-I$(SRCDIR)/desktop/inc \
))
-$(eval $(call gb_Executable_use_sdk_api,gtktiledviewer))
-
$(eval $(call gb_Executable_use_externals,gtktiledviewer,\
gtk \
))
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk
index 01db40f3a917..ff800d0f1d96 100644
--- a/libreofficekit/Library_libreofficekitgtk.mk
+++ b/libreofficekit/Library_libreofficekitgtk.mk
@@ -9,6 +9,7 @@
$(eval $(call gb_Library_Library,libreofficekitgtk))
+$(eval $(call gb_Library_use_sdk_api,libreofficekitgtk))
$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
gtk \
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 194ee41c3c8f..9c1c7ed6ce38 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -12,16 +12,12 @@
#include <string.h>
#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <LibreOfficeKit/LibreOfficeKitGtk.h>
#include <LibreOfficeKit/LibreOfficeKitInit.h>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
-#include <com/sun/star/awt/Key.hpp>
-#include <rsc/rsc-vcl-shared-types.hxx>
-
#ifndef g_info
#define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__)
#endif
@@ -119,65 +115,6 @@ void toggleBold(GtkWidget* /*pButton*/, gpointer /*pItem*/)
lok_docview_post_command(pLOKDocView, ".uno:Bold");
}
-/// Receives a key press or release event.
-static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/)
-{
- LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
- int nCharCode = 0;
- int nKeyCode = 0;
-
- if (!lok_docview_get_edit(pLOKDocView))
- {
- g_info("signalKey: not in edit mode, ignore");
- return;
- }
-
- switch (pEvent->keyval)
- {
- case GDK_BackSpace:
- nKeyCode = com::sun::star::awt::Key::BACKSPACE;
- break;
- case GDK_Return:
- nKeyCode = com::sun::star::awt::Key::RETURN;
- break;
- case GDK_Escape:
- nKeyCode = com::sun::star::awt::Key::ESCAPE;
- break;
- case GDK_Tab:
- nKeyCode = com::sun::star::awt::Key::TAB;
- break;
- case GDK_Down:
- nKeyCode = com::sun::star::awt::Key::DOWN;
- break;
- case GDK_Up:
- nKeyCode = com::sun::star::awt::Key::UP;
- break;
- case GDK_Left:
- nKeyCode = com::sun::star::awt::Key::LEFT;
- break;
- case GDK_Right:
- nKeyCode = com::sun::star::awt::Key::RIGHT;
- break;
- default:
- if (pEvent->keyval >= GDK_F1 && pEvent->keyval <= GDK_F26)
- nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_F1);
- else
- nCharCode = gdk_keyval_to_unicode(pEvent->keyval);
- }
-
- // rsc is not public API, but should be good enough for debugging purposes.
- // If this is needed for real, then probably a new param of type
- // css::awt::KeyModifier is needed in postKeyEvent().
- if (pEvent->state & GDK_SHIFT_MASK)
- nKeyCode |= KEY_SHIFT;
-
- LibreOfficeKitDocument* pDocument = lok_docview_get_document(pLOKDocView);
- if (pEvent->type == GDK_KEY_RELEASE)
- pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
- else
- pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
-}
-
// GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
void populatePartSelector()
@@ -330,8 +267,8 @@ int main( int argc, char* argv[] )
g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
// Input handling.
- g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), NULL);
- g_signal_connect(pWindow, "key-release-event", G_CALLBACK(signalKey), NULL);
+ g_signal_connect(pWindow, "key-press-event", G_CALLBACK(lok_docview_post_key), pDocView);
+ g_signal_connect(pWindow, "key-release-event", G_CALLBACK(lok_docview_post_key), pDocView);
gtk_container_add( GTK_CONTAINER(pVBox), pDocView );
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index fa44b1d709cb..86a7e18d75b7 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -11,10 +11,14 @@
#include <math.h>
#include <string.h>
+#include <gdk/gdkkeysyms.h>
+
+#include <com/sun/star/awt/Key.hpp>
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.h>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <LibreOfficeKit/LibreOfficeKitGtk.h>
+#include <rsc/rsc-vcl-shared-types.hxx>
#if !GLIB_CHECK_VERSION(2,32,0)
#define G_SOURCE_REMOVE FALSE
@@ -104,6 +108,8 @@ struct LOKDocView_Impl
float pixelToTwip(float fInput);
/// Converts from document coordinates to screen pixels.
float twipToPixel(float fInput);
+ /// Receives a key press or release event.
+ void signalKey(GdkEventKey* pEvent);
};
LOKDocView_Impl::LOKDocView_Impl()
@@ -166,6 +172,63 @@ float LOKDocView_Impl::twipToPixel(float fInput)
return fInput / 1440.0f * DPI * m_fZoom;
}
+void LOKDocView_Impl::signalKey(GdkEventKey* pEvent)
+{
+ int nCharCode = 0;
+ int nKeyCode = 0;
+
+ if (!m_bEdit)
+ {
+ g_info("signalKey: not in edit mode, ignore");
+ return;
+ }
+
+ switch (pEvent->keyval)
+ {
+ case GDK_BackSpace:
+ nKeyCode = com::sun::star::awt::Key::BACKSPACE;
+ break;
+ case GDK_Return:
+ nKeyCode = com::sun::star::awt::Key::RETURN;
+ break;
+ case GDK_Escape:
+ nKeyCode = com::sun::star::awt::Key::ESCAPE;
+ break;
+ case GDK_Tab:
+ nKeyCode = com::sun::star::awt::Key::TAB;
+ break;
+ case GDK_Down:
+ nKeyCode = com::sun::star::awt::Key::DOWN;
+ break;
+ case GDK_Up:
+ nKeyCode = com::sun::star::awt::Key::UP;
+ break;
+ case GDK_Left:
+ nKeyCode = com::sun::star::awt::Key::LEFT;
+ break;
+ case GDK_Right:
+ nKeyCode = com::sun::star::awt::Key::RIGHT;
+ break;
+ default:
+ if (pEvent->keyval >= GDK_F1 && pEvent->keyval <= GDK_F26)
+ nKeyCode = com::sun::star::awt::Key::F1 + (pEvent->keyval - GDK_F1);
+ else
+ nCharCode = gdk_keyval_to_unicode(pEvent->keyval);
+ }
+
+ // rsc is not public API, but should be good enough for debugging purposes.
+ // If this is needed for real, then probably a new param of type
+ // css::awt::KeyModifier is needed in postKeyEvent().
+ if (pEvent->state & GDK_SHIFT_MASK)
+ nKeyCode |= KEY_SHIFT;
+
+ if (pEvent->type == GDK_KEY_RELEASE)
+ m_pDocument->pClass->postKeyEvent(m_pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
+ else
+ m_pDocument->pClass->postKeyEvent(m_pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
+}
+
+
static void lok_docview_class_init( gpointer );
static void lok_docview_init( GTypeInstance *, gpointer );
static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData);
@@ -1051,4 +1114,10 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_post_command(LOKDocView* pDocView, const c
pDocView->m_pImpl->m_pDocument->pClass->postUnoCommand(pDocView->m_pImpl->m_pDocument, pCommand);
}
+SAL_DLLPUBLIC_EXPORT void lok_docview_post_key(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer pData)
+{
+ LOKDocView* pDocView = static_cast<LOKDocView *>(pData);
+ pDocView->m_pImpl->signalKey(pEvent);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */