diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-12-17 13:19:28 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-01-23 19:53:58 +0100 |
commit | 218acb48df79101392c2cc3a030ddb5dcee878c7 (patch) | |
tree | 2026a703f5629ee075843eb0692c5171e956cada /sw/qa/extras | |
parent | 1cc2690fe2f87e8acce4e9b4e0cb533fda26e295 (diff) |
tdf#146728 lok: IME: preset formatting in the new paragraph
When we wrote something using Heading or Title style and
then moved to the next paragraph by pressing enter
we should get "Text Body" style in the new line.
Do not copy style. Use NOHINTEXPAND when inserting initially
so we can use EMPTYEXPAND later - at the end of composing -
and use correct styling.
followup for:
lok: IME: directly copy formatting for inserted text
d8dbd123bfa7f39489ceb15ac83142635531fd43
https://cgit.freedesktop.org/libreoffice/core/commit/?id=d8dbd123bfa7f39489ceb15ac83142635531fd43
Change-Id: I55b764068337e125eea3fba641edb6486b2ac9d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127875
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ash@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128832
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 9a09dc504a0f..cc50ef8e9c83 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -139,6 +139,7 @@ public: void testRedlineField(); void testIMESupport(); void testIMEFormattingAtEndOfParagraph(); + void testIMEFormattingAfterHeader(); void testSplitNodeRedlineCallback(); void testDeleteNodeRedlineCallback(); void testVisCursorInvalidation(); @@ -224,6 +225,7 @@ public: CPPUNIT_TEST(testRedlineField); CPPUNIT_TEST(testIMESupport); CPPUNIT_TEST(testIMEFormattingAtEndOfParagraph); + CPPUNIT_TEST(testIMEFormattingAfterHeader); CPPUNIT_TEST(testSplitNodeRedlineCallback); CPPUNIT_TEST(testDeleteNodeRedlineCallback); CPPUNIT_TEST(testVisCursorInvalidation); @@ -2538,6 +2540,75 @@ void SwTiledRenderingTest::testIMEFormattingAtEndOfParagraph() CPPUNIT_ASSERT_EQUAL(OUString("bab"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); } +void SwTiledRenderingTest::testIMEFormattingAfterHeader() +{ + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + VclPtr<vcl::Window> pDocWindow = pXTextDocument->getDocWindow(); + + SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current()); + assert(pView); + + // delete all characters + + comphelper::dispatchCommand(".uno:SelectAll", uno::Sequence<beans::PropertyValue>()); + Scheduler::ProcessEventsToIdle(); + + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DELETE); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_DELETE); + + Scheduler::ProcessEventsToIdle(); + + pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "a"); + pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); + + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); + Scheduler::ProcessEventsToIdle(); + + // status: "a\n" + + comphelper::dispatchCommand( + ".uno:StyleApply?Style:string=Heading 2&FamilyName:string=ParagraphStyles", + uno::Sequence<beans::PropertyValue>()); + Scheduler::ProcessEventsToIdle(); + + pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "b"); + pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); + + pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "b"); + pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); + Scheduler::ProcessEventsToIdle(); + + std::unique_ptr<SfxPoolItem> pItem; + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); + auto pWeightItem = dynamic_cast<SvxWeightItem*>(pItem.get()); + CPPUNIT_ASSERT(pWeightItem); + + CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_BOLD, pWeightItem->GetWeight()); + + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); + Scheduler::ProcessEventsToIdle(); + + // status: "a\n + // <h2>bb</h2>\n" + + pDocWindow->PostExtTextInputEvent(VclEventId::ExtTextInput, "c"); + pDocWindow->PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); + Scheduler::ProcessEventsToIdle(); + + // status: "a\n + // <h2>bb</h2>\n" + // c" + + pView->GetViewFrame()->GetBindings().QueryState(SID_ATTR_CHAR_WEIGHT, pItem); + auto pWeightItem2 = dynamic_cast<SvxWeightItem*>(pItem.get()); + CPPUNIT_ASSERT(pWeightItem2); + + CPPUNIT_ASSERT_EQUAL(FontWeight::WEIGHT_NORMAL, pWeightItem2->GetWeight()); +} + void SwTiledRenderingTest::testSplitNodeRedlineCallback() { // Load a document. |