summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-05-11 16:29:55 -0400
committerAndras Timar <andras.timar@collabora.com>2023-06-14 14:31:25 +0200
commit11be07a66dee9f324850cfbdf7d92a4c6774902d (patch)
treebe14c615956d82a7348810ecf1957b4d9da562b6
parenttdf#154477: sc: copy cache values when clone color conditional format (diff)
downloadcore-11be07a66dee9f324850cfbdf7d92a4c6774902d.tar.gz
core-11be07a66dee9f324850cfbdf7d92a4c6774902d.zip
tdf#154477: sc: filter: html: fix missing color scale conditional format
When copying a range cell to an external application that request html data, the color scale conditional format does not have an associate a set attribute. Signed-off-by: Henry Castro <hcastro@collabora.com> Change-Id: I82b466a2100abc5070e92f844dc706d9b015c2e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151837 Tested-by: Jenkins (cherry picked from commit 604c27f7c382bdd6baea73e60eed6525b9bfbd3d)
-rw-r--r--sc/source/filter/html/htmlexp.cxx23
1 files changed, 22 insertions, 1 deletions
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 9c9f8745fac0..1f9edb6b5a3d 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -64,6 +64,8 @@
#include <editutil.hxx>
#include <ftools.hxx>
#include <cellvalue.hxx>
+#include <conditio.hxx>
+#include <colorscale.hxx>
#include <mtvelements.hxx>
#include <editeng/flditem.hxx>
@@ -880,10 +882,27 @@ void ScHTMLExport::WriteTables()
void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow, SCTAB nTab )
{
+ std::optional<Color> aColorScale;
ScAddress aPos( nCol, nRow, nTab );
ScRefCellValue aCell(*pDoc, aPos, rBlockPos);
const ScPatternAttr* pAttr = pDoc->GetPattern( nCol, nRow, nTab );
const SfxItemSet* pCondItemSet = pDoc->GetCondResult( nCol, nRow, nTab, &aCell );
+ if (!pCondItemSet)
+ {
+ ScConditionalFormatList* pCondList = pDoc->GetCondFormList(nTab);
+ const ScCondFormatItem& rCondItem = pAttr->GetItem(ATTR_CONDITIONAL);
+ const ScCondFormatIndexes& rCondIndex = rCondItem.GetCondFormatData();
+ if (rCondIndex.size() > 0)
+ {
+ ScConditionalFormat* pCondFmt = pCondList->GetFormat(rCondIndex[0]);
+ if (pCondFmt)
+ {
+ const ScColorScaleFormat* pEntry = dynamic_cast<const ScColorScaleFormat*>(pCondFmt->GetEntry(0));
+ if (pEntry)
+ aColorScale = pEntry->GetColor(aPos);
+ }
+ }
+ }
const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( ATTR_MERGE_FLAG, pCondItemSet );
if ( rMergeFlagAttr.IsOverlapped() )
@@ -1022,7 +1041,9 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC
ATTR_BACKGROUND, pCondItemSet );
Color aBgColor;
- if ( rBrushItem.GetColor().GetAlpha() == 0 )
+ if ( aColorScale )
+ aBgColor = *aColorScale;
+ else if ( rBrushItem.GetColor().GetAlpha() == 0 )
aBgColor = aHTMLStyle.aBackgroundColor; // No unwanted background color
else
aBgColor = rBrushItem.GetColor();