diff options
-rw-r--r-- | sc/qa/unit/data/ods/tdf145059.ods | bin | 0 -> 15610 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 31 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/inc/xestyle.hxx | 5 |
5 files changed, 50 insertions, 6 deletions
diff --git a/sc/qa/unit/data/ods/tdf145059.ods b/sc/qa/unit/data/ods/tdf145059.ods Binary files differnew file mode 100644 index 000000000000..a76da3b5cb4e --- /dev/null +++ b/sc/qa/unit/data/ods/tdf145059.ods diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 20be9da85bfb..f035efba1aac 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -214,6 +214,7 @@ public: void testTdf142264ManyChartsToXLSX(); void testTdf143929MultiColumnToODS(); void testTdf142578(); + void testTdf145059(); void testTdf130104_XLSXIndent(); CPPUNIT_TEST_SUITE(ScExportTest2); @@ -328,6 +329,7 @@ public: CPPUNIT_TEST(testTdf142264ManyChartsToXLSX); CPPUNIT_TEST(testTdf143929MultiColumnToODS); CPPUNIT_TEST(testTdf142578); + CPPUNIT_TEST(testTdf145059); CPPUNIT_TEST(testTdf130104_XLSXIndent); CPPUNIT_TEST_SUITE_END(); @@ -2993,6 +2995,35 @@ void ScExportTest2::testTdf142578() xDocSh->DoClose(); } +void ScExportTest2::testTdf145059() +{ + ScDocShellRef xDocSh = loadDoc(u"tdf145059.", FORMAT_ODS); + CPPUNIT_ASSERT(xDocSh); + + // Export to xlsx. + std::shared_ptr<utl::TempFile> pXPathFile + = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); + xmlDocUniquePtr pSheet + = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pSheet); + xmlDocUniquePtr pStyle = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml"); + CPPUNIT_ASSERT(pStyle); + + sal_Int32 nColorFilterDxdId + = getXPath(pSheet, "/x:worksheet/x:autoFilter/x:filterColumn/x:colorFilter", "dxfId") + .toInt32(); + + // Ensure that dxf id is not -1 + CPPUNIT_ASSERT(nColorFilterDxdId >= 0); + + // Find color by this dxfid + OString sDxfIdPath = "/x:styleSheet/x:dxfs/x:dxf[" + OString::number(nColorFilterDxdId + 1) + + "]/x:fill/x:patternFill/x:fgColor"; + assertXPath(pStyle, sDxfIdPath, "rgb", "FF4472C4"); + + xDocSh->DoClose(); +} + void ScExportTest2::testTdf130104_XLSXIndent() { ScDocShellRef xDocSh = loadDoc(u"tdf130104_indent.", FORMAT_XLSX); diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 65edd87ee5bc..570167b8014b 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -796,6 +796,10 @@ void XclExpAutofilter::AddColorEntry(const ScQueryEntry& rEntry) { maColorValues.push_back( std::make_pair(rItem.maColor, rItem.meType == ScQueryEntry::ByBackgroundColor)); + // Ensure that selected color(s) will be added to dxf: selection can be not in list + // of already added to dfx colors taken from filter range + if (GetDxfs().GetDxfByColor(rItem.maColor) == -1) + GetDxfs().AddColor(rItem.maColor); } } diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 3898c5cad9b6..291b51c6c83e 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3176,22 +3176,30 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) } } -sal_Int32 XclExpDxfs::GetDxfId( const OUString& rStyleName ) +sal_Int32 XclExpDxfs::GetDxfId( const OUString& rStyleName ) const { - std::map<OUString, sal_Int32>::iterator itr = maStyleNameToDxfId.find(rStyleName); + std::map<OUString, sal_Int32>::const_iterator itr = maStyleNameToDxfId.find(rStyleName); if(itr!= maStyleNameToDxfId.end()) return itr->second; return -1; } -sal_Int32 XclExpDxfs::GetDxfByColor(Color aColor) +sal_Int32 XclExpDxfs::GetDxfByColor(Color aColor) const { - std::map<Color, sal_Int32>::iterator itr = maColorToDxfId.find(aColor); + std::map<Color, sal_Int32>::const_iterator itr = maColorToDxfId.find(aColor); if (itr != maColorToDxfId.end()) return itr->second; return -1; } +void XclExpDxfs::AddColor(Color aColor) +{ + maColorToDxfId.emplace(aColor, maDxf.size()); + + std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(aColor, 0)); + maDxf.push_back(std::make_unique<XclExpDxf>(GetRoot(), std::move(pExpCellArea))); +} + void XclExpDxfs::SaveXml( XclExpXmlStream& rStrm ) { if(maDxf.empty()) diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx index 7bacfb6eccb4..d922b45399e2 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -748,8 +748,9 @@ class XclExpDxfs : public XclExpRecordBase, protected XclExpRoot public: XclExpDxfs( const XclExpRoot& rRoot ); - sal_Int32 GetDxfId(const OUString& rName); - sal_Int32 GetDxfByColor(Color aColor); + sal_Int32 GetDxfId(const OUString& rName) const; + sal_Int32 GetDxfByColor(Color aColor) const; + void AddColor(Color aColor); virtual void SaveXml( XclExpXmlStream& rStrm) override; private: |