summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-30 12:40:49 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 18:04:14 +0200
commit0c93c4b9788dd3746a43556ea683465b16d5660a (patch)
tree22e1beab237a26b8e80d59080ae422593c466524
parent8e739f68cc863107e9782f1453f2c6370c6874ec (diff)
sw lok: mix missing invalidation due to page calc in visible cursor change
Steps to reproduce in gtktiledviewer: - two windows, then enable edit in both - view #0: go inside a word - view #1: select the same word - press Del in view #1 -> no invalidation Fix the problem by changing the LOK-specific GetPageNum() call in SwVisibleCursor::SetPosAndShow(), so that it doesn't re-calculate the frame, that way later when SwLayAction::TurboAction_() attempts to re-calculate the layout, then the frame will be still invalid, and that re-calculation then triggers the necessary invalidations. Change-Id: I8c4472b9809537fcbd4a20c73f39be7ebca16b1f Reviewed-on: https://gerrit.libreoffice.org/26802 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 6168f10b6280b2d60de44a333f3f1dc23cbb9bcf)
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx49
-rw-r--r--sw/source/core/crsr/viscrs.cxx4
2 files changed, 51 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 699802311fa2..e43d0717ed58 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -53,6 +53,7 @@ public:
void testPageDownInvalidation();
void testPartHash();
void testViewCursors();
+ void testMissingInvalidation();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -72,6 +73,7 @@ public:
CPPUNIT_TEST(testPageDownInvalidation);
CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST(testViewCursors);
+ CPPUNIT_TEST(testMissingInvalidation);
CPPUNIT_TEST_SUITE_END();
private:
@@ -551,12 +553,14 @@ public:
bool m_bViewCursorInvalidated;
bool m_bOwnSelectionSet;
bool m_bViewSelectionSet;
+ bool m_bTilesInvalidated;
ViewCallback()
: m_bOwnCursorInvalidated(false),
m_bViewCursorInvalidated(false),
m_bOwnSelectionSet(false),
- m_bViewSelectionSet(false)
+ m_bViewSelectionSet(false),
+ m_bTilesInvalidated(false)
{
}
@@ -569,6 +573,11 @@ public:
{
switch (nType)
{
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ {
+ m_bTilesInvalidated = true;
+ }
+ break;
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
m_bOwnCursorInvalidated = true;
@@ -593,6 +602,44 @@ public:
}
};
+void SwTiledRenderingTest::testMissingInvalidation()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ int nView1 = SfxLokHelper::getView();
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ int nView2 = SfxLokHelper::getView();
+
+ // First view: put the cursor into the first word.
+ SfxLokHelper::setView(nView1);
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+
+ // Second view: select the first word.
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT(pXTextDocument->GetDocShell()->GetWrtShell() != pWrtShell);
+ pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ pWrtShell->SelWrd();
+
+ // Now delete the selected word and make sure both views are invalidated.
+ aView1.m_bTilesInvalidated = false;
+ aView2.m_bTilesInvalidated = false;
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DELETE);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
+ CPPUNIT_ASSERT(aView2.m_bTilesInvalidated);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
void SwTiledRenderingTest::testViewCursors()
{
comphelper::LibreOfficeKit::setActive();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 585a0f414738..2c0ca9e2073e 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -186,7 +186,9 @@ void SwVisibleCursor::_SetPosAndShow()
{
// notify about page number change (if that happened)
sal_uInt16 nPage, nVirtPage;
- const_cast<SwCursorShell*>(m_pCursorShell)->GetPageNum(nPage, nVirtPage);
+ // bCalcFrame=false is important to avoid calculating the layout when
+ // we're in the middle of doing that already.
+ const_cast<SwCursorShell*>(m_pCursorShell)->GetPageNum(nPage, nVirtPage, /*bAtCursorPos=*/true, /*bCalcFrame=*/false);
if (nPage != m_nPageLastTime)
{
m_nPageLastTime = nPage;