From 2abaaf97e95bf6149378c6cd5e58cdb2ce78dc4b Mon Sep 17 00:00:00 2001 From: Attila Szűcs Date: Thu, 16 Jul 2020 09:34:31 +0200 Subject: tdf#134459 XLSX export: fix missing font color in header/footer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tibor Nagy (NISZ) Change-Id: I7aacbad1c4052b2480630d0b98175b46cf2aeed0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98873 Tested-by: László Németh Reviewed-by: László Németh --- .../unit/data/xlsx/tdf134459_HeaderFooterColor.xlsx | Bin 0 -> 9421 bytes sc/qa/unit/subsequent_export-test.cxx | 20 ++++++++++++++++++++ sc/source/filter/excel/xehelper.cxx | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 sc/qa/unit/data/xlsx/tdf134459_HeaderFooterColor.xlsx (limited to 'sc') diff --git a/sc/qa/unit/data/xlsx/tdf134459_HeaderFooterColor.xlsx b/sc/qa/unit/data/xlsx/tdf134459_HeaderFooterColor.xlsx new file mode 100644 index 000000000000..fe799886c062 Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf134459_HeaderFooterColor.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index cfdaebe86902..6a40b53b9ac8 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -251,6 +251,7 @@ public: void testTdf81470(); void testTdf122331(); void testTdf83779(); + void testTdf134459_HeaderFooterColorXLSX(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -400,6 +401,7 @@ public: CPPUNIT_TEST(testTdf81470); CPPUNIT_TEST(testTdf122331); CPPUNIT_TEST(testTdf83779); + CPPUNIT_TEST(testTdf134459_HeaderFooterColorXLSX); CPPUNIT_TEST_SUITE_END(); @@ -5121,6 +5123,24 @@ void ScExportTest::testTdf83779() xShell->DoClose(); } +void ScExportTest::testTdf134459_HeaderFooterColorXLSX() +{ + // Colors in header and footer should be exported, and imported properly + ScDocShellRef xShell = loadDoc("tdf134459_HeaderFooterColor.", FORMAT_XLSX); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/sheet1.xml", FORMAT_XLSX); + CPPUNIT_ASSERT(pDoc); + + assertXPathContent(pDoc, "/x:worksheet/x:headerFooter/x:oddHeader", "&L&Kc06040l&C&K4c3789c&Rr"); + assertXPathContent(pDoc, "/x:worksheet/x:headerFooter/x:oddFooter", "&Ll&C&K64cf5fc&R&Kcd15aar"); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx index 6584c314aae5..b9df7b460c58 100644 --- a/sc/source/filter/excel/xehelper.cxx +++ b/sc/source/filter/excel/xehelper.cxx @@ -780,6 +780,13 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico (nTmpUnderl == EXC_FONTUNDERL_SINGLE)? aParaText.append("&U") : aParaText.append("&E"); } + // font color + aNewData.maColor = aFont.GetColor(); + if ( !aFontData.maColor.IsRGBEqual( aNewData.maColor ) ) + { + aParaText.append("&K").append(aNewData.maColor.AsRGBHexString()); + } + // strikeout aNewData.mbStrikeout = (aFont.GetStrikeout() != STRIKEOUT_NONE); if( aFontData.mbStrikeout != aNewData.mbStrikeout ) -- cgit