summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-05-11 16:07:10 -0400
committerAron Budea <aron.budea@collabora.com>2023-05-24 21:11:34 +0200
commit5a04a1198bfd1b16fa980edb2d0cd2a4da99bdac (patch)
tree8ac693fa2108ae22daa4324805107c0af8f9ae05
parent10714b0e2112a99c234368cad5ac0e87a57598d7 (diff)
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/+/151685 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> (cherry picked from commit 1751877e646667793dd3593dff95665790100b69)
-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 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(