sd/qa/unit/uiimpress.cxx | 31 +++++++++++++++++++++++++++++++ sd/source/ui/view/drviewse.cxx | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-)
New commits: commit 7c81ce180ddb48cc031be28ef57581d1955d9f1b Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Mon Feb 28 18:40:30 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Mar 7 11:27:47 2022 +0100 tdf#38669 - Create the key event using a Unicode character Instead of using a plain char, create a key event using a Unicode character, otherwise the key event creates texts including rectangles or wrong characters. Change-Id: I9ec0d64998927d54eb3ae90a192c3b28e235f56d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130721 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> (cherry picked from commit 9d25f86236885c40662bcd24517f231688361e8c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131018 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 68786fac3698..286672341a3b 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -745,6 +745,37 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSpellOnlineParameter) CPPUNIT_ASSERT_EQUAL(!bSet, pImpressDocument->GetDoc()->GetOnlineSpell()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf38669) +{ + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); + auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pImpressDocument); + + // Insert shape with ctrl key + uno::Sequence<beans::PropertyValue> aArgs( + comphelper::InitPropertySequence({ { "KeyModifier", uno::makeAny(KEY_MOD1) } })); + dispatchCommand(mxComponent, ".uno:BasicShapes.rectangle", aArgs); + Scheduler::ProcessEventsToIdle(); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws = xDrawPagesSupplier->getDrawPages(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); + + // Insert an UTF-8 character (176 is the code of the degree sign, i.e., '°') + pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 176, 0); + pImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 176, 0); + Scheduler::ProcessEventsToIdle(); + + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(2), uno::UNO_QUERY); + // Without the fix in place, this test would have failed with: + // - Expected: ° + // - Actual : ㅀ + CPPUNIT_ASSERT_EQUAL(OUString(u"°"), xShape->getString()); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf123841) { // To check if selecting unfilled rectangle produces unfilled rectangle diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index f0e76ec6a32f..429ae789856f 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -125,9 +125,9 @@ static void ImpAddPrintableCharactersToTextEdit(SfxRequest const & rReq, ::sd::V { for(sal_Int32 a(0); a < aInputString.getLength(); a++) { - char aChar = static_cast<char>(aInputString[a]); vcl::KeyCode aKeyCode; - KeyEvent aKeyEvent(aChar, aKeyCode); + // tdf#38669 - create the key event using a Unicode character + KeyEvent aKeyEvent(aInputString[a], aKeyCode); // add actual character pOLV->PostKeyEvent(aKeyEvent);