summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-05-11 16:29:55 -0400
committerAron Budea <aron.budea@collabora.com>2023-05-24 21:11:54 +0200
commit6cedc29a03938784ea9d59626221fb17abfb7258 (patch)
treebd67b466c399940a116230613b34dc5fafcaf808
parent4e897dc555ad00e611b16cba7a7ae18bd2a745c2 (diff)
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/+/151687 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> (cherry picked from commit 3a8420ae420d475e4e8fbeecc6a8ac74b6bc5b33)
-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 270312f594ce..d21fcf4d0035 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>
@@ -881,10 +883,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() )
@@ -1023,7 +1042,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();