diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-22 15:27:40 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-22 20:27:04 +0200 |
commit | ba3d6d8a39d31316923d2326059c07b0a7e3c05e (patch) | |
tree | bc247bdff9035fea03e9fb35546cb8abed8fed9f /sd/qa | |
parent | c6fc963c534bc9069ef975246e5d619777b9f570 (diff) |
sd lok: fix pixel-to-logic conversion in DrawViewShell::MakeVisible()
The problem, as seen by the user is that during shape text edit,
sometimes just traveling with the cursor causes invalidations, which is
unexpected.
What happens is sd::Window::KeyInput() invokes
sd::DrawViewShell::MakeVisible(), which does a pixel-to-logic
conversion, but because the map mode is in general disabled in the LOK
case, nothing happens. Then a bit later aVisArea.IsInside(rRect) fails,
as it compares pixel and logic units, which results in
sd::ViewOverlayManager::UpdateTags() scheduling an async call to
sd::ViewOverlayManager::UpdateTagsHdl(), which at the end causes a full
invalidation in sd::SmartTagSet::remove().
Fix the situation by temporarily enabling map mode, so we don't detect
a visible cursor area as a non-visible one.
Change-Id: I6d16f24d13143dc263a89317fbc38111e652c0ac
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/tiledrendering/data/2slides.odp | bin | 0 -> 10984 bytes | |||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/data/2slides.odp b/sd/qa/unit/tiledrendering/data/2slides.odp Binary files differnew file mode 100644 index 000000000000..baa42ba9fca5 --- /dev/null +++ b/sd/qa/unit/tiledrendering/data/2slides.odp diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 3f1a08c8372d..14dfb2a64244 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -77,6 +77,7 @@ public: void testCreateViewGraphicSelection(); void testCreateViewTextCursor(); void testTdf102223(); + void testPostKeyEventInvalidation(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -105,6 +106,7 @@ public: CPPUNIT_TEST(testCreateViewGraphicSelection); CPPUNIT_TEST(testCreateViewTextCursor); CPPUNIT_TEST(testTdf102223); + CPPUNIT_TEST(testPostKeyEventInvalidation); CPPUNIT_TEST_SUITE_END(); private: @@ -1289,6 +1291,51 @@ void SdTiledRenderingTest::testTdf102223() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testPostKeyEventInvalidation() +{ + // Load a document and begin text edit on the first slide. + comphelper::LibreOfficeKit::setActive(); + SdXImpressDocument* pXImpressDocument = createDoc("2slides.odp"); + CPPUNIT_ASSERT_EQUAL(0, pXImpressDocument->getPart()); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdrView* pView = pViewShell->GetView(); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F2); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_F2); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(pView->GetTextEditObject()); + + // Create a second view and begin text edit there as well, in parallel. + SfxLokHelper::createView(); + pXImpressDocument->initializeForTiledRendering({}); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + pXImpressDocument->setPart(1); + sd::ViewShell* pViewShell2 = pXImpressDocument->GetDocShell()->GetViewShell(); + SdrView* pView2 = pViewShell2->GetView(); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F2); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_F2); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(pView2->GetTextEditObject()); + + // Now go left with the cursor in the second view an watch for + // invalidations. + aView2.m_bTilesInvalidated = false; + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_LEFT); + Scheduler::ProcessEventsToIdle(); + // This failed: moving the cursor caused unexpected invalidation. + CPPUNIT_ASSERT(!aView2.m_bTilesInvalidated); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); |