[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Sep 30 07:42:30 UTC 2016


 sw/qa/extras/tiledrendering/tiledrendering.cxx |   26 +++++++++++++++++++++++++
 sw/source/core/crsr/viscrs.cxx                 |    8 +++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

New commits:
commit 59cff0dbbdcbe1382f09fb23c71eadbe7d471fa8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 29 16:53:59 2016 +0200

    sw lok: disable pixel alignment of cursor logic values
    
    It just makes harder for a client to find out if the cursor of one view
    is at the same position as the cursor of an other view.
    
    Change-Id: Ifaebd1c93c45918c87f3c2c3d12bbb3af949184e
    Reviewed-on: https://gerrit.libreoffice.org/29393
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit b32b6c09d190effbe29389a87a80df36007d2e99)

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 9da36aa..e7b78b7 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -77,6 +77,7 @@ public:
     void testCreateViewTextSelection();
     void testRedlineColors();
     void testCommentEndTextEdit();
+    void testCursorPosition();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -117,6 +118,7 @@ public:
     CPPUNIT_TEST(testCreateViewTextSelection);
     CPPUNIT_TEST(testRedlineColors);
     CPPUNIT_TEST(testCommentEndTextEdit);
+    CPPUNIT_TEST(testCursorPosition);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1504,6 +1506,30 @@ void SwTiledRenderingTest::testCommentEndTextEdit()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SwTiledRenderingTest::testCursorPosition()
+{
+    // Load a document and register a callback, should get an own cursor.
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc();
+    ViewCallback aView1;
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+    // Crete a second view, so the first view gets a collaborative cursor.
+    SfxLokHelper::createView();
+    pXTextDocument->initializeForTiledRendering({});
+    ViewCallback aView2;
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+
+    // Make sure the two are exactly the same.
+    // This failed, own cursor was at '1418, 1418', collaborative cursor was at
+    // '1425, 1425', due to pixel alignment.
+    CPPUNIT_ASSERT_EQUAL(aView1.m_aOwnCursor.toString(), aView1.m_aViewCursor.toString());
+
+    mxComponent->dispose();
+    mxComponent.clear();
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 19e3762..64154fe 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -170,10 +170,14 @@ void SwVisibleCursor::_SetPosAndShow(SfxViewShell* pViewShell)
         }
     }
 
-    if( aRect.Height() )
+    if( aRect.Height())
     {
         ::SwCalcPixStatics( m_pCursorShell->GetOut() );
-        ::SwAlignRect( aRect, static_cast<SwViewShell const *>(m_pCursorShell), m_pCursorShell->GetOut() );
+
+        // Disable pixel alignment when tiled rendering, so that twip values of
+        // the cursor don't depend on statics.
+        if (!comphelper::LibreOfficeKit::isActive())
+            ::SwAlignRect( aRect, static_cast<SwViewShell const *>(m_pCursorShell), m_pCursorShell->GetOut() );
     }
     if( !m_pCursorShell->IsOverwriteCursor() || m_bIsDragCursor ||
         m_pCursorShell->IsSelection() )


More information about the Libreoffice-commits mailing list