New future record interface, and more CFRule12 toString output

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1690773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2015-07-13 17:32:05 +00:00
parent 4fbce64e1d
commit 935491b4e2
3 changed files with 80 additions and 7 deletions

View File

@ -18,6 +18,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.hssf.record.common.FtrHeader; 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.ss.util.CellRangeAddress;
import org.apache.poi.util.LittleEndianOutput; import org.apache.poi.util.LittleEndianOutput;
@ -25,7 +26,7 @@ import org.apache.poi.util.LittleEndianOutput;
* Conditional Formatting Header v12 record CFHEADER12 (0x0879), * Conditional Formatting Header v12 record CFHEADER12 (0x0879),
* for conditional formattings introduced in Excel 2007 and newer. * 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; public static final short sid = 0x0879;
private FtrHeader futureHeader; private FtrHeader futureHeader;
@ -68,6 +69,16 @@ public final class CFHeader12Record extends CFHeaderBase {
return sid; return sid;
} }
public short getFutureRecordType() {
return futureHeader.getRecordType();
}
public FtrHeader getFutureHeader() {
return futureHeader;
}
public CellRangeAddress getAssociatedRange() {
return futureHeader.getAssociatedRange();
}
public Object clone() { public Object clone() {
CFHeader12Record result = new CFHeader12Record(); CFHeader12Record result = new CFHeader12Record();
result.futureHeader = (FtrHeader)futureHeader.clone(); result.futureHeader = (FtrHeader)futureHeader.clone();

View File

@ -20,9 +20,12 @@ package org.apache.poi.hssf.record;
import java.util.Arrays; import java.util.Arrays;
import org.apache.poi.hssf.record.common.FtrHeader; 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.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.formula.Formula; import org.apache.poi.ss.formula.Formula;
import org.apache.poi.ss.formula.ptg.Ptg; 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.LittleEndianOutput;
import org.apache.poi.util.POILogger; 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}, * {@link #CONDITION_TYPE_CELL_VALUE_IS} or {@link #CONDITION_TYPE_FORMULA},
* this is only used for the other types * 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; public static final short sid = 0x087A;
private FtrHeader futureHeader; private FtrHeader futureHeader;
@ -260,10 +263,29 @@ public final class CFRule12Record extends CFRuleBase {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[CFRULE12]\n"); buffer.append("[CFRULE12]\n");
buffer.append(" .condition_type=").append(getConditionType()).append("\n"); buffer.append(" .condition_type=").append(getConditionType()).append("\n");
buffer.append(" TODO The rest!\n"); // TODO The Rest buffer.append(" .dxfn12_length =0x").append(Integer.toHexString(ext_formatting_length)).append("\n");
buffer.append(" Formula 1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n"); buffer.append(" .option_flags =0x").append(Integer.toHexString(getOptions())).append("\n");
buffer.append(" Formula 2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n"); if (containsFontFormattingBlock()) {
buffer.append(" Formula S =").append(Arrays.toString(formula_scale.getTokens())).append("\n"); 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"); buffer.append("[/CFRULE12]\n");
return buffer.toString(); return buffer.toString();
} }
@ -278,4 +300,14 @@ public final class CFRule12Record extends CFRuleBase {
return rec; return rec;
} }
public short getFutureRecordType() {
return futureHeader.getRecordType();
}
public FtrHeader getFutureHeader() {
return futureHeader;
}
public CellRangeAddress getAssociatedRange() {
return futureHeader.getAssociatedRange();
}
} }

View File

@ -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();
}