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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jul 22 07:05:50 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 27aac319ca9f2d580aea45542c5d0428616f7e0b
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>

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 e66585d..fb4759f 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>
@@ -56,6 +57,7 @@ public:
     void testEmptyColumnSelection();
     void testViewCursors();
     void testTextViewSelection();
+    void testDocumentSizeChanged();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -65,6 +67,7 @@ public:
     CPPUNIT_TEST(testEmptyColumnSelection);
     CPPUNIT_TEST(testViewCursors);
     CPPUNIT_TEST(testTextViewSelection);
+    CPPUNIT_TEST(testDocumentSizeChanged);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -74,6 +77,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
@@ -144,12 +148,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;
@@ -419,7 +429,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());
@@ -430,7 +440,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()
@@ -448,7 +458,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);
@@ -458,6 +468,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 698c356..459ab62 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 118e224..6c8a94b 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