summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-03-28 18:03:21 -0400
committerHenry Castro <hcastro@collabora.com>2023-06-16 22:49:05 +0200
commit7f733ff497a2ac1731229b3963602f1feb3ef88e (patch)
tree7847fe4e378d5d3abbfb421fe31b97fccc107f1f /sc
parent967c8db8e1ebee924b185b7476df712189e4e51b (diff)
sc: filter: oox: fix conditional color scale same range
Otherwise, the condition color scale the priority order will be lost. <conditionalFormatting sqref="G1:G5"> <cfRule type="colorScale" priority="5"> <colorScale> <cfvo type="min" val=""""/> <cfvo type="max" val=""""/> <color theme="5" tint="-0.249977111117893"/> <color rgb="FF92D050"/> </colorScale> </cfRule> </conditionalFormatting> <conditionalFormatting sqref="G1:G5"> <cfRule type="colorScale" priority="1"> <colorScale> <cfvo type="min" val=""""/> <cfvo type="max" val=""""/> <color theme="0" tint="0"/> <color theme="0" tint="0"/> </colorScale> </cfRule> </conditionalFormatting> Signed-off-by: Henry Castro <hcastro@collabora.com> Change-Id: I33fa73bfe8f0bada1cf79bc07be2e43495a4290c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149721 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151979 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153182 Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/inc/condformatbuffer.hxx4
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx25
-rw-r--r--sc/source/filter/oox/condformatcontext.cxx4
3 files changed, 32 insertions, 1 deletions
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index a1cc7bb81381..81961151beb8 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -148,6 +148,7 @@ private:
/** Represents a single rule in a conditional formatting. */
class CondFormatRule final : public WorksheetHelper
{
+friend class CondFormatBuffer;
public:
explicit CondFormatRule( const CondFormat& rCondFormat, ScConditionalFormat* pFormat );
@@ -167,6 +168,7 @@ public:
/** Returns the priority of this rule. */
sal_Int32 getPriority() const { return maModel.mnPriority; }
+ ColorScaleRule* getCurColorScale() const { return mpColor.get(); }
ColorScaleRule* getColorScale();
DataBarRule* getDataBar();
@@ -310,6 +312,8 @@ public:
static sal_Int32 convertToApiOperator( sal_Int32 nToken );
static ScConditionMode convertToInternalOperator( sal_Int32 nToken );
void finalizeImport();
+ bool insertColorScale(CondFormatRef const & xCondFmt, CondFormatRuleRef const & xRule);
+
private:
CondFormatRef createCondFormat();
void updateImport(const ScDataBarFormatData* pTarget);
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 4ce1ca7fc257..d049534d2f6a 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1208,6 +1208,31 @@ void CondFormatBuffer::updateImport(const ScDataBarFormatData* pTarget)
}
}
+bool CondFormatBuffer::insertColorScale(CondFormatRef const & xCondFmt, CondFormatRuleRef const & xRule)
+{
+ CondFormatRef xFoundFmt;
+ ScRangeList aRanges = xCondFmt->getRanges();
+
+ for (auto& rCondFmt : maCondFormats)
+ {
+ if (xCondFmt == rCondFmt)
+ continue;
+
+ if (aRanges == rCondFmt->getRanges())
+ {
+ xFoundFmt = rCondFmt;
+ break;
+ }
+ }
+
+ if (xFoundFmt)
+ {
+ xRule->mpFormat = xFoundFmt->mpFormat;
+ xFoundFmt->insertRule(xRule);
+ }
+
+ return static_cast<bool>(xFoundFmt);
+}
void CondFormatBuffer::finalizeImport()
{
diff --git a/sc/source/filter/oox/condformatcontext.cxx b/sc/source/filter/oox/condformatcontext.cxx
index 845d105b7605..a28b7b12453d 100644
--- a/sc/source/filter/oox/condformatcontext.cxx
+++ b/sc/source/filter/oox/condformatcontext.cxx
@@ -205,7 +205,9 @@ void CondFormatContext::onEndElement()
case XLS_TOKEN( cfRule ):
if (mxCondFmt && mxRule)
{
- mxCondFmt->insertRule(mxRule);
+ if (!mxRule->getCurColorScale() ||
+ !getCondFormats().insertColorScale(mxCondFmt, mxRule))
+ mxCondFmt->insertRule(mxRule);
}
break;
}