sc/qa/unit/data/xlsx/tdf145129_DefaultRowHeight_28.35pt_SavedByExcel.xlsx 
|binary
 sc/qa/unit/subsequent_export_test2.cxx                                    |   
17 ++++++++++
 sc/source/filter/oox/worksheetfragment.cxx                                |    
7 +++-
 3 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 69424f0fd66a74dbabba66c9c7fb1420aa1ff4e9
Author:     Attila Szűcs <szucs.atti...@nisz.hu>
AuthorDate: Fri Oct 15 13:55:36 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Oct 26 11:13:45 2021 +0200

    tdf#145129 XLSX import: round down default row height
    
    like table layout of MSO does, e.g. 20 pt to 19.5 pt.
    
    Same as tdf#144642, but with default row height.
    
    Follow-up to commit 537cb82be8fa021fd9382cca874645c75daaef20
    "tdf#144642 XLSX import: round down row height to 0.75 pt".
    
    Co-authored-by: Tibor Nagy (NISZ)
    
    Change-Id: Iefb615b56e5ddc11a5e839cf6d90516b18646045
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123655
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git 
a/sc/qa/unit/data/xlsx/tdf145129_DefaultRowHeight_28.35pt_SavedByExcel.xlsx 
b/sc/qa/unit/data/xlsx/tdf145129_DefaultRowHeight_28.35pt_SavedByExcel.xlsx
new file mode 100644
index 000000000000..f8041d58eb65
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf145129_DefaultRowHeight_28.35pt_SavedByExcel.xlsx 
differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 2be6a07c4af8..53aaedb48288 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -200,6 +200,7 @@ public:
     void testTdf139258_rotated_image();
     void testTdf142854_GridVisibilityImportXlsxInHeadlessMode();
     void testTdf144642_RowHeightRounding();
+    void testTdf145129_DefaultRowHeightRounding();
     void testTdf140431();
     void testCheckboxFormControlXlsxExport();
     void testButtonFormControlXlsxExport();
@@ -311,6 +312,7 @@ public:
     CPPUNIT_TEST(testTdf139258_rotated_image);
     CPPUNIT_TEST(testTdf142854_GridVisibilityImportXlsxInHeadlessMode);
     CPPUNIT_TEST(testTdf144642_RowHeightRounding);
+    CPPUNIT_TEST(testTdf145129_DefaultRowHeightRounding);
     CPPUNIT_TEST(testTdf140431);
     CPPUNIT_TEST(testCheckboxFormControlXlsxExport);
     CPPUNIT_TEST(testButtonFormControlXlsxExport);
@@ -2572,6 +2574,21 @@ void ScExportTest2::testTdf144642_RowHeightRounding()
     xShell->DoClose();
 }
 
+void ScExportTest2::testTdf145129_DefaultRowHeightRounding()
+{
+    // MS Excel round down row heights to 0.75pt
+    // Same as Tdf144642 but with default row height.
+
+    ScDocShellRef xShell
+        = loadDoc(u"tdf145129_DefaultRowHeight_28.35pt_SavedByExcel.", 
FORMAT_XLSX);
+    CPPUNIT_ASSERT(xShell.is());
+    ScDocument& rDoc = xShell->GetDocument();
+    // 555twips == 27.75pt == 9.79mm
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(555), rDoc.GetRowHeight(0, 0));
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(555 * 52), rDoc.GetRowHeight(0, 51, 0, 
true));
+    xShell->DoClose();
+}
+
 void ScExportTest2::testTdf140431()
 {
     ScDocShellRef xShell = loadDoc(u"129969-min.", FORMAT_XLSX);
diff --git a/sc/source/filter/oox/worksheetfragment.cxx 
b/sc/source/filter/oox/worksheetfragment.cxx
index a0e01c915dcf..218ab447545b 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -667,8 +667,13 @@ void WorksheetFragment::importSheetFormatPr( const 
AttributeList& rAttribs )
     // XML_outlineLevelRow
     // XML_outlineLevelCol
     // as it will be updated during export to OOXML
+    double fDefaultRowHeight = rAttribs.getDouble(XML_defaultRowHeight, 0.0);
+    if (getFilter().isMSODocument())
+    {
+        fDefaultRowHeight -= fmod(fDefaultRowHeight, 0.75);  //round down to 
0.75pt
+    }
     setDefaultRowSettings(
-        rAttribs.getDouble( XML_defaultRowHeight, 0.0 ),
+        fDefaultRowHeight,
         rAttribs.getBool( XML_customHeight, false ),
         rAttribs.getBool( XML_zeroHeight, false ),
         rAttribs.getBool( XML_thickTop, false ),

Reply via email to