]> source.dussan.org Git - poi.git/commitdiff
Fixed a problem with save-and-load of conditional formattings (CFHeader12 wasn't...
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 5 Oct 2015 00:26:19 +0000 (00:26 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 5 Oct 2015 00:26:19 +0000 (00:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1706739 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/model/InternalSheet.java
src/java/org/apache/poi/hssf/record/CFHeaderBase.java
src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java

index cbb921b2f7c15a8b2d75aa1d54f2da692c2cd676..8cb482a574af41dc383148a465a613368cf19012 100644 (file)
@@ -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;
index aa9f2daf03aa88444cd94a71ea4fb36dacdd7fc5..dc7052de4539979054642ae69df8f41be7dd8cf2 100644 (file)
@@ -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() {
index 7806fb518443f6c72a3991a785fa5648d1cd8d72..e6c8c1bf5e4074c2817cecfa79f2048dc98f5b60 100644 (file)
@@ -97,6 +97,7 @@ public class HSSFExtendedColor extends ExtendedColor {
             rgb[3] = a;
             color.setRGBA(rgb);
         }
+        color.setType(TYPE_RGB);
     }
 
     public double getTint() {