diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-19 10:02:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-19 08:31:50 +0000 |
commit | 299b9377469473abd8f58ba7f1054794491bdc56 (patch) | |
tree | 1b5ba8d483552f1dce3ffb8b84f28fa9f9aba8c3 /sd | |
parent | ae30c85f61557bad0ce3ddf2fc80c710d9e31f69 (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>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/data/shape.odp | bin | 10159 -> 10446 bytes | |||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 57 | ||||
-rw-r--r-- | sd/source/ui/inc/ViewShellBase.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellBase.cxx | 13 |
5 files changed, 70 insertions, 5 deletions
diff --git a/sd/qa/unit/tiledrendering/data/shape.odp b/sd/qa/unit/tiledrendering/data/shape.odp Binary files differindex f73476140d73..b1ffa54e367f 100644 --- a/sd/qa/unit/tiledrendering/data/shape.odp +++ b/sd/qa/unit/tiledrendering/data/shape.odp diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index a465b63ea93a..948f06d9a9a0 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(); diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index 546dbef4acae..4d92b0d671fe 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -217,6 +217,8 @@ public: /** returns the ui descriptive name for the given uno slot. The result is taken from the configuration and not cached, so do not use it excessive (f.e. in status updates) */ OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) const; + /// See SfxViewShell::getPart(). + int getPart() const override; protected: diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 6902bbade4fc..851f38c11a15 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2309,8 +2309,7 @@ int SdXImpressDocument::getPart() if (!pViewSh) return 0; - // curPageId seems to start at 1 - return pViewSh->GetCurPageId() - 1; + return pViewSh->GetViewShellBase().getPart(); } OUString SdXImpressDocument::getPartName( int nPart ) diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 3da448914465..f22a8a4a7486 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -1020,6 +1020,19 @@ OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) cons return ImplRetrieveLabelFromCommand( xFrame, aCmdURL ); } +int ViewShellBase::getPart() const +{ + ViewShell* pViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); + + if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell)) + { + // curPageId seems to start at 1 + return pDrawViewShell->GetCurPageId() - 1; + } + + return 0; +} + //===== ViewShellBase::Implementation ========================================= ViewShellBase::Implementation::Implementation (ViewShellBase& rBase) |