summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-20 20:33:50 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 16:48:18 +0200
commita27fdd7f9aa0fde0385f4c26a74ea17bdfff5642 (patch)
tree2be4762b191382673d9b14df322c22a6f7db7454 /sw
parent5cf23f50bdb5e51a2180c33e298b95a0e5154e2a (diff)
sfx2 lok: fix missing view cursors in a new view
When a new view was created, the old views got the position of the new view, but not the other way around. Make sure that the old views notify the new one right after registering the callback. Reviewed-on: https://gerrit.libreoffice.org/26523 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 4d211384f048b689f20e46d4d586f342b110cb5c) Conflicts: sfx2/source/view/viewsh.cxx Change-Id: If26edbd57aa939e453d95f4907a0e5722329dd65
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx60
1 files changed, 60 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 0c49294df583..10d7b654f8e8 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -27,6 +27,7 @@
#include <ndtxt.hxx>
#include <wrtsh.hxx>
#include <sfx2/viewsh.hxx>
+#include <sfx2/lokhelper.hxx>
static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
@@ -51,6 +52,7 @@ public:
void testSearchAllNotifications();
void testPageDownInvalidation();
void testPartHash();
+ void testViewCursors();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -69,6 +71,7 @@ public:
CPPUNIT_TEST(testSearchAllNotifications);
CPPUNIT_TEST(testPageDownInvalidation);
CPPUNIT_TEST(testPartHash);
+ CPPUNIT_TEST(testViewCursors);
CPPUNIT_TEST_SUITE_END();
private:
@@ -488,6 +491,8 @@ void SwTiledRenderingTest::testSearchAllNotifications()
SwXTextDocument* pXTextDocument = createDoc("search.odt");
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+ // Reset notification counter before search.
+ m_nSelectionBeforeSearchResult = 0;
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
{
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
@@ -539,6 +544,61 @@ void SwTiledRenderingTest::testPartHash()
comphelper::LibreOfficeKit::setActive(false);
}
+class ViewCallback
+{
+public:
+ bool m_bOwnCursorInvalidated;
+ bool m_bViewCursorInvalidated;
+
+ ViewCallback()
+ : m_bOwnCursorInvalidated(false),
+ m_bViewCursorInvalidated(false)
+ {
+ }
+
+ static void callback(int nType, const char* pPayload, void* pData)
+ {
+ static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
+ }
+
+ void callbackImpl(int nType, const char* /*pPayload*/)
+ {
+ switch (nType)
+ {
+ case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
+ {
+ m_bOwnCursorInvalidated = true;
+ }
+ break;
+ case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
+ {
+ m_bViewCursorInvalidated = true;
+ }
+ break;
+ }
+ }
+};
+
+void SwTiledRenderingTest::testViewCursors()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ createDoc("dummy.fodt");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated);
+ CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
+ CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
+ // This failed: the cursor position of view1 was only known to view2 once
+ // it changed.
+ CPPUNIT_ASSERT(aView2.m_bViewCursorInvalidated);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();