sc/inc/colorscale.hxx | 3 +++ sc/inc/conditio.hxx | 5 +++++ sc/source/core/data/colorscale.cxx | 21 +++++++++++++++++++++ sc/source/core/data/conditio.cxx | 20 ++++++++++++++++++++ sc/source/core/data/table2.cxx | 3 +++ sc/source/filter/html/htmlexp.cxx | 23 ++++++++++++++++++++++- 6 files changed, 74 insertions(+), 1 deletion(-)
New commits: commit 6cedc29a03938784ea9d59626221fb17abfb7258 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu May 11 16:29:55 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Wed May 24 21:11:54 2023 +0200 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 <hcas...@collabora.com> Change-Id: I82b466a2100abc5070e92f844dc706d9b015c2e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151687 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 3a8420ae420d475e4e8fbeecc6a8ac74b6bc5b33) 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(); commit 4e897dc555ad00e611b16cba7a7ae18bd2a745c2 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu May 11 16:23:03 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Wed May 24 21:11:45 2023 +0200 sc: copy cache values when clone color conditional format When clone a conditional format list, also copy the cache values that hold the min and max values, otherwise if clone occurs when copying to the clipboard the values have wrong data due to limiting range cells copied. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: Id9085a1488a3bde24842e0d2e062c9b425074157 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151686 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 8ac5e24a3575d140008a6b8d4c6414dc3ef1ef4b) diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 9923eac4c572..fc5c34dda287 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -224,6 +224,8 @@ public: virtual ~ScColorFormat() override; const ScRangeList& GetRange() const; + void SetCache(const std::vector<double>& aValues); + std::vector<double> GetCache() const; virtual void SetParent(ScConditionalFormat* pParent) override; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index b84d6a063034..8b1a8987acbb 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -379,6 +379,9 @@ ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleForma { maColorScales.emplace_back(new ScColorScaleEntry(pDoc, *rxEntry)); } + + auto aCache = rFormat.GetCache(); + SetCache(aCache); } ScColorFormat* ScColorScaleFormat::Clone(ScDocument* pDoc) const @@ -440,6 +443,18 @@ const ScRangeList& ScColorFormat::GetRange() const return mpParent->GetRange(); } +std::vector<double> ScColorFormat::GetCache() const +{ + std::vector<double> empty; + return mpCache ? mpCache->maValues : empty; +} + +void ScColorFormat::SetCache(const std::vector<double>& aValues) +{ + mpCache.reset(new ScColorFormatCache); + mpCache->maValues = aValues; +} + std::vector<double>& ScColorFormat::getValues() const { if(!mpCache) commit 5a04a1198bfd1b16fa980edb2d0cd2a4da99bdac Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu May 11 16:07:10 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Wed May 24 21:11:34 2023 +0200 sc: add "updateValues" method to conditional format list When copying a range cells to a clipboard, if exists a color scale conditional format from different ranges, it should update the min and max values, otherwise the color scale conditional format could not calculate min and max values due to limiting range cell copied. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: I660e18090a60b99ddf2b55ce1f713fd41121290e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151685 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 1751877e646667793dd3593dff95665790100b69) diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index de74030dbc85..9923eac4c572 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -229,6 +229,7 @@ public: virtual void startRendering() override; virtual void endRendering() override; + virtual void updateValues() override; protected: std::vector<double>& getValues() const; diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index a2441d22c3c2..a891bda54897 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -252,6 +252,7 @@ public: virtual void startRendering(); virtual void endRendering(); + virtual void updateValues(); protected: ScDocument* mpDoc; @@ -599,6 +600,8 @@ public: void startRendering(); void endRendering(); + void updateValues(); + // Forced recalculation for formulas void CalcAll(); }; @@ -684,6 +687,8 @@ public: void startRendering(); void endRendering(); + void updateValues(); + sal_uInt32 getMaxKey() const; /// Forced recalculation of formulas diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 52496653ab1b..b84d6a063034 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -512,6 +512,12 @@ void ScColorFormat::endRendering() mpCache.reset(); } +void ScColorFormat::updateValues() +{ + getMinValue(); + getMaxValue(); +} + namespace { sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 ) diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 35a6ff99c699..72446f306562 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -73,6 +73,10 @@ void ScFormatEntry::endRendering() { } +void ScFormatEntry::updateValues() +{ +} + static bool lcl_HasRelRef( ScDocument* pDoc, const ScTokenArray* pFormula, sal_uInt16 nRecursion = 0 ) { if (pFormula) @@ -2040,6 +2044,14 @@ void ScConditionalFormat::endRendering() } } +void ScConditionalFormat::updateValues() +{ + for(auto& rxEntry : maEntries) + { + rxEntry->updateValues(); + } +} + void ScConditionalFormat::CalcAll() { for(const auto& rxEntry : maEntries) @@ -2287,6 +2299,14 @@ void ScConditionalFormatList::endRendering() } } +void ScConditionalFormatList::updateValues() +{ + for (auto const& it : m_ConditionalFormats) + { + it->updateValues(); + } +} + void ScConditionalFormatList::clear() { m_ConditionalFormats.clear(); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index c2de8dead98c..1f5d1fb34f4b 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -522,7 +522,10 @@ void ScTable::CopyToClip( for (SCCOL i = nCol1; i <= nCol2; i++) pTable->aCol[i].RemoveProtected(nRow1, nRow2); + mpCondFormatList->startRendering(); + mpCondFormatList->updateValues(); pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->rDocument, *mpCondFormatList)); + mpCondFormatList->endRendering(); } void ScTable::CopyToClip(