diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-25 10:42:05 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-26 09:41:15 +0200 |
commit | a6e4d41bab2469c1b36384b6384a99287bffb926 (patch) | |
tree | 21c720a7cea8ef09f882e109702db099737be6b8 /sc | |
parent | 177918ae1acd14641652f63ca0d2fc495cc372cc (diff) |
sc: implement LOK_CALLBACK_VIEW_LOCK
This is the same shape text editing indicator that's available in Writer
and Impress already.
Change-Id: I5f7fbf2efdc92a10b169a3f1b27e24426f3dfb3d
Reviewed-on: https://gerrit.libreoffice.org/27507
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit d54fdb0b1b9c8115c7766061d7d698d84c21c887)
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/tiledrendering/data/shape.ods | bin | 0 -> 8804 bytes | |||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 55 | ||||
-rw-r--r-- | sc/source/ui/view/drawview.cxx | 20 |
3 files changed, 71 insertions, 4 deletions
diff --git a/sc/qa/unit/tiledrendering/data/shape.ods b/sc/qa/unit/tiledrendering/data/shape.ods Binary files differnew file mode 100644 index 000000000000..eeb89938f9d2 --- /dev/null +++ b/sc/qa/unit/tiledrendering/data/shape.ods diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 1801e220acde..a1a9dc83b41c 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -30,6 +30,7 @@ #include <comphelper/lok.hxx> #include <comphelper/propertyvalue.hxx> #include <sfx2/lokhelper.hxx> +#include <svx/svdpage.hxx> #include <tabvwsh.hxx> #include <docsh.hxx> @@ -57,6 +58,7 @@ public: void testViewCursors(); void testTextViewSelection(); void testDocumentSizeChanged(); + void testViewLock(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -66,6 +68,7 @@ public: CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST(testTextViewSelection); CPPUNIT_TEST(testDocumentSizeChanged); + CPPUNIT_TEST(testViewLock); CPPUNIT_TEST_SUITE_END(); private: @@ -78,11 +81,9 @@ private: Size m_aDocumentSize; uno::Reference<lang::XComponent> mxComponent; - // TODO various test-related members - when needed }; ScTiledRenderingTest::ScTiledRenderingTest() - // TODO various test-related members - when needed { } @@ -349,11 +350,13 @@ public: bool m_bOwnCursorInvalidated; bool m_bViewCursorInvalidated; bool m_bTextViewSelectionInvalidated; + bool m_bViewLock; ViewCallback() : m_bOwnCursorInvalidated(false), m_bViewCursorInvalidated(false), - m_bTextViewSelectionInvalidated(false) + m_bTextViewSelectionInvalidated(false), + m_bViewLock(false) { } @@ -362,7 +365,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) { @@ -381,6 +384,14 @@ public: m_bTextViewSelectionInvalidated = 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; } } }; @@ -470,6 +481,42 @@ void ScTiledRenderingTest::testDocumentSizeChanged() comphelper::LibreOfficeKit::setActive(false); } +void ScTiledRenderingTest::testViewLock() +{ + comphelper::LibreOfficeKit::setActive(); + + // Load a document that has a shape and create two views. + ScModelObj* pModelObj = createDoc("shape.ods"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + ViewCallback aView2; + pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + + // Begin text edit in the second view and assert that the first gets a lock + // notification. + const ScViewData* pViewData = ScDocShell::GetViewData(); + ScTabViewShell* pViewShell = pViewData->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + SdrModel* pDrawModel = pViewData->GetDocument()->GetDrawLayer(); + SdrPage* pDrawPage = pDrawModel->GetPage(0); + SdrObject* pObject = pDrawPage->GetObj(0); + SdrView* pView = pViewShell->GetSdrView(); + 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(ScTiledRenderingTest); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index a4827144b7f5..8efac68d8738 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -35,6 +35,9 @@ #include <sfx2/viewfrm.hxx> #include <svx/sdrundomanager.hxx> #include <svx/xbtmpit.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include "drawview.hxx" #include "global.hxx" @@ -550,6 +553,19 @@ bool ScDrawView::SdrBeginTextEdit( bOnlyOneView, bGrabFocus ); ScTabViewShell* pViewSh = pViewData->GetViewShell(); + + if (comphelper::LibreOfficeKit::isActive()) + { + if (OutlinerView* pView = GetTextEditOutlinerView()) + { + Rectangle aRectangle = pView->GetOutputArea(); + if (pWinL && pWinL->GetMapMode().GetMapUnit() == MAP_100TH_MM) + aRectangle = OutputDevice::LogicToLogic(aRectangle, MAP_100TH_MM, MAP_TWIP); + OString sRectangle = aRectangle.toString(); + SfxLokHelper::notifyOtherViews(pViewSh, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle); + } + } + if ( pViewSh->GetViewFrame() ) { SfxFrame& rFrame = pViewSh->GetViewFrame()->GetFrame(); @@ -570,6 +586,10 @@ SdrEndTextEditKind ScDrawView::SdrEndTextEdit( bool bDontDeleteReally ) const SdrEndTextEditKind eRet = FmFormView::SdrEndTextEdit( bDontDeleteReally ); ScTabViewShell* pViewSh = pViewData->GetViewShell(); + + if (comphelper::LibreOfficeKit::isActive()) + SfxLokHelper::notifyOtherViews(pViewSh, LOK_CALLBACK_VIEW_LOCK, "rectangle", "EMPTY"); + if ( pViewSh->GetViewFrame() ) { SfxFrame& rFrame = pViewSh->GetViewFrame()->GetFrame(); |