summaryrefslogtreecommitdiff
path: root/sd/qa/unit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-19 10:02:08 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-21 10:43:11 +0200
commitfc4bb1254ef77d29368535c9a810875c8db15b77 (patch)
treeb1ebc10536f79914dd18466292b7c285d57f6572 /sd/qa/unit
parentff11e4ff92036006851458cc5d935ff946618ae8 (diff)
sfx2 lok: expose part number in SfxLokHelper::notifyOtherViews()
This way a client can decide if the view cursor it gets is relevant (the views show the same part) or not. Change-Id: I7b274b28f0c4f0509df5071831acf50512eff640 Reviewed-on: https://gerrit.libreoffice.org/27311 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 299b9377469473abd8f58ba7f1054794491bdc56)
Diffstat (limited to 'sd/qa/unit')
-rw-r--r--sd/qa/unit/tiledrendering/data/shape.odpbin10159 -> 10446 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx57
2 files changed, 54 insertions, 3 deletions
diff --git a/sd/qa/unit/tiledrendering/data/shape.odp b/sd/qa/unit/tiledrendering/data/shape.odp
index f73476140d73..b1ffa54e367f 100644
--- a/sd/qa/unit/tiledrendering/data/shape.odp
+++ b/sd/qa/unit/tiledrendering/data/shape.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 316936f44d47..acff325c6498 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -64,6 +64,7 @@ public:
void testResizeTable();
void testResizeTableColumn();
void testViewCursors();
+ void testViewCursorParts();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -84,6 +85,7 @@ public:
CPPUNIT_TEST(testResizeTable);
CPPUNIT_TEST(testResizeTableColumn);
CPPUNIT_TEST(testViewCursors);
+ CPPUNIT_TEST(testViewCursorParts);
CPPUNIT_TEST_SUITE_END();
private:
@@ -814,10 +816,13 @@ class ViewCallback
public:
bool m_bGraphicSelectionInvalidated;
bool m_bGraphicViewSelectionInvalidated;
+ /// Our current part, to be able to decide if a view cursor/selection is relevant for us.
+ int m_nPart;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
- m_bGraphicViewSelectionInvalidated(false)
+ m_bGraphicViewSelectionInvalidated(false),
+ m_nPart(0)
{
}
@@ -826,7 +831,7 @@ public:
static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload);
}
- void callbackImpl(int nType, const char* /*pPayload*/)
+ void callbackImpl(int nType, const char* pPayload)
{
switch (nType)
{
@@ -837,7 +842,12 @@ public:
break;
case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
{
- m_bGraphicViewSelectionInvalidated = true;
+ std::stringstream aStream(pPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ if (aTree.get_child("part").get_value<int>() == m_nPart)
+ // Ignore callbacks which are for a different part.
+ m_bGraphicViewSelectionInvalidated = true;
}
break;
}
@@ -874,6 +884,47 @@ void SdTiledRenderingTest::testViewCursors()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testViewCursorParts()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+
+ // Select the shape in the second view.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ Scheduler::ProcessEventsToIdle();
+ // First view notices that there was a selection change in the other view.
+ CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated);
+ pView->UnmarkAllObj(pView->GetSdrPageView());
+
+ // Now switch to the second part in the second view.
+ pXImpressDocument->setPart(1);
+ aView2.m_nPart = 1;
+ aView1.m_bGraphicViewSelectionInvalidated = false;
+ pActualPage = pViewShell->GetActualPage();
+ pObject = pActualPage->GetObj(0);
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ Scheduler::ProcessEventsToIdle();
+ // First view ignores view selection, as it would be for part 1, and it's in part 0.
+ // This failed when the "part" was always 0 in the callback.
+ CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelectionInvalidated);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();