summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2018-02-07 21:23:42 +0530
committerpranavk <pranavk@collabora.co.uk>2018-02-13 10:07:23 +0100
commit5f84c096edff526d8c5f0c603c1f5344d4d45525 (patch)
tree6bcebd2318f0fb0c78d654b097850c870c3cc7d0 /sc
parent758eafa1e2dd342ed47552c2b1cf13cc6d88b7ba (diff)
sd, sc lok: IME support + unit tests
Change-Id: I710ba4347977641102b89fd274a159d34bc29e72 Reviewed-on: https://gerrit.libreoffice.org/49385 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk> (cherry picked from commit b746577d27437f9298fa111512d083eaccd4fbed) Reviewed-on: https://gerrit.libreoffice.org/49624 Tested-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/docuno.hxx3
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx35
-rw-r--r--sc/source/ui/unoobj/docuno.cxx25
3 files changed, 63 insertions, 0 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index e37f11a9ba49..4c4e74583023 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -385,6 +385,9 @@ public:
/// @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 f8357435f0e3..801f7ad55288 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -81,6 +81,7 @@ public:
void testDocumentRepair();
void testLanguageStatus();
void testMultiViewCopyPaste();
+ void testIMESupport();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -111,6 +112,7 @@ public:
CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
CPPUNIT_TEST(testMultiViewCopyPaste);
+ CPPUNIT_TEST(testIMESupport);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1559,6 +1561,39 @@ void ScTiledRenderingTest::testMultiViewCopyPaste()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testIMESupport()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ ScModelObj* pModelObj = createDoc("empty.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
+
+ ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ CPPUNIT_ASSERT(pView);
+
+ pView->SetCursor(0, 0);
+ // sequence of chineese IME compositions when 'nihao' is typed in an IME
+ const std::vector<OString> aUtf8Inputs{ "年", "你", "你好", "你哈", "你好", "你好" };
+ std::vector<OUString> aInputs;
+ std::transform(aUtf8Inputs.begin(), aUtf8Inputs.end(),
+ std::back_inserter(aInputs), [](OString aInput) {
+ return OUString::fromUtf8(aInput);
+ });
+ for (const auto& aInput: aInputs)
+ {
+ pModelObj->postExtTextInputEvent(LOK_EXT_TEXTINPUT, aInput);
+ }
+ pModelObj->postExtTextInputEvent(LOK_EXT_TEXTINPUT_END, "");
+
+ // commit the string to the cell
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+
+ CPPUNIT_ASSERT_EQUAL(aInputs[aInputs.size() - 1], pDoc->GetString(ScAddress(0, 0, 0)));
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index dbd63f6ad14b..fafd3b466102 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -42,6 +42,7 @@
#include <sfx2/printer.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
+#include <vcl/commandevent.hxx>
#include <vcl/pdfextoutdevdata.hxx>
#include <vcl/waitobj.hxx>
#include <unotools/charclass.hxx>
@@ -615,6 +616,30 @@ 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;