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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jul 22 07:20:05 UTC 2016


 sc/qa/unit/tiledrendering/data/small.ods     |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   42 ++++++++++++++++++++++++---
 sc/source/ui/view/tabview3.cxx               |    7 +++-
 sw/source/core/view/viewsh.cxx               |    4 +-
 4 files changed, 46 insertions(+), 7 deletions(-)

New commits:
commit afd70f0490c6207ce8ce1e10897b84af0ca21bfd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jul 21 16:07:35 2016 +0200

    sc: provide size in the payload of LOK_CALLBACK_DOCUMENT_SIZE_CHANGED
    
    The sw implementation does so, and the API documentation also says
    clients can depend on this.
    
    Change-Id: Ib4d25d7207fd8358de2ec1186d4ca2306e996497
    Reviewed-on: https://gerrit.libreoffice.org/27379
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 27aac319ca9f2d580aea45542c5d0428616f7e0b)

diff --git a/sc/qa/unit/tiledrendering/data/small.ods b/sc/qa/unit/tiledrendering/data/small.ods
new file mode 100644
index 0000000..ebaae64
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/small.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 5857dab..1801e22 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -28,6 +28,7 @@
 #include <svl/srchitem.hxx>
 
 #include <comphelper/lok.hxx>
+#include <comphelper/propertyvalue.hxx>
 #include <sfx2/lokhelper.hxx>
 
 #include <tabvwsh.hxx>
@@ -55,6 +56,7 @@ public:
     void testDocumentSize();
     void testViewCursors();
     void testTextViewSelection();
+    void testDocumentSizeChanged();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -63,6 +65,7 @@ public:
     CPPUNIT_TEST(testDocumentSize);
     CPPUNIT_TEST(testViewCursors);
     CPPUNIT_TEST(testTextViewSelection);
+    CPPUNIT_TEST(testDocumentSizeChanged);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -72,6 +75,7 @@ private:
 
     /// document size changed callback.
     osl::Condition m_aDocSizeCondition;
+    Size m_aDocumentSize;
 
     uno::Reference<lang::XComponent> mxComponent;
     // TODO various test-related members - when needed
@@ -142,12 +146,18 @@ static void lcl_convertRectangle(const OUString& rString, Rectangle& rRectangle)
 }
 */
 
-void ScTiledRenderingTest::callbackImpl(int nType, const char* /*pPayload*/)
+void ScTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
 {
     switch (nType)
     {
     case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
     {
+        OString aPayload(pPayload);
+        sal_Int32 nIndex = 0;
+        OString aToken = aPayload.getToken(0, ',', nIndex);
+        m_aDocumentSize.setWidth(aToken.toInt32());
+        aToken = aPayload.getToken(0, ',', nIndex);
+        m_aDocumentSize.setHeight(aToken.toInt32());
         m_aDocSizeCondition.set();
     }
     break;
@@ -397,7 +407,7 @@ void ScTiledRenderingTest::testViewCursors()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
-void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand)
+void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rArguments)
 {
     uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
@@ -408,7 +418,7 @@ void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, con
     uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext));
     CPPUNIT_ASSERT(xDispatchHelper.is());
 
-    xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, {});
+    xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rArguments);
 }
 
 void ScTiledRenderingTest::testTextViewSelection()
@@ -426,7 +436,7 @@ void ScTiledRenderingTest::testTextViewSelection()
 
     // Create a selection on two cells in the second view, that's a text selection in LOK terms.
     aView1.m_bTextViewSelectionInvalidated = false;
-    lcl_dispatchCommand(mxComponent, ".uno:GoRightSel");
+    lcl_dispatchCommand(mxComponent, ".uno:GoRightSel", {});
     Scheduler::ProcessEventsToIdle();
     // Make sure the first view got its notification.
     CPPUNIT_ASSERT(aView1.m_bTextViewSelectionInvalidated);
@@ -436,6 +446,30 @@ void ScTiledRenderingTest::testTextViewSelection()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void ScTiledRenderingTest::testDocumentSizeChanged()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    // Load a document that doesn't have much content.
+    createDoc("small.ods");
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this);
+
+    // Go to the A30 cell -- that will extend the document size.
+    uno::Sequence<beans::PropertyValue> aPropertyValues =
+    {
+        comphelper::makePropertyValue("ToPoint", OUString("$A$30")),
+    };
+    lcl_dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+    // Assert that the size in the payload is not 0.
+    CPPUNIT_ASSERT(m_aDocumentSize.getWidth() > 0);
+    CPPUNIT_ASSERT(m_aDocumentSize.getHeight() > 0);
+
+    mxComponent->dispose();
+    mxComponent.clear();
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 5011437..440a418 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -322,7 +322,12 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
 
                 if (pDocSh)
                 {
-                    aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+                    // Provide size in the payload, so clients don't have to
+                    // call lok::Document::getDocumentSize().
+                    std::stringstream ss;
+                    ss << aNewSize.Width() << ", " << aNewSize.Height();
+                    OString sSize = ss.str().c_str();
+                    aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
 
                     // New area extended to the right of the sheet after last column
                     // including overlapping area with aNewRowArea
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index b660674..1affa5d 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1010,8 +1010,8 @@ void SwViewShell::SizeChgNotify()
                     Size aDocSize = GetDocSize();
                     std::stringstream ss;
                     ss << aDocSize.Width() + 2L * DOCUMENTBORDER << ", " << aDocSize.Height() + 2L * DOCUMENTBORDER;
-                    OString sRect = ss.str().c_str();
-                    GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr());
+                    OString sSize = ss.str().c_str();
+                    GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr());
                 }
             }
         }


More information about the Libreoffice-commits mailing list