[Libreoffice-commits] core.git: sc/qa sc/source

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


 sc/qa/unit/tiledrendering/data/shape.ods     |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   55 +++++++++++++++++++++++++--
 sc/source/ui/view/drawview.cxx               |   20 +++++++++
 3 files changed, 71 insertions(+), 4 deletions(-)

New commits:
commit d54fdb0b1b9c8115c7766061d7d698d84c21c887
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 25 10:42:05 2016 +0200

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sc/qa/unit/tiledrendering/data/shape.ods b/sc/qa/unit/tiledrendering/data/shape.ods
new file mode 100644
index 0000000..eeb89938
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/shape.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index be83927..314febc 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>
@@ -58,6 +59,7 @@ public:
     void testViewCursors();
     void testTextViewSelection();
     void testDocumentSizeChanged();
+    void testViewLock();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -68,6 +70,7 @@ public:
     CPPUNIT_TEST(testViewCursors);
     CPPUNIT_TEST(testTextViewSelection);
     CPPUNIT_TEST(testDocumentSizeChanged);
+    CPPUNIT_TEST(testViewLock);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -80,11 +83,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
 {
 }
 
@@ -371,11 +372,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)
     {
     }
 
@@ -384,7 +387,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)
         {
@@ -403,6 +406,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;
         }
     }
 };
@@ -492,6 +503,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 34daf66..70662c9 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();


More information about the Libreoffice-commits mailing list