[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit include/vcl sc/inc sc/qa sc/source sd/qa sd/source sw/inc sw/qa sw/source vcl/source
Pranav Kant
pranavk at collabora.co.uk
Wed Feb 14 18:20:01 UTC 2018
desktop/source/lib/init.cxx | 36 +++++++++++++++++++++----
include/LibreOfficeKit/LibreOfficeKit.h | 1
include/LibreOfficeKit/LibreOfficeKit.hxx | 6 ++--
include/vcl/ITiledRenderable.hxx | 12 +++-----
sc/inc/docuno.hxx | 6 ++--
sc/qa/unit/tiledrendering/tiledrendering.cxx | 6 ++--
sc/source/ui/unoobj/docuno.cxx | 34 ++++++-----------------
sd/qa/unit/tiledrendering/tiledrendering.cxx | 6 ++--
sd/source/ui/inc/unomodel.hxx | 3 --
sd/source/ui/unoidl/unomodel.cxx | 36 ++++++-------------------
sw/inc/unotxdoc.hxx | 4 +-
sw/qa/extras/tiledrendering/tiledrendering.cxx | 6 ++--
sw/source/uibase/uno/unotxdoc.cxx | 30 ++++++--------------
vcl/source/window/window.cxx | 8 ++++-
14 files changed, 96 insertions(+), 98 deletions(-)
New commits:
commit 712540224d7c5c8cdb4a5214e2d7963a314c1928
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Wed Feb 14 17:33:16 2018 +0530
lok IME: support dialogs as well
Change-Id: Ic78da45dadaa5a4e1ca78e20d04974108581121e
Reviewed-on: https://gerrit.libreoffice.org/49714
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: pranavk <pranavk at collabora.co.uk>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bc788d243b9e..8d0611c21d07 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -543,6 +543,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
int nCharCode,
int nKeyCode);
static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis,
+ unsigned nWindowId,
int nType,
const char* pText);
static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
@@ -2298,18 +2299,43 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
}
-static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis, int nType, const char* pText)
+static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText)
{
SolarMutexGuard aGuard;
+ VclPtr<vcl::Window> pWindow;
+ if (nWindowId == 0)
+ {
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+ pWindow = pDoc->getDocWindow();
+ }
+ else
+ {
+ pWindow = vcl::Window::FindLOKWindow(nWindowId);
+ }
- ITiledRenderable* pDoc = getTiledRenderable(pThis);
- if (!pDoc)
+ if (!pWindow)
{
- gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ gImpl->maLastExceptionMsg = "No window found for window id: " + OUString::number(nWindowId);
return;
}
- pDoc->postExtTextInputEvent(nType, OUString::fromUtf8(OString(pText, strlen(pText))));
+ switch (nType)
+ {
+ case LOK_EXT_TEXTINPUT:
+ pWindow->PostExtTextInputEvent(VclEventId::ExtTextInput,
+ OUString::fromUtf8(OString(pText, strlen(pText))));
+ break;
+ case LOK_EXT_TEXTINPUT_END:
+ pWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
+ break;
+ default:
+ assert(false && "Unhandled External Text input event!");
+ }
}
static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index ebc112fb7bd5..7492fcc7a561 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -302,6 +302,7 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::postExtTextInputEvent
void (*postExtTextInputEvent) (LibreOfficeKitDocument* pThis,
+ unsigned nWindowId,
int nType,
const char* pText);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 0983560898a4..55e29ebda1c8 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -540,12 +540,14 @@ public:
/**
* Post the text input from external input window, like IME
*
+ * @param nWindowId Specify the window id to post the input event to. If
+ * nWindow is 0, the event is posted into the document
* @param nType see LibreOfficeKitExtTextInputType
* @param pText Text for LOK_EXT_TEXTINPUT
*/
- void postExtTextInputEvent(int nType, const char* pText)
+ void postExtTextInputEvent(unsigned nWindowId, int nType, const char* pText)
{
- mpDoc->pClass->postExtTextInputEvent(mpDoc, nType, pText);
+ mpDoc->pClass->postExtTextInputEvent(mpDoc, nWindowId, nType, pText);
}
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index de3b098a496d..5a7034d476d0 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -81,6 +81,11 @@ public:
}
/**
+ * Get the vcl::Window for the document being edited
+ */
+ virtual VclPtr<vcl::Window> getDocWindow() = 0;
+
+ /**
* Get the hash of the currently displayed part, i.e. sheet in a spreadsheet
* or slide in a presentation.
*/
@@ -103,13 +108,6 @@ public:
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) = 0;
/**
- * Posts an external text input event
- *
- * @see lok::Document::postExtTextInputEvent().
- */
- virtual void postExtTextInputEvent(int nType, const OUString& rText) = 0;
-
- /**
* Posts a mouse event on the document.
*
* @see lok::Document::postMouseEvent().
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 6cf2cc35c360..5e1ce12bd37a 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -319,15 +319,15 @@ public:
/// @see vcl::ITiledRenderable::getPartHash().
virtual OUString getPartHash( int nPart ) override;
+ /// @see vcl::ITiledRenderable::getDocWindow().
+ virtual VclPtr<vcl::Window> getDocWindow() override;
+
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
/// @see vcl::ITiledRenderable::postKeyEvent().
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) override;
- /// @see vcl::ITiledRenderable::postExtTextInputEvent().
- virtual void postExtTextInputEvent(int nType, const OUString& rText) override;
-
/// @see vcl::ITiledRenderable::postMouseEvent().
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override;
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index d306b32afd46..e70d4f17b3f7 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -33,6 +33,7 @@
#include <sfx2/lokhelper.hxx>
#include <svx/svdpage.hxx>
#include <vcl/scheduler.hxx>
+#include <vcl/vclevent.hxx>
#include <chrono>
#include <cstddef>
@@ -1575,6 +1576,7 @@ void ScTiledRenderingTest::testIMESupport()
comphelper::LibreOfficeKit::setActive();
ScModelObj* pModelObj = createDoc("empty.ods");
+ VclPtr<vcl::Window> pDocWindow = pModelObj->getDocWindow();
ScDocument* pDoc = pModelObj->GetDocument();
ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
@@ -1590,9 +1592,9 @@ void ScTiledRenderingTest::testIMESupport()
});
for (const auto& aInput: aInputs)
{
- pModelObj->postExtTextInputEvent(LOK_EXT_TEXTINPUT, aInput);
+ pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, aInput);
}
- pModelObj->postExtTextInputEvent(LOK_EXT_TEXTINPUT_END, "");
+ pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
// commit the string to the cell
pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d12a063a926a..b64645dfe667 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -549,6 +549,16 @@ OUString ScModelObj::getPartHash( int nPart )
return (pViewData->GetDocument()->GetHashCode(nPart, nHashCode) ? OUString::number(nHashCode) : OUString());
}
+VclPtr<vcl::Window> ScModelObj::getDocWindow()
+{
+ SolarMutexGuard aGuard;
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ VclPtr<vcl::Window> pWindow;
+ if (pViewData)
+ pWindow = pViewData->GetActiveWin();
+ return pWindow;
+}
+
Size ScModelObj::getDocumentSize()
{
Size aSize(10, 10); // minimum size
@@ -619,30 +629,6 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
}
}
-void ScModelObj::postExtTextInputEvent(int nType, const OUString& rText)
-{
- SolarMutexGuard aGuard;
-
- ScViewData* pViewData = ScDocShell::GetViewData();
- vcl::Window* pWindow = pViewData->GetActiveWin();
-
- if (!pWindow)
- return;
-
- CommandExtTextInputData aTextInputData(rText, nullptr, 0, 0, false);
- switch (nType)
- {
- case LOK_EXT_TEXTINPUT:
- pWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, rText);
- break;
- case LOK_EXT_TEXTINPUT_END:
- pWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
- break;
- default:
- assert(false && "Unhandled External Text input event!");
- }
-}
-
void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
SolarMutexGuard aGuard;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 6990b25ae3ce..dbb77a32b3e8 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -49,6 +49,7 @@
#include <DrawViewShell.hxx>
#include <pres.hxx>
#include <vcl/scheduler.hxx>
+#include <vcl/vclevent.hxx>
#include <chrono>
@@ -1948,6 +1949,7 @@ void SdTiledRenderingTest::testIMESupport()
comphelper::LibreOfficeKit::setActive();
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ VclPtr<vcl::Window> pDocWindow = pXImpressDocument->getDocWindow();
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
SdrObject* pObject = pViewShell->GetActualPage()->GetObj(0);
SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pObject);
@@ -1966,9 +1968,9 @@ void SdTiledRenderingTest::testIMESupport()
});
for (const auto& aInput: aInputs)
{
- pXImpressDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT, aInput);
+ pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, aInput);
}
- pXImpressDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT_END, "");
+ pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
// the cursor should be at position 3rd
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 096afe120ccf..67770cc27313 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -239,6 +239,7 @@ public:
virtual int getParts() override;
virtual OUString getPartName( int nPart ) override;
virtual OUString getPartHash( int nPart ) override;
+ virtual VclPtr<vcl::Window> getDocWindow() override;
virtual void setPartMode( int nPartMode ) override;
@@ -246,8 +247,6 @@ public:
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
/// @see vcl::ITiledRenderable::postKeyEvent().
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) override;
- /// @see vcl::ITiledRenderable::postExtTextInputEvent().
- virtual void postExtTextInputEvent(int nType, const OUString& rText) override;
/// @see vcl::ITiledRenderable::postMouseEvent().
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override;
/// @see vcl::ITiledRenderable::setTextSelection().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 973702c926be..50702bed3a3e 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2337,6 +2337,16 @@ OUString SdXImpressDocument::getPartHash( int nPart )
return OUString::number(pPage->GetHashCode());
}
+VclPtr<vcl::Window> SdXImpressDocument::getDocWindow()
+{
+ SolarMutexGuard aGuard;
+ DrawViewShell* pViewShell = GetViewShell();
+ VclPtr<vcl::Window> pWindow;
+ if (pViewShell)
+ pWindow = pViewShell->GetActiveWindow();
+ return pWindow;
+}
+
void SdXImpressDocument::setPartMode( int nPartMode )
{
DrawViewShell* pViewSh = GetViewShell();
@@ -2487,32 +2497,6 @@ void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
}
}
-void SdXImpressDocument::postExtTextInputEvent(int nType, const OUString& rText)
-{
- SolarMutexGuard aGuard;
-
- DrawViewShell* pViewShell = GetViewShell();
- if (!pViewShell)
- return;
-
- vcl::Window* pWindow = pViewShell->GetActiveWindow();
- if (!pWindow)
- return;
-
- CommandExtTextInputData aTextInputData(rText, nullptr, 0, 0, false);
- switch (nType)
- {
- case LOK_EXT_TEXTINPUT:
- pWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, rText);
- break;
- case LOK_EXT_TEXTINPUT_END:
- pWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
- break;
- default:
- assert(false && "Unhandled External Text input event!");
- }
-}
-
void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
SolarMutexGuard aGuard;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index fe01d4722b6c..472ea5015cd5 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -399,12 +399,12 @@ public:
virtual OUString getPartName(int nPart) override;
/// @see vcl::ITiledRenderable::getPartHash().
virtual OUString getPartHash(int nPart) override;
+ /// @see vcl::ITiledRenderable::getDocWindow().
+ virtual VclPtr<vcl::Window> getDocWindow() override;
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
/// @see vcl::ITiledRenderable::postKeyEvent().
virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) override;
- /// @see vcl::ITiledRenderable::postExtTextInputEvent().
- virtual void postExtTextInputEvent(int nType, const OUString& rText) override;
/// @see vcl::ITiledRenderable::postMouseEvent().
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override;
/// @see vcl::ITiledRenderable::setTextSelection().
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 68fae582f70a..226291ac7422 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -38,6 +38,7 @@
#include <redline.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <vcl/scheduler.hxx>
+#include <vcl/vclevent.hxx>
#include <flddat.hxx>
static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/";
@@ -2094,6 +2095,7 @@ void SwTiledRenderingTest::testIMESupport()
{
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ VclPtr<vcl::Window> pDocWindow = pXTextDocument->getDocWindow();
SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
assert(pView);
@@ -2108,9 +2110,9 @@ void SwTiledRenderingTest::testIMESupport()
});
for (const auto& aInput: aInputs)
{
- pXTextDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT, aInput);
+ pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, aInput);
}
- pXTextDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT_END, "");
+ pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
// the cursor should be at position 2nd
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 19f7c24b2a37..63f5d0faceba 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3399,6 +3399,16 @@ OUString SwXTextDocument::getPartHash(int nPart)
return OUString::number(sPart.hashCode());
}
+VclPtr<vcl::Window> SwXTextDocument::getDocWindow()
+{
+ SolarMutexGuard aGuard;
+ VclPtr<vcl::Window> pWindow;
+ SwView* pView = pDocShell->GetView();
+ if (pView)
+ pWindow = &(pView->GetEditWin());
+ return pWindow;
+}
+
void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
{
SolarMutexGuard aGuard;
@@ -3495,26 +3505,6 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
}
}
-void SwXTextDocument::postExtTextInputEvent(int nType, const OUString& rText)
-{
- SolarMutexGuard aGuard;
-
- vcl::Window* pWindow = &(pDocShell->GetView()->GetEditWin());
-
- CommandExtTextInputData aTextInputData(rText, nullptr, 0, 0, false);
- switch (nType)
- {
- case LOK_EXT_TEXTINPUT:
- pWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, rText);
- break;
- case LOK_EXT_TEXTINPUT_END:
- pWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, "");
- break;
- default:
- assert(false && "Unhandled External Text input event!");
- }
-}
-
void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
SolarMutexGuard aGuard;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index c93e194ab88c..6a9612f36e8e 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2076,8 +2076,14 @@ void Window::PostExtTextInputEvent(VclEventId nType, const OUString& rText)
{
case VclEventId::ExtTextInput:
{
- SalExtTextInputEvent aEvent { rText, nullptr, rText.getLength(), 0 };
+ std::unique_ptr<ExtTextInputAttr[]> pAttr(new ExtTextInputAttr[rText.getLength()]);
+ for (int i = 0; i < rText.getLength(); ++i) {
+ pAttr[i] = ExtTextInputAttr::NONE;
+ }
+ SalExtTextInputEvent aEvent { rText, pAttr.get(), rText.getLength(), EXTTEXTINPUT_CURSOR_OVERWRITE };
ImplWindowFrameProc(this, SalEvent::ExtTextInput, &aEvent);
+ SalExtTextInputPosEvent evt;
+ ImplWindowFrameProc(this, SalEvent::ExtTextInputPos, &evt);
}
break;
case VclEventId::EndExtTextInput:
More information about the Libreoffice-commits
mailing list