[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Jun 30 11:38:05 UTC 2016
sw/qa/extras/tiledrendering/tiledrendering.cxx | 49 ++++++++++++++++++++++++-
sw/source/core/crsr/viscrs.cxx | 4 +-
2 files changed, 51 insertions(+), 2 deletions(-)
New commits:
commit 6168f10b6280b2d60de44a333f3f1dc23cbb9bcf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jun 30 12:40:49 2016 +0200
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 at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 240a27c..7709df8 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -52,6 +52,7 @@ public:
void testPageDownInvalidation();
void testPartHash();
void testViewCursors();
+ void testMissingInvalidation();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -71,6 +72,7 @@ public:
CPPUNIT_TEST(testPageDownInvalidation);
CPPUNIT_TEST(testPartHash);
CPPUNIT_TEST(testViewCursors);
+ CPPUNIT_TEST(testMissingInvalidation);
CPPUNIT_TEST_SUITE_END();
private:
@@ -550,12 +552,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)
{
}
@@ -568,6 +572,11 @@ public:
{
switch (nType)
{
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ {
+ m_bTilesInvalidated = true;
+ }
+ break;
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
m_bOwnCursorInvalidated = true;
@@ -592,6 +601,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 1ba80d9..bde11875 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;
More information about the Libreoffice-commits
mailing list