From: Yegor Kozlov Date: Sat, 20 Nov 2010 14:49:47 +0000 (+0000) Subject: removed dependencies on HSSF, prepare to move common formula stuff to org.apache... X-Git-Tag: REL_3_8_BETA1~126 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3d98facdd2d8335825447c16bdb06b476c88282a;p=poi.git removed dependencies on HSSF, prepare to move common formula stuff to org.apache.poi.ss.formula git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1037228 13f79535-47bb-0310-9956-ffa450edef68 --- 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 dfbfb7ab32..6bd4a8bbbc 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; @@ -49,7 +49,7 @@ public final class AreaErrPtg extends OperandPtg { } public String toFormulaString() { - return HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF); + return ErrorConstants.getText(ErrorConstants.ERROR_REF); } public byte getDefaultOperandClass() { diff --git a/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java index 0cf412d859..558f7af55d 100644 --- a/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.ss.formula.FormulaRenderingWorkbook; import org.apache.poi.ss.formula.WorkbookDependentFormula; import org.apache.poi.util.LittleEndianInput; @@ -49,7 +49,7 @@ public final class DeletedArea3DPtg extends OperandPtg implements WorkbookDepend } public String toFormulaString(FormulaRenderingWorkbook book) { return ExternSheetNameResolver.prependSheetName(book, field_1_index_extern_sheet, - HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF)); + ErrorConstants.getText(ErrorConstants.ERROR_REF)); } public String toFormulaString() { throw new RuntimeException("3D references need a workbook to determine formula text"); diff --git a/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java index dcc07ab6d9..1174f319b7 100644 --- a/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java @@ -18,7 +18,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.ss.formula.FormulaRenderingWorkbook; import org.apache.poi.ss.formula.WorkbookDependentFormula; import org.apache.poi.util.LittleEndianInput; @@ -49,7 +49,7 @@ public final class DeletedRef3DPtg extends OperandPtg implements WorkbookDepende public String toFormulaString(FormulaRenderingWorkbook book) { return ExternSheetNameResolver.prependSheetName(book, field_1_index_extern_sheet, - HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF)); + ErrorConstants.getText(ErrorConstants.ERROR_REF)); } public String toFormulaString() { throw new RuntimeException("3D references need a workbook to determine formula text"); 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 361e4b5cf9..2b9b1cdce5 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; @@ -27,7 +27,7 @@ import org.apache.poi.util.LittleEndianOutput; public final class ErrPtg extends ScalarConstantPtg { // convenient access to namespace - private static final HSSFErrorConstants EC = null; + private static final ErrorConstants EC = null; /** #NULL! - Intersection of two cell ranges is empty */ public static final ErrPtg NULL_INTERSECTION = new ErrPtg(EC.ERROR_NULL); @@ -52,7 +52,7 @@ public final class ErrPtg extends ScalarConstantPtg { /** Creates new ErrPtg */ private ErrPtg(int errorCode) { - if(!HSSFErrorConstants.isValidCode(errorCode)) { + if(!ErrorConstants.isValidCode(errorCode)) { throw new IllegalArgumentException("Invalid error code (" + errorCode + ")"); } field_1_error_code = errorCode; @@ -68,7 +68,7 @@ public final class ErrPtg extends ScalarConstantPtg { } public String toFormulaString() { - return HSSFErrorConstants.getText(field_1_error_code); + return ErrorConstants.getText(field_1_error_code); } public int getSize() { @@ -81,13 +81,13 @@ public final class ErrPtg extends ScalarConstantPtg { public static ErrPtg valueOf(int code) { switch(code) { - case HSSFErrorConstants.ERROR_DIV_0: return DIV_ZERO; - case HSSFErrorConstants.ERROR_NA: return N_A; - case HSSFErrorConstants.ERROR_NAME: return NAME_INVALID; - case HSSFErrorConstants.ERROR_NULL: return NULL_INTERSECTION; - case HSSFErrorConstants.ERROR_NUM: return NUM_ERROR; - case HSSFErrorConstants.ERROR_REF: return REF_INVALID; - case HSSFErrorConstants.ERROR_VALUE: return VALUE_INVALID; + case ErrorConstants.ERROR_DIV_0: return DIV_ZERO; + case ErrorConstants.ERROR_NA: return N_A; + case ErrorConstants.ERROR_NAME: return NAME_INVALID; + case ErrorConstants.ERROR_NULL: return NULL_INTERSECTION; + case ErrorConstants.ERROR_NUM: return NUM_ERROR; + case ErrorConstants.ERROR_REF: return REF_INVALID; + case ErrorConstants.ERROR_VALUE: return VALUE_INVALID; } throw new RuntimeException("Unexpected error code (" + code + ")"); } 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 4cbd501053..1cca3b110a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; @@ -53,7 +53,7 @@ public final class RefErrorPtg extends OperandPtg { } public String toFormulaString() { - return HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF); + return ErrorConstants.getText(ErrorConstants.ERROR_REF); } public byte getDefaultOperandClass() { diff --git a/src/java/org/apache/poi/hssf/record/formula/atp/YearFracCalculator.java b/src/java/org/apache/poi/hssf/record/formula/atp/YearFracCalculator.java index 40a5eb8dbd..9475db1bc6 100644 --- a/src/java/org/apache/poi/hssf/record/formula/atp/YearFracCalculator.java +++ b/src/java/org/apache/poi/hssf/record/formula/atp/YearFracCalculator.java @@ -23,7 +23,7 @@ import java.util.TimeZone; import org.apache.poi.hssf.record.formula.eval.ErrorEval; import org.apache.poi.hssf.record.formula.eval.EvaluationException; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.DateUtil; /** @@ -317,7 +317,7 @@ final class YearFracCalculator { private static SimpleDate createDate(int dayCount) { GregorianCalendar calendar = new GregorianCalendar(UTC_TIME_ZONE); - HSSFDateUtil.setCalendar(calendar, dayCount, 0, false); + DateUtil.setCalendar(calendar, dayCount, 0, false); return new SimpleDate(calendar); } diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/ErrorEval.java b/src/java/org/apache/poi/hssf/record/formula/eval/ErrorEval.java index 687052566b..13f51f5f80 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/ErrorEval.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/ErrorEval.java @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record.formula.eval; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; /** * @author Amol S. Deshmukh < amolweb at ya hoo dot com > @@ -26,7 +26,7 @@ import org.apache.poi.hssf.usermodel.HSSFErrorConstants; public final class ErrorEval implements ValueEval { // convenient access to namespace - private static final HSSFErrorConstants EC = null; + private static final ErrorConstants EC = null; /** #NULL! - Intersection of two cell ranges is empty */ public static final ErrorEval NULL_INTERSECTION = new ErrorEval(EC.ERROR_NULL); @@ -58,13 +58,13 @@ public final class ErrorEval implements ValueEval { */ public static ErrorEval valueOf(int errorCode) { switch(errorCode) { - case HSSFErrorConstants.ERROR_NULL: return NULL_INTERSECTION; - case HSSFErrorConstants.ERROR_DIV_0: return DIV_ZERO; - case HSSFErrorConstants.ERROR_VALUE: return VALUE_INVALID; - case HSSFErrorConstants.ERROR_REF: return REF_INVALID; - case HSSFErrorConstants.ERROR_NAME: return NAME_INVALID; - case HSSFErrorConstants.ERROR_NUM: return NUM_ERROR; - case HSSFErrorConstants.ERROR_NA: return NA; + case ErrorConstants.ERROR_NULL: return NULL_INTERSECTION; + case ErrorConstants.ERROR_DIV_0: return DIV_ZERO; + case ErrorConstants.ERROR_VALUE: return VALUE_INVALID; + case ErrorConstants.ERROR_REF: return REF_INVALID; + case ErrorConstants.ERROR_NAME: return NAME_INVALID; + case ErrorConstants.ERROR_NUM: return NUM_ERROR; + case ErrorConstants.ERROR_NA: return NA; // non-std errors (conditions modeled as errors by POI) case CIRCULAR_REF_ERROR_CODE: return CIRCULAR_REF_ERROR; } @@ -77,8 +77,8 @@ public final class ErrorEval implements ValueEval { * @return the String representation of the specified Excel error code. */ public static String getText(int errorCode) { - if(HSSFErrorConstants.isValidCode(errorCode)) { - return HSSFErrorConstants.getText(errorCode); + if(ErrorConstants.isValidCode(errorCode)) { + return ErrorConstants.getText(errorCode); } // It is desirable to make these (arbitrary) strings look clearly different from any other // value expression that might appear in a formula. In addition these error strings should diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java b/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java index 75d68540fe..f81ebdde0f 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java @@ -149,7 +149,7 @@ public final class OperandResolver { cells this method could not detect it. Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector - (and HSSFFormulaEvaluator). + (and FormulaEvaluator). */ } diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/RefEval.java b/src/java/org/apache/poi/hssf/record/formula/eval/RefEval.java index b4200825d8..cb4a9e47dc 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/RefEval.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/RefEval.java @@ -23,7 +23,7 @@ package org.apache.poi.hssf.record.formula.eval; * RefEval is the super interface for Ref2D and Ref3DEval. Basically a RefEval * impl should contain reference to the original ReferencePtg or Ref3DPtg as * well as the final "value" resulting from the evaluation of the cell - * reference. Thus if the HSSFCell has type CELL_TYPE_NUMERIC, the contained + * reference. Thus if the Cell has type CELL_TYPE_NUMERIC, the contained * value object should be of type NumberEval; if cell type is CELL_TYPE_STRING, * contained value object should be of type StringEval */ diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java b/src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java index 3261f209be..48d3a16215 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java @@ -26,7 +26,7 @@ import org.apache.poi.hssf.record.formula.eval.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; import org.apache.poi.hssf.record.formula.eval.ValueEval; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.DateUtil; /** * Implementation of Excel functions DAY, MONTH and YEAR @@ -73,7 +73,7 @@ public final class CalendarFieldFunction extends Fixed1ArgFunction { } throw new IllegalStateException("bad date field " + _dateFieldId); } - Date d = HSSFDateUtil.getJavaDate(serialDay, false); // TODO fix 1900/1904 problem + Date d = DateUtil.getJavaDate(serialDay, false); // TODO fix 1900/1904 problem Calendar c = new GregorianCalendar(); c.setTime(d); diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java b/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java index 0422168fd2..55bc0825fd 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/DateFunc.java @@ -24,7 +24,7 @@ import org.apache.poi.hssf.record.formula.eval.ErrorEval; import org.apache.poi.hssf.record.formula.eval.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.DateUtil; /** @@ -77,7 +77,7 @@ public final class DateFunc extends Fixed3ArgFunction { c.set(year, month, day, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); - return HSSFDateUtil.getExcelDate(c.getTime(), false); // TODO - fix 1900/1904 problem + return DateUtil.getExcelDate(c.getTime(), false); // TODO - fix 1900/1904 problem } private static int getYear(double d) { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java b/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java index 72de76273c..25dda0a1b3 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java @@ -22,7 +22,7 @@ import org.apache.poi.hssf.record.formula.eval.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; import org.apache.poi.hssf.record.formula.eval.ValueEval; -import org.apache.poi.hssf.usermodel.HSSFErrorConstants; +import org.apache.poi.ss.usermodel.ErrorConstants; /** * Implementation for the ERROR.TYPE() Excel function. @@ -45,7 +45,7 @@ import org.apache.poi.hssf.usermodel.HSSFErrorConstants; * * * Note - the results of ERROR.TYPE() are different to the constants defined in - * HSSFErrorConstants. + * ErrorConstants. *

* * @author Josh Micich @@ -65,13 +65,13 @@ public final class Errortype extends Fixed1ArgFunction { private int translateErrorCodeToErrorTypeValue(int errorCode) { switch (errorCode) { - case HSSFErrorConstants.ERROR_NULL: return 1; - case HSSFErrorConstants.ERROR_DIV_0: return 2; - case HSSFErrorConstants.ERROR_VALUE: return 3; - case HSSFErrorConstants.ERROR_REF: return 4; - case HSSFErrorConstants.ERROR_NAME: return 5; - case HSSFErrorConstants.ERROR_NUM: return 6; - case HSSFErrorConstants.ERROR_NA : return 7; + case ErrorConstants.ERROR_NULL: return 1; + case ErrorConstants.ERROR_DIV_0: return 2; + case ErrorConstants.ERROR_VALUE: return 3; + case ErrorConstants.ERROR_REF: return 4; + case ErrorConstants.ERROR_NAME: return 5; + case ErrorConstants.ERROR_NUM: return 6; + case ErrorConstants.ERROR_NA : return 7; } throw new IllegalArgumentException("Invalid error code (" + errorCode + ")"); } diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Now.java b/src/java/org/apache/poi/hssf/record/formula/functions/Now.java index 766f5694d4..c6d7c236a9 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Now.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Now.java @@ -21,7 +21,7 @@ import java.util.Date; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.DateUtil; /** * Implementation of Excel NOW() Function @@ -32,6 +32,6 @@ public final class Now extends Fixed0ArgFunction { public ValueEval evaluate(int srcRowIndex, int srcColumnIndex) { Date now = new Date(System.currentTimeMillis()); - return new NumberEval(HSSFDateUtil.getExcelDate(now)); + return new NumberEval(DateUtil.getExcelDate(now)); } } diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Today.java b/src/java/org/apache/poi/hssf/record/formula/functions/Today.java index f50ea73c1a..9acbdbd332 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Today.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Today.java @@ -22,7 +22,7 @@ import java.util.GregorianCalendar; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.DateUtil; /** * Implementation of Excel TODAY() Function
@@ -36,6 +36,6 @@ public final class Today extends Fixed0ArgFunction { Calendar now = new GregorianCalendar(); now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE),0,0,0); now.set(Calendar.MILLISECOND, 0); - return new NumberEval(HSSFDateUtil.getExcelDate(now.getTime())); + return new NumberEval(DateUtil.getExcelDate(now.getTime())); } } diff --git a/src/testcases/org/apache/poi/hssf/record/formula/atp/TestRandBetween.java b/src/testcases/org/apache/poi/hssf/record/formula/atp/TestRandBetween.java index 1cd0db22d4..6be56bad64 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/atp/TestRandBetween.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/atp/TestRandBetween.java @@ -20,7 +20,6 @@ import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.record.formula.eval.ErrorEval; -import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Row; @@ -50,7 +49,7 @@ public class TestRandBetween extends TestCase { Row row = sheet.createRow(0); bottomValueCell = row.createCell(0); topValueCell = row.createCell(1); - formulaCell = row.createCell(2, HSSFCell.CELL_TYPE_FORMULA); + formulaCell = row.createCell(2, Cell.CELL_TYPE_FORMULA); } @Override diff --git a/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculator.java b/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculator.java index 890a5c2cbd..bd580f06c6 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculator.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculator.java @@ -23,7 +23,7 @@ import java.util.GregorianCalendar; import junit.framework.TestCase; import org.apache.poi.hssf.record.formula.eval.EvaluationException; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.DateUtil; /** * Specific test cases for YearFracCalculator @@ -62,6 +62,6 @@ public final class TestYearFracCalculator extends TestCase { c.set(year, month-1, day, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); - return HSSFDateUtil.getExcelDate(c.getTime()); + return DateUtil.getExcelDate(c.getTime()); } }