[Libreoffice-commits] core.git: desktop/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Sep 28 15:19:37 UTC 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   17 ++++++++++++++---
 sw/source/uibase/docvw/PostItMgr.cxx        |   10 ++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit 7fd1516ed3eeb6523276eabbf9d7f8fcb246e96a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 28 17:16:16 2016 +0200

    sw lok: fix one view inserting a comment, other view jumping there as well
    
    Views are expected to be more or less independent. So when one view
    inserts a comment, don't emit cursor callbacks in the other views, so
    that the other views don't jump to the comment position.
    
    Change-Id: I5e4eadccef971dce2b7c759f3094f6d348d07645

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3456576..1425c1c 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1572,19 +1572,24 @@ void DesktopLOKTest::testPaintPartTile()
 
 void DesktopLOKTest::testWriterCommentInsertCursor()
 {
-    // Load a document and type a character into the body text.
+    // Load a document and type a character into the body text of the second view.
     comphelper::LibreOfficeKit::setActive();
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
     pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
     ViewCallback aView1;
     pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1);
+    pDocument->m_pDocumentClass->createView(pDocument);
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
+    ViewCallback aView2;
+    pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0);
     Scheduler::ProcessEventsToIdle();
-    Rectangle aBodyCursor = aView1.m_aOwnCursor;
+    Rectangle aBodyCursor = aView2.m_aOwnCursor;
 
     // Now insert a comment and make sure that the comment's cursor is shown,
     // not the body text's one.
+    aView1.m_aOwnCursor.SetEmpty();
     const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC);
@@ -1594,7 +1599,13 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
     osl::Thread::wait(std::chrono::seconds(1));
     Scheduler::ProcessEventsToIdle();
     // This failed: the body cursor was shown right after inserting a comment.
-    CPPUNIT_ASSERT(aView1.m_aOwnCursor.getX() > aBodyCursor.getX());
+    CPPUNIT_ASSERT(aView2.m_aOwnCursor.getX() > aBodyCursor.getX());
+    // This failed, the first view's cursor also jumped when the second view
+    // inserted the comment.
+    CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty());
+
+    mxComponent->dispose();
+    mxComponent.clear();
     comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index c417b91..2b8f5ee 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -731,7 +731,17 @@ void SwPostItMgr::LayoutPostIts()
                         bool bTop = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= (pPage->mPageRect.Top()+aSidebarheight);
                         if ( bBottom && bTop )
                         {
+                            // When tiled rendering, make sure that only the
+                            // view that has the comment focus emits callbacks,
+                            // so the editing view jumps to the comment, but
+                            // not the others.
+                            bool bTiledPainting = mpView->getTiledPainting();
+                            if (!bTiledPainting)
+                                // No focus -> disable callbacks.
+                                mpView->setTiledPainting(!(*i)->HasChildPathFocus());
                             (*i)->ShowNote();
+                            if (!bTiledPainting)
+                                mpView->setTiledPainting(bTiledPainting);
                         }
                         else
                         {


More information about the Libreoffice-commits mailing list