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

Miklos Vajna vmiklos at collabora.co.uk
Tue Jul 26 07:46:46 UTC 2016


 libreofficekit/source/gtk/lokdocview.cxx     |   26 ++++++------
 sc/qa/unit/tiledrendering/data/shape.ods     |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   55 +++++++++++++++++++++++++--
 sc/source/ui/view/drawview.cxx               |   20 +++++++++
 4 files changed, 84 insertions(+), 17 deletions(-)

New commits:
commit a6e4d41bab2469c1b36384b6384a99287bffb926
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>
    (cherry picked from commit d54fdb0b1b9c8115c7766061d7d698d84c21c887)

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 1801e22..a1a9dc8 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 a482714..8efac68 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();
commit 177918ae1acd14641652f63ca0d2fc495cc372cc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 25 08:52:40 2016 +0200

    lokdocview: draw a lock inside the lock indicator
    
    Hopefully less confusing, the crossed out rectangle is also used inside
    the tiles for deleted comments, and the two are independent.
    
    Change-Id: Id06fbf6ec1b21dfbab1c126c3c432f91cf51430c
    Reviewed-on: https://gerrit.libreoffice.org/27503
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 57c8915376dbb580760486071cac6533e05427bf)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 37b0604..2625316 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1774,19 +1774,19 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
         cairo_set_line_width(pCairo, 2.0);
         cairo_stroke(pCairo);
 
-        // Cross it.
-        cairo_move_to(pCairo,
-                      twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom),
-                      twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom));
-        cairo_line_to(pCairo,
-                      twipToPixel(rRectangle.m_aRectangle.x + rRectangle.m_aRectangle.width, priv->m_fZoom),
-                      twipToPixel(rRectangle.m_aRectangle.y + rRectangle.m_aRectangle.height, priv->m_fZoom));
-        cairo_move_to(pCairo,
-                      twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom),
-                      twipToPixel(rRectangle.m_aRectangle.y + rRectangle.m_aRectangle.height, priv->m_fZoom));
-        cairo_line_to(pCairo,
-                      twipToPixel(rRectangle.m_aRectangle.x + rRectangle.m_aRectangle.width, priv->m_fZoom),
-                      twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom));
+        // And a lock.
+        cairo_rectangle(pCairo,
+                        twipToPixel(rRectangle.m_aRectangle.x + rRectangle.m_aRectangle.width, priv->m_fZoom) - 25,
+                        twipToPixel(rRectangle.m_aRectangle.y + rRectangle.m_aRectangle.height, priv->m_fZoom) - 15,
+                        20,
+                        10);
+        cairo_fill(pCairo);
+        cairo_arc(pCairo,
+                  twipToPixel(rRectangle.m_aRectangle.x + rRectangle.m_aRectangle.width, priv->m_fZoom) - 15,
+                  twipToPixel(rRectangle.m_aRectangle.y + rRectangle.m_aRectangle.height, priv->m_fZoom) - 15,
+                  5,
+                  180.0 * (M_PI/180.0),
+                  360.0 * (M_PI/180.0));
         cairo_stroke(pCairo);
     }
 


More information about the Libreoffice-commits mailing list