summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-05-11 16:07:10 -0400
committerHenry Castro <hcastro@collabora.com>2023-06-29 19:30:14 +0200
commite4010b7d83244d9d51f36e22c9d9cd63eda870cb (patch)
tree9d8c1c473ba987352909631732e773a537e3238a /sc
parent284ac82b1af70c8734bae6eb841ae01735bb6b41 (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) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152520
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/colorscale.hxx1
-rw-r--r--sc/inc/conditio.hxx5
-rw-r--r--sc/source/core/data/colorscale.cxx6
-rw-r--r--sc/source/core/data/conditio.cxx20
-rw-r--r--sc/source/core/data/table2.cxx3
5 files changed, 35 insertions, 0 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index fb987f5af1b5..6652e224fe67 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -231,6 +231,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 50b74bd8721c..47f5fdb3addb 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 e3c3780971fb..4e61dbdbc228 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -544,6 +544,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 54f89dd3a7b3..b70f9579d0e8 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)
@@ -2053,6 +2057,14 @@ void ScConditionalFormat::endRendering()
}
}
+void ScConditionalFormat::updateValues()
+{
+ for(auto& rxEntry : maEntries)
+ {
+ rxEntry->updateValues();
+ }
+}
+
void ScConditionalFormat::CalcAll()
{
for(const auto& rxEntry : maEntries)
@@ -2300,6 +2312,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 91f90dbb1ae4..910568d35720 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -532,7 +532,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(