diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-22 16:39:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-22 15:13:07 +0000 |
commit | 897189cfc6b3f6f3a9a0148b060ea25e5f8d9eaa (patch) | |
tree | d0323d739785025c1ac3296a2212c350159ce7c9 /sw | |
parent | 4da8378302093dd3e3dc3e201ac5e188c55f8009 (diff) |
sw: add new LOK_CALLBACK_VIEW_LOCK callback
When we're after SdrBeginTextEdit(), but before SdrEndTextEdit(), and
have multiple views, then only the active view paints the edited text,
the other views look like the shape has no text at all.
Add a new callback that exposes the position and size of the rectangle
where the shape text will be painted after text edit ended, so clients
can draw some kind of locking indicator there. This way the rendered
result can differ in the "shape has no text" and the "shape text is
edited in an other view" cases.
Change-Id: I6096479a8a05c2547d15222e6d997b848af02945
Reviewed-on: https://gerrit.libreoffice.org/27441
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 49 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 9 |
3 files changed, 64 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index b4ccff4202fd..c20fe735ebac 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -25,6 +25,7 @@ #include <drawdoc.hxx> #include <ndtxt.hxx> #include <wrtsh.hxx> +#include <view.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/lokhelper.hxx> @@ -55,6 +56,7 @@ public: void testMissingInvalidation(); void testViewCursorVisibility(); void testViewCursorCleanup(); + void testViewLock(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -77,6 +79,7 @@ public: CPPUNIT_TEST(testMissingInvalidation); CPPUNIT_TEST(testViewCursorVisibility); CPPUNIT_TEST(testViewCursorCleanup); + CPPUNIT_TEST(testViewLock); CPPUNIT_TEST_SUITE_END(); private: @@ -559,6 +562,7 @@ public: bool m_bTilesInvalidated; bool m_bViewCursorVisible; bool m_bGraphicViewSelection; + bool m_bViewLock; ViewCallback() : m_bOwnCursorInvalidated(false), @@ -567,7 +571,8 @@ public: m_bViewSelectionSet(false), m_bTilesInvalidated(false), m_bViewCursorVisible(false), - m_bGraphicViewSelection(false) + m_bGraphicViewSelection(false), + m_bViewLock(false) { } @@ -618,6 +623,14 @@ public: m_bGraphicViewSelection = aTree.get_child("selection").get_value<std::string>() != "EMPTY"; } 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; } } }; @@ -772,6 +785,40 @@ void SwTiledRenderingTest::testViewCursorCleanup() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testViewLock() +{ + comphelper::LibreOfficeKit::setActive(); + + // Load a document that has a shape and create two views. + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + + // Begin text edit in the second view and assert that the first gets a lock + // notification. + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + SdrView* pView = pWrtShell->GetDrawView(); + aView1.m_bViewLock = false; + pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin()); + CPPUNIT_ASSERT(aView1.m_bViewLock); + + // End text edit in the second view, and assert that the lock is removed in + // the first view. + pWrtShell->EndTextEdit(); + CPPUNIT_ASSERT(!aView1.m_bViewLock); + + mxComponent->dispose(); + mxComponent.clear(); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 894fa01509d4..5e4b92c66aa6 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -82,6 +82,9 @@ #include <sortedobjs.hxx> #include <HandleAnchorNodeChg.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <calbck.hxx> #include <com/sun/star/embed/EmbedMisc.hpp> @@ -1054,6 +1057,10 @@ void SwFEShell::EndTextEdit() } else pView->SdrEndTextEdit(); + + if (comphelper::LibreOfficeKit::isActive()) + SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_LOCK, "rectangle", "EMPTY"); + EndAllAction(); } diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index d5dcb932337e..011afcb3299c 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -68,6 +68,9 @@ #include <svx/svdpagv.hxx> #include <svx/extrusionbar.hxx> #include <vcl/svapp.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> using namespace ::com::sun::star; @@ -573,6 +576,12 @@ bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin, if (pView) { pView->SetSelection(aNewSelection); + + if (comphelper::LibreOfficeKit::isActive()) + { + OString sRect = pView->GetOutputArea().toString(); + SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRect); + } } } |