summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-05-11 16:23:03 -0400
committerHenry Castro <hcastro@collabora.com>2023-06-29 19:29:56 +0200
commit284ac82b1af70c8734bae6eb841ae01735bb6b41 (patch)
tree52c807f06fb20702ab30617d79a7812f6ee7152a
parent56c965372e2de4ea53b1ab09056906c85fbff06b (diff)
tdf#154477: 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 <hcastro@collabora.com> Change-Id: Id9085a1488a3bde24842e0d2e062c9b425074157 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151836 Tested-by: Jenkins (cherry picked from commit c85255fd7a62bec9342fa6f2a79d1395979d54be) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152521
-rw-r--r--sc/inc/colorscale.hxx2
-rw-r--r--sc/source/core/data/colorscale.cxx15
2 files changed, 17 insertions, 0 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 88e35775419a..fb987f5af1b5 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 876d100840bf..e3c3780971fb 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -378,6 +378,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
@@ -457,6 +460,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)