From 9aa44bca070e88ec9f0945522e4b4620213f68d5 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 19 Jul 2015 22:09:41 +0000 Subject: [PATCH] #58130 CF Threshold formats differ slightly between types git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691858 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/record/CFRule12Record.java | 3 +- .../record/cf/ColorGradientFormatting.java | 79 +++++++++++++------ .../record/cf/ColorGradientThreshold.java | 63 +++++++++++++++ .../record/cf/IconMultiStateFormatting.java | 2 +- .../record/cf/IconMultiStateThreshold.java | 75 ++++++++++++++++++ .../apache/poi/hssf/record/cf/Threshold.java | 38 ++------- .../usermodel/HSSFColorScaleFormatting.java | 8 +- 7 files changed, 208 insertions(+), 60 deletions(-) create mode 100644 src/java/org/apache/poi/hssf/record/cf/ColorGradientThreshold.java create mode 100644 src/java/org/apache/poi/hssf/record/cf/IconMultiStateThreshold.java diff --git a/src/java/org/apache/poi/hssf/record/CFRule12Record.java b/src/java/org/apache/poi/hssf/record/CFRule12Record.java index e7974a092..80a31b321 100644 --- a/src/java/org/apache/poi/hssf/record/CFRule12Record.java +++ b/src/java/org/apache/poi/hssf/record/CFRule12Record.java @@ -21,6 +21,7 @@ import java.util.Arrays; import org.apache.poi.hssf.record.cf.ColorGradientFormatting; import org.apache.poi.hssf.record.cf.IconMultiStateFormatting; +import org.apache.poi.hssf.record.cf.IconMultiStateThreshold; import org.apache.poi.hssf.record.cf.Threshold; import org.apache.poi.hssf.record.common.FtrHeader; import org.apache.poi.hssf.record.common.FutureRecord; @@ -125,7 +126,7 @@ public final class CFRule12Record extends CFRuleBase implements FutureRecord { public static CFRule12Record create(HSSFSheet sheet, IconSet iconSet) { Threshold[] ts = new Threshold[iconSet.num]; for (int i=0; i 0) { @@ -63,9 +53,6 @@ public final class Threshold { type != RangeType.MAX.id) { value = in.readDouble(); } - equals = in.readByte(); - // Reserved, 4 bytes, all 0 - in.readInt(); } public byte getType() { @@ -74,7 +61,7 @@ public final class Threshold { public void setType(byte type) { this.type = type; - // Ensure the value presense / absense is consistent for the new type + // Ensure the value presence / absence is consistent for the new type if (type == RangeType.MIN.id || type == RangeType.MAX.id || type == RangeType.FORMULA.id) { this.value = null; @@ -106,19 +93,11 @@ public final class Threshold { this.value = value; } - public byte getEquals() { - return equals; - } - public void setEquals(byte equals) { - this.equals = equals; - } - public int getDataLength() { int len = 1 + formula.getEncodedSize(); if (value != null) { len += 8; } - len += 5; return len; } @@ -132,13 +111,10 @@ public final class Threshold { return buffer.toString(); } - public Object clone() { - Threshold rec = new Threshold(); + public void copyTo(Threshold rec) { rec.type = type; rec.formula = formula; rec.value = value; - rec.equals = equals; - return rec; } public void serialize(LittleEndianOutput out) { @@ -151,7 +127,5 @@ public final class Threshold { if (value != null) { out.writeDouble(value); } - out.writeByte(equals); - out.writeInt(0); // Reserved } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFColorScaleFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFColorScaleFormatting.java index 6e82072d4..3d4613f98 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFColorScaleFormatting.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFColorScaleFormatting.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.record.CFRule12Record; import org.apache.poi.hssf.record.cf.ColorGradientFormatting; +import org.apache.poi.hssf.record.cf.ColorGradientThreshold; import org.apache.poi.hssf.record.cf.Threshold; import org.apache.poi.ss.usermodel.Color; import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold; @@ -62,14 +63,15 @@ public final class HSSFColorScaleFormatting implements org.apache.poi.ss.usermod } public void setThresholds(ConditionalFormattingThreshold[] thresholds) { - Threshold[] t = new Threshold[thresholds.length]; + ColorGradientThreshold[] t = new ColorGradientThreshold[thresholds.length]; for (int i=0; i