diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2022-11-29 09:45:36 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-12-13 15:51:35 +0000 |
commit | 9934947c36bf1a1e548f667c72fba1891bbb2cff (patch) | |
tree | 7f57569fc0aa48d9558eb6e0bcfdbda77bf1f8bc /sc | |
parent | c7db08cc6741d7d0edb0c9956b47dcab964caea4 (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx | bin | 0 -> 12993 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 23 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 8 |
3 files changed, 28 insertions, 3 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx b/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx Binary files differnew file mode 100644 index 000000000000..e48562022af8 --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx 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 ) : |