sw/qa/extras/tiledrendering/tiledrendering.cxx | 26 +++++++++++++++++++++++++ sw/source/core/crsr/viscrs.cxx | 8 +++++-- 2 files changed, 32 insertions(+), 2 deletions(-)
New commits: commit b32b6c09d190effbe29389a87a80df36007d2e99 Author: Miklos Vajna <vmik...@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 <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 47beefc..82f5b11 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -76,6 +76,7 @@ public: void testCreateViewTextSelection(); void testRedlineColors(); void testCommentEndTextEdit(); + void testCursorPosition(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -116,6 +117,7 @@ public: CPPUNIT_TEST(testCreateViewTextSelection); CPPUNIT_TEST(testRedlineColors); CPPUNIT_TEST(testCommentEndTextEdit); + CPPUNIT_TEST(testCursorPosition); CPPUNIT_TEST_SUITE_END(); private: @@ -1503,6 +1505,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 7a886e9..696ddc2 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() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits