SHARED FORMULA SUPPORT:
Implemented my long standing (but incomplete) patch attached to Bug 26502. Now shared formula conversion is working. Tested against file attached to Bug 26502 and Bug 18311. TestValueRecordAggregate fails with the patch at the moment, too tired to look at. Will do tomorrow. Jason git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@425402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
79d49c2b67
commit
94429ddb32
@ -27,6 +27,8 @@ import java.util.List;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -53,6 +55,9 @@ public class FormulaRecord
|
||||
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;
|
||||
@ -192,6 +197,10 @@ public class FormulaRecord
|
||||
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
|
||||
@ -263,6 +272,10 @@ public class FormulaRecord
|
||||
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
|
||||
* record passed with a differing ID.
|
||||
@ -474,6 +487,12 @@ public class FormulaRecord
|
||||
.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())
|
||||
@ -485,9 +504,9 @@ public class FormulaRecord
|
||||
|
||||
|
||||
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())
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -36,9 +40,14 @@ public class SharedFormulaRecord
|
||||
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()
|
||||
{
|
||||
@ -56,43 +65,49 @@ public class SharedFormulaRecord
|
||||
super(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
public int getRecordSize()
|
||||
{
|
||||
int retval = 4;
|
||||
|
||||
if (thedata != null)
|
||||
{
|
||||
retval += thedata.length;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
//Because this record is converted to individual Formula records, this method is not required.
|
||||
throw new UnsupportedOperationException("Cannot serialize a SharedFormulaRecord");
|
||||
}
|
||||
|
||||
public int getRecordSize()
|
||||
{
|
||||
//Because this record is converted to individual Formula records, this method is not required.
|
||||
throw new UnsupportedOperationException("Cannot get the size for a SharedFormulaRecord");
|
||||
|
||||
}
|
||||
|
||||
@ -107,6 +122,33 @@ public class SharedFormulaRecord
|
||||
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();
|
||||
}
|
||||
@ -121,7 +163,99 @@ public class SharedFormulaRecord
|
||||
*/
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,10 +275,7 @@ public class SharedFormulaRecord
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ public class ValueRecordsAggregate
|
||||
int k = 0;
|
||||
|
||||
FormulaRecordAggregate lastFormulaAggregate = null;
|
||||
SharedFormulaRecord lastSharedFormula = null;
|
||||
|
||||
for (k = offset; k < records.size(); k++)
|
||||
{
|
||||
@ -136,6 +137,26 @@ public class ValueRecordsAggregate
|
||||
}
|
||||
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 );
|
||||
}
|
||||
@ -143,11 +164,11 @@ public class ValueRecordsAggregate
|
||||
{
|
||||
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);
|
||||
|
107
src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java
Normal file
107
src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java
Normal file
@ -0,0 +1,107 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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;
|
||||
}
|
||||
}
|
106
src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
Normal file
106
src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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");
|
||||
}
|
||||
}
|
106
src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
Normal file
106
src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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");
|
||||
}
|
||||
}
|
107
src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
Normal file
107
src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
Normal file
@ -0,0 +1,107 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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");
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public class AreaPtg
|
||||
private BitField colRelative = BitFieldFactory.getInstance(0x4000);
|
||||
private BitField column = BitFieldFactory.getInstance(0x3FFF);
|
||||
|
||||
private AreaPtg() {
|
||||
protected AreaPtg() {
|
||||
//Required for clone methods
|
||||
}
|
||||
|
||||
@ -60,7 +60,17 @@ public class AreaPtg
|
||||
setLastColRelative(!ar.getCells()[1].isColAbsolute());
|
||||
setFirstRowRelative(!ar.getCells()[0].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)
|
||||
@ -72,11 +82,16 @@ public class AreaPtg
|
||||
//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");
|
||||
|
108
src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java
Normal file
108
src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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;
|
||||
}
|
||||
}
|
@ -63,11 +63,27 @@ public class ExpPtg
|
||||
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() {
|
||||
|
@ -112,19 +112,15 @@ public abstract class Ptg
|
||||
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)
|
||||
{
|
||||
@ -197,12 +193,22 @@ public abstract class Ptg
|
||||
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.
|
||||
@ -216,11 +222,20 @@ public abstract class Ptg
|
||||
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);
|
||||
|
104
src/java/org/apache/poi/hssf/record/formula/RefAPtg.java
Normal file
104
src/java/org/apache/poi/hssf/record/formula/RefAPtg.java
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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;
|
||||
}
|
||||
}
|
105
src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java
Normal file
105
src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java
Normal file
@ -0,0 +1,105 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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");
|
||||
}
|
||||
}
|
106
src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
Normal file
106
src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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");
|
||||
}
|
||||
}
|
102
src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java
Normal file
102
src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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");
|
||||
}
|
||||
}
|
101
src/java/org/apache/poi/hssf/record/formula/RefVPtg.java
Normal file
101
src/java/org/apache/poi/hssf/record/formula/RefVPtg.java
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
/* ====================================================================
|
||||
* 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;
|
||||
}
|
||||
}
|
@ -39,8 +39,9 @@ public class ReferencePtg extends 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
|
||||
}
|
||||
|
||||
@ -56,21 +57,33 @@ public class ReferencePtg extends Ptg
|
||||
setRowRelative(!c.isRowAbsolute());
|
||||
}
|
||||
|
||||
public ReferencePtg(short row, short column, boolean isRowRelative, boolean isColumnRelative) {
|
||||
setRow(row);
|
||||
setColumn(column);
|
||||
setRowRelative(isRowRelative);
|
||||
setColRelative(isColumnRelative);
|
||||
}
|
||||
|
||||
/** Creates new ValueReferencePtg */
|
||||
|
||||
public ReferencePtg(RecordInputStream in)
|
||||
{
|
||||
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();
|
||||
@ -123,12 +136,12 @@ public class ReferencePtg extends Ptg
|
||||
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user