[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sc/qa sc/source

Vasily Melenchuk Vasily.Melenchuk at cib.de
Fri Jun 8 03:57:58 UTC 2018


Rebased ref, commits from common ancestor:
commit 81edd2a15b7b47264d301a7a4c71e8dee93caebe
Author: Vasily Melenchuk <Vasily.Melenchuk at cib.de>
Date:   Fri Apr 6 20:19:10 2018 +0300

    tdf#62268: allow row height recalculation on document load
    
    During document load rows with style:use-optimal-row-height="true"
    should recalculate it's height.
    
    Reviewed-on: https://gerrit.libreoffice.org/52521
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    
    Conflicts:
            sc/qa/unit/subsequent_filters-test.cxx
            sc/source/filter/xml/xmlimprt.hxx
            sc/source/filter/xml/xmlimprt.cxx
            sc/source/filter/xml/xmlrowi.cxx
    
    Change-Id: Ib38b5b753d9ff8352116d77851d228c5d77bd530

diff --git a/sc/qa/unit/data/ods/tdf62268.ods b/sc/qa/unit/data/ods/tdf62268.ods
new file mode 100644
index 000000000000..da88adfd25cd
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf62268.ods differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index ac61dc2f9955..7b3c6b57109c 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -731,7 +731,8 @@ void ScBootstrapFixture::miscRowHeightsTest( TestParam* aTestValues, unsigned in
                     bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
                     CPPUNIT_ASSERT_EQUAL(aTestValues[ index ].pData[ i ].bOptimal, bOpt);
                 }
-                CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight);
+                // Due to some minor differences on Mac this comparison is made bit fuzzy
+                CPPUNIT_ASSERT_LESSEQUAL( 3, abs( nHeight - nExpectedHeight ) );
             }
         }
         xShell->DoClose();
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 4e90034a5f99..ba3e5dc610af 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -800,60 +800,57 @@ void ScExportTest::testOutlineExportXLSX()
     // We expected that exactly 13 unique Nodes will be produced
     assertXPath(pSheet, "/x:worksheet/x:cols/x:col", 13);
 
-    // We need to save all 30 rows, as it provides information about outLineLevel
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "r", "1");
+    // First row is empty and default so it is not written into XML file
+    // so we need to save 29 rows, as it provides information about outLineLevel
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "r", "2");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "hidden", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "outlineLevel", "0");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "outlineLevel", "1");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "r", "2");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "r", "3");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "hidden", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "outlineLevel", "1");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "outlineLevel", "2");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "r", "3");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "r", "4");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "hidden", "false");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "outlineLevel", "2");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "r", "4");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "r", "5");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "hidden", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "outlineLevel", "2");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "outlineLevel", "3");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "r", "5");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "r", "6");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "hidden", "false");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "outlineLevel", "3");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[5]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "r", "6");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "hidden", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "outlineLevel", "3");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "r", "7");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "hidden", "true");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "outlineLevel", "4");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[6]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "r", "7");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "r", "8");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "hidden", "true");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "outlineLevel", "4");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[7]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "r", "8");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "r", "9");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "hidden", "true");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "outlineLevel", "4");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[8]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "r", "9");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "hidden", "true");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "outlineLevel", "4");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[9]", "collapsed", "false");
     // Next rows are the same as the previous one but it needs to bre preserved,
     // as they contain information about outlineLevel
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "r", "21");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "hidden", "true");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "outlineLevel", "4");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "collapsed", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "r", "22");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "r", "21");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "hidden", "true");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "outlineLevel", "4");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[20]", "collapsed", "false");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "r", "22");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "hidden", "false");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "outlineLevel", "3");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[21]", "collapsed", "true");
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "r", "23");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "hidden", "false");
     assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "outlineLevel", "3");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "collapsed", "true");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "r", "23");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "hidden", "false");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "outlineLevel", "3");
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[23]", "collapsed", "false");
-
-    // We expected that exactly 30 Row Nodes will be produced
-    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 30);
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[22]", "collapsed", "false");
+
+    // We expected that exactly 29 Row Nodes will be produced
+    assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 29);
 }
 
 
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 69d7a4f43a36..c493f3606cf8 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -220,6 +220,8 @@ public:
 
     void testBnc762542();
 
+    void testTdf62268();
+
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testBooleanFormatXLSX);
     CPPUNIT_TEST(testBasicCellContentODS);
@@ -328,6 +330,8 @@ public:
 
     CPPUNIT_TEST(testHiddenSheetsXLSX);
 
+    CPPUNIT_TEST(testTdf62268);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2856,8 +2860,8 @@ void ScFiltersTest::testMiscRowHeights()
 
     TestParam::RowData MultiLineOptData[] =
     {
-        // Row 0 is 12.63 mm and optimal flag is set
-        { 0, 0, 0, 1263, CHECK_OPTIMAL, true  },
+        // Row 0 is 12.63 mm, but optimal flag is set
+        { 0, 0, 0, 1236, CHECK_OPTIMAL, true  },
         // Row 1 is 11.99 mm and optimal flag is NOT set
         { 1, 1, 0, 1199, CHECK_OPTIMAL, false  },
     };
@@ -2890,8 +2894,9 @@ void ScFiltersTest::testOptimalHeightReset()
     rDoc.EnableAdjustHeight( true );
     // open document in read/write mode ( otherwise optimal height stuff won't
     // be triggered ) *and* you can't delete cell contents.
-    int nHeight = sc::TwipsToHMM ( rDoc.GetRowHeight(nRow, nTab, false) );
-    CPPUNIT_ASSERT_EQUAL(1263, nHeight);
+    int nHeight = rDoc.GetRowHeight(nRow, nTab, false);
+    // Due to some minor differences on Mac this comparison is made bit fuzzy
+    CPPUNIT_ASSERT_LESSEQUAL( 3, abs( nHeight - 701 ) );
 
     ScDocFunc &rFunc = xDocSh->GetDocFunc();
 
@@ -3499,6 +3504,21 @@ void ScFiltersTest::testRelFormulaValidationXLS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testTdf62268()
+{
+    ScDocShellRef xDocSh = loadDoc("tdf62268.", FORMAT_ODS);
+    ScDocument& rDoc = xDocSh->GetDocument();
+    int nHeight;
+
+    SCTAB nTab = 0;
+    nHeight = rDoc.GetRowHeight(0, nTab, false);
+    CPPUNIT_ASSERT_EQUAL(256, nHeight);
+    nHeight = rDoc.GetRowHeight(1, nTab, false);
+    CPPUNIT_ASSERT_EQUAL(1905, nHeight);
+
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "sc/qa/unit/data" )
 {
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index a82de485c12e..1dd8918c44a1 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -73,6 +73,7 @@
 #include "pivotsource.hxx"
 #include <unonames.hxx>
 #include <numformat.hxx>
+#include <sizedev.hxx>
 
 #include <comphelper/extract.hxx>
 
@@ -3257,6 +3258,26 @@ void SAL_CALL ScXMLImport::endDocument()
                     pDoc->SetStreamValid( nTab, true );
             }
         }
+
+        // There are rows with optimal height which need to be updated
+        if (!maRecalcRowRanges.empty())
+        {
+            bool bLockHeight = pDoc->IsAdjustHeightEnabled();
+            if (bLockHeight)
+            {
+                pDoc->EnableAdjustHeight(true);
+            }
+
+            ScSizeDeviceProvider aProv(static_cast<ScDocShell*>(pDoc->GetDocumentShell()));
+            ScDocRowHeightUpdater aUpdater(*pDoc, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &maRecalcRowRanges);
+            aUpdater.update();
+
+            if (bLockHeight)
+            {
+                pDoc->EnableAdjustHeight(false);
+            }
+        }
+
         aTables.FixupOLEs();
     }
     if (GetModel().is())
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 570d2f206c28..da905e6a8dd8 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -32,6 +32,7 @@
 #include "global.hxx"
 #include <formula/grammar.hxx>
 #include "compiler.hxx"
+#include "dociter.hxx"
 
 #include "xmlstyle.hxx"
 #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
@@ -936,6 +937,8 @@ class ScXMLImport: public SvXMLImport
 
     ScMyTables              aTables;
 
+    std::vector<ScDocRowHeightUpdater::TabRanges> maRecalcRowRanges;
+
     ScMyNamedExpressions*   m_pMyNamedExpressions;
     SheetNamedExpMap m_SheetNamedExpressions;
 
@@ -1010,6 +1013,8 @@ public:
 
     ScMyTables& GetTables() { return aTables; }
 
+    std::vector<ScDocRowHeightUpdater::TabRanges>& GetRecalcRowRanges() { return maRecalcRowRanges; }
+
     bool IsStylesOnlyMode() const { return !bLoadDoc; }
 
     sal_Int16 GetCellType(const OUString& rStrValue) const;
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index 2de0899e8443..d2308a69f722 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -27,6 +27,7 @@
 #include "olinetab.hxx"
 #include "sheetdata.hxx"
 #include "documentimport.hxx"
+#include "unonames.hxx"
 
 #include <xmloff/xmltkmap.hxx>
 #include <xmloff/nmspmap.hxx>
@@ -205,6 +206,21 @@ void ScXMLTableRowContext::EndElement()
                     }
                     if (bFiltered)
                         xRowProperties->setPropertyValue(SC_ISFILTERED, uno::makeAny(bFiltered));
+
+                    uno::Any any = xRowProperties->getPropertyValue(SC_UNONAME_OHEIGHT);
+                    bool bOptionalHeight = false;
+                    any >>= bOptionalHeight;
+                    if (bOptionalHeight)
+                    {
+                        // Save this row for later height update
+                        std::vector<ScDocRowHeightUpdater::TabRanges>& rRecalcRanges = rXMLImport.GetRecalcRowRanges();
+                        while (static_cast<SCTAB>(rRecalcRanges.size()) <= nSheet)
+                        {
+                            rRecalcRanges.emplace_back(0);
+                        }
+                        rRecalcRanges.at(nSheet).mnTab = nSheet;
+                        rRecalcRanges.at(nSheet).mpRanges->setTrue(nFirstRow, nCurrentRow);
+                    }
                 }
             }
         }


More information about the Libreoffice-commits mailing list