Blame SOURCES/0269-sc-lok-avoid-placeholder-row-when-providing-all-head.patch

135360
From 177773ea3cb22e81fa30dd9ffc89aa7e8a8fa4f1 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Tue, 3 Nov 2015 16:26:46 +0100
135360
Subject: [PATCH 269/398] sc lok: avoid placeholder row when providing all
135360
 headers
135360
135360
In case the logic visible area is known, info is provided only about the
135360
visible headers. Given that only relative sizes (no absolute positions)
135360
are provided, a placeholder row/col is added to the result that contains
135360
the total size of the skipped items.
135360
135360
These placeholder items are not needed when providing all headers, so
135360
don't emit them.
135360
135360
Change-Id: I48ccb73554313f4d2bb420e4402995719b0f9f7d
135360
(cherry picked from commit 788cec0a60dcfce6d86c820e9d0f7a1eb634f7bf)
135360
---
135360
 desktop/qa/desktop_lib/test_desktop_lib.cxx | 32 +++++++++++++++++++++++++++++
135360
 sc/source/ui/view/tabview.cxx               |  4 ++--
135360
 2 files changed, 34 insertions(+), 2 deletions(-)
135360
135360
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
135360
index c14261e82db6..29b0aedd4dfa 100644
135360
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
135360
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
135360
@@ -66,6 +66,7 @@ public:
135360
     void testSaveAs();
135360
     void testSaveAsCalc();
135360
     void testPasteWriter();
135360
+    void testRowColumnHeaders();
135360
 
135360
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
135360
     CPPUNIT_TEST(testGetStyles);
135360
@@ -78,6 +79,7 @@ public:
135360
     CPPUNIT_TEST(testSaveAs);
135360
     CPPUNIT_TEST(testSaveAsCalc);
135360
     CPPUNIT_TEST(testPasteWriter);
135360
+    CPPUNIT_TEST(testRowColumnHeaders);
135360
     CPPUNIT_TEST_SUITE_END();
135360
 
135360
     uno::Reference<lang::XComponent> mxComponent;
135360
@@ -346,6 +348,36 @@ void DesktopLOKTest::testPasteWriter()
135360
     comphelper::LibreOfficeKit::setActive(false);
135360
 }
135360
 
135360
+void DesktopLOKTest::testRowColumnHeaders()
135360
+{
135360
+    LibLODocument_Impl* pDocument = loadDoc("search.ods");
135360
+    boost::property_tree::ptree aTree;
135360
+    char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewRowColumnHeaders");
135360
+    std::stringstream aStream(pJSON);
135360
+    free(pJSON);
135360
+    CPPUNIT_ASSERT(!aStream.str().empty());
135360
+
135360
+    boost::property_tree::read_json(aStream, aTree);
135360
+    for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("rows"))
135360
+    {
135360
+        sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
135360
+        CPPUNIT_ASSERT(nSize > 0);
135360
+        OString aText(rValue.second.get<std::string>("text").c_str());
135360
+        // This failed, as the first item did not contain the text of the first row.
135360
+        CPPUNIT_ASSERT_EQUAL(OString("1"), aText);
135360
+        break;
135360
+    }
135360
+
135360
+    for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("columns"))
135360
+    {
135360
+        sal_Int32 nSize = OString(rValue.second.get<std::string>("size").c_str()).toInt32();
135360
+        CPPUNIT_ASSERT(nSize > 0);
135360
+        OString aText(rValue.second.get<std::string>("text").c_str());
135360
+        CPPUNIT_ASSERT_EQUAL(OString("A"), aText);
135360
+        break;
135360
+    }
135360
+}
135360
+
135360
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
135360
 
135360
 CPPUNIT_PLUGIN_IMPLEMENT();
135360
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
135360
index ab77b47bed0c..8edec1b22f3a 100644
135360
--- a/sc/source/ui/view/tabview.cxx
135360
+++ b/sc/source/ui/view/tabview.cxx
135360
@@ -2332,7 +2332,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
135360
         }
135360
         if (!bSkip)
135360
         {
135360
-            if (aRows.empty())
135360
+            if (aRows.empty() && nTotal > 0)
135360
             {
135360
                 // The sizes are relative sizes, so include the total skipped size before the real items.
135360
                 boost::property_tree::ptree aRow;
135360
@@ -2369,7 +2369,7 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
135360
         }
135360
         if (!bSkip)
135360
         {
135360
-            if (aCols.empty())
135360
+            if (aCols.empty() && nTotal > 0)
135360
             {
135360
                 boost::property_tree::ptree aCol;
135360
                 aCol.put("size", OString::number(long((nTotalPixels + 0.5) / aViewData.GetPPTX())).getStr());
135360
-- 
135360
2.12.0
135360