acoliver 2002/07/14 17:14:40
Modified: src/java/org/apache/poi/hssf/dev FormulaViewer.java
src/java/org/apache/poi/hssf/model Sheet.java Workbook.java
src/java/org/apache/poi/hssf/record ExternSheetRecord.java
NameRecord.java
src/java/org/apache/poi/hssf/record/formula
AbstractFunctionPtg.java AddPtg.java Area3DPtg.java
AreaPtg.java AttrPtg.java ConcatPtg.java
DividePtg.java ExpPtg.java FuncVarPtg.java
IntPtg.java MemErrPtg.java MissingArgPtg.java
MultiplyPtg.java NamePtg.java NumberPtg.java
ParenthesisPtg.java PowerPtg.java Ptg.java
Ref3DPtg.java ReferencePtg.java StringPtg.java
SubtractPtg.java UnknownPtg.java
src/java/org/apache/poi/hssf/usermodel HSSFCell.java
HSSFName.java
Log:
While I don't consider this idea, I like it much better than having the
circular dependancies. This should fix the bug I caused the other day by
removing Thread Local.
Revision Changes Path
1.5 +4 -3 jakarta-poi/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
Index: FormulaViewer.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/dev/FormulaViewer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FormulaViewer.java 12 Jun 2002 12:40:03 -0000 1.4
+++ FormulaViewer.java 15 Jul 2002 00:14:38 -0000 1.5
@@ -77,6 +77,7 @@
import org.apache.poi.hssf.record.formula.*;
import org.apache.poi.hssf.model.*;
import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* FormulaViewer - finds formulas in a BIFF8 file and attempts to read them/display
@@ -143,7 +144,7 @@
StringBuffer buf = new StringBuffer();
if (token instanceof ExpPtg) return;
- buf.append(name=((OperationPtg) token).toFormulaString());
+ buf.append(name=((OperationPtg)
token).toFormulaString((SheetReferences)null));
buf.append(sep);
switch (token.getPtgClass()) {
case Ptg.CLASS_REF :
@@ -212,7 +213,7 @@
StringBuffer buf = new StringBuffer();
for (int i=0;i<numptgs;i++) {
token = (Ptg) tokens.get(i);
- buf.append( token.toFormulaString());
+ buf.append( token.toFormulaString((SheetReferences)null));
switch (token.getPtgClass()) {
case Ptg.CLASS_REF :
buf.append("(R)");
@@ -232,7 +233,7 @@
private String composeFormula(FormulaRecord record)
{
- return FormulaParser.toFormulaString(record.getParsedExpression());
+ return
FormulaParser.toFormulaString((SheetReferences)null,record.getParsedExpression());
}
/**
1.11 +0 -1 jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java
Index: Sheet.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Sheet.java 25 Jun 2002 08:35:16 -0000 1.10
+++ Sheet.java 15 Jul 2002 00:14:38 -0000 1.11
@@ -64,7 +64,6 @@
import org.apache.poi.util.POILogFactory;
import org.apache.poi.hssf
.record.*; // normally I don't do this, buy we literally mean ALL
-import org.apache.poi.hssf.record.formula.FormulaParser;
import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.util.IntList;
import org.apache.poi.util.POILogger;
1.11 +18 -3 jakarta-poi/src/java/org/apache/poi/hssf/model/Workbook.java
Index: Workbook.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/model/Workbook.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Workbook.java 6 Jul 2002 18:45:16 -0000 1.10
+++ Workbook.java 15 Jul 2002 00:14:38 -0000 1.11
@@ -61,10 +61,13 @@
import java.util.List;
import java.util.Iterator;
-import org.apache.poi.hssf.record.*;
+
import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
+import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
* Workbook
* Low level model implementation of a Workbook. Provides creational methods
@@ -88,7 +91,7 @@
public class Workbook {
private static final int DEBUG = POILogger.DEBUG;
- public static Workbook currentBook = null;
+// public static Workbook currentBook = null;
/**
* constant used to set the "codepage" wherever "codepage" is set in records
@@ -111,7 +114,7 @@
protected SSTRecord sst = null;
/**
- * Holds the Extern Sheet with referenced to bound sheets
+ * Holds the Extern Sheet with references to bound sheets
*/
protected ExternSheetRecord externSheet= null;
@@ -1629,6 +1632,18 @@
protected Record createEOF() {
return new EOFRecord();
+ }
+
+ public SheetReferences getSheetReferences() {
+ SheetReferences refs = new SheetReferences();
+
+ if (externSheet != null) {
+ for (int k = 0; k < externSheet.getNumOfREFStructures(); k++) {
+ String sheetName = findSheetNameFromExternSheet((short)k);
+ refs.addSheetReference(sheetName, k);
+ }
+ }
+ return refs;
}
/** fins the sheet name by his extern sheet index
1.3 +13 -10
jakarta-poi/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java
Index: ExternSheetRecord.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/ExternSheetRecord.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExternSheetRecord.java 7 May 2002 23:38:05 -0000 1.2
+++ ExternSheetRecord.java 15 Jul 2002 00:14:38 -0000 1.3
@@ -135,35 +135,38 @@
}
}
- /** sets the number of the REF structors , that is in Excel file
+ /**
+ * sets the number of the REF structors , that is in Excel file
* @param numStruct number of REF structs
*/
public void setNumOfREFStructures(short numStruct) {
field_1_number_of_REF_sturcutres = numStruct;
}
- /** return the number of the REF structors , that is in Excel file
+ /**
+ * return the number of the REF structors , that is in Excel file
* @return number of REF structs
*/
public short getNumOfREFStructures() {
return field_1_number_of_REF_sturcutres;
}
- /** adds REF struct (ExternSheetSubRecord)
+ /**
+ * adds REF struct (ExternSheetSubRecord)
* @param rec REF struct
*/
public void addREFRecord(ExternSheetSubRecord rec) {
field_2_REF_structures.add(rec);
}
- /** returns the number of REF Record , which is in model
+ /** returns the number of REF Records, which is in model
* @return number of REF records
*/
- public int getNumOfREFRecord() {
+ public int getNumOfREFRecords() {
return field_2_REF_structures.size();
}
- /** return the REF record (ExternSheetSubRecord)
+ /** returns the REF record (ExternSheetSubRecord)
* @param elem index to place
* @return REF record
*/
@@ -178,7 +181,7 @@
buffer.append("[EXTERNSHEET]\n");
buffer.append(" numOfRefs =
").append(getNumOfREFStructures()).append("\n");
- for (int k=0; k < this.getNumOfREFRecord(); k++) {
+ for (int k=0; k < this.getNumOfREFRecords(); k++) {
buffer.append("refrec #").append(k).append('\n');
buffer.append(getREFRecordAt(k).toString());
buffer.append("----refrec #").append(k).append('\n');
@@ -200,13 +203,13 @@
*/
public int serialize(int offset, byte [] data) {
LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecord()
*6)));
+ LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecords()
*6)));
LittleEndian.putShort(data, 4 + offset, getNumOfREFStructures());
int pos = 6 ;
- for (int k = 0; k < getNumOfREFRecord(); k++) {
+ for (int k = 0; k < getNumOfREFRecords(); k++) {
ExternSheetSubRecord record = getREFRecordAt(k);
System.arraycopy(record.serialize(), 0, data, pos + offset, 6);
@@ -216,7 +219,7 @@
}
public int getRecordSize() {
- return 4 + 2 + getNumOfREFRecord() * 6;
+ return 4 + 2 + getNumOfREFRecords() * 6;
}
/**
1.4 +4 -3 jakarta-poi/src/java/org/apache/poi/hssf/record/NameRecord.java
Index: NameRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/NameRecord.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NameRecord.java 1 Jul 2002 17:29:31 -0000 1.3
+++ NameRecord.java 15 Jul 2002 00:14:38 -0000 1.4
@@ -63,6 +63,7 @@
import org.apache.poi.hssf.record.formula.Ref3DPtg;
import java.util.List;
import org.apache.poi.hssf.util.RangeAddress;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* Title: Name Record (aka Named Range) <P>
@@ -501,16 +502,16 @@
/** gets the reference , the area only (range)
* @return area reference
*/
- public String getAreaReference(){
+ public String getAreaReference(SheetReferences refs){
if (field_13_name_definition == null) return "#REF!";
Ptg ptg = (Ptg) field_13_name_definition.peek();
String result = "";
if (ptg.getClass() == Area3DPtg.class){
- result = ((Area3DPtg) ptg).toFormulaString();
+ result = ((Area3DPtg) ptg).toFormulaString(refs);
} else if (ptg.getClass() == Ref3DPtg.class){
- result = ((Ref3DPtg) ptg).toFormulaString();
+ result = ((Ref3DPtg) ptg).toFormulaString(refs);
}
return result;
1.4 +4 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
Index: AbstractFunctionPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractFunctionPtg.java 17 Jun 2002 18:06:04 -0000 1.3
+++ AbstractFunctionPtg.java 15 Jul 2002 00:14:39 -0000 1.4
@@ -1,6 +1,8 @@
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.BinaryTree;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
* This class provides the base functionality for Excel sheet functions
* There are two kinds of function Ptgs - tFunc and tFuncVar
@@ -46,7 +48,7 @@
return lookupName(field_2_fnc_index);
}
- public String toFormulaString() {
+ public String toFormulaString(SheetReferences refs) {
return getName();
}
@@ -802,7 +804,7 @@
return returnClass;
}
- protected byte getParameterClass(int index) {
+ public byte getParameterClass(int index) {
try {
return paramClass[index];
} catch (ArrayIndexOutOfBoundsException aioobe) {
1.11 +5 -3
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
Index: AddPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AddPtg.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AddPtg.java 27 May 2002 21:00:10 -0000 1.10
+++ AddPtg.java 15 Jul 2002 00:14:39 -0000 1.11
@@ -62,6 +62,8 @@
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
* Addition operator PTG the "+" binomial operator. If you need more
* explanation than that then well...We really can't help you here.
@@ -78,7 +80,7 @@
/** Creates new AddPtg */
- protected AddPtg()
+ public AddPtg()
{
}
@@ -110,7 +112,7 @@
}
/** Implementation of method from Ptg */
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "+";
}
@@ -120,7 +122,7 @@
StringBuffer buffer = new StringBuffer();
buffer.append(operands[ 0 ]);
- buffer.append(toFormulaString());
+ buffer.append(ADD);
buffer.append(operands[ 1 ]);
return buffer.toString();
}
1.9 +5 -5
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
Index: Area3DPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Area3DPtg.java 6 Jul 2002 18:45:16 -0000 1.8
+++ Area3DPtg.java 15 Jul 2002 00:14:39 -0000 1.9
@@ -59,6 +59,7 @@
import org.apache.poi.hssf.util.RangeAddress;
import org.apache.poi.hssf.util.AreaReference;
import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.util.SheetReferences;
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.util.BitField;
@@ -88,7 +89,7 @@
/** Creates new AreaPtg */
public Area3DPtg() {}
- protected Area3DPtg(String arearef, short externIdx) {
+ public Area3DPtg(String arearef, short externIdx) {
AreaReference ar = new AreaReference(arearef);
setFirstRow((short)ar.getCells()[0].getRow());
@@ -286,12 +287,11 @@
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
StringBuffer retval = new StringBuffer();
- Object book = Workbook.currentBook;
- if (book != null) {
- retval.append(((Workbook)
book).findSheetNameFromExternSheet(this.field_1_index_extern_sheet));
+ if (refs != null) {
+ retval.append(refs.getSheetName(this.field_1_index_extern_sheet));
retval.append('!');
}
retval.append((new
CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative())).toString());
1.11 +3 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
Index: AreaPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AreaPtg.java 26 Jun 2002 18:05:39 -0000 1.10
+++ AreaPtg.java 15 Jul 2002 00:14:39 -0000 1.11
@@ -65,6 +65,7 @@
import org.apache.poi.hssf.util.AreaReference;
import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* Specifies a rectangular area of cells A1:A4 for instance.
@@ -87,7 +88,7 @@
- protected AreaPtg(String arearef) {
+ public AreaPtg(String arearef) {
AreaReference ar = new AreaReference(arearef);
setFirstRow((short)ar.getCells()[0].getRow());
setFirstColumn((short)ar.getCells()[0].getCol());
@@ -301,7 +302,7 @@
field_4_last_column = column;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return (new
CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative())).toString()
+ ":" +
(new
CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative())).toString();
1.10 +4 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
Index: AttrPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AttrPtg.java 12 Jun 2002 07:50:28 -0000 1.9
+++ AttrPtg.java 15 Jul 2002 00:14:39 -0000 1.10
@@ -60,6 +60,8 @@
*/
package org.apache.poi.hssf.record.formula;
+import org.apache.poi.hssf.util.SheetReferences;
+
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField;
@@ -196,7 +198,7 @@
return operands[ 0 ];
}
else {
- return toFormulaString() + "(" + operands[ 0 ] + ")";
+ return toFormulaString((SheetReferences)null) + "(" + operands[ 0 ] +
")";
}
}
@@ -211,7 +213,7 @@
return -1;
}
- public String toFormulaString() {
+ public String toFormulaString(SheetReferences refs) {
if(semiVolatile.isSet(field_1_options)) {
return "ATTR(semiVolatile)";
}
1.3 +4 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
Index: ConcatPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConcatPtg.java 30 Apr 2002 23:22:27 -0000 1.2
+++ ConcatPtg.java 15 Jul 2002 00:14:39 -0000 1.3
@@ -62,6 +62,8 @@
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
*
* @author andy
@@ -81,7 +83,7 @@
// doesn't need anything
}
- protected ConcatPtg() {
+ public ConcatPtg() {
}
@@ -105,7 +107,7 @@
return 2;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return CONCAT;
}
1.7 +7 -5
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
Index: DividePtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/DividePtg.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DividePtg.java 30 Apr 2002 23:22:27 -0000 1.6
+++ DividePtg.java 15 Jul 2002 00:14:39 -0000 1.7
@@ -62,9 +62,11 @@
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
- *
- * @author andy
+ * This PTG implements the standard binomial divide "/"
+ * @author Andrew C. Oliver acoliver at apache dot org
*/
public class DividePtg
@@ -75,7 +77,7 @@
/** Creates new AddPtg */
- protected DividePtg()
+ public DividePtg()
{
}
@@ -105,7 +107,7 @@
return 2;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "/";
}
@@ -114,7 +116,7 @@
StringBuffer buffer = new StringBuffer();
buffer.append(operands[ 0 ]);
- buffer.append(toFormulaString());
+ buffer.append(toFormulaString((SheetReferences)null));
buffer.append(operands[ 1 ]);
return buffer.toString();
}
1.4 +4 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
Index: ExpPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExpPtg.java 27 May 2002 21:00:10 -0000 1.3
+++ ExpPtg.java 15 Jul 2002 00:14:39 -0000 1.4
@@ -60,6 +60,8 @@
*/
package org.apache.poi.hssf.record.formula;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
*
* @author andy
@@ -73,7 +75,7 @@
/** Creates new ExpPtg */
- protected ExpPtg()
+ public ExpPtg()
{
}
@@ -92,7 +94,7 @@
return SIZE;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "NO IDEA SHARED FORMULA EXP PTG";
}
1.3 +1 -1
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
Index: FuncVarPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FuncVarPtg.java 12 Jun 2002 07:50:28 -0000 1.2
+++ FuncVarPtg.java 15 Jul 2002 00:14:39 -0000 1.3
@@ -16,7 +16,7 @@
/**
* Create a function ptg from a string tokenised by the parser
*/
- protected FuncVarPtg(String pName, byte pNumOperands) {
+ public FuncVarPtg(String pName, byte pNumOperands) {
field_1_num_args = pNumOperands;
field_2_fnc_index = lookupIndex(pName);
try{
1.8 +4 -3
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
Index: IntPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/IntPtg.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- IntPtg.java 27 May 2002 21:00:10 -0000 1.7
+++ IntPtg.java 15 Jul 2002 00:14:39 -0000 1.8
@@ -61,11 +61,12 @@
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* Integer (short intger)
* Stores a (java) short value in a formula
- * @author andy
+ * @author Andrew C. Oliver (acoliver at apache dot org)
*/
public class IntPtg
@@ -85,7 +86,7 @@
// IntPtg should be able to create itself, shouldnt have to call setValue
- protected IntPtg(String formulaToken) {
+ public IntPtg(String formulaToken) {
setValue(Short.parseShort(formulaToken));
}
@@ -110,7 +111,7 @@
return SIZE;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "" + getValue();
}
1.3 +2 -1
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
Index: MemErrPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MemErrPtg.java 27 May 2002 21:00:10 -0000 1.2
+++ MemErrPtg.java 15 Jul 2002 00:14:39 -0000 1.3
@@ -61,6 +61,7 @@
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hssf.util.SheetReferences;
/**
*
@@ -116,7 +117,7 @@
return SIZE;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "ERR#";
}
1.2 +3 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
Index: MissingArgPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MissingArgPtg.java 11 Jun 2002 20:18:28 -0000 1.1
+++ MissingArgPtg.java 15 Jul 2002 00:14:39 -0000 1.2
@@ -54,6 +54,7 @@
package org.apache.poi.hssf.record.formula;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* Missing Function Arguments
@@ -67,7 +68,7 @@
private final static int SIZE = 1;
public final static byte sid = 0x16;
- protected MissingArgPtg()
+ public MissingArgPtg()
{
}
@@ -89,7 +90,7 @@
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return " ";
}
1.8 +8 -7
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
Index: MultiplyPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MultiplyPtg.java 30 Apr 2002 23:22:27 -0000 1.7
+++ MultiplyPtg.java 15 Jul 2002 00:14:39 -0000 1.8
@@ -61,10 +61,11 @@
package org.apache.poi.hssf.record.formula;
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
/**
- *
- * @author andy
+ * Implements the standard mathmatical multiplication - *
+ * @author Andrew C. Oliver (acoliver at apache dot org)
*/
public class MultiplyPtg
@@ -77,7 +78,7 @@
/** Creates new AddPtg */
- protected MultiplyPtg()
+ public MultiplyPtg()
{
}
@@ -112,7 +113,7 @@
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "*";
}
@@ -121,9 +122,9 @@
{
StringBuffer buffer = new StringBuffer();
- buffer.append(operands[ 0 ].toFormulaString());
+ buffer.append(operands[ 0 ].toFormulaString((SheetReferences)null));
buffer.append("*");
- buffer.append(operands[ 1 ].toFormulaString());
+ buffer.append(operands[ 1 ].toFormulaString((SheetReferences)null));
return buffer.toString();
}
@@ -131,7 +132,7 @@
StringBuffer buffer = new StringBuffer();
buffer.append(operands[ 0 ]);
- buffer.append(toFormulaString());
+ buffer.append(toFormulaString((SheetReferences)null));
buffer.append(operands[ 1 ]);
return buffer.toString();
}
1.4 +3 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
Index: NamePtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/NamePtg.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NamePtg.java 27 May 2002 21:00:10 -0000 1.3
+++ NamePtg.java 15 Jul 2002 00:14:39 -0000 1.4
@@ -61,6 +61,7 @@
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hssf.util.SheetReferences;
/**
*
@@ -78,7 +79,7 @@
/** Creates new NamePtg */
- protected NamePtg(String name)
+ public NamePtg(String name)
{
//TODO
}
@@ -102,7 +103,7 @@
return SIZE;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "NO IDEA - NAME";
}
1.4 +3 -3
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java
Index: NumberPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NumberPtg.java 27 May 2002 21:00:10 -0000 1.3
+++ NumberPtg.java 15 Jul 2002 00:14:39 -0000 1.4
@@ -55,7 +55,7 @@
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
-
+import org.apache.poi.hssf.util.SheetReferences;
/**
* Number
* Stores a floating point value in a formula
@@ -82,7 +82,7 @@
* that calls this method.
* @param value : String representation of a floating point number
*/
- protected NumberPtg(String value) {
+ public NumberPtg(String value) {
setValue(Double.parseDouble(value));
}
@@ -109,7 +109,7 @@
return SIZE;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "" + getValue();
}
1.8 +4 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java
Index: ParenthesisPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ParenthesisPtg.java 27 May 2002 21:00:10 -0000 1.7
+++ ParenthesisPtg.java 15 Jul 2002 00:14:39 -0000 1.8
@@ -57,6 +57,8 @@
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
* While formula tokens are stored in RPN order and thus do not need parenthesis
for
* precedence reasons, Parenthesis tokens ARE written to ensure that user entered
@@ -72,7 +74,7 @@
private final static int SIZE = 1;
public final static byte sid = 0x15;
- protected ParenthesisPtg()
+ public ParenthesisPtg()
{
}
@@ -104,7 +106,7 @@
return 1;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "()";
}
1.9 +5 -3
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java
Index: PowerPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PowerPtg.java 27 May 2002 21:00:10 -0000 1.8
+++ PowerPtg.java 15 Jul 2002 00:14:39 -0000 1.9
@@ -62,6 +62,8 @@
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
*
* @author andy
@@ -75,7 +77,7 @@
/** Creates new AddPtg */
- protected PowerPtg()
+ public PowerPtg()
{
}
@@ -105,7 +107,7 @@
return 2;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "^";
}
@@ -115,7 +117,7 @@
buffer.append(operands[ 0 ]);
- buffer.append(toFormulaString());
+ buffer.append(toFormulaString((SheetReferences)null));
buffer.append(operands[ 1 ]);
return buffer.toString();
}
1.20 +3 -1 jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Ptg.java
Index: Ptg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Ptg.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Ptg.java 12 Jun 2002 18:06:52 -0000 1.19
+++ Ptg.java 15 Jul 2002 00:14:39 -0000 1.20
@@ -63,6 +63,8 @@
import java.util.List;
import java.util.ArrayList;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
*
* @author andy
@@ -295,7 +297,7 @@
/**
* return a string representation of this token alone
*/
- public abstract String toFormulaString();
+ public abstract String toFormulaString(SheetReferences refs);
/**
* dump a debug representation (hexdump) to a strnig
*/
1.8 +6 -5
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
Index: Ref3DPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Ref3DPtg.java 6 Jul 2002 18:45:16 -0000 1.7
+++ Ref3DPtg.java 15 Jul 2002 00:14:39 -0000 1.8
@@ -57,8 +57,10 @@
package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian;
+
import org.apache.poi.hssf.util.RangeAddress;
import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.util.SheetReferences;
import org.apache.poi.util.BitField;
import org.apache.poi.hssf.model.Workbook;
@@ -89,7 +91,7 @@
field_3_column = LittleEndian.getShort(data, 4 + offset);
}
- protected Ref3DPtg(String cellref, short externIdx ) {
+ public Ref3DPtg(String cellref, short externIdx ) {
CellReference c= new CellReference(cellref);
setRow((short) c.getRow());
setColumn((short) c.getCol());
@@ -190,11 +192,10 @@
}
- public String toFormulaString() {
+ public String toFormulaString(SheetReferences refs) {
StringBuffer retval = new StringBuffer();
- Object book = Workbook.currentBook;
- if (book != null) {
- retval.append(((Workbook)
book).findSheetNameFromExternSheet(this.field_1_index_extern_sheet));
+ if (refs != null) {
+ retval.append(refs.getSheetName((int)this.field_1_index_extern_sheet));
retval.append('!');
}
retval.append((new
CellReference(getRow(),getColumn(),!isRowRelative(),!isColRelative())).toString());
1.6 +3 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
Index: ReferencePtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ReferencePtg.java 27 May 2002 21:00:10 -0000 1.5
+++ ReferencePtg.java 15 Jul 2002 00:14:39 -0000 1.6
@@ -64,6 +64,7 @@
import org.apache.poi.util.BitField;
import org.apache.poi.hssf.util.CellReference;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* ReferencePtg - handles references (such as A1, A2, IA4)
@@ -86,7 +87,7 @@
* Takes in a String represnetation of a cell reference and fills out the
* numeric fields.
*/
- protected ReferencePtg(String cellref) {
+ public ReferencePtg(String cellref) {
CellReference c= new CellReference(cellref);
setRow((short) c.getRow());
setColumn((short) c.getCol());
@@ -175,7 +176,7 @@
return SIZE;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
//TODO -- should we store a cellreference instance in this ptg?? but ..
memory is an issue, i believe!
return (new
CellReference(getRow(),getColumn(),!isRowRelative(),!isColRelative())).toString();
1.3 +4 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
Index: StringPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/StringPtg.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StringPtg.java 27 May 2002 21:00:10 -0000 1.2
+++ StringPtg.java 15 Jul 2002 00:14:39 -0000 1.3
@@ -56,6 +56,8 @@
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
* Number
* Stores a String value in a formula value stored in the format <length 2
bytes>char[]
@@ -81,7 +83,7 @@
* that calls this method.
* @param value : String representation of a floating point number
*/
- protected StringPtg(String value) {
+ public StringPtg(String value) {
setValue(value);
}
@@ -110,7 +112,7 @@
return field_1_value.length() + 3;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return getValue();
}
1.7 +3 -2
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java
Index: SubtractPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SubtractPtg.java 30 Apr 2002 23:22:27 -0000 1.6
+++ SubtractPtg.java 15 Jul 2002 00:14:39 -0000 1.7
@@ -61,6 +61,7 @@
package org.apache.poi.hssf.record.formula;
import java.util.List;
+import org.apache.poi.hssf.util.SheetReferences;
/**
*
@@ -73,7 +74,7 @@
public final static int SIZE = 1;
public final static byte sid = 0x04;
- protected SubtractPtg()
+ public SubtractPtg()
{
}
@@ -103,7 +104,7 @@
return 2;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "-";
}
1.3 +3 -1
jakarta-poi/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
Index: UnknownPtg.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UnknownPtg.java 27 May 2002 21:00:10 -0000 1.2
+++ UnknownPtg.java 15 Jul 2002 00:14:39 -0000 1.3
@@ -60,6 +60,8 @@
*/
package org.apache.poi.hssf.record.formula;
+import org.apache.poi.hssf.util.SheetReferences;
+
/**
*
* @author andy
@@ -91,7 +93,7 @@
return size;
}
- public String toFormulaString()
+ public String toFormulaString(SheetReferences refs)
{
return "UNKNOWN";
}
1.15 +9 -6 jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
Index: HSSFCell.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- HSSFCell.java 6 Jul 2002 18:45:16 -0000 1.14
+++ HSSFCell.java 15 Jul 2002 00:14:40 -0000 1.15
@@ -62,6 +62,7 @@
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.model.Sheet;
+import org.apache.poi.hssf.model.FormulaParser;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.FormulaRecord;
@@ -71,8 +72,9 @@
import org.apache.poi.hssf.record.BoolErrRecord;
import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.util.SheetReferences;
-import org.apache.poi.hssf.record.formula.FormulaParser;
+//import org.apache.poi.hssf.record.formula.FormulaParser;
import java.util.Date;
import java.util.Calendar;
@@ -693,7 +695,7 @@
}
public void setCellFormula(String formula) {
- Workbook.currentBook=book;
+ //Workbook.currentBook=book;
if (formula==null) {
setCellType(CELL_TYPE_BLANK,false);
} else {
@@ -712,14 +714,15 @@
rec.pushExpressionToken(ptg[ k ]);
}
rec.setExpressionLength(( short ) size);
- Workbook.currentBook = null;
+ //Workbook.currentBook = null;
}
}
public String getCellFormula() {
- Workbook.currentBook=book;
- String retval =
FormulaParser.toFormulaString(((FormulaRecord)record).getParsedExpression());
- Workbook.currentBook=null;
+ //Workbook.currentBook=book;
+ SheetReferences refs = book.getSheetReferences();
+ String retval = FormulaParser.toFormulaString(refs,
((FormulaRecord)record).getParsedExpression());
+ //Workbook.currentBook=null;
return retval;
}
1.5 +3 -3 jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
Index: HSSFName.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFName.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HSSFName.java 14 Jul 2002 21:44:01 -0000 1.4
+++ HSSFName.java 15 Jul 2002 00:14:40 -0000 1.5
@@ -64,6 +64,7 @@
import java.util.Iterator;
import java.util.TreeMap;
import org.apache.poi.hssf.util.RangeAddress;
+import org.apache.poi.hssf.util.SheetReferences;
/**
* Title: High Level Represantion of Named Range <P>
@@ -137,10 +138,9 @@
*/
public String getReference() {
- Workbook.currentBook=book;
String result;
- result = name.getAreaReference();
- Workbook.currentBook=null;
+ SheetReferences refs = book.getSheetReferences();
+ result = name.getAreaReference(refs);
return result;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>