diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-01-08 17:13:20 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-01-12 11:06:41 +0100 |
commit | 8de39435246176ed3eb603c177c8c3d26f9027b9 (patch) | |
tree | c0e84eaacb06dd0911c94946ec48a9fdb64a47b8 | |
parent | 8d8729cecd3b1707c936873ec02c9fbca3c66cf2 (diff) |
Add lok::Office::postKeyEvent()
Change-Id: Ib80a8dd433b22a5e88aaab8e11d5c42ced8097ae
-rw-r--r-- | desktop/source/lib/init.cxx | 18 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 4 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 11 | ||||
-rw-r--r-- | vcl/inc/headless/svpframe.hxx | 4 |
4 files changed, 35 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 08a353fbd2d5..c3eedf5b98d7 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 573e44d80d13..d4c1f99dceaa 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 2a5723269d22..fdc025ba14c5 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 d2a786c6bd2d..85e5f6bb4c97 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; } }; |