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

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 3 07:28:46 PST 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   32 ++++++++++++++++++++++++++++
 sc/source/ui/view/tabview.cxx               |    4 +--
 2 files changed, 34 insertions(+), 2 deletions(-)

New commits:
commit 788cec0a60dcfce6d86c820e9d0f7a1eb634f7bf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 3 16:26:46 2015 +0100

    sc lok: avoid placeholder row when providing all headers
    
    In case the logic visible area is known, info is provided only about the
    visible headers. Given that only relative sizes (no absolute positions)
    are provided, a placeholder row/col is added to the result that contains
    the total size of the skipped items.
    
    These placeholder items are not needed when providing all headers, so
    don't emit them.
    
    Change-Id: I48ccb73554313f4d2bb420e4402995719b0f9f7d

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 4debd8c..cbd18f7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -66,6 +66,7 @@ public:
     void testSaveAs();
     void testSaveAsCalc();
     void testPasteWriter();
+    void testRowColumnHeaders();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(testGetStyles);
@@ -78,6 +79,7 @@ public:
     CPPUNIT_TEST(testSaveAs);
     CPPUNIT_TEST(testSaveAsCalc);
     CPPUNIT_TEST(testPasteWriter);
+    CPPUNIT_TEST(testRowColumnHeaders);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -346,6 +348,36 @@ void DesktopLOKTest::testPasteWriter()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testRowColumnHeaders()
+{
+    LibLODocument_Impl* pDocument = loadDoc("search.ods");
+    boost::property_tree::ptree aTree;
+    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
+    std::stringstream aStream(pJSON);
+    free(pJSON);
+    CPPUNIT_ASSERT(!aStream.str().empty());
+
+    boost::property_tree::read_json(aStream, aTree);
+    for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
+    {
+        sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
+        CPPUNIT_ASSERT(nSize > 0);
+        OString aText(rValue.second.get<std::string>("text").c_str());
+        // This failed, as the first item did not contain the text of the first row.
+        CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
+        break;
+    }
+
+    for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
+    {
+        sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
+        CPPUNIT_ASSERT(nSize > 0);
+        OString aText(rValue.second.get<std::string>("text").c_str());
+        CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
+        break;
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 615f0d9..d197750 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2308,7 +2308,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
         }
         if (!bSkip)
         {
-            if (aRows.empty())
+            if (aRows.empty() && nTotal > 0)
             {
                 // The sizes are relative sizes, so include the total skipped size before the real items.
                 boost::property_tree::ptree aRow;
@@ -2345,7 +2345,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
         }
         if (!bSkip)
         {
-            if (aCols.empty())
+            if (aCols.empty() && nTotal > 0)
             {
                 boost::property_tree::ptree aCol;
                 aCol.put("size", OString::number(long((nTotalPixels + 0.5) / aViewData.GetPPTX())).getStr());


More information about the Libreoffice-commits mailing list