summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-22 17:27:25 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-25 08:16:50 +0200
commit4a7c5abb15e559f23f737ef38202a5d72dcb8eb1 (patch)
tree59b03276588a59501ad8f3a04f2391c3e3806afe /sd
parent599b1306ac59abc507f53ead3e7ca92bce3e6b77 (diff)
sd: implement LOK_CALLBACK_VIEW_LOCK
So that edited shape text doesn't just disappear in other views without any indication. Change-Id: I806051492f7bc247c0e66eceda4df5eba8322aad Reviewed-on: https://gerrit.libreoffice.org/27444 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit ffd9972e2a21f6490f25c712cd0ba49e534238c8)
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx45
-rw-r--r--sd/source/ui/view/sdview.cxx19
2 files changed, 63 insertions, 1 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 47fd21a92266..93b227218b96 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 d3c6e1641736..01a23f08f515 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() );