[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 2 commits - desktop/source include/LibreOfficeKit libreofficekit/qa vcl/inc
Miklos Vajna
vmiklos at collabora.co.uk
Thu Jan 8 08:16:28 PST 2015
desktop/source/lib/init.cxx | 18 ++++++++++++++++++
include/LibreOfficeKit/LibreOfficeKit.h | 4 ++++
include/LibreOfficeKit/LibreOfficeKit.hxx | 11 +++++++++++
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 8 +++++++-
vcl/inc/headless/svpframe.hxx | 4 ++--
5 files changed, 42 insertions(+), 3 deletions(-)
New commits:
commit 2056d411d8c1fb352f6c60ddd58a240e04edc15c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 8 17:14:28 2015 +0100
gtktiledviewer: invoke lok::Office::postKeyEvent() on key press / release
Change-Id: I82587fb48f5b7d037d66c0eb0e4aa1c7cee8702a
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index bb3c28a..c4725f2 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -125,8 +125,14 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ )
}
/// Receives a key press or release event.
-static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* /*pEvent*/, gpointer /*pData*/)
+static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/)
{
+ LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
+
+ if (pEvent->type == GDK_KEY_RELEASE)
+ pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, 1, gdk_keyval_to_unicode(pEvent->keyval));
+ else
+ pLOKDocView->pOffice->pClass->postKeyEvent(pLOKDocView->pOffice, 0, gdk_keyval_to_unicode(pEvent->keyval));
}
// GtkComboBox requires gtk 2.24 or later
commit e4037c22988934eb14e99ac6eb7270c582d1c09f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 8 17:13:20 2015 +0100
Add lok::Office::postKeyEvent()
Change-Id: Ib80a8dd433b22a5e88aaab8e11d5c42ced8097ae
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 08a353f..c3eedf5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -54,6 +54,7 @@
#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
#include <headless/svpinst.hxx>
+#include <headless/svpframe.hxx>
#include <headless/svpvd.hxx>
#include <basebmp/bitmapdevice.hxx>
@@ -251,6 +252,8 @@ 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);
+
struct LibLibreOffice_Impl : public _LibreOfficeKit
{
@@ -268,6 +271,7 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
m_pOfficeClass->destroy = lo_destroy;
m_pOfficeClass->documentLoad = lo_documentLoad;
m_pOfficeClass->getError = lo_getError;
+ m_pOfficeClass->postKeyEvent = lo_postKeyEvent;
gOfficeClass = m_pOfficeClass;
}
@@ -647,6 +651,20 @@ static char* lo_getError (LibreOfficeKit *pThis)
return pMemory;
}
+static void lo_postKeyEvent(LibreOfficeKit* /*pThis*/, int nType, int nCode)
+{
+#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
+ if (SalFrame *pFocus = SvpSalFrame::GetFocusFrame())
+ {
+ KeyEvent aEvent(nCode, nCode, 0);
+ if (nType == 0)
+ Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent);
+ else
+ Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent);
+ }
+#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 573e44d..d4c1f99 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -79,6 +79,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);
};
#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
@@ -143,6 +144,9 @@ struct _LibreOfficeKitDocumentClass
void (*registerCallback) (LibreOfficeKitDocument* pThis,
LibreOfficeKitCallback pCallback,
void* pData);
+ void (*postKeyEvent) (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nCode);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 2a57232..fdc025b 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -135,6 +135,17 @@ public:
{
return mpThis->pClass->getError(mpThis);
}
+
+ /**
+ * Posts a keyboard event to the focused frame.
+ *
+ * @param nType Event type, like press or release.
+ * @param nCode Code of the key.
+ */
+ inline void postKeyEvent(int nType, int nCode)
+ {
+ mpThis->pClass->postKeyEvent(mpThis, nType, nCode);
+ }
};
inline Office* lok_cpp_init(const char* pInstallPath)
diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx
index 4154252..08882c4 100644
--- a/vcl/inc/headless/svpframe.hxx
+++ b/vcl/inc/headless/svpframe.hxx
@@ -58,7 +58,7 @@ class SvpSalFrame : public SalFrame
std::list< SvpSalGraphics* > m_aGraphics;
- static SvpSalFrame* s_pFocusFrame;
+ SAL_DLLPUBLIC_EXPORT static SvpSalFrame* s_pFocusFrame;
public:
SvpSalFrame( SvpSalInstance* pInstance,
SalFrame* pParent,
@@ -137,7 +137,7 @@ public:
virtual void SetApplicationID(const OUString &rApplicationID) SAL_OVERRIDE { (void) rApplicationID; }
bool IsVisible() { return m_bVisible; }
- static SvpSalFrame* GetFocusFrame() { return s_pFocusFrame; }
+ SAL_DLLPUBLIC_EXPORT static SvpSalFrame* GetFocusFrame() { return s_pFocusFrame; }
};
More information about the Libreoffice-commits
mailing list