You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/07/13 19:32:05 UTC

svn commit: r1690773 - in /poi/trunk/src/java/org/apache/poi/hssf/record: CFHeader12Record.java CFRule12Record.java common/FutureRecord.java

Author: nick
Date: Mon Jul 13 17:32:05 2015
New Revision: 1690773

URL: http://svn.apache.org/r1690773
Log:
New future record interface, and more CFRule12 toString output

Added:
    poi/trunk/src/java/org/apache/poi/hssf/record/common/FutureRecord.java
Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/CFHeader12Record.java
    poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFHeader12Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFHeader12Record.java?rev=1690773&r1=1690772&r2=1690773&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFHeader12Record.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFHeader12Record.java Mon Jul 13 17:32:05 2015
@@ -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.LittleEndianO
  * 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 exte
         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();

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java?rev=1690773&r1=1690772&r2=1690773&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java Mon Jul 13 17:32:05 2015
@@ -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 extend
     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 extend
 
         return rec;
     }
+    
+    public short getFutureRecordType() {
+        return futureHeader.getRecordType();
+    }
+    public FtrHeader getFutureHeader() {
+        return futureHeader;
+    }
+    public CellRangeAddress getAssociatedRange() {
+        return futureHeader.getAssociatedRange();
+    }
 }

Added: poi/trunk/src/java/org/apache/poi/hssf/record/common/FutureRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FutureRecord.java?rev=1690773&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FutureRecord.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FutureRecord.java Mon Jul 13 17:32:05 2015
@@ -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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org