sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx |binary sc/qa/unit/subsequent_export_test2.cxx | 21 +++++++++++++ sc/source/filter/excel/xetable.cxx | 8 +++- 3 files changed, 26 insertions(+), 3 deletions(-)
New commits: commit c57d113e9ef8608f5690e8707a97879cb4f6a185 Author: Attila Szűcs <attila.sz...@collabora.com> AuthorDate: Tue Nov 29 09:45:36 2022 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Mon Dec 19 06:16:08 2022 +0000 tdf#151755 fix export of borders of contentless cells Change-Id: I650aeebb4d021911c1f14d4867c5beee84020155 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143880 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx b/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx new file mode 100644 index 000000000000..e48562022af8 Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 4010cc9dce1f..40fb4f360536 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -166,6 +166,7 @@ public: void testTdf139258_rotated_image(); void testTdf144642_RowHeightRounding(); void testTdf145129_DefaultRowHeightRounding(); + void testTdf151755_stylesLostOnXLSXExport(); void testTdf140431(); void testCheckboxFormControlXlsxExport(); void testButtonFormControlXlsxExport(); @@ -293,6 +294,7 @@ public: CPPUNIT_TEST(testTdf139258_rotated_image); CPPUNIT_TEST(testTdf144642_RowHeightRounding); CPPUNIT_TEST(testTdf145129_DefaultRowHeightRounding); + CPPUNIT_TEST(testTdf151755_stylesLostOnXLSXExport); CPPUNIT_TEST(testTdf140431); CPPUNIT_TEST(testCheckboxFormControlXlsxExport); CPPUNIT_TEST(testButtonFormControlXlsxExport); @@ -2269,6 +2271,25 @@ void ScExportTest2::testTdf145129_DefaultRowHeightRounding() CPPUNIT_ASSERT_EQUAL(tools::Long(555 * 52), pDoc->GetRowHeight(0, 51, 0, true)); } +void ScExportTest2::testTdf151755_stylesLostOnXLSXExport() +{ + // Check if empty cells with custom sytle are exported, even if + // there is other empty cells with default style, left of it. + createScDoc("xlsx/tdf151755_stylesLostOnXLSXExport.xlsx"); + + // Resave the xlsx file without any modification. + save("Calc Office Open XML"); + xmlDocUniquePtr pSheet = parseExport("xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pSheet); + + // Check if all the 3 empty cells with styles are saved, and have the same style id. + assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c", 4); + OUString aCellStyleId = getXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]", "s"); + assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]", "s", aCellStyleId); + assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[3]", "s", aCellStyleId); + assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[4]", "s", aCellStyleId); +} + void ScExportTest2::testTdf140431() { createScDoc("xlsx/129969-min.xlsx"); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 146f6a06833b..e7abb111c63e 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1310,12 +1310,14 @@ void XclExpMultiCellBase::RemoveUnusedXFIndexes( const ScfUInt16Vec& rXFIndexes, sal_uInt16 XclExpMultiCellBase::GetStartColAllDefaultCell() const { sal_uInt16 col = GetXclCol(); + sal_uInt16 nMaxNonDefCol = col; for( const auto& rXFId : maXFIds ) { - if( rXFId.mnXFIndex != EXC_XF_DEFAULTCELL ) - col += rXFId.mnCount; + col += rXFId.mnCount; + if (rXFId.mnXFIndex != EXC_XF_DEFAULTCELL) + nMaxNonDefCol = col; } - return col; + return nMaxNonDefCol; } XclExpBlankCell::XclExpBlankCell( const XclAddress& rXclPos, const XclExpMultiXFId& rXFId ) :