sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx |binary sc/qa/unit/subsequent_export_test2.cxx | 23 +++++++++++++ sc/source/filter/excel/xetable.cxx | 8 ++-- 3 files changed, 28 insertions(+), 3 deletions(-)
New commits: commit 9934947c36bf1a1e548f667c72fba1891bbb2cff Author: Attila Szűcs <[email protected]> AuthorDate: Tue Nov 29 09:45:36 2022 +0100 Commit: Andras Timar <[email protected]> CommitDate: Tue Dec 13 15:51:35 2022 +0000 tdf#151755 fix export of borders of contentless cells Change-Id: I650aeebb4d021911c1f14d4867c5beee84020155 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143431 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Andras Timar <[email protected]> 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 c958f40402ef..bcf262dd42e9 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -204,6 +204,7 @@ public: void testTdf142854_GridVisibilityImportXlsxInHeadlessMode(); void testTdf144642_RowHeightRounding(); void testTdf145129_DefaultRowHeightRounding(); + void testTdf151755_stylesLostOnXLSXExport(); void testTdf140431(); void testCheckboxFormControlXlsxExport(); void testButtonFormControlXlsxExport(); @@ -322,6 +323,7 @@ public: CPPUNIT_TEST(testTdf142854_GridVisibilityImportXlsxInHeadlessMode); CPPUNIT_TEST(testTdf144642_RowHeightRounding); CPPUNIT_TEST(testTdf145129_DefaultRowHeightRounding); + CPPUNIT_TEST(testTdf151755_stylesLostOnXLSXExport); CPPUNIT_TEST(testTdf140431); CPPUNIT_TEST(testCheckboxFormControlXlsxExport); CPPUNIT_TEST(testButtonFormControlXlsxExport); @@ -2605,6 +2607,27 @@ void ScExportTest2::testTdf145129_DefaultRowHeightRounding() xShell->DoClose(); } +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. + ScDocShellRef pShell = loadDoc(u"tdf151755_stylesLostOnXLSXExport.", FORMAT_XLSX); + + // Resave the xlsx file without any modification. + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(*pShell, FORMAT_XLSX); + xmlDocUniquePtr pSheet + = XPathHelper::parseExport(pXPathFile, m_xSFactory, "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); + pShell->DoClose(); +} + void ScExportTest2::testTdf140431() { ScDocShellRef xShell = loadDoc(u"129969-min.", FORMAT_XLSX); diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index dcbcba7251bb..804c09bd447f 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 ) :
