[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sd/qa sd/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jul 25 06:21:06 UTC 2016


 sd/qa/unit/tiledrendering/tiledrendering.cxx |   45 ++++++++++++++++++++++++++-
 sd/source/ui/view/sdview.cxx                 |   19 +++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

New commits:
commit 4a7c5abb15e559f23f737ef38202a5d72dcb8eb1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jul 22 17:27:25 2016 +0200

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit ffd9972e2a21f6490f25c712cd0ba49e534238c8)

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 47fd21a..93b2272 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 d3c6e16..01a23f0 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() );


More information about the Libreoffice-commits mailing list