diff options
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 45 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 19 |
2 files changed, 63 insertions, 1 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 40fc29639a05..6467cf7d933f 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -66,6 +66,7 @@ public: void testViewCursors(); void testViewCursorParts(); void testCursorViews(); + void testViewLock(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -88,6 +89,7 @@ public: CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST(testViewCursorParts); CPPUNIT_TEST(testCursorViews); + CPPUNIT_TEST(testViewLock); CPPUNIT_TEST_SUITE_END(); private: @@ -821,12 +823,14 @@ public: /// Our current part, to be able to decide if a view cursor/selection is relevant for us. int m_nPart; bool m_bCursorVisibleChanged; + bool m_bViewLock; ViewCallback() : m_bGraphicSelectionInvalidated(false), m_bGraphicViewSelectionInvalidated(false), m_nPart(0), - m_bCursorVisibleChanged(false) + m_bCursorVisibleChanged(false), + m_bViewLock(false) { } @@ -859,6 +863,14 @@ public: m_bCursorVisibleChanged = true; } break; + case LOK_CALLBACK_VIEW_LOCK: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; + } + break; } } }; @@ -963,6 +975,37 @@ void SdTiledRenderingTest::testCursorViews() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testViewLock() +{ + comphelper::LibreOfficeKit::setActive(); + + // Load a document that has a shape and create two views. + SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + + // Begin text edit in the second view and assert that the first gets a lock + // notification. + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + SdrObject* pObject = pActualPage->GetObj(0); + SdrView* pView = pViewShell->GetView(); + aView1.m_bViewLock = false; + pView->SdrBeginTextEdit(pObject); + CPPUNIT_ASSERT(aView1.m_bViewLock); + + // End text edit in the second view, and assert that the lock is removed in + // the first view. + pView->SdrEndTextEdit(); + CPPUNIT_ASSERT(!aView1.m_bViewLock); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index df17d6c2b9a9..5e097ddfc269 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -91,6 +91,9 @@ #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <svx/unoapi.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include "DrawController.hxx" #include <memory> @@ -700,6 +703,18 @@ bool View::SdrBeginTextEdit( if ( mpViewSh ) { mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener(); + + if (comphelper::LibreOfficeKit::isActive()) + { + if (OutlinerView* pView = GetTextEditOutlinerView()) + { + Rectangle aRectangle = pView->GetOutputArea(); + if (pWin && pWin->GetMapMode().GetMapUnit() == MAP_100TH_MM) + aRectangle = OutputDevice::LogicToLogic(aRectangle, MAP_100TH_MM, MAP_TWIP); + OString sRectangle = aRectangle.toString(); + SfxLokHelper::notifyOtherViews(&mpViewSh->GetViewShellBase(), LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle); + } + } } if (bReturn) @@ -790,6 +805,10 @@ SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally) if ( mpViewSh ) { mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener(); + + if (comphelper::LibreOfficeKit::isActive()) + SfxLokHelper::notifyOtherViews(&mpViewSh->GetViewShellBase(), LOK_CALLBACK_VIEW_LOCK, "rectangle", "EMPTY"); + } SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() ); |