diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 18:05:43 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 17:20:17 +0000 |
commit | 3ebfc5b95559a9bcb2fc0508b51fd00e8eb20260 (patch) | |
tree | 1dc7b603d93ab73d05a2e2c720972ac2ed926b8a /sd | |
parent | a2c09913d87127230cfc6944dc7454088f966165 (diff) |
svx lok: add LOK_CALLBACK_GRAPHIC_VIEW_SELECTION
So a view can be aware where the graphic selections of other views are.
Change-Id: I0cc420cfe4bf3824fbfa1a58da889cac5e9a7b60
Reviewed-on: https://gerrit.libreoffice.org/26863
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/tiledrendering.cxx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 4d3ed11e4218..a465b63ea93a 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -12,6 +12,7 @@ #include <test/xmltesttools.hxx> #include <boost/property_tree/json_parser.hpp> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <sfx2/lokhelper.hxx> #include <com/sun/star/frame/Desktop.hpp> #include <comphelper/dispatchcommand.hxx> #include <comphelper/processfactory.hxx> @@ -62,6 +63,7 @@ public: void testPartHash(); void testResizeTable(); void testResizeTableColumn(); + void testViewCursors(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -81,6 +83,7 @@ public: CPPUNIT_TEST(testPartHash); CPPUNIT_TEST(testResizeTable); CPPUNIT_TEST(testResizeTableColumn); + CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST_SUITE_END(); private: @@ -806,6 +809,71 @@ void SdTiledRenderingTest::testResizeTableColumn() comphelper::LibreOfficeKit::setActive(false); } +class ViewCallback +{ +public: + bool m_bGraphicSelectionInvalidated; + bool m_bGraphicViewSelectionInvalidated; + + ViewCallback() + : m_bGraphicSelectionInvalidated(false), + m_bGraphicViewSelectionInvalidated(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_GRAPHIC_SELECTION: + { + m_bGraphicSelectionInvalidated = true; + } + break; + case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: + { + m_bGraphicViewSelectionInvalidated = true; + } + break; + } + } +}; + +void SdTiledRenderingTest::testViewCursors() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + 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); + // Second view notices that there was a selection change in its own view. + CPPUNIT_ASSERT(aView2.m_bGraphicSelectionInvalidated); + mxComponent->dispose(); + mxComponent.clear(); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |