import java.util.Stack;
import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian;
/**
private short field_3_xf;
private double field_4_value;
private short field_5_options;
+ private BitField alwaysCalc = BitFieldFactory.getInstance(0x0001);
+ private BitField calcOnLoad = BitFieldFactory.getInstance(0x0002);
+ private BitField sharedFormula = BitFieldFactory.getInstance(0x0008);
private int field_6_zero;
private short field_7_expression_len;
private Stack field_8_parsed_expr;
{
return field_5_options;
}
-
+
+ public boolean isSharedFormula() {
+ return sharedFormula.isSet(field_5_options);
+ }
+
/**
* get the length (in number of tokens) of the expression
* @return expression length
{
return field_8_parsed_expr;
}
+
+ public void setParsedExpression(Stack ptgs) {
+ field_8_parsed_expr = ptgs;
+ }
/**
* called by constructor, should throw runtime exception in the event of a
.append("\n");
buffer.append(" .options = ").append(getOptions())
.append("\n");
+ buffer.append(" .alwaysCalc = ").append(alwaysCalc.isSet(getOptions()))
+ .append("\n");
+ buffer.append(" .calcOnLoad = ").append(calcOnLoad.isSet(getOptions()))
+ .append("\n");
+ buffer.append(" .sharedFormula = ").append(sharedFormula.isSet(getOptions()))
+ .append("\n");
buffer.append(" .zero = ").append(field_6_zero)
.append("\n");
buffer.append(" .expressionlength= ").append(getExpressionLength())
for (int k = 0; k < field_8_parsed_expr.size(); k++ ) {
- buffer.append("Formula ")
+ buffer.append(" Ptg(")
.append(k)
- .append("=")
+ .append(")=")
.append(field_8_parsed_expr.get(k).toString())
.append("\n")
.append(((Ptg)field_8_parsed_expr.get(k)).toDebugString())
package org.apache.poi.hssf.record;
+import java.util.Stack;
+import java.util.List;
+
+import org.apache.poi.hssf.record.formula.*;
import org.apache.poi.util.LittleEndian;
/**
extends Record
{
public final static short sid = 0x4BC;
- private short size = 0;
- private byte[] thedata = null;
- int offset = 0;
+
+ private int field_1_first_row;
+ private int field_2_last_row;
+ private short field_3_first_column;
+ private short field_4_last_column;
+ private int field_5_reserved;
+ private short field_6_expression_len;
+ private Stack field_7_parsed_expr;
public SharedFormulaRecord()
{
{
super(in);
}
+
+ protected void validateSid(short id)
+ {
+ if (id != this.sid)
+ {
+ throw new RecordFormatException("Not a valid SharedFormula");
+ }
+ }
+
+ public int getFirstRow() {
+ return field_1_first_row;
+ }
+
+ public int getLastRow() {
+ return field_2_last_row;
+ }
+
+ public short getFirstColumn() {
+ return field_3_first_column;
+ }
+
+ public short getLastColumn() {
+ return field_4_last_column;
+ }
+
+ public short getExpressionLength()
+ {
+ return field_6_expression_len;
+ }
/**
* spit the record out AS IS. no interperatation or identification
public int serialize(int offset, byte [] data)
{
- if (thedata == null)
- {
- thedata = new byte[ 0 ];
- }
- LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset, ( short ) (thedata.length));
- if (thedata.length > 0)
- {
- System.arraycopy(thedata, 0, data, 4 + offset, thedata.length);
- }
- return getRecordSize();
+ //Because this record is converted to individual Formula records, this method is not required.
+ throw new UnsupportedOperationException("Cannot serialize a SharedFormulaRecord");
}
public int getRecordSize()
{
- int retval = 4;
+ //Because this record is converted to individual Formula records, this method is not required.
+ throw new UnsupportedOperationException("Cannot get the size for a SharedFormulaRecord");
- if (thedata != null)
- {
- retval += thedata.length;
- }
- return retval;
- }
-
-
- protected void validateSid(short id)
- {
- if (id != this.sid)
- {
- throw new RecordFormatException("Not a valid SharedFormula");
- }
-
}
/**
buffer.append("[SHARED FORMULA RECORD:" + Integer.toHexString(sid) + "]\n");
buffer.append(" .id = ").append(Integer.toHexString(sid))
.append("\n");
+ buffer.append(" .first_row = ")
+ .append(Integer.toHexString(getFirstRow())).append("\n");
+ buffer.append(" .last_row = ")
+ .append(Integer.toHexString(getLastRow()))
+ .append("\n");
+ buffer.append(" .first_column = ")
+ .append(Integer.toHexString(getFirstColumn())).append("\n");
+ buffer.append(" .last_column = ")
+ .append(Integer.toHexString(getLastColumn()))
+ .append("\n");
+ buffer.append(" .reserved = ")
+ .append(Integer.toHexString(field_5_reserved))
+ .append("\n");
+ buffer.append(" .expressionlength= ").append(getExpressionLength())
+ .append("\n");
+
+ buffer.append(" .numptgsinarray = ").append(field_7_parsed_expr.size())
+ .append("\n");
+
+ for (int k = 0; k < field_7_parsed_expr.size(); k++ ) {
+ buffer.append("Formula ")
+ .append(k)
+ .append("\n")
+ .append(field_7_parsed_expr.get(k).toString())
+ .append("\n");
+ }
+
buffer.append("[/SHARED FORMULA RECORD]\n");
return buffer.toString();
}
*/
protected void fillFields(RecordInputStream in)
{
- thedata = in.readRemainder();
+ field_1_first_row = in.readShort();
+ field_2_last_row = in.readShort();
+ field_3_first_column = in.readByte();
+ field_4_last_column = in.readByte();
+ field_5_reserved = in.readShort();
+ field_6_expression_len = in.readShort();
+ field_7_parsed_expr = getParsedExpressionTokens(in);
+ }
+
+ private Stack getParsedExpressionTokens(RecordInputStream in)
+ {
+ Stack stack = new Stack();
+
+ while (in.remaining() != 0) {
+ Ptg ptg = Ptg.createPtg(in);
+ stack.push(ptg);
+ }
+ return stack;
+ }
+
+ public boolean isFormulaInShared(FormulaRecord formula) {
+ final int formulaRow = formula.getRow();
+ final int formulaColumn = formula.getColumn();
+ return ((getFirstRow() <= formulaRow) && (getLastRow() >= formulaRow) &&
+ (getFirstColumn() <= formulaColumn) && (getLastColumn() >= formulaColumn));
+ }
+
+ /** Creates a non shared formula from the shared formula counter part*/
+ public void convertSharedFormulaRecord(FormulaRecord formula) {
+ //Sanity checks
+ final int formulaRow = formula.getRow();
+ final int formulaColumn = formula.getColumn();
+ if (isFormulaInShared(formula)) {
+ formula.setExpressionLength(getExpressionLength());
+ Stack newPtgStack = new Stack();
+
+ for (int k = 0; k < field_7_parsed_expr.size(); k++) {
+ Ptg ptg = (Ptg) field_7_parsed_expr.get(k);
+ if (ptg instanceof RefNPtg) {
+ RefNPtg refNPtg = (RefNPtg)ptg;
+ ptg = new ReferencePtg( (short)(formulaRow + refNPtg.getRow()),
+ (byte)(formulaColumn + refNPtg.getColumn()),
+ refNPtg.isRowRelative(),
+ refNPtg.isColRelative());
+ } else if (ptg instanceof RefNVPtg) {
+ RefNVPtg refNVPtg = (RefNVPtg)ptg;
+ ptg = new RefVPtg( (short)(formulaRow + refNVPtg.getRow()),
+ (byte)(formulaColumn + refNVPtg.getColumn()),
+ refNVPtg.isRowRelative(),
+ refNVPtg.isColRelative());
+ } else if (ptg instanceof RefNAPtg) {
+ RefNAPtg refNAPtg = (RefNAPtg)ptg;
+ ptg = new RefAPtg( (short)(formulaRow + refNAPtg.getRow()),
+ (byte)(formulaColumn + refNAPtg.getColumn()),
+ refNAPtg.isRowRelative(),
+ refNAPtg.isColRelative());
+ } else if (ptg instanceof AreaNPtg) {
+ AreaNPtg areaNPtg = (AreaNPtg)ptg;
+ ptg = new AreaPtg((short)(formulaRow + areaNPtg.getFirstRow()),
+ (short)(formulaRow + areaNPtg.getLastRow()),
+ (short)(formulaColumn + areaNPtg.getFirstColumn()),
+ (short)(formulaColumn + areaNPtg.getLastColumn()),
+ areaNPtg.isFirstRowRelative(),
+ areaNPtg.isLastRowRelative(),
+ areaNPtg.isFirstColRelative(),
+ areaNPtg.isLastColRelative());
+ } else if (ptg instanceof AreaNVPtg) {
+ AreaNVPtg areaNVPtg = (AreaNVPtg)ptg;
+ ptg = new AreaVPtg((short)(formulaRow + areaNVPtg.getFirstRow()),
+ (short)(formulaRow + areaNVPtg.getLastRow()),
+ (short)(formulaColumn + areaNVPtg.getFirstColumn()),
+ (short)(formulaColumn + areaNVPtg.getLastColumn()),
+ areaNVPtg.isFirstRowRelative(),
+ areaNVPtg.isLastRowRelative(),
+ areaNVPtg.isFirstColRelative(),
+ areaNVPtg.isLastColRelative());
+ } else if (ptg instanceof AreaNAPtg) {
+ AreaNAPtg areaNAPtg = (AreaNAPtg)ptg;
+ ptg = new AreaAPtg((short)(formulaRow + areaNAPtg.getFirstRow()),
+ (short)(formulaRow + areaNAPtg.getLastRow()),
+ (short)(formulaColumn + areaNAPtg.getFirstColumn()),
+ (short)(formulaColumn + areaNAPtg.getLastColumn()),
+ areaNAPtg.isFirstRowRelative(),
+ areaNAPtg.isLastRowRelative(),
+ areaNAPtg.isFirstColRelative(),
+ areaNAPtg.isLastColRelative());
+ }
+ newPtgStack.add(ptg);
+ }
+ formula.setParsedExpression(newPtgStack);
+ } else {
+ throw new RuntimeException("Shared Formula Conversion: Coding Error");
+ }
}
/**
}
public Object clone() {
- SharedFormulaRecord rec = new SharedFormulaRecord();
- rec.offset = offset;
- rec.size = size;
- rec.thedata = thedata;
- return rec;
+ //Because this record is converted to individual Formula records, this method is not required.
+ throw new UnsupportedOperationException("Cannot clone a SharedFormulaRecord");
}
}
int k = 0;
FormulaRecordAggregate lastFormulaAggregate = null;
+ SharedFormulaRecord lastSharedFormula = null;
for (k = offset; k < records.size(); k++)
{
}
if (rec instanceof FormulaRecord)
{
+ FormulaRecord formula = (FormulaRecord)rec;
+ if (formula.isSharedFormula()) {
+ if ((lastSharedFormula != null) && (lastSharedFormula.isFormulaInShared(formula))) {
+ //Convert this Formula Record from a shared formula to a real formula
+ lastSharedFormula.convertSharedFormulaRecord(formula);
+ } else {
+ Record nextRecord = (Record) records.get(k + 1);
+ if (nextRecord instanceof SharedFormulaRecord) {
+ k++;
+ lastSharedFormula = (SharedFormulaRecord) nextRecord;
+
+ //Convert this Formula Record from a shared formula to a real formula
+ lastSharedFormula.convertSharedFormulaRecord(formula);
+ }
+ else
+ throw new RuntimeException(
+ "Shared formula bit set but next record is not a Shared Formula??");
+ }
+ }
+
lastFormulaAggregate = new FormulaRecordAggregate((FormulaRecord)rec, null);
insertCell( lastFormulaAggregate );
}
{
lastFormulaAggregate.setStringRecord((StringRecord)rec);
}
- else if (rec instanceof SharedFormulaRecord)
- {
- //these follow the first formula in a group
- lastFormulaAggregate.setSharedFormulaRecord((SharedFormulaRecord)rec);
- }
+ //else if (rec instanceof SharedFormulaRecord)
+ //{
+ // //these follow the first formula in a group
+ // lastFormulaAggregate.setSharedFormulaRecord((SharedFormulaRecord)rec);
+ //}
else if (rec.isValue())
{
insertCell(( CellValueRecordInterface ) rec);
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * AreaPtg.java
+ *
+ * Created on November 17, 2001, 9:30 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.AreaReference;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * Specifies a rectangular area of cells A1:A4 for instance.
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class AreaAPtg
+ extends AreaPtg
+{
+ public final static short sid = 0x65;
+
+ protected AreaAPtg() {
+ //Required for clone methods
+ }
+
+ public AreaAPtg(short firstRow, short lastRow, short firstColumn, short lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
+ super(firstRow, lastRow, firstColumn, lastColumn, firstRowRelative, lastRowRelative, firstColRelative, lastColRelative);
+ }
+
+ public AreaAPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public String getAreaPtgName() {
+ return "AreaAPtg";
+ }
+
+ public Object clone() {
+ AreaAPtg ptg = new AreaAPtg();
+ ptg.setFirstRow(getFirstRow());
+ ptg.setLastRow(getLastRow());
+ ptg.setFirstColumnRaw(getFirstColumnRaw());
+ ptg.setLastColumnRaw(getLastColumnRaw());
+ ptg.setClass(ptgClass);
+ return ptg;
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * AreaPtg.java
+ *
+ * Created on November 17, 2001, 9:30 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.AreaReference;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * Specifies a rectangular area of cells A1:A4 for instance.
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class AreaNAPtg
+ extends AreaPtg
+{
+ public final static short sid = 0x6D;
+
+ protected AreaNAPtg() {
+ //Required for clone methods
+ }
+
+ public AreaNAPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public void writeBytes(byte [] array, int offset) {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public String getAreaPtgName() {
+ return "AreaNAPtg";
+ }
+
+ public String toFormulaString(Workbook book)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public Object clone() {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * AreaPtg.java
+ *
+ * Created on November 17, 2001, 9:30 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.AreaReference;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * Specifies a rectangular area of cells A1:A4 for instance.
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class AreaNPtg
+ extends AreaPtg
+{
+ public final static short sid = 0x2D;
+
+ protected AreaNPtg() {
+ //Required for clone methods
+ }
+
+ public AreaNPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public void writeBytes(byte [] array, int offset) {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public String getAreaPtgName() {
+ return "AreaNPtg";
+ }
+
+ public String toFormulaString(Workbook book)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public Object clone() {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * AreaPtg.java
+ *
+ * Created on November 17, 2001, 9:30 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.AreaReference;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * Specifies a rectangular area of cells A1:A4 for instance.
+ * @author andy
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class AreaNVPtg
+ extends AreaPtg
+{
+ public final static short sid = 0x4D;
+
+ protected AreaNVPtg() {
+ //Required for clone methods
+ }
+
+ public AreaNVPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public void writeBytes(byte [] array, int offset) {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public String getAreaPtgName() {
+ return "AreaNVPtg";
+ }
+
+ public String toFormulaString(Workbook book)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public Object clone() {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+}
private BitField colRelative = BitFieldFactory.getInstance(0x4000);
private BitField column = BitFieldFactory.getInstance(0x3FFF);
- private AreaPtg() {
+ protected AreaPtg() {
//Required for clone methods
}
setFirstColRelative(!ar.getCells()[0].isColAbsolute());
setLastColRelative(!ar.getCells()[1].isColAbsolute());
setFirstRowRelative(!ar.getCells()[0].isRowAbsolute());
- setLastRowRelative(!ar.getCells()[1].isRowAbsolute());
-
+ setLastRowRelative(!ar.getCells()[1].isRowAbsolute());
}
+
+ public AreaPtg(short firstRow, short lastRow, short firstColumn, short lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
+ setFirstRow(firstRow);
+ setLastRow(lastRow);
+ setFirstColumn(firstColumn);
+ setLastColumn(lastColumn);
+ setFirstRowRelative(firstRowRelative);
+ setLastRowRelative(lastRowRelative);
+ setFirstColRelative(firstColRelative);
+ setLastColRelative(lastColRelative);
+ }
public AreaPtg(RecordInputStream in)
{
field_4_last_column = in.readShort();
//System.out.println(toString());
}
+
+ public String getAreaPtgName() {
+ return "AreaPtg";
+ }
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AreaPtg\n");
+ buffer.append(getAreaPtgName());
+ buffer.append("\n");
buffer.append("firstRow = " + getFirstRow()).append("\n");
buffer.append("lastRow = " + getLastRow()).append("\n");
buffer.append("firstCol = " + getFirstColumn()).append("\n");
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * AreaPtg.java
+ *
+ * Created on November 17, 2001, 9:30 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.AreaReference;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * Specifies a rectangular area of cells A1:A4 for instance.
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class AreaVPtg
+ extends AreaPtg
+{
+ public final static short sid = 0x45;
+
+ protected AreaVPtg() {
+ //Required for clone methods
+ }
+
+ public AreaVPtg(short firstRow, short lastRow, short firstColumn, short lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
+ super(firstRow, lastRow, firstColumn, lastColumn, firstRowRelative, lastRowRelative, firstColRelative, lastColRelative);
+ }
+
+
+ public AreaVPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public String getAreaPtgName() {
+ return "AreaVPtg";
+ }
+
+ public Object clone() {
+ AreaVPtg ptg = new AreaVPtg();
+ ptg.setFirstRow(getFirstRow());
+ ptg.setLastRow(getLastRow());
+ ptg.setFirstColumnRaw(getFirstColumnRaw());
+ ptg.setLastColumnRaw(getLastColumnRaw());
+ ptg.setClass(ptgClass);
+ return ptg;
+ }
+}
{
return SIZE;
}
+
+ public short getRow() {
+ return field_1_first_row;
+ }
+
+ public short getColumn() {
+ return field_2_first_col;
+ }
public String toFormulaString(Workbook book)
{
return "NO IDEA SHARED FORMULA EXP PTG";
}
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer("[Array Formula or Shared Formula]\n");
+ buffer.append("row = ").append(getRow()).append("\n");
+ buffer.append("col = ").append(getColumn()).append("\n");
+ return buffer.toString();
+ }
+
public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
public Object clone() {
return stack;
}
- private static Ptg createPtg(RecordInputStream in)
+ public static Ptg createPtg(RecordInputStream in)
{
byte id = in.readByte();
Ptg retval = null;
- final byte valueRef = ReferencePtg.sid + 0x20;
- final byte arrayRef = ReferencePtg.sid + 0x40;
final byte valueFunc = FuncPtg.sid + 0x20;
final byte arrayFunc = FuncPtg.sid + 0x40;
final byte valueFuncVar = FuncVarPtg.sid +0x20;
final byte arrayFuncVar = FuncVarPtg.sid+0x40;
- final byte valueArea = AreaPtg.sid + 0x20;
- final byte arrayArea = AreaPtg.sid + 0x40;
switch (id)
{
case AreaPtg.sid :
retval = new AreaPtg(in);
break;
- case valueArea:
- retval = new AreaPtg(in);
+ case AreaAPtg.sid:
+ retval = new AreaAPtg(in);
break;
- case arrayArea:
- retval = new AreaPtg(in);
+ case AreaVPtg.sid:
+ retval = new AreaVPtg(in);
+ break;
+ case AreaNAPtg.sid :
+ retval = new AreaNAPtg(in);
+ break;
+ case AreaNPtg.sid :
+ retval = new AreaNPtg(in);
break;
+ case AreaNVPtg.sid :
+ retval = new AreaNVPtg(in);
+ break;
+
case MemErrPtg.sid : // 0x27 These 3 values
case MemErrPtg.sid+0x20 : // 0x47 documented in
case MemErrPtg.sid+0x40 : // 0x67 openOffice.org doc.
case ReferencePtg.sid :
retval = new ReferencePtg(in);
break;
- case valueRef :
- retval = new ReferencePtg(in);
+ case RefAPtg.sid :
+ retval = new RefAPtg(in);
break;
- case arrayRef :
- retval = new ReferencePtg(in);
+ case RefVPtg.sid :
+ retval = new RefVPtg(in);
break;
+ case RefNAPtg.sid :
+ retval = new RefNAPtg(in);
+ break;
+ case RefNPtg.sid :
+ retval = new RefNPtg(in);
+ break;
+ case RefNVPtg.sid :
+ retval = new RefNVPtg(in);
+ break;
case RefErrorPtg.sid:
retval = new RefErrorPtg(in);
break;
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * ValueReferencePtg.java
+ *
+ * Created on November 21, 2001, 5:27 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * RefNAPtg
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class RefAPtg extends ReferencePtg
+{
+ public final static byte sid = 0x64;
+
+ protected RefAPtg() {
+ super();
+ }
+
+ public RefAPtg(short row, short column, boolean isRowRelative, boolean isColumnRelative) {
+ super(row, column, isRowRelative, isColumnRelative);
+ }
+
+ public RefAPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+
+ public String getRefPtgName() {
+ return "RefAPtg";
+ }
+
+ public Object clone() {
+ RefAPtg ptg = new RefAPtg();
+ ptg.setRow(getRow());
+ ptg.setColumnRaw(getColumnRaw());
+ ptg.setClass(ptgClass);
+ return ptg;
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * ValueReferencePtg.java
+ *
+ * Created on November 21, 2001, 5:27 PM
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * RefNAPtg
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class RefNAPtg extends ReferencePtg
+{
+ public final static byte sid = 0x6C;
+
+ protected RefNAPtg() {
+ //Required for clone methods
+ }
+
+ public RefNAPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public void writeBytes(byte [] array, int offset)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public String getRefPtgName() {
+ return "RefNAPtg";
+ }
+
+ public String toFormulaString(Workbook book)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public Object clone() {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+/*
+ * RefNPtg.java
+ *
+ */
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * RefNPtg
+ * @author Jason Height (jheight at apache dot com)
+ */
+
+public class RefNPtg extends ReferencePtg
+{
+ public final static byte sid = 0x2C;
+
+ protected RefNPtg() {
+ //Required for clone methods
+ }
+
+ /** Creates new ValueReferencePtg */
+
+ public RefNPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public void writeBytes(byte [] array, int offset)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public String getRefPtgName() {
+ return "RefNPtg";
+ }
+
+ public String toFormulaString(Workbook book)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public Object clone() {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * RefNVPtg
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class RefNVPtg extends ReferencePtg
+{
+ public final static byte sid = 0x4C;
+
+ protected RefNVPtg() {
+ //Required for clone methods
+ }
+
+ /** Creates new ValueReferencePtg */
+
+ public RefNVPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public void writeBytes(byte [] array, int offset)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public String getRefPtgName() {
+ return "RefNVPtg";
+ }
+
+ public String toFormulaString(Workbook book)
+ {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+
+ public Object clone() {
+ throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.record.formula;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.model.Workbook;
+
+/**
+ * RefVPtg
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+
+public class RefVPtg extends ReferencePtg
+{
+ public final static byte sid = 0x44;
+
+ protected RefVPtg() {
+ super();
+ }
+
+ public RefVPtg(short row, short column, boolean isRowRelative, boolean isColumnRelative) {
+ super(row, column, isRowRelative, isColumnRelative);
+ }
+
+
+ /** Creates new ValueReferencePtg */
+
+ public RefVPtg(RecordInputStream in)
+ {
+ super(in);
+ }
+
+ public String getRefPtgName() {
+ return "RefVPtg";
+ }
+
+ public Object clone() {
+ RefVPtg ptg = new RefVPtg();
+ ptg.setRow(getRow());
+ ptg.setColumnRaw(getColumnRaw());
+ ptg.setClass(ptgClass);
+ return ptg;
+ }
+}
private short field_2_col;
private BitField rowRelative = BitFieldFactory.getInstance(0x8000);
private BitField colRelative = BitFieldFactory.getInstance(0x4000);
+ private BitField column = BitFieldFactory.getInstance(0x3FFF);
- private ReferencePtg() {
+ protected ReferencePtg() {
//Required for clone methods
}
setColRelative(!c.isColAbsolute());
setRowRelative(!c.isRowAbsolute());
}
+
+ public ReferencePtg(short row, short column, boolean isRowRelative, boolean isColumnRelative) {
+ setRow(row);
+ setColumn(column);
+ setRowRelative(isRowRelative);
+ setColRelative(isColumnRelative);
+ }
/** Creates new ValueReferencePtg */
{
field_1_row = in.readShort();
field_2_col = in.readShort();
-
}
+
+ public String getRefPtgName() {
+ return "ReferencePtg";
+ }
public String toString()
{
- StringBuffer buffer = new StringBuffer("[ValueReferencePtg]\n");
+ StringBuffer buffer = new StringBuffer("[");
+ buffer.append(getRefPtgName());
+ buffer.append("]\n");
buffer.append("row = ").append(getRow()).append("\n");
- buffer.append("col = ").append(getColumnRaw()).append("\n");
+ buffer.append("col = ").append(getColumn()).append("\n");
buffer.append("rowrelative = ").append(isRowRelative()).append("\n");
buffer.append("colrelative = ").append(isColRelative()).append("\n");
return buffer.toString();
public void setColumn(short col)
{
- field_2_col = col; // fix this
+ field_2_col = column.setShortValue(field_2_col, col);
}
public short getColumn()
{
- return rowRelative.setShortBoolean(colRelative.setShortBoolean(field_2_col,false),false);
+ return column.getShortValue(field_2_col);
}
public int getSize()