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

Miklos Vajna vmiklos at collabora.co.uk
Tue Mar 1 12:46:03 UTC 2016


 desktop/qa/data/hidden-row.ods              |binary
 desktop/qa/desktop_lib/test_desktop_lib.cxx |   35 ++++++++++++++++++++++++++++
 sc/source/ui/view/tabview.cxx               |    3 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit f5005d52389cb7519734b45d6268434ed3604679
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Mar 1 11:38:19 2016 +0100

    ccu#1573 sc lok: fix reporting of hidden row height
    
    For columns we use ScDocument::GetColWidth(), which returns 0 for hidden
    columsn. Do the same for rows: so instead of using GetOriginalHeight(),
    use GetRowHeight(), and then 0 size will be reported for hidden rows as
    well.
    
    (cherry picked from commit 20ad023a918204da922c4c262b50a411f2e2dace)
    
    Change-Id: Ic23b6af744bbc8e194e1906614adebe5ba0c7ced

diff --git a/desktop/qa/data/hidden-row.ods b/desktop/qa/data/hidden-row.ods
new file mode 100644
index 0000000..25fe898
Binary files /dev/null and b/desktop/qa/data/hidden-row.ods differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3315029..3a0e67b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -85,6 +85,7 @@ public:
     void testPasteWriter();
     void testPasteWriterJPEG();
     void testRowColumnHeaders();
+    void testHiddenRowHeaders();
     void testCommandResult();
     void testWriterComments();
     void testSheetOperations();
@@ -103,6 +104,7 @@ public:
     CPPUNIT_TEST(testPasteWriter);
     CPPUNIT_TEST(testPasteWriterJPEG);
     CPPUNIT_TEST(testRowColumnHeaders);
+    CPPUNIT_TEST(testHiddenRowHeaders);
     CPPUNIT_TEST(testCommandResult);
     CPPUNIT_TEST(testWriterComments);
     CPPUNIT_TEST(testSheetOperations);
@@ -521,6 +523,39 @@ void DesktopLOKTest::testRowColumnHeaders()
     }
 }
 
+void DesktopLOKTest::testHiddenRowHeaders()
+{
+    LibLODocument_Impl* pDocument = loadDoc("hidden-row.ods");
+
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
+
+    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);
+    sal_Int32 nPrevious = 0;
+    bool bFirst = true;
+    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);
+
+        if (bFirst)
+            bFirst = false;
+        else
+        {
+            // nSize was 509, nPrevious was 254, i.e. hidden row wasn't reported as 0 height.
+            CPPUNIT_ASSERT_EQUAL(nPrevious, nSize);
+            break;
+        }
+
+        nPrevious = nSize;
+    }
+}
+
 void DesktopLOKTest::testCommandResult()
 {
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 903013c..c7cf4cb 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2324,7 +2324,8 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
     long nTotalPixels = 0;
     for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
     {
-        sal_uInt16 nSize = pDoc->GetOriginalHeight(nRow, aViewData.GetTabNo());
+        // nSize will be 0 for hidden rows.
+        sal_uInt16 nSize = pDoc->GetRowHeight(nRow, aViewData.GetTabNo());
         long nSizePixels = ScViewData::ToPixel(nSize, aViewData.GetPPTY());
         OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
 


More information about the Libreoffice-commits mailing list