summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-27 17:07:47 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-28 09:04:51 +0200
commit9931331e5e9cdd4e581962e332024af572f7f90e (patch)
tree3561f8735f2389a115276ad55a92a70e12a143e3 /sd
parent0f83ff712a6253066b758d39d92ac528bdb2f5d3 (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> (cherry picked from commit 5f65ca15a2297f298536d07cfa8564a1f7c67abb)
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/data/title-shape.odpbin0 -> 11406 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx36
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
new file mode 100644
index 000000000000..15d39d68e1ef
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/title-shape.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 93b227218b96..88239247cb53 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -824,13 +824,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)
{
}
@@ -843,6 +845,11 @@ public:
{
switch (nType)
{
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ {
+ m_bTilesInvalidated = true;
+ }
+ break;
case LOK_CALLBACK_GRAPHIC_SELECTION:
{
m_bGraphicSelectionInvalidated = true;
@@ -951,17 +958,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;
@@ -970,6 +980,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);