diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2022-12-19 05:35:36 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-12-20 12:57:14 +0000 |
commit | b66e35c721742d2ad1c8c2cc3251661b6ce81952 (patch) | |
tree | 88ed7a93055ae058fd942a15f2a584ff4a7d7638 | |
parent | 4f09c5f925dbfc32829b2c6a81f43290b4d3512e (diff) |
tdf#152581 SC: fix export of conditional border color
Call XclExpDxf::mpBorder->SetFinalColors(..) during export, before SaveXml().
It will calculate the prepered colors from mnLeftColorId to mnLeftColor,
so saveXml() will be able to save it.
Change-Id: I1a1eccccd621c6d0e883cb9016e60ae0b344bf90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144576
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx | bin | 0 -> 9984 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 15 | ||||
-rw-r--r-- | sc/source/filter/excel/xeroot.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/inc/xestyle.hxx | 3 |
5 files changed, 35 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx b/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx Binary files differnew file mode 100644 index 000000000000..2423f4cc0243 --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 9717f3579972..5a1ebc5c2d3c 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -167,6 +167,7 @@ public: void testTdf144642_RowHeightRounding(); void testTdf145129_DefaultRowHeightRounding(); void testTdf151755_stylesLostOnXLSXExport(); + void testTdf152581_bordercolorNotExportedToXLSX(); void testTdf140431(); void testCheckboxFormControlXlsxExport(); void testButtonFormControlXlsxExport(); @@ -295,6 +296,7 @@ public: CPPUNIT_TEST(testTdf144642_RowHeightRounding); CPPUNIT_TEST(testTdf145129_DefaultRowHeightRounding); CPPUNIT_TEST(testTdf151755_stylesLostOnXLSXExport); + CPPUNIT_TEST(testTdf152581_bordercolorNotExportedToXLSX); CPPUNIT_TEST(testTdf140431); CPPUNIT_TEST(testCheckboxFormControlXlsxExport); CPPUNIT_TEST(testButtonFormControlXlsxExport); @@ -2290,6 +2292,19 @@ void ScExportTest2::testTdf151755_stylesLostOnXLSXExport() assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[4]", "s", aCellStyleId); } +void ScExportTest2::testTdf152581_bordercolorNotExportedToXLSX() +{ + createScDoc("xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx"); + + // Resave the xlsx file without any modification. + save("Calc Office Open XML"); + xmlDocUniquePtr pStyles = parseExport("xl/styles.xml"); + CPPUNIT_ASSERT(pStyles); + + // Check if conditional format border color is exported + assertXPath(pStyles, "/x:styleSheet/x:dxfs/x:dxf/x:border/x:left/x:color", "rgb", "FFED7D31"); +} + void ScExportTest2::testTdf140431() { createScDoc("xlsx/129969-min.xlsx"); diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx index 38884c48415c..807a24aae60b 100644 --- a/sc/source/filter/excel/xeroot.cxx +++ b/sc/source/filter/excel/xeroot.cxx @@ -276,6 +276,7 @@ void XclExpRoot::InitializeSave() { GetPalette().Finalize(); GetXFBuffer().Finalize(); + GetDxfs().Finalize(); } XclExpRecordRef XclExpRoot::CreateRecord( sal_uInt16 nRecId ) const diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index cb1c3c8fe26a..3e335a50110c 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3210,6 +3210,14 @@ void XclExpDxfs::SaveXml( XclExpXmlStream& rStrm ) rStyleSheet->endElement( XML_dxfs ); } +void XclExpDxfs::Finalize() +{ + for (auto& rxDxf : maDxf) + { + rxDxf->SetFinalColors(); + } +} + XclExpDxf::XclExpDxf( const XclExpRoot& rRoot, std::unique_ptr<XclExpCellAlign> pAlign, std::unique_ptr<XclExpCellBorder> pBorder, std::unique_ptr<XclExpDxfFont> pFont, std::unique_ptr<XclExpNumFmt> pNumberFmt, std::unique_ptr<XclExpCellProt> pProt, std::unique_ptr<XclExpColor> pColor) @@ -3233,6 +3241,14 @@ XclExpDxf::~XclExpDxf() { } +void XclExpDxf::SetFinalColors() +{ + if (mpBorder) + { + mpBorder->SetFinalColors(GetPalette()); + } +} + void XclExpDxf::SaveXml( XclExpXmlStream& rStrm ) { sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream(); diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx index 7857e215557b..8c3493d352f3 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -734,6 +734,7 @@ public: virtual void SaveXml( XclExpXmlStream& rStrm ) override; void SaveXmlExt( XclExpXmlStream& rStrm); + void SetFinalColors(); private: std::unique_ptr<XclExpCellAlign> mpAlign; @@ -755,6 +756,8 @@ public: void AddColor(Color aColor); virtual void SaveXml( XclExpXmlStream& rStrm) override; + void Finalize(); + private: typedef std::vector< std::unique_ptr<XclExpDxf> > DxfContainer; std::map<OUString, sal_Int32> maStyleNameToDxfId; |