sc/inc/colorscale.hxx | 1 + sc/inc/conditio.hxx | 5 +++++ sc/source/core/data/colorscale.cxx | 6 ++++++ sc/source/core/data/conditio.cxx | 20 ++++++++++++++++++++ sc/source/core/data/table2.cxx | 3 +++ 5 files changed, 35 insertions(+)
New commits: commit da818b2b96368fa088240f9d24586d1cea7650be Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu May 11 16:07:10 2023 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Tue May 16 22:18:18 2023 +0200 tdf#154477: 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/+/151838 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 513eb11cf2f4..e78baf0871b2 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 afd16ba27365..51786d3dc712 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -251,6 +251,7 @@ public: virtual void startRendering(); virtual void endRendering(); + virtual void updateValues(); protected: ScDocument* mpDoc; @@ -598,6 +599,8 @@ public: void startRendering(); void endRendering(); + void updateValues(); + // Forced recalculation for formulas void CalcAll(); }; @@ -683,6 +686,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 192dd1cea78c..1bb36712fd13 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -529,6 +529,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 8da18a4a0471..1979d8ab44dd 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -74,6 +74,10 @@ void ScFormatEntry::endRendering() { } +void ScFormatEntry::updateValues() +{ +} + static bool lcl_HasRelRef( ScDocument* pDoc, const ScTokenArray* pFormula, sal_uInt16 nRecursion = 0 ) { if (pFormula) @@ -2051,6 +2055,14 @@ void ScConditionalFormat::endRendering() } } +void ScConditionalFormat::updateValues() +{ + for(auto& rxEntry : maEntries) + { + rxEntry->updateValues(); + } +} + void ScConditionalFormat::CalcAll() { for(const auto& rxEntry : maEntries) @@ -2298,6 +2310,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 4eb5671f0dc7..47b3d1634c77 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -529,7 +529,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(