diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-27 17:07:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-27 16:27:16 +0000 |
commit | 5f65ca15a2297f298536d07cfa8564a1f7c67abb (patch) | |
tree | df14d2a9b4a6f69774cc25a704094f6c5422d71e /sd | |
parent | a02f7aa735c52f5d20df0e2a94cc06879cb3dfac (diff) |
svx lok: fix handling of text edit drawing when view/page changes
This is a follow-up to commit 9d91d371e92548c7f75a7d0155eecaf3769fdee6
(svx lok: draw text edits in all views, 2016-07-26). Two corner-cases
are now handled:
1) When the SfxViewShell is created after begin text edit and
2) When the other draw view is already created, but at the time begin
text edit happens, the other draw view shows a different page.
And the opposite of these: switching away from a page were we observe a
text edit done in an other view or destroying a view that observes a
text edit.
When the complete view goes away, then SdrObjEditView::HideSdrPage() is
not called, so also try to destroy the outliner view of the text edit
from SdrObjEditView::DeleteWindowFromPaintView(). The GetSfxViewShell()
call in SdrObjEditView::ShowSdrPage() is important, because we let the
other draw view create the outliner view, but the outliner view should
invoke our view shell, not the view shell of the other draw view.
Also improve the SdTiledRenderingTest::testCursorViews() testcase, so
that it asserts it managed to begin text edit and use a test document
that still has a single slide and shape, but the shape is not
auto-sized; otherwise invalidations happen even if outliner views are
not created in all draw views, so the test would pass even without the
fixes.
Change-Id: I2c3bb27826c6887115366db818599fc8adabc5a5
Reviewed-on: https://gerrit.libreoffice.org/27583
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/data/title-shape.odp | bin | 0 -> 11406 bytes | |||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 36 |
2 files changed, 30 insertions, 6 deletions
diff --git a/sd/qa/unit/tiledrendering/data/title-shape.odp b/sd/qa/unit/tiledrendering/data/title-shape.odp Binary files differnew file mode 100644 index 000000000000..15d39d68e1ef --- /dev/null +++ b/sd/qa/unit/tiledrendering/data/title-shape.odp diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 3822664c40e9..603efff3f0bd 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -828,13 +828,15 @@ public: int m_nPart; bool m_bCursorVisibleChanged; bool m_bViewLock; + bool m_bTilesInvalidated; ViewCallback() : m_bGraphicSelectionInvalidated(false), m_bGraphicViewSelectionInvalidated(false), m_nPart(0), m_bCursorVisibleChanged(false), - m_bViewLock(false) + m_bViewLock(false), + m_bTilesInvalidated(false) { } @@ -847,6 +849,11 @@ public: { switch (nType) { + case LOK_CALLBACK_INVALIDATE_TILES: + { + m_bTilesInvalidated = true; + } + break; case LOK_CALLBACK_GRAPHIC_SELECTION: { m_bGraphicSelectionInvalidated = true; @@ -955,17 +962,20 @@ void SdTiledRenderingTest::testCursorViews() comphelper::LibreOfficeKit::setActive(); // Create the first view. - SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); + SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp"); ViewCallback aView1; + int nView1 = SfxLokHelper::getView(); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); // Begin text edit on the only object on the slide. sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); - SdPage* pActualPage = pViewShell->GetActualPage(); - SdrObject* pObject = pActualPage->GetObj(0); SdrView* pView = pViewShell->GetView(); - pView->MarkObj(pObject, pView->GetSdrPageView()); - pView->SdrBeginTextEdit(pObject); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(pView->IsTextEdit()); // Make sure that cursor state is not changed just because we create a second view. aView1.m_bCursorVisibleChanged = false; @@ -974,6 +984,20 @@ void SdTiledRenderingTest::testCursorViews() Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(!aView1.m_bCursorVisibleChanged); + // Make sure that typing in the first view causes an invalidation in the + // second view as well, even if the second view was created after begin + // text edit in the first view. + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + SfxLokHelper::setView(nView1); + aView2.m_bTilesInvalidated = false; + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + Scheduler::ProcessEventsToIdle(); + // This failed: the second view was not invalidated when pressing a key in + // the first view. + CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); + mxComponent->dispose(); mxComponent.clear(); comphelper::LibreOfficeKit::setActive(false); |