summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorAttila Szűcs <attila.szucs@collabora.com>2022-12-19 03:48:13 +0100
committerAndras Timar <andras.timar@collabora.com>2022-12-20 12:57:24 +0000
commit77449c9877bff4979e4d9ff0fe489f61e340c975 (patch)
tree46ff49cb7fbd0bb1a52889fab830bbf206acdc71 /sc
parent8d0a80fd909d961c37eb613d51858720aa766332 (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/+/144411 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/tdf152581_bordercolorNotExportedToXLSX.xlsxbin0 -> 9984 bytes
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx16
-rw-r--r--sc/source/filter/excel/xeroot.cxx1
-rw-r--r--sc/source/filter/excel/xestyle.cxx16
-rw-r--r--sc/source/filter/inc/xestyle.hxx4
5 files changed, 37 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx b/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx
new file mode 100644
index 000000000000..2423f4cc0243
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index bcf262dd42e9..329210a6d9eb 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -205,6 +205,7 @@ public:
void testTdf144642_RowHeightRounding();
void testTdf145129_DefaultRowHeightRounding();
void testTdf151755_stylesLostOnXLSXExport();
+ void testTdf152581_bordercolorNotExportedToXLSX();
void testTdf140431();
void testCheckboxFormControlXlsxExport();
void testButtonFormControlXlsxExport();
@@ -324,6 +325,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);
@@ -2628,6 +2630,20 @@ void ScExportTest2::testTdf151755_stylesLostOnXLSXExport()
pShell->DoClose();
}
+void ScExportTest2::testTdf152581_bordercolorNotExportedToXLSX()
+{
+ ScDocShellRef pShell = loadDoc(u"tdf152581_bordercolorNotExportedToXLSX.", FORMAT_XLSX);
+
+ // Resave the xlsx file without any modification.
+ std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(*pShell, FORMAT_XLSX);
+ xmlDocUniquePtr pStyles = XPathHelper::parseExport(pXPathFile, m_xSFactory, "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");
+ pShell->DoClose();
+}
+
void ScExportTest2::testTdf140431()
{
ScDocShellRef xShell = loadDoc(u"129969-min.", FORMAT_XLSX);
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index b0ac71643674..ea6ad3098a29 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -277,6 +277,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 1dd6401a79eb..63386c63555c 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 26ba9fcf8e39..84b03dc846a7 100644
--- a/sc/source/filter/inc/xestyle.hxx
+++ b/sc/source/filter/inc/xestyle.hxx
@@ -734,6 +734,8 @@ public:
virtual void SaveXml( XclExpXmlStream& rStrm ) override;
void SaveXmlExt( XclExpXmlStream& rStrm);
+ void SetFinalColors();
+
private:
std::unique_ptr<XclExpCellAlign> mpAlign;
std::unique_ptr<XclExpCellBorder> mpBorder;
@@ -754,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;