[Libreoffice-commits] core.git: include/vcl sc/inc sc/qa sc/source sd/qa sd/source
Pranav Kant
pranavk at collabora.co.uk
Thu Feb 8 08:45:15 UTC 2018
include/vcl/ITiledRenderable.hxx | 2 -
sc/inc/docuno.hxx | 3 +
sc/qa/unit/tiledrendering/tiledrendering.cxx | 35 ++++++++++++++++++++++
sc/source/ui/unoobj/docuno.cxx | 25 ++++++++++++++++
sd/qa/unit/tiledrendering/tiledrendering.cxx | 42 +++++++++++++++++++++++++++
sd/source/ui/inc/unomodel.hxx | 2 +
sd/source/ui/unoidl/unomodel.cxx | 27 +++++++++++++++++
7 files changed, 135 insertions(+), 1 deletion(-)
New commits:
commit b746577d27437f9298fa111512d083eaccd4fbed
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Wed Feb 7 21:23:42 2018 +0530
sd, sc lok: IME support + unit tests
Change-Id: I710ba4347977641102b89fd274a159d34bc29e72
Reviewed-on: https://gerrit.libreoffice.org/49385
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: pranavk <pranavk at collabora.co.uk>
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 135f74064afa..de3b098a496d 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -107,7 +107,7 @@ public:
*
* @see lok::Document::postExtTextInputEvent().
*/
- virtual void postExtTextInputEvent(int /*nType*/, const OUString& /*rText*/) {}
+ virtual void postExtTextInputEvent(int nType, const OUString& rText) = 0;
/**
* Posts a mouse event on the document.
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index aa55a1ad4c35..6cf2cc35c360 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -325,6 +325,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 a1dd154f4717..e70ec8b519a5 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -89,6 +89,7 @@ public:
void testDocumentRepair();
void testLanguageStatus();
void testMultiViewCopyPaste();
+ void testIMESupport();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -119,6 +120,7 @@ public:
CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
CPPUNIT_TEST(testMultiViewCopyPaste);
+ CPPUNIT_TEST(testIMESupport);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1568,6 +1570,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 70c8123711af..d12a063a926a 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -44,6 +44,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>
@@ -618,6 +619,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;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 93c76ffaa037..c32e9876971c 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -107,6 +107,7 @@ public:
void testDocumentRepair();
void testLanguageStatus();
void testDefaultView();
+ void testIMESupport();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -147,6 +148,7 @@ public:
CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
CPPUNIT_TEST(testDefaultView);
+ CPPUNIT_TEST(testIMESupport);
CPPUNIT_TEST_SUITE_END();
@@ -1940,6 +1942,46 @@ void SdTiledRenderingTest::testDefaultView()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testIMESupport()
+{
+ // Load the document with notes view.
+ comphelper::LibreOfficeKit::setActive();
+
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdrObject* pObject = pViewShell->GetActualPage()->GetObj(0);
+ SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pObject);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pTextObj, pView->GetSdrPageView());
+ SfxStringItem aInputString(SID_ATTR_CHAR, "x");
+ pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(SID_ATTR_CHAR,
+ SfxCallMode::SYNCHRON, { &aInputString });
+
+ // 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)
+ {
+ pXImpressDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT, aInput);
+ }
+ pXImpressDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT_END, "");
+
+ // the cursor should be at position 3rd
+ EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), rEditView.GetSelection().nStartPos);
+
+ ESelection aWordSelection(0, 0, 0, 3); // start para, start char, end para, end char.
+ rEditView.SetSelection(aWordSelection);
+ // content contains only the last IME composition, not all
+ CPPUNIT_ASSERT_EQUAL(OUString("x").concat(aInputs[aInputs.size() - 1]), rEditView.GetSelected());
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 03924470f724..096afe120ccf 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -246,6 +246,8 @@ 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 9eff10023c07..973702c926be 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -45,6 +45,7 @@
#include "unopool.hxx"
#include <sfx2/dispatch.hxx>
#include <sfx2/bindings.hxx>
+#include <vcl/commandevent.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -2486,6 +2487,32 @@ 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;
More information about the Libreoffice-commits
mailing list