aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-10-05 00:26:19 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-10-05 00:26:19 +0000
commit79879fb28620e4fbde8741ec35dd800c60555e90 (patch)
treeb9fb816fa9ffd21e5be139779961266276de78c9
parent012cfb107cc9b72f962085c284467a8907f48794 (diff)
downloadpoi-79879fb28620e4fbde8741ec35dd800c60555e90.tar.gz
poi-79879fb28620e4fbde8741ec35dd800c60555e90.zip
Fixed a problem with save-and-load of conditional formattings (CFHeader12 wasn't added to conditional formattings, rgb value wasn't saved in extended color)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1706739 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/poi/hssf/model/InternalSheet.java3
-rw-r--r--src/java/org/apache/poi/hssf/record/CFHeaderBase.java16
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java1
3 files changed, 14 insertions, 6 deletions
diff --git a/src/java/org/apache/poi/hssf/model/InternalSheet.java b/src/java/org/apache/poi/hssf/model/InternalSheet.java
index cbb921b2f7..8cb482a574 100644
--- a/src/java/org/apache/poi/hssf/model/InternalSheet.java
+++ b/src/java/org/apache/poi/hssf/model/InternalSheet.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.poi.hssf.record.BOFRecord;
+import org.apache.poi.hssf.record.CFHeader12Record;
import org.apache.poi.hssf.record.CFHeaderRecord;
import org.apache.poi.hssf.record.CalcCountRecord;
import org.apache.poi.hssf.record.CalcModeRecord;
@@ -190,7 +191,7 @@ public final class InternalSheet {
while (rs.hasNext()) {
int recSid = rs.peekNextSid();
- if ( recSid == CFHeaderRecord.sid ) {
+ if ( recSid == CFHeaderRecord.sid || recSid == CFHeader12Record.sid ) {
condFormatting = new ConditionalFormattingTable(rs);
records.add(condFormatting);
continue;
diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderBase.java b/src/java/org/apache/poi/hssf/record/CFHeaderBase.java
index aa9f2daf03..dc7052de45 100644
--- a/src/java/org/apache/poi/hssf/record/CFHeaderBase.java
+++ b/src/java/org/apache/poi/hssf/record/CFHeaderBase.java
@@ -62,13 +62,17 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
public boolean getNeedRecalculation() {
// Held on the 1st bit
- return field_2_need_recalculation_and_id % 2 == 1;
+ return (field_2_need_recalculation_and_id & 1) == 1;
}
public void setNeedRecalculation(boolean b) {
// held on the first bit
- if (b == getNeedRecalculation()) return;
- if (b) field_2_need_recalculation_and_id++;
- else field_2_need_recalculation_and_id--;
+ if (b == getNeedRecalculation()) {
+ return;
+ } else if (b) {
+ field_2_need_recalculation_and_id++;
+ } else {
+ field_2_need_recalculation_and_id--;
+ }
}
public int getID() {
@@ -79,7 +83,9 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
// Remaining 15 bits of field 2
boolean needsRecalc = getNeedRecalculation();
field_2_need_recalculation_and_id = (id<<1);
- if (needsRecalc) field_2_need_recalculation_and_id++;
+ if (needsRecalc) {
+ field_2_need_recalculation_and_id++;
+ }
}
public CellRangeAddress getEnclosingCellRange() {
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java b/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
index 7806fb5184..e6c8c1bf5e 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
@@ -97,6 +97,7 @@ public class HSSFExtendedColor extends ExtendedColor {
rgb[3] = a;
color.setRGBA(rgb);
}
+ color.setType(TYPE_RGB);
}
public double getTint() {