diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-12 17:05:10 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-13 08:16:36 +0200 |
commit | 176c7905f469bcefb06dc0772a6bbadfc8a8833f (patch) | |
tree | fde0e3489dbde1005385ef4a4122e5436399e4fb /sw/qa | |
parent | 50b66e4d3ef790b4228a3cc099346edf1838f2e7 (diff) |
sw: emit LOK_CALLBACK_TEXT_VIEW_SELECTION as part of registerCallback()
Have a Writer text selection in the first view, create a new view, the
second view doesn't see the selection. But the same works if the text
selection is created when the second view was created earlier.
Emit the selection state as part of SwCursorShell::NotifyCursor() to fix
the problem.
Reviewed-on: https://gerrit.libreoffice.org/28844
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit c4224e6cafa5aa5c604dfdc0daf7f145aa6c08be)
Conflicts:
sw/source/core/crsr/crsrsh.cxx
Change-Id: I7d71c9b58941c8ca8720b0e63e54bc757b1aaf61
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 142ca1092c2c..048ade6c634b 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -73,6 +73,7 @@ public: void testRedlineUpdateCallback(); void testSetViewGraphicSelection(); void testCreateViewGraphicSelection(); + void testCreateViewTextSelection(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -110,6 +111,7 @@ public: CPPUNIT_TEST(testRedlineUpdateCallback); CPPUNIT_TEST(testSetViewGraphicSelection); CPPUNIT_TEST(testCreateViewGraphicSelection); + CPPUNIT_TEST(testCreateViewTextSelection); CPPUNIT_TEST_SUITE_END(); private: @@ -604,6 +606,7 @@ public: bool m_bViewCursorInvalidated; bool m_bOwnSelectionSet; bool m_bViewSelectionSet; + OString m_aViewSelection; bool m_bTilesInvalidated; bool m_bViewCursorVisible; bool m_bGraphicViewSelection; @@ -656,6 +659,7 @@ public: case LOK_CALLBACK_TEXT_VIEW_SELECTION: { m_bViewSelectionSet = true; + m_aViewSelection = aPayload; } break; case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: @@ -1310,6 +1314,39 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testCreateViewTextSelection() +{ + // Load a document. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + // Create a text selection: + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + // Move the cursor into the second word. + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 5, /*bBasicCall=*/false); + // Create a selection on the word. + pWrtShell->SelWrd(); + SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); + // Did we indeed manage to select the second word? + CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText()); + + // Create a second view. + SfxLokHelper::createView(); + + // Make sure that the text selection is visible in the second view. + ViewCallback aView2; + aView2.m_bViewSelectionSet = true; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + // This failed, the second view didn't get the text selection of the first view. + CPPUNIT_ASSERT(!aView2.m_aViewSelection.isEmpty()); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |