diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2021-12-30 15:32:37 +0300 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2022-01-06 21:25:18 +0100 |
commit | f0ad6ec2a23a36ade407db8cda36655ba2f144c1 (patch) | |
tree | 6ba9b42d9f0f52483ee299ed5bc3962fbfbd9ff9 /sc/source | |
parent | e9dce4e8cbea04d6c6636a45f5a172e986714409 (diff) |
tdf#145059: sc: always write dxf node for color filter for XLSX
If there is no dxf reference to color filter (for example if selected
color is not in range of available colors for current range) Excel
is not able to show color filter correctly: it is not marked as used
filter, no ability to reset, etc.
Change-Id: I65378ddd6f8f8233cda147ff9dcd28f455a58225
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127745
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sc/source')
-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 |
3 files changed, 19 insertions, 6 deletions
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: |