diff options
author | Nick Burch <nick@apache.org> | 2008-04-15 23:18:25 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2008-04-15 23:18:25 +0000 |
commit | a874dfc1a69ed6a1563f2e9dd392171beaa8ca6b (patch) | |
tree | a7b838a130d0f51564c1a9ebaab6fb3eab5b6103 /src/java | |
parent | b292ad07c3c7664d825a3e9277548560de14e463 (diff) | |
download | poi-a874dfc1a69ed6a1563f2e9dd392171beaa8ca6b.tar.gz poi-a874dfc1a69ed6a1563f2e9dd392171beaa8ca6b.zip |
In the ooxml branch, convert the formula stuff from using hssf.HSSFWorkbook to ss.Workbook, so that everything now works for XSSF too
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@648454 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
58 files changed, 181 insertions, 161 deletions
diff --git a/src/java/org/apache/poi/hssf/model/FormulaParser.java b/src/java/org/apache/poi/hssf/model/FormulaParser.java index 05b4d80f4a..33966e932e 100644 --- a/src/java/org/apache/poi/hssf/model/FormulaParser.java +++ b/src/java/org/apache/poi/hssf/model/FormulaParser.java @@ -27,7 +27,7 @@ import java.util.regex.Pattern; import org.apache.poi.hssf.record.formula.*; import org.apache.poi.hssf.record.formula.function.FunctionMetadata; import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * This class parses a formula string into a List of tokens in RPN order. @@ -87,7 +87,7 @@ public final class FormulaParser { */ private char look; - private HSSFWorkbook book; + private Workbook book; /** @@ -102,14 +102,14 @@ public final class FormulaParser { * model.Workbook, then use the convenience method on * usermodel.HSSFFormulaEvaluator */ - public FormulaParser(String formula, HSSFWorkbook book){ + public FormulaParser(String formula, Workbook book){ formulaString = formula; pointer=0; this.book = book; formulaLength = formulaString.length(); } - public static Ptg[] parse(String formula, HSSFWorkbook book) { + public static Ptg[] parse(String formula, Workbook book) { FormulaParser fp = new FormulaParser(formula, book); fp.parse(); return fp.getRPNPtg(); @@ -252,7 +252,7 @@ public final class FormulaParser { Match('!'); String sheetName = name; String first = GetName(); - short externIdx = book.getExternalSheetIndex(book.getSheetIndex(sheetName)); + short externIdx = (short)book.getExternalSheetIndex(book.getSheetIndex(sheetName)); if (look == ':') { Match(':'); String second=GetName(); @@ -927,7 +927,7 @@ end; * @param lptgs list of Ptg, can be null or empty * @return a human readable String */ - public static String toFormulaString(HSSFWorkbook book, List lptgs) { + public static String toFormulaString(Workbook book, List lptgs) { String retval = null; if (lptgs == null || lptgs.size() == 0) return "#NAME"; Ptg[] ptgs = new Ptg[lptgs.size()]; @@ -953,7 +953,7 @@ end; * @param ptgs array of Ptg, can be null or empty * @return a human readable String */ - public static String toFormulaString(HSSFWorkbook book, Ptg[] ptgs) { + public static String toFormulaString(Workbook book, Ptg[] ptgs) { if (ptgs == null || ptgs.length == 0) { // TODO - what is the justification for returning "#NAME" (which is not "#NAME?", btw) return "#NAME"; diff --git a/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java b/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java index 82d85ccebb..5133eca206 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.formula.function.FunctionMetadata; import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry; @@ -73,7 +73,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg { return field_2_fnc_index == FUNCTION_INDEX_EXTERNAL; } - public String toFormulaString(HSSFWorkbook book) { + public String toFormulaString(Workbook book) { return getName(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/AddPtg.java b/src/java/org/apache/poi/hssf/record/formula/AddPtg.java index 4f79d76027..69bbdce701 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AddPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AddPtg.java @@ -23,7 +23,7 @@ */ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -75,7 +75,7 @@ public class AddPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "+"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java index 5a02394c7c..458bd1e594 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.util.AreaReference; import org.apache.poi.hssf.util.CellReference; @@ -273,7 +273,7 @@ public class Area3DPtg extends Ptg implements AreaI * @return text representation of this area reference that can be used in text * formulas. The sheet name will get properly delimited if required. */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { // First do the sheet name StringBuffer retval = new StringBuffer(); diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java index 6ff0b05b16..e984b69f2f 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java @@ -29,7 +29,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * Specifies a rectangular area of cells A1:A4 for instance. diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java index 187957e587..182b8b43e3 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java @@ -20,7 +20,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.BitField; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -66,7 +66,7 @@ public class AreaErrPtg extends AreaPtg array[offset] = (byte) (sid + ptgClass); } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "#REF!"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java index 6b0eb908ac..3d406d3e39 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java @@ -29,7 +29,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * Specifies a rectangular area of cells A1:A4 for instance. @@ -58,7 +58,7 @@ public class AreaNAPtg return "AreaNAPtg"; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java index 71e413fead..4ff10d55f9 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java @@ -29,7 +29,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * Specifies a rectangular area of cells A1:A4 for instance. @@ -61,7 +61,7 @@ public class AreaNPtg return "AreaNPtg"; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java index 2ebf019829..53ef8c8ee2 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java @@ -29,7 +29,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * Specifies a rectangular area of cells A1:A4 for instance. @@ -59,7 +59,7 @@ public class AreaNVPtg return "AreaNVPtg"; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java index 27e4d1759c..3e3e6c8fae 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java @@ -24,7 +24,7 @@ import org.apache.poi.util.BitFieldFactory; import org.apache.poi.hssf.util.AreaReference; import org.apache.poi.hssf.util.CellReference; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -303,11 +303,11 @@ public class AreaPtg field_4_last_column = column; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return toFormulaString(this, book); } - protected static String toFormulaString(AreaI area, HSSFWorkbook book) { + protected static String toFormulaString(AreaI area, Workbook book) { CellReference topLeft = new CellReference(area.getFirstRow(),area.getFirstColumn(),!area.isFirstRowRelative(),!area.isFirstColRelative()); CellReference botRight = new CellReference(area.getLastRow(),area.getLastColumn(),!area.isLastRowRelative(),!area.isLastColRelative()); diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java index e5e3d525cc..77c02bf77f 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java @@ -29,7 +29,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * Specifies a rectangular area of cells A1:A4 for instance. diff --git a/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java b/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java index 01942be55c..2a01178625 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java @@ -23,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.StringUtil; import org.apache.poi.hssf.util.CellReference; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.SSTRecord; @@ -198,7 +198,7 @@ public class ArrayPtg extends Ptg return size; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { StringBuffer b = new StringBuffer(); b.append("{"); diff --git a/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java b/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java index 616f737b84..8f567c967c 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java +++ b/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java @@ -23,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.StringUtil; import org.apache.poi.hssf.util.CellReference; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.SSTRecord; diff --git a/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java b/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java index 94aa32383f..4c3e17c5ef 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java +++ b/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java @@ -23,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.StringUtil; import org.apache.poi.hssf.util.CellReference; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.SSTRecord; diff --git a/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java b/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java index 351d44a421..c2ff29116f 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.util.LittleEndian; @@ -209,11 +209,11 @@ public final class AttrPtg extends OperationPtg { if(space.isSet(field_1_options)) { return operands[ 0 ]; } else if (optiIf.isSet(field_1_options)) { - return toFormulaString((HSSFWorkbook)null) + "(" + operands[ 0 ] +")"; + return toFormulaString((Workbook)null) + "(" + operands[ 0 ] +")"; } else if (optGoto.isSet(field_1_options)) { - return toFormulaString((HSSFWorkbook)null) + operands[0]; //goto isn't a real formula element should not show up + return toFormulaString((Workbook)null) + operands[0]; //goto isn't a real formula element should not show up } else { - return toFormulaString((HSSFWorkbook)null) + "(" + operands[ 0 ] + ")"; + return toFormulaString((Workbook)null) + "(" + operands[ 0 ] + ")"; } } @@ -228,7 +228,7 @@ public final class AttrPtg extends OperationPtg { return -1; } - public String toFormulaString(HSSFWorkbook book) { + public String toFormulaString(Workbook book) { if(semiVolatile.isSet(field_1_options)) { return "ATTR(semiVolatile)"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java b/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java index 80c9f39d79..a738653951 100644 --- a/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -70,7 +70,7 @@ public class BoolPtg return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return field_1_value ? "TRUE" : "FALSE"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java b/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java index 951872f43b..366a2ad3c2 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -64,7 +64,7 @@ public class ConcatPtg return 2; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return CONCAT; } diff --git a/src/java/org/apache/poi/hssf/record/formula/DividePtg.java b/src/java/org/apache/poi/hssf/record/formula/DividePtg.java index 70fa62e58b..f471c8a3ce 100644 --- a/src/java/org/apache/poi/hssf/record/formula/DividePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/DividePtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -65,7 +65,7 @@ public class DividePtg return 2; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "/"; } @@ -74,7 +74,7 @@ public class DividePtg StringBuffer buffer = new StringBuffer(); buffer.append(operands[ 0 ]); - buffer.append(toFormulaString((HSSFWorkbook)null)); + buffer.append(toFormulaString((Workbook)null)); buffer.append(operands[ 1 ]); return buffer.toString(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java index a08a863d1c..b31a6fa14c 100644 --- a/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -64,7 +64,7 @@ public class EqualPtg return 2; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "="; } @@ -74,7 +74,7 @@ public class EqualPtg buffer.append(operands[ 0 ]); - buffer.append(toFormulaString((HSSFWorkbook)null)); + buffer.append(toFormulaString((Workbook)null)); buffer.append(operands[ 1 ]); return buffer.toString(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java b/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java index a16992f943..3343238b99 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.usermodel.HSSFErrorConstants; @@ -70,7 +70,7 @@ public final class ErrPtg extends Ptg { array[offset + 1] = (byte)field_1_error_code; } - public String toFormulaString(HSSFWorkbook book) { + public String toFormulaString(Workbook book) { return HSSFErrorConstants.getText(field_1_error_code); } diff --git a/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java b/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java index 0cd54e5f55..05b0fbe864 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordFormatException; import org.apache.poi.hssf.record.RecordInputStream; @@ -73,7 +73,7 @@ public class ExpPtg return field_2_first_col; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RecordFormatException("Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java index 677d78c3e5..88cfa84d4f 100755 --- a/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; @@ -67,7 +67,7 @@ public class GreaterEqualPtg return 2; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return ">="; } @@ -77,7 +77,7 @@ public class GreaterEqualPtg buffer.append(operands[ 0 ]); - buffer.append(toFormulaString((HSSFWorkbook)null)); + buffer.append(toFormulaString((Workbook)null)); buffer.append(operands[ 1 ]); return buffer.toString(); diff --git a/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java b/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java index 6501203edc..cfe45a404a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java @@ -25,7 +25,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -97,7 +97,7 @@ public class GreaterThanPtg * Implementation of method from Ptg * @param book the Sheet References */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return this.GREATERTHAN; } diff --git a/src/java/org/apache/poi/hssf/record/formula/IntPtg.java b/src/java/org/apache/poi/hssf/record/formula/IntPtg.java index f3dd16f068..a1753f5ac1 100644 --- a/src/java/org/apache/poi/hssf/record/formula/IntPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/IntPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -72,7 +72,7 @@ public final class IntPtg extends Ptg { return SIZE; } - public String toFormulaString(HSSFWorkbook book) { + public String toFormulaString(Workbook book) { return String.valueOf(getValue()); } public byte getDefaultOperandClass() { diff --git a/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java b/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java index 8f5bddc190..61d02edaa7 100644 --- a/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -59,7 +59,7 @@ public class IntersectionPtg extends OperationPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return " "; } diff --git a/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java index f42966394b..e63fda02d3 100755 --- a/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java @@ -20,7 +20,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; @@ -68,7 +68,7 @@ public class LessEqualPtg return 2; } - public String toFormulaString( HSSFWorkbook book ) + public String toFormulaString( Workbook book ) { return "<="; } @@ -77,7 +77,7 @@ public class LessEqualPtg { StringBuffer buffer = new StringBuffer(); buffer.append( operands[0] ); - buffer.append( toFormulaString( (HSSFWorkbook) null ) ); + buffer.append( toFormulaString( (Workbook) null ) ); buffer.append( operands[1] ); return buffer.toString(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java b/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java index c23658d2db..6f3c0b0a29 100644 --- a/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java @@ -27,7 +27,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; //POI -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -106,7 +106,7 @@ public class LessThanPtg * Implementation of method from Ptg * @param book the Sheet References */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return this.LESSTHAN; } diff --git a/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java b/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java index ec33d10921..add7b0461b 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java @@ -25,7 +25,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -83,7 +83,7 @@ public class MemAreaPtg return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return ""; // TODO: Not sure how to format this. -- DN } diff --git a/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java b/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java index 359c76e668..4c9156a904 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java @@ -25,7 +25,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -57,7 +57,7 @@ public class MemErrPtg array[offset] = (byte) (sid + ptgClass); } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "ERR#"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java b/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java index 63c07a79e7..ac23e8aab7 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java @@ -24,7 +24,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -60,7 +60,7 @@ public class MemFuncPtg extends ControlPtg LittleEndian.putShort( array, offset + 1, (short)field_1_len_ref_subexpression ); } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return ""; } diff --git a/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java b/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java index d539405cd0..32ba801406 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -55,7 +55,7 @@ public class MissingArgPtg } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return " "; } diff --git a/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java b/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java index cbc0b67002..04589c1a86 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -68,7 +68,7 @@ public class MultiplyPtg } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "*"; } @@ -77,9 +77,9 @@ public class MultiplyPtg { StringBuffer buffer = new StringBuffer(); - buffer.append(operands[ 0 ].toFormulaString((HSSFWorkbook)null)); + buffer.append(operands[ 0 ].toFormulaString((Workbook)null)); buffer.append("*"); - buffer.append(operands[ 1 ].toFormulaString((HSSFWorkbook)null)); + buffer.append(operands[ 1 ].toFormulaString((Workbook)null)); return buffer.toString(); } @@ -87,7 +87,7 @@ public class MultiplyPtg StringBuffer buffer = new StringBuffer(); buffer.append(operands[ 0 ]); - buffer.append(toFormulaString((HSSFWorkbook)null)); + buffer.append(toFormulaString((Workbook)null)); buffer.append(operands[ 1 ]); return buffer.toString(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/NamePtg.java b/src/java/org/apache/poi/hssf/record/formula/NamePtg.java index 9d93f1e982..f501f2b3da 100644 --- a/src/java/org/apache/poi/hssf/record/formula/NamePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/NamePtg.java @@ -17,11 +17,10 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFName; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.RecordInputStream; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.LittleEndian; /** * @@ -49,13 +48,13 @@ public class NamePtg * in the workbook. The search for the name record is case insensitive. If it is not found, * it gets created. */ - public NamePtg(String name, HSSFWorkbook book) { + public NamePtg(String name, Workbook book) { field_1_label_index = (short)(1+getOrCreateNameRecord(book, name)); // convert to 1-based } /** * @return zero based index of the found or newly created defined name record. */ - private static final int getOrCreateNameRecord(HSSFWorkbook book, String name) { + private static final int getOrCreateNameRecord(Workbook book, String name) { // perhaps this logic belongs in Workbook? int countNames = book.getNumberOfNames(); for (int i = 0; i < countNames; i++) { @@ -64,7 +63,7 @@ public class NamePtg } } - HSSFName nameObj = book.createName(); + Name nameObj = book.createName(); nameObj.setNameName(name); return countNames; @@ -99,7 +98,7 @@ public class NamePtg return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return book.getNameName(field_1_label_index - 1); } diff --git a/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java b/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java index 3036800b10..39e05262a7 100644 --- a/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -61,7 +61,7 @@ public final class NameXPtg extends Ptg { return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { // -1 to convert definedNameIndex from 1-based to zero-based return book.resolveNameXText(field_1_ixals, field_2_ilbl-1); diff --git a/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java index 5dbbec8754..713e8fb046 100755 --- a/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -64,7 +64,7 @@ public class NotEqualPtg return 2; } - public String toFormulaString( HSSFWorkbook book ) + public String toFormulaString( Workbook book ) { return "<>"; } @@ -75,7 +75,7 @@ public class NotEqualPtg buffer.append( operands[0] ); - buffer.append( toFormulaString( (HSSFWorkbook) null ) ); + buffer.append( toFormulaString( (Workbook) null ) ); buffer.append( operands[1] ); return buffer.toString(); diff --git a/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java b/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java index 8ec67345b4..f74faf0917 100644 --- a/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -78,7 +78,7 @@ public class NumberPtg return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "" + getValue(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java b/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java index 402dbd3774..9d977f5eb8 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java @@ -20,7 +20,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -71,7 +71,7 @@ public class ParenthesisPtg return 1; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "()"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/PercentPtg.java b/src/java/org/apache/poi/hssf/record/formula/PercentPtg.java index 0c59bb7acb..3e1d650dcd 100644 --- a/src/java/org/apache/poi/hssf/record/formula/PercentPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/PercentPtg.java @@ -23,7 +23,7 @@ */ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -74,7 +74,7 @@ public class PercentPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "%"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java b/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java index 0dbb3ba283..327f9c566a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -66,7 +66,7 @@ public class PowerPtg return 2; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "^"; } @@ -76,7 +76,7 @@ public class PowerPtg buffer.append(operands[ 0 ]); - buffer.append(toFormulaString((HSSFWorkbook)null)); + buffer.append(toFormulaString((Workbook)null)); buffer.append(operands[ 1 ]); return buffer.toString(); } diff --git a/src/java/org/apache/poi/hssf/record/formula/Ptg.java b/src/java/org/apache/poi/hssf/record/formula/Ptg.java index 0e8c7741ac..24c80d8f7b 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ptg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ptg.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.ArrayList; import java.util.Stack; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -418,7 +418,7 @@ public abstract class Ptg /** * return a string representation of this token alone */ - public abstract String toFormulaString(HSSFWorkbook book); + public abstract String toFormulaString(Workbook book); /** * dump a debug representation (hexdump) to a string */ diff --git a/src/java/org/apache/poi/hssf/record/formula/RangePtg.java b/src/java/org/apache/poi/hssf/record/formula/RangePtg.java index 4726a70c17..09bedaecf6 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RangePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RangePtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -59,7 +59,7 @@ public class RangePtg extends OperationPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return ":"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java index f9f5c6e202..1ae56cf52e 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java @@ -18,11 +18,11 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; -import org.apache.poi.hssf.util.CellReference; import org.apache.poi.hssf.util.RangeAddress; -import org.apache.poi.hssf.util.SheetReferences; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.ss.util.SheetReferences; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.LittleEndian; @@ -162,8 +162,8 @@ public class Ref3DPtg extends Ptg { } // TODO - find a home for this method - // There is already a method on HSSFWorkbook called getSheetName but it seems to do something different. - static String getSheetName(HSSFWorkbook book, int externSheetIndex) { + // There is already a method on Workbook called getSheetName but it seems to do something different. + static String getSheetName(Workbook book, int externSheetIndex) { // TODO - there are 3 ways this method can return null. Is each valid? if (book == null) { return null; @@ -179,7 +179,7 @@ public class Ref3DPtg extends Ptg { * @return text representation of this cell reference that can be used in text * formulas. The sheet name will get properly delimited if required. */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { StringBuffer retval = new StringBuffer(); String sheetName = getSheetName(book, field_1_index_extern_sheet); diff --git a/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java b/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java index c29b55bf94..031fa41120 100755 --- a/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java @@ -21,7 +21,7 @@ import org.apache.poi.util.LittleEndian; import org.apache.poi.util.BitField; import org.apache.poi.hssf.util.CellReference; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -74,7 +74,7 @@ public class RefErrorPtg extends Ptg return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { //TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe! return "#REF!"; diff --git a/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java b/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java index 6f18e4b94e..f813ea23ce 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java @@ -28,7 +28,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * RefNAPtg @@ -57,7 +57,7 @@ public class RefNAPtg extends ReferencePtg return "RefNAPtg"; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java b/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java index e7522e7e5f..fc19859b50 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java @@ -27,7 +27,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * RefNPtg @@ -58,7 +58,7 @@ public class RefNPtg extends ReferencePtg return "RefNPtg"; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java b/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java index 40b111b3ec..52b2e51fb2 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java @@ -23,7 +23,7 @@ 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.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; /** * RefNVPtg @@ -54,7 +54,7 @@ public class RefNVPtg extends ReferencePtg return "RefNVPtg"; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java b/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java index 3df731c7ac..ff6f4a20ee 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java @@ -22,7 +22,7 @@ import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.hssf.util.CellReference; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -176,7 +176,7 @@ public class ReferencePtg extends Ptg { return SIZE; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { //TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe! return (new CellReference(getRowAsInt(),getColumn(),!isRowRelative(),!isColRelative())).formatAsString(); diff --git a/src/java/org/apache/poi/hssf/record/formula/StringPtg.java b/src/java/org/apache/poi/hssf/record/formula/StringPtg.java index ca6fb55dc6..b6615182d3 100644 --- a/src/java/org/apache/poi/hssf/record/formula/StringPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/StringPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.StringUtil; @@ -109,7 +109,7 @@ public class StringPtg } } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "\""+getValue()+"\""; } diff --git a/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java b/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java index 37af74ba9e..6d1d1e860d 100644 --- a/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -63,7 +63,7 @@ public class SubtractPtg return 2; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "-"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java index 7c134b97d1..d85cc4913e 100644 --- a/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -69,7 +69,7 @@ public class UnaryMinusPtg extends OperationPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "+"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java index 148c83fa41..6ae89cf2c1 100644 --- a/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -69,7 +69,7 @@ public class UnaryPlusPtg extends OperationPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "+"; } diff --git a/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java index 8d00ec34df..3b671e22fd 100644 --- a/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -59,7 +59,7 @@ public class UnionPtg extends OperationPtg } /** Implementation of method from Ptg */ - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return ","; } diff --git a/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java index 56493d906a..af5ebc8441 100644 --- a/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.hssf.record.RecordInputStream; /** @@ -51,7 +51,7 @@ public class UnknownPtg return size; } - public String toFormulaString(HSSFWorkbook book) + public String toFormulaString(Workbook book) { return "UNKNOWN"; } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java index 4152e3ae19..bd955f8254 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java @@ -112,7 +112,8 @@ public class HSSFName implements Name { private void setSheetName(String sheetName){ int sheetNumber = book.getSheetIndex(sheetName); - short externSheetNumber = book.getExternalSheetIndex(sheetNumber); + short externSheetNumber = (short) + book.getExternalSheetIndex(sheetNumber); name.setExternSheetNumber(externSheetNumber); // name.setIndexToSheet(externSheetNumber); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 4135694830..4b44fb5c4c 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -548,7 +548,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm * Used by some of the more obscure formula and * named range things. */ - public short getExternalSheetIndex(int internalSheetIndex) { + public int getExternalSheetIndex(int internalSheetIndex) { return workbook.checkExternSheet(internalSheetIndex); } diff --git a/src/java/org/apache/poi/hssf/util/SheetReferences.java b/src/java/org/apache/poi/hssf/util/SheetReferences.java index 9fe8dd1f3d..d23ed27c6b 100644 --- a/src/java/org/apache/poi/hssf/util/SheetReferences.java +++ b/src/java/org/apache/poi/hssf/util/SheetReferences.java @@ -17,9 +17,6 @@ package org.apache.poi.hssf.util; -import java.util.HashMap; -import java.util.Map; - /** * Holds a collection of Sheet names and their associated * reference numbers. @@ -27,20 +24,6 @@ import java.util.Map; * @author Andrew C. Oliver (acoliver at apache dot org) * */ -public class SheetReferences +public class SheetReferences extends org.apache.poi.ss.util.SheetReferences { - Map map; - public SheetReferences() - { - map = new HashMap(5); - } - - public void addSheetReference(String sheetName, int number) { - map.put(new Integer(number), sheetName); - } - - public String getSheetName(int number) { - return (String)map.get(new Integer(number)); - } - } diff --git a/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java b/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java index 80287f5ec4..b133c0ff33 100644 --- a/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java +++ b/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java @@ -60,7 +60,6 @@ import org.apache.poi.hssf.record.formula.eval.RefEval; import org.apache.poi.hssf.record.formula.eval.StringEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; /** * @author Amol S. Deshmukh < amolweb at ya hoo dot com > @@ -333,16 +332,8 @@ public class FormulaEvaluator { private static ValueEval evaluateCell(Workbook workbook, Sheet sheet, int srcRowNum, short srcColNum, String cellFormulaText) { - FormulaParser parser; - if(workbook instanceof HSSFWorkbook) { - parser = HSSFFormulaEvaluator.getUnderlyingParser( - (HSSFWorkbook)workbook, - cellFormulaText - ); - } else { - // Hope for the best... - parser = new FormulaParser(cellFormulaText, null); - } + FormulaParser parser = + new FormulaParser(cellFormulaText, workbook); parser.parse(); Ptg[] ptgs = parser.getRPNPtg(); diff --git a/src/java/org/apache/poi/ss/util/SheetReferences.java b/src/java/org/apache/poi/ss/util/SheetReferences.java new file mode 100644 index 0000000000..74b84f5f26 --- /dev/null +++ b/src/java/org/apache/poi/ss/util/SheetReferences.java @@ -0,0 +1,46 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.ss.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * Holds a collection of Sheet names and their associated + * reference numbers. + * + * @author Andrew C. Oliver (acoliver at apache dot org) + * + */ +public class SheetReferences +{ + Map map; + public SheetReferences() + { + map = new HashMap(5); + } + + public void addSheetReference(String sheetName, int number) { + map.put(new Integer(number), sheetName); + } + + public String getSheetName(int number) { + return (String)map.get(new Integer(number)); + } + +} |