]> source.dussan.org Git - poi.git/commitdiff
New future record interface, and more CFRule12 toString output
authorNick Burch <nick@apache.org>
Mon, 13 Jul 2015 17:32:05 +0000 (17:32 +0000)
committerNick Burch <nick@apache.org>
Mon, 13 Jul 2015 17:32:05 +0000 (17:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1690773 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/CFHeader12Record.java
src/java/org/apache/poi/hssf/record/CFRule12Record.java
src/java/org/apache/poi/hssf/record/common/FutureRecord.java [new file with mode: 0644]

index 58b7780917f5586eb19f9d5e98df183246b269a2..89c4421de56a111223f7799cde92432fdc0cde38 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.hssf.record.common.FtrHeader;
+import org.apache.poi.hssf.record.common.FutureRecord;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LittleEndianOutput;
 
@@ -25,7 +26,7 @@ import org.apache.poi.util.LittleEndianOutput;
  * Conditional Formatting Header v12 record CFHEADER12 (0x0879),
  *  for conditional formattings introduced in Excel 2007 and newer.
  */
-public final class CFHeader12Record extends CFHeaderBase {
+public final class CFHeader12Record extends CFHeaderBase implements FutureRecord {
     public static final short sid = 0x0879;
 
     private FtrHeader futureHeader;
@@ -68,6 +69,16 @@ public final class CFHeader12Record extends CFHeaderBase {
         return sid;
     }
 
+    public short getFutureRecordType() {
+        return futureHeader.getRecordType();
+    }
+    public FtrHeader getFutureHeader() {
+        return futureHeader;
+    }
+    public CellRangeAddress getAssociatedRange() {
+        return futureHeader.getAssociatedRange();
+    }
+    
     public Object clone() {
         CFHeader12Record result = new CFHeader12Record();
         result.futureHeader = (FtrHeader)futureHeader.clone();
index c5afb3e4e80dae10549f6143ae2fc9a90e07016c..f496f4e9b4dd17f85d145ddcbe7b7d8ff4f283f2 100644 (file)
@@ -20,9 +20,12 @@ package org.apache.poi.hssf.record;
 import java.util.Arrays;
 
 import org.apache.poi.hssf.record.common.FtrHeader;
+import org.apache.poi.hssf.record.common.FutureRecord;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.ss.formula.Formula;
 import org.apache.poi.ss.formula.ptg.Ptg;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.HexDump;
 import org.apache.poi.util.LittleEndianOutput;
 import org.apache.poi.util.POILogger;
 
@@ -36,7 +39,7 @@ import org.apache.poi.util.POILogger;
  *  {@link #CONDITION_TYPE_CELL_VALUE_IS} or {@link #CONDITION_TYPE_FORMULA},
  *  this is only used for the other types
  */
-public final class CFRule12Record extends CFRuleBase {
+public final class CFRule12Record extends CFRuleBase implements FutureRecord {
     public static final short sid = 0x087A;
 
     private FtrHeader futureHeader;
@@ -259,11 +262,30 @@ public final class CFRule12Record extends CFRuleBase {
     public String toString() {
         StringBuffer buffer = new StringBuffer();
         buffer.append("[CFRULE12]\n");
-        buffer.append("    .condition_type   =").append(getConditionType()).append("\n");
-        buffer.append("    TODO The rest!\n"); // TODO The Rest
-        buffer.append("    Formula 1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n");
-        buffer.append("    Formula 2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n");
-        buffer.append("    Formula S =").append(Arrays.toString(formula_scale.getTokens())).append("\n");
+        buffer.append("    .condition_type=").append(getConditionType()).append("\n");
+        buffer.append("    .dxfn12_length =0x").append(Integer.toHexString(ext_formatting_length)).append("\n");
+        buffer.append("    .option_flags  =0x").append(Integer.toHexString(getOptions())).append("\n");
+        if (containsFontFormattingBlock()) {
+            buffer.append(_fontFormatting.toString()).append("\n");
+        }
+        if (containsBorderFormattingBlock()) {
+            buffer.append(_borderFormatting.toString()).append("\n");
+        }
+        if (containsPatternFormattingBlock()) {
+            buffer.append(_patternFormatting.toString()).append("\n");
+        }
+        buffer.append("    .dxfn12_ext=").append(HexDump.toHex(ext_formatting_data)).append("\n");
+        buffer.append("    .formula_1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n");
+        buffer.append("    .formula_2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n");
+        buffer.append("    .formula_S =").append(Arrays.toString(formula_scale.getTokens())).append("\n");
+        buffer.append("    .ext Opts  =").append(ext_opts).append("\n");
+        buffer.append("    .priority  =").append(priority).append("\n");
+        buffer.append("    .template_type  =").append(template_type).append("\n");
+        buffer.append("    .template_params=").append(HexDump.toHex(template_params)).append("\n");
+        buffer.append("    .gradient_data  =").append(HexDump.toHex(gradient_data)).append("\n");
+        buffer.append("    .databar_data   =").append(HexDump.toHex(databar_data)).append("\n");
+        buffer.append("    .filter_data    =").append(HexDump.toHex(filter_data)).append("\n");
+        buffer.append("    .multistate_data=").append(HexDump.toHex(multistate_data)).append("\n");
         buffer.append("[/CFRULE12]\n");
         return buffer.toString();
     }
@@ -278,4 +300,14 @@ public final class CFRule12Record extends CFRuleBase {
 
         return rec;
     }
+    
+    public short getFutureRecordType() {
+        return futureHeader.getRecordType();
+    }
+    public FtrHeader getFutureHeader() {
+        return futureHeader;
+    }
+    public CellRangeAddress getAssociatedRange() {
+        return futureHeader.getAssociatedRange();
+    }
 }
diff --git a/src/java/org/apache/poi/hssf/record/common/FutureRecord.java b/src/java/org/apache/poi/hssf/record/common/FutureRecord.java
new file mode 100644 (file)
index 0000000..65a26cc
--- /dev/null
@@ -0,0 +1,30 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.common;
+
+import org.apache.poi.ss.util.CellRangeAddress;
+
+/**
+ * Title: Future Record, a newer (largely Excel 2007+) record
+ *  which contains a Future Record Header ({@link FtrHeader})
+ */
+public interface FutureRecord {
+    public short getFutureRecordType();
+    public FtrHeader getFutureHeader();
+    public CellRangeAddress getAssociatedRange();
+}
\ No newline at end of file