diff options
author | Henry Castro <hcastro@collabora.com> | 2023-05-11 16:07:10 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-06-14 14:30:48 +0200 |
commit | b81ccbf6d48c6c2e79929332f5574ac5e6f48d6d (patch) | |
tree | 9b181eb441e3850e06a18ee6cab38da6677fc69b | |
parent | 705f89a66b736f2680a8e40268aab8a898669d4b (diff) |
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 <hcastro@collabora.com>
Change-Id: I660e18090a60b99ddf2b55ce1f713fd41121290e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151835
Tested-by: Jenkins
(cherry picked from commit fcb348da642f7e5c41fe495cf6289f9992bfa1b9)
-rw-r--r-- | sc/inc/colorscale.hxx | 1 | ||||
-rw-r--r-- | sc/inc/conditio.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 3 |
5 files changed, 35 insertions, 0 deletions
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 d47b841b0880..ed4c196c2066 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 0a357828c61e..33880848d5fc 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -511,6 +511,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 dae08455b0e9..a9ac1f45fd00 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) @@ -2057,6 +2061,14 @@ void ScConditionalFormat::endRendering() } } +void ScConditionalFormat::updateValues() +{ + for(auto& rxEntry : maEntries) + { + rxEntry->updateValues(); + } +} + void ScConditionalFormat::CalcAll() { for(const auto& rxEntry : maEntries) @@ -2304,6 +2316,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 713be792ac19..a424a0a8308d 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( |