poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r670186 [1/7] - in /poi/tags/REL_3_1_FINAL: ./ legal/ src/documentation/content/xdocs/ src/examples/src/org/apache/poi/hslf/ src/examples/src/org/apache/poi/hslf/usermodel/ src/examples/src/org/apache/poi/hslf/usermodel/examples/ src/java/o...
Date Sat, 21 Jun 2008 12:03:49 GMT
Author: yegor
Date: Sat Jun 21 05:03:44 2008
New Revision: 670186

URL: http://svn.apache.org/viewvc?rev=670186&view=rev
Log:
merged with trunk r670185

Added:
    poi/tags/REL_3_1_FINAL/src/examples/src/org/apache/poi/hslf/
      - copied from r670185, poi/trunk/src/examples/src/org/apache/poi/hslf/
    poi/tags/REL_3_1_FINAL/src/examples/src/org/apache/poi/hslf/usermodel/
      - copied from r670185, poi/trunk/src/examples/src/org/apache/poi/hslf/usermodel/
    poi/tags/REL_3_1_FINAL/src/examples/src/org/apache/poi/hslf/usermodel/examples/
      - copied from r670185, poi/trunk/src/examples/src/org/apache/poi/hslf/usermodel/examples/
    poi/tags/REL_3_1_FINAL/src/examples/src/org/apache/poi/hslf/usermodel/examples/SoundFinder.java
      - copied unchanged from r670185, poi/trunk/src/examples/src/org/apache/poi/hslf/usermodel/examples/SoundFinder.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/OperandClassTransformer.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/model/OperandClassTransformer.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/ParseNode.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/model/ParseNode.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/OperandPtg.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/OperandPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefPtg.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ScalarConstantPtg.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/ScalarConstantPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ValueOperatorPtg.java
      - copied unchanged from r670185, poi/trunk/src/java/org/apache/poi/hssf/record/formula/ValueOperatorPtg.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/model/FSPA.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPA.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeInsertion.doc
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeInsertion.doc
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeReplacement.doc
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeReplacement.doc
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeInsertion.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeInsertion.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
      - copied unchanged from r670185, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/data/30978-alt.xls
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/data/30978-alt.xls
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/data/30978-deleted.xls
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/data/30978-deleted.xls
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/data/WithCheckBoxes.xls
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/data/WithCheckBoxes.xls
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/data/ex42564-elementOrder.xls
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/data/ex42564-elementOrder.xls
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/data/ex45046-21984.xls
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/data/ex45046-21984.xls
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/data/testRVA.xls
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/data/testRVA.xls
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/model/TestRVA.java
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/FormulaExtractor.java
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/FormulaExtractor.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestLinkTable.java
      - copied unchanged from r670185, poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestLinkTable.java
Removed:
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefAPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefVPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
Modified:
    poi/tags/REL_3_1_FINAL/build.xml
    poi/tags/REL_3_1_FINAL/legal/NOTICE
    poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/changes.xml
    poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/index.xml
    poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/status.xml
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/POIDocument.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherDggRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/dev/BiffViewer.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/FormulaParser.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/LinkTable.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/Sheet.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/Workbook.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/DBCellRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/EmbeddedObjectRefSubRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/FormulaRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/NameRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/ObjRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ControlPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/DeletedArea3DPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/DeletedRef3DPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/OperationPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/PercentPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/Ptg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RangePtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/record/formula/eval/Ref2DEval.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFObjectData.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/util/AreaReference.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/util/HSSFColor.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/poifs/storage/RawDataBlock.java
    poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/poifs/storage/RawDataBlockList.java
    poi/tags/REL_3_1_FINAL/src/resources/main/org/apache/poi/hssf/record/formula/function/functionMetadata-asGenerated.txt
    poi/tags/REL_3_1_FINAL/src/resources/main/org/apache/poi/hssf/record/formula/function/functionMetadata.txt
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFChart.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
    poi/tags/REL_3_1_FINAL/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/model/AllModelTests.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/model/TestSheet.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/eval/TestUnaryPlusEval.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/function/TestReadMissingBuiltInFuncs.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/functions/EvalFactory.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java
    poi/tags/REL_3_1_FINAL/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java

Modified: poi/tags/REL_3_1_FINAL/build.xml
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/build.xml?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/build.xml (original)
+++ poi/tags/REL_3_1_FINAL/build.xml Sat Jun 21 05:03:44 2008
@@ -135,7 +135,7 @@
   <property name="mavendist.poi.dir" location="build/maven-dist/poi"/>
   <property name="mavendist.oap.dir" location="build/maven-dist/org.apache.poi"/>
   <property name="jar.name" value="poi"/>
-  <property name="version.id" value="3.1-beta2"/>
+  <property name="version.id" value="3.1-beta3"/>
   <property name="halt.on.test.failure" value="true"/>
   <property name="jdk.version.source" value="1.3"
     description="JDK version of source code"/>
@@ -170,6 +170,7 @@
   <path id="examples.classpath">
     <path refid="main.classpath"/>
     <pathelement location="${main.output.dir}"/>
+    <pathelement location="${scratchpad.output.dir}"/>
   </path>
 
 

Modified: poi/tags/REL_3_1_FINAL/legal/NOTICE
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/legal/NOTICE?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/legal/NOTICE (original)
+++ poi/tags/REL_3_1_FINAL/legal/NOTICE Sat Jun 21 05:03:44 2008
@@ -10,14 +10,6 @@
 	http://www.opensource.org/licenses/cpl.php
 See http://www.junit.org/
 
-A single data file of the POI component HDGF is based on VSDump,
- and is under the GNU General Public Licence version 3 (GPL v3):
-	http://gplv3.fsf.org/
-Since this is a data file, and has no compiled version (the original
- file is distributed in both source and binary versions), there should
- be little difference in licencing requirements compared to the ASL.
-See http://www.gnome.ru/projects/vsdump_en.html
-
 
 The Office Open XML experimental support had additional dependencies,
 with their own licensing:

Modified: poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/changes.xml?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/changes.xml (original)
+++ poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/changes.xml Sat Jun 21 05:03:44 2008
@@ -36,6 +36,34 @@
     </devs>
 
 		<!-- Don't forget to update status.xml too! -->
+        <release version="3.1-final" date="2008-06-??">
+           <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d</action>
+           <action dev="POI-DEVELOPERS" type="fix">45234 - Removed incorrect shared formula conversion in CFRuleRecord</action>
+           <action dev="POI-DEVELOPERS" type="fix">45001 - Improved HWPF Range.replaceText()</action>
+           <action dev="POI-DEVELOPERS" type="fix">44692 - Fixed HSSFPicture.resize() to properly resize pictures if the underlying columns/rows have modified size</action>
+           <action dev="POI-DEVELOPERS" type="add">Support custom image renderers in HSLF</action>
+           <action dev="POI-DEVELOPERS" type="fix">Correctly increment the reference count of a blip when a picture is inserted</action>
+           <action dev="POI-DEVELOPERS" type="fix">45110 - Fixed TextShape.resizeToFitText() to properly resize TextShape</action>
+           <action dev="POI-DEVELOPERS" type="fix">45091 - Fixed serialization of RefN~ tokens.  Simplified Ptg class hierarchy</action>
+           <action dev="POI-DEVELOPERS" type="fix">45133 - Fixed OBJ Record (5Dh) to pad the sub-record data to a 4-byte boundary</action>
+           <action dev="POI-DEVELOPERS" type="fix">45145 - Fixed Sheet to always enforce RowRecordsAggregate before ValueRecordsAggregate</action>
+           <action dev="POI-DEVELOPERS" type="fix">45123 - Fixed SharedFormulaRecord.convertSharedFormulas() to propagate token operand classes</action>
+           <action dev="POI-DEVELOPERS" type="fix">45087 - Correctly detect date formats like [Black]YYYY as being date based</action>
+           <action dev="POI-DEVELOPERS" type="add">45060 - Improved token class transformation during formula parsing</action>
+           <action dev="POI-DEVELOPERS" type="add">44840 - Improved handling of HSSFObjectData, especially for entries with data held not in POIFS</action>
+           <action dev="POI-DEVELOPERS" type="add">45043 - Support for getting excel cell comments when extracting text</action>
+           <action dev="POI-DEVELOPERS" type="add">Extend the support for specifying a policy to HSSF on missing / blank cells when fetching, to be able to specify the policy at the HSSFWorkbook level</action>
+           <action dev="POI-DEVELOPERS" type="fix">45025 - improved FormulaParser parse error messages</action>
+           <action dev="POI-DEVELOPERS" type="fix">45046 - allowed EXTERNALBOOK(0x01AE) to be optional in the LinkTable</action>
+           <action dev="POI-DEVELOPERS" type="fix">45066 - fixed sheet encoding size mismatch problems</action>
+           <action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action>
+           <action dev="POI-DEVELOPERS" type="fix">45001 - Partial fix for HWPF Range.insertBefore() and Range.delete() with unicode characters</action>
+           <action dev="POI-DEVELOPERS" type="fix">44977 - Support for AM/PM in excel date formats</action>
+           <action dev="POI-DEVELOPERS" type="add">Support for specifying a policy to HSSF on missing / blank cells when fetching</action>
+           <action dev="POI-DEVELOPERS" type="add">44937 - Partial support for extracting Escher images from HWPF files</action>
+           <action dev="POI-DEVELOPERS" type="fix">44824 - Avoid an infinite loop when reading some HWPF pictures</action>
+           <action dev="POI-DEVELOPERS" type="fix">44898 - Correctly handle short last blocks in POIFS</action>
+        </release>  
         <release version="3.1-beta2" date="2008-05-26">
            <action dev="POI-DEVELOPERS" type="fix">44306 - fixed reading/writing of AttrPtg(type=choose) and method toFormulaString() for CHOOSE formulas</action>
            <action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted() to check if the name points to cell that no longer exists</action>

Modified: poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/index.xml?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/index.xml (original)
+++ poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/index.xml Sat Jun 21 05:03:44 2008
@@ -31,9 +31,9 @@
   </header>
 
   <body>
-    <section><title>POI 3.1-BETA1 Released (2008-04028)</title>
+    <section><title>POI 3.1-BETA2 Released (2008-05-28)</title>
       <p>
-        The POI team is pleased to announce the release of 3.1 BETA1 which is one of the final steps before 3.1 FINAL.
+        The POI team is pleased to announce the release of 3.1 BETA2 which is one of the final steps before 3.1 FINAL.
         The status of this release is a beta, meaning that we encourage users to try it out.
         If you find any bugs, please report them to the POI <link href="https://issues.apache.org/bugzilla/buglist.cgi?product=POI">bug database</link> or to
         the <link href="./mailinglists.html">POI Developer List</link>.
@@ -45,7 +45,7 @@
       </p>
       <p>
         The release is also available from the central Maven repository 
-        under Group ID "org.apache.poi" and Version "3.1-beta1".
+        under Group ID "org.apache.poi" and Version "3.1-beta2".
       </p>  
     </section>
     <section><title>POI 3.0.2 Released</title>

Modified: poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/status.xml?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/status.xml (original)
+++ poi/tags/REL_3_1_FINAL/src/documentation/content/xdocs/status.xml Sat Jun 21 05:03:44 2008
@@ -33,6 +33,34 @@
 
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
+        <release version="3.1-final" date="2008-06-??">
+           <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d</action>
+           <action dev="POI-DEVELOPERS" type="fix">45234 - Removed incorrect shared formula conversion in CFRuleRecord</action>
+           <action dev="POI-DEVELOPERS" type="fix">45001 - Improved HWPF Range.replaceText()</action>
+           <action dev="POI-DEVELOPERS" type="fix">44692 - Fixed HSSFPicture.resize() to properly resize pictures if the underlying columns/rows have modified size</action>
+           <action dev="POI-DEVELOPERS" type="add">Support custom image renderers in HSLF</action>
+           <action dev="POI-DEVELOPERS" type="fix">Correctly increment the reference count of a blip when a picture is inserted</action>
+           <action dev="POI-DEVELOPERS" type="fix">45110 - Fixed TextShape.resizeToFitText() to properly resize TextShape</action>
+           <action dev="POI-DEVELOPERS" type="fix">45091 - Fixed serialization of RefN~ tokens.  Simplified Ptg class hierarchy</action>
+           <action dev="POI-DEVELOPERS" type="fix">45133 - Fixed OBJ Record (5Dh) to pad the sub-record data to a 4-byte boundary</action>
+           <action dev="POI-DEVELOPERS" type="fix">45145 - Fixed Sheet to always enforce RowRecordsAggregate before ValueRecordsAggregate</action>
+           <action dev="POI-DEVELOPERS" type="fix">45123 - Fixed SharedFormulaRecord.convertSharedFormulas() to propagate token operand classes</action>
+           <action dev="POI-DEVELOPERS" type="fix">45087 - Correctly detect date formats like [Black]YYYY as being date based</action>
+           <action dev="POI-DEVELOPERS" type="add">45060 - Improved token class transformation during formula parsing</action>
+           <action dev="POI-DEVELOPERS" type="add">44840 - Improved handling of HSSFObjectData, especially for entries with data held not in POIFS</action>
+           <action dev="POI-DEVELOPERS" type="add">45043 - Support for getting excel cell comments when extracting text</action>
+           <action dev="POI-DEVELOPERS" type="add">Extend the support for specifying a policy to HSSF on missing / blank cells when fetching, to be able to specify the policy at the HSSFWorkbook level</action>
+           <action dev="POI-DEVELOPERS" type="fix">45025 - improved FormulaParser parse error messages</action>
+           <action dev="POI-DEVELOPERS" type="fix">45046 - allowed EXTERNALBOOK(0x01AE) to be optional in the LinkTable</action>
+           <action dev="POI-DEVELOPERS" type="fix">45066 - fixed sheet encoding size mismatch problems</action>
+           <action dev="POI-DEVELOPERS" type="add">45003 - Support embeded HDGF visio documents</action>
+           <action dev="POI-DEVELOPERS" type="fix">45001 - Partial fix for HWPF Range.insertBefore() and Range.delete() with unicode characters</action>
+           <action dev="POI-DEVELOPERS" type="fix">44977 - Support for AM/PM in excel date formats</action>
+           <action dev="POI-DEVELOPERS" type="add">Support for specifying a policy to HSSF on missing / blank cells when fetching</action>
+           <action dev="POI-DEVELOPERS" type="add">44937 - Partial support for extracting Escher images from HWPF files</action>
+           <action dev="POI-DEVELOPERS" type="fix">44824 - Avoid an infinite loop when reading some HWPF pictures</action>
+           <action dev="POI-DEVELOPERS" type="fix">44898 - Correctly handle short last blocks in POIFS</action>
+        </release>  
         <release version="3.1-beta2" date="2008-05-26">
            <action dev="POI-DEVELOPERS" type="fix">44306 - fixed reading/writing of AttrPtg(type=choose) and method toFormulaString() for CHOOSE formulas</action>
            <action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted() to check if the name points to cell that no longer exists</action>

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/POIDocument.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/POIDocument.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/POIDocument.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/POIDocument.java Sat Jun 21 05:03:44 2008
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Iterator;
 import java.util.List;
 
@@ -191,6 +192,11 @@
 			System.err.println("Couldn't write property set with name " + name + " as not supported by HPSF yet");
 		}
 	}
+	
+	/**
+	 * Writes the document out to the specified output stream
+	 */
+	public abstract void write(OutputStream out) throws IOException;
 
 	/**
 	 * Copies nodes from one POIFS to the other minus the excepts

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java Sat Jun 21 05:03:44 2008
@@ -65,20 +65,27 @@
         int size           = 0;
 
         // Always find 4 two byte entries. Sometimes find 9
-        field_1_flag   =  LittleEndian.getShort( data, pos + size );     size += 2;
-        field_2_col1   =  LittleEndian.getShort( data, pos + size );     size += 2;
-        field_3_dx1    =  LittleEndian.getShort( data, pos + size );     size += 2;
-        field_4_row1   =  LittleEndian.getShort( data, pos + size );     size += 2;
-        if(bytesRemaining >= 18) {
-		    field_5_dy1    =  LittleEndian.getShort( data, pos + size );     size += 2;
-		    field_6_col2   =  LittleEndian.getShort( data, pos + size );     size += 2;
-		    field_7_dx2    =  LittleEndian.getShort( data, pos + size );     size += 2;
-		    field_8_row2   =  LittleEndian.getShort( data, pos + size );     size += 2;
-		    field_9_dy2    =  LittleEndian.getShort( data, pos + size );     size += 2;
-			shortRecord = false;
-        } else {
-			shortRecord = true;
-		}
+        if (bytesRemaining == 4) // Word format only 4 bytes
+        {
+            // Not sure exactly what the format is quite yet, likely a reference to a PLC
+        }
+        else
+        {
+            field_1_flag   =  LittleEndian.getShort( data, pos + size );     size += 2;
+            field_2_col1   =  LittleEndian.getShort( data, pos + size );     size += 2;
+            field_3_dx1    =  LittleEndian.getShort( data, pos + size );     size += 2;
+            field_4_row1   =  LittleEndian.getShort( data, pos + size );     size += 2;
+            if(bytesRemaining >= 18) {
+                field_5_dy1    =  LittleEndian.getShort( data, pos + size );     size += 2;
+                field_6_col2   =  LittleEndian.getShort( data, pos + size );     size += 2;
+                field_7_dx2    =  LittleEndian.getShort( data, pos + size );     size += 2;
+                field_8_row2   =  LittleEndian.getShort( data, pos + size );     size += 2;
+                field_9_dy2    =  LittleEndian.getShort( data, pos + size );     size += 2;
+                shortRecord = false;
+            } else {
+                shortRecord = true;
+            }
+        }
         bytesRemaining -= size;
         remainingData  =  new byte[bytesRemaining];
         System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherDggRecord.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherDggRecord.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherDggRecord.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/ddf/EscherDggRecord.java Sat Jun 21 05:03:44 2008
@@ -238,6 +238,10 @@
         return maxDgId;
     }
 
+    public void setMaxDrawingGroupId(int id){
+        maxDgId = id;
+    }
+
      public FileIdCluster[] getFileIdClusters()
     {
         return field_5_fileIdClusters;

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/dev/BiffViewer.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/dev/BiffViewer.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/dev/BiffViewer.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/dev/BiffViewer.java Sat Jun 21 05:03:44 2008
@@ -87,7 +87,8 @@
                         records.add(record);
                         if (activeRecord != null)
                             activeRecord.dump(ps);
-                        activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), (int)recStream.getPos(), record);
+                        int startPos = (int)(recStream.getPos()-recStream.getLength() - 4);
+                        activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), startPos, record);
                     }
                     if (dump) {
                         recStream.dumpBytes(ps);

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java Sat Jun 21 05:03:44 2008
@@ -20,6 +20,7 @@
 
 import org.apache.poi.POIOLE2TextExtractor;
 import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFComment;
 import org.apache.poi.hssf.usermodel.HSSFRichTextString;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -39,6 +40,7 @@
 	private HSSFWorkbook wb;
 	private boolean includeSheetNames = true;
 	private boolean formulasNotResults = false;
+	private boolean includeCellComments = false;
 	
 	public ExcelExtractor(HSSFWorkbook wb) {
 		super(wb);
@@ -62,6 +64,12 @@
 	public void setFormulasNotResults(boolean formulasNotResults) {
 		this.formulasNotResults = formulasNotResults;
 	}
+	/**
+     * Should cell comments be included? Default is true
+     */
+    public void setIncludeCellComments(boolean includeCellComments) {
+        this.includeCellComments = includeCellComments;
+    }
 	
 	/**
 	 * Retreives the text contents of the file
@@ -128,6 +136,15 @@
 							break;
 					}
 					
+					// Output the comment, if requested and exists
+				    HSSFComment comment = cell.getCellComment();
+					if(includeCellComments && comment != null) {
+					    // Replace any newlines with spaces, otherwise it
+					    //  breaks the output
+					    String commentText = comment.getString().getString().replace('\n', ' ');
+					    text.append(" Comment by "+comment.getAuthor()+": "+commentText);
+					}
+					
 					// Output a tab if we're not on the last cell
 					if(outputContents && k < (lastCell-1)) {
 						text.append("\t");

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/FormulaParser.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/FormulaParser.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/FormulaParser.java Sat Jun 21 05:03:44 2008
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.model;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
 import java.util.regex.Pattern;
@@ -55,23 +54,23 @@
      */
     static final class FormulaParseException extends RuntimeException {
         // This class was given package scope until it would become clear that it is useful to
-        // general client code. 
+        // general client code.
         public FormulaParseException(String msg) {
             super(msg);
         }
     }
 
-    public static int FORMULA_TYPE_CELL = 0;
-    public static int FORMULA_TYPE_SHARED = 1;
-    public static int FORMULA_TYPE_ARRAY =2;
-    public static int FORMULA_TYPE_CONDFOMRAT = 3;
-    public static int FORMULA_TYPE_NAMEDRANGE = 4;
+    public static final int FORMULA_TYPE_CELL = 0;
+    public static final int FORMULA_TYPE_SHARED = 1;
+    public static final int FORMULA_TYPE_ARRAY =2;
+    public static final int FORMULA_TYPE_CONDFOMRAT = 3;
+    public static final int FORMULA_TYPE_NAMEDRANGE = 4;
 
     private final String formulaString;
     private final int formulaLength;
     private int pointer;
 
-    private final List tokens = new Stack();
+    private ParseNode _rootNode;
 
     /**
      * Used for spotting if we have a cell reference,
@@ -127,39 +126,34 @@
             // Just return if so and reset 'look' to something to keep
             // SkipWhitespace from spinning
             look = (char)0;
-        }    
+        }
         pointer++;
         //System.out.println("Got char: "+ look);
     }
 
     /** Report What Was Expected */
     private RuntimeException expected(String s) {
-        return new FormulaParseException(s + " Expected");
+        String msg = "Parse error near char " + (pointer-1) + " '" + look + "'"
+            + " in specified formula '" + formulaString + "'. Expected "
+            + s;
+        return new FormulaParseException(msg);
     }
 
-
-
     /** Recognize an Alpha Character */
     private boolean IsAlpha(char c) {
         return Character.isLetter(c) || c == '$' || c=='_';
     }
 
-
-
     /** Recognize a Decimal Digit */
     private boolean IsDigit(char c) {
-        //System.out.println("Checking digit for"+c);
         return Character.isDigit(c);
     }
 
-
-
     /** Recognize an Alphanumeric */
     private boolean  IsAlNum(char c) {
         return  (IsAlpha(c) || IsDigit(c));
     }
 
-
     /** Recognize White Space */
     private boolean IsWhite( char c) {
         return  (c ==' ' || c== TAB);
@@ -175,7 +169,7 @@
     /**
      *  Consumes the next input character if it is equal to the one specified otherwise throws an
      *  unchecked exception. This method does <b>not</b> consume whitespace (before or after the
-     *  matched character). 
+     *  matched character).
      */
     private void Match(char x) {
         if (look != x) {
@@ -215,7 +209,6 @@
         return Token.toString();
     }
 
-
     /** Get a Number */
     private String GetNum() {
         StringBuffer value = new StringBuffer();
@@ -227,14 +220,15 @@
         return value.length() == 0 ? null : value.toString();
     }
 
-    /** Parse and Translate a String Identifier */
-    private Ptg parseIdent() {
-        String name;
-        name = GetName();
+    private ParseNode parseFunctionOrIdentifier() {
+        String name = GetName();
         if (look == '('){
             //This is a function
             return function(name);
         }
+        return new ParseNode(parseIdentifier(name));
+    }
+    private Ptg parseIdentifier(String name) {
 
         if (look == ':' || look == '.') { // this is a AreaReference
             GetChar();
@@ -278,89 +272,46 @@
         // This can be either a cell ref or a named range
         // Try to spot which it is
         boolean cellRef = CELL_REFERENCE_PATTERN.matcher(name).matches();
- 
+
         if (cellRef) {
-            return new ReferencePtg(name);
+            return new RefPtg(name);
         }
 
         for(int i = 0; i < book.getNumberOfNames(); i++) {
             // named range name matching is case insensitive
-        	if(book.getNameAt(i).getNameName().equalsIgnoreCase(name)) {
+            if(book.getNameAt(i).getNameName().equalsIgnoreCase(name)) {
                 return new NamePtg(name, book);
             }
         }
-        throw new FormulaParseException("Found reference to named range \"" 
+        throw new FormulaParseException("Found reference to named range \""
                     + name + "\", but that named range wasn't defined!");
     }
 
     /**
-     * Adds a pointer to the last token to the latest function argument list.
-     * @param obj
-     */
-    private void addArgumentPointer(List argumentPointers) {
-        argumentPointers.add(tokens.get(tokens.size()-1));
-    }
-
-    /**
      * Note - Excel function names are 'case aware but not case sensitive'.  This method may end
      * up creating a defined name record in the workbook if the specified name is not an internal
-     * Excel function, and has not been encountered before. 
-     * 
-     * @param name case preserved function name (as it was entered/appeared in the formula). 
+     * Excel function, and has not been encountered before.
+     *
+     * @param name case preserved function name (as it was entered/appeared in the formula).
      */
-    private Ptg function(String name) {
-        int numArgs =0 ;
-        // Note regarding parameter - 
+    private ParseNode function(String name) {
+        NamePtg nameToken = null;
+        // Note regarding parameter -
         if(!AbstractFunctionPtg.isInternalFunctionName(name)) {
             // external functions get a Name token which points to a defined name record
-            NamePtg nameToken = new NamePtg(name, this.book);
-            
+            nameToken = new NamePtg(name, this.book);
+
             // in the token tree, the name is more or less the first argument
-            numArgs++;  
-            tokens.add(nameToken);
         }
-        //average 2 args per function
-        List argumentPointers = new ArrayList(2);
 
         Match('(');
-        numArgs += Arguments(argumentPointers);
+        ParseNode[] args = Arguments();
         Match(')');
 
-        return getFunction(name, numArgs, argumentPointers);
+        return getFunction(name, nameToken, args);
     }
 
     /**
-     * Adds the size of all the ptgs after the provided index (inclusive).
-     * <p>
-     * Initially used to count a goto
-     * @param index
-     * @return int
-     */
-    private int getPtgSize(int index) {
-        int count = 0;
-
-        Iterator ptgIterator = tokens.listIterator(index);
-        while (ptgIterator.hasNext()) {
-            Ptg ptg = (Ptg)ptgIterator.next();
-            count+=ptg.getSize();
-        }
-
-        return count;
-    }
-
-    private int getPtgSize(int start, int end) {
-        int count = 0;
-        int index = start;
-        Iterator ptgIterator = tokens.listIterator(index);
-        while (ptgIterator.hasNext() && index <= end) {
-            Ptg ptg = (Ptg)ptgIterator.next();
-            count+=ptg.getSize();
-            index++;
-        }
-
-        return count;
-    }
-    /**
      * Generates the variable function ptg for the formula.
      * <p>
      * For IF Formulas, additional PTGs are added to the tokens
@@ -368,84 +319,35 @@
      * @param numArgs
      * @return Ptg a null is returned if we're in an IF formula, it needs extreme manipulation and is handled in this function
      */
-    private AbstractFunctionPtg getFunction(String name, int numArgs, List argumentPointers) {
+    private ParseNode getFunction(String name, NamePtg namePtg, ParseNode[] args) {
 
-        boolean isVarArgs;
-        int funcIx;
         FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
+        int numArgs = args.length;
         if(fm == null) {
+            if (namePtg == null) {
+                throw new IllegalStateException("NamePtg must be supplied for external functions");
+            }
             // must be external function
-            isVarArgs = true;
-            funcIx = FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL;
-        } else {
-            isVarArgs = !fm.hasFixedArgsLength();
-            funcIx = fm.getIndex();
-            validateNumArgs(numArgs, fm);
+            ParseNode[] allArgs = new ParseNode[numArgs+1];
+            allArgs[0] = new ParseNode(namePtg);
+            System.arraycopy(args, 0, allArgs, 1, numArgs);
+            return new ParseNode(new FuncVarPtg(name, (byte)(numArgs+1)), allArgs);
         }
+
+        if (namePtg != null) {
+            throw new IllegalStateException("NamePtg no applicable to internal functions");
+        }
+        boolean isVarArgs = !fm.hasFixedArgsLength();
+        int funcIx = fm.getIndex();
+        validateNumArgs(args.length, fm);
+
         AbstractFunctionPtg retval;
         if(isVarArgs) {
             retval = new FuncVarPtg(name, (byte)numArgs);
         } else {
             retval = new FuncPtg(funcIx);
         }
-        if (!name.equals(AbstractFunctionPtg.FUNCTION_NAME_IF)) {
-            // early return for everything else besides IF()
-            return retval;
-        }
-
-
-        AttrPtg ifPtg = new AttrPtg();
-        ifPtg.setData((short)7); //mirroring excel output
-        ifPtg.setOptimizedIf(true);
-
-        if (argumentPointers.size() != 2  && argumentPointers.size() != 3) {
-            throw new IllegalArgumentException("["+argumentPointers.size()+"] Arguments Found - An IF formula requires 2 or 3 arguments. IF(CONDITION, TRUE_VALUE, FALSE_VALUE [OPTIONAL]");
-        }
-
-        //Biffview of an IF formula record indicates the attr ptg goes after the condition ptgs and are
-        //tracked in the argument pointers
-        //The beginning first argument pointer is the last ptg of the condition
-        int ifIndex = tokens.indexOf(argumentPointers.get(0))+1;
-        tokens.add(ifIndex, ifPtg);
-
-        //we now need a goto ptgAttr to skip to the end of the formula after a true condition
-        //the true condition is should be inserted after the last ptg in the first argument
-
-        int gotoIndex = tokens.indexOf(argumentPointers.get(1))+1;
-
-        AttrPtg goto1Ptg = new AttrPtg();
-        goto1Ptg.setGoto(true);
-
-
-        tokens.add(gotoIndex, goto1Ptg);
-
-
-        if (numArgs > 2) { //only add false jump if there is a false condition
-
-            //second goto to skip past the function ptg
-            AttrPtg goto2Ptg = new AttrPtg();
-            goto2Ptg.setGoto(true);
-            goto2Ptg.setData((short)(retval.getSize()-1));
-            //Page 472 of the Microsoft Excel Developer's kit states that:
-            //The b(or w) field specifies the number byes (or words to skip, minus 1
-
-            tokens.add(goto2Ptg); //this goes after all the arguments are defined
-        }
-
-        //data portion of the if ptg points to the false subexpression (Page 472 of MS Excel Developer's kit)
-        //count the number of bytes after the ifPtg to the False Subexpression
-        //doesn't specify -1 in the documentation
-        ifPtg.setData((short)(getPtgSize(ifIndex+1, gotoIndex)));
-
-        //count all the additional (goto) ptgs but dont count itself
-        int ptgCount = this.getPtgSize(gotoIndex)-goto1Ptg.getSize()+retval.getSize();
-        if (ptgCount > Short.MAX_VALUE) {
-            throw new RuntimeException("Ptg Size exceeds short when being specified for a goto ptg in an if");
-        }
-
-        goto1Ptg.setData((short)(ptgCount-1));
-
-        return retval;
+        return new ParseNode(retval, args);
     }
 
     private void validateNumArgs(int numArgs, FunctionMetadata fm) {
@@ -474,99 +376,99 @@
     private static boolean isArgumentDelimiter(char ch) {
         return ch ==  ',' || ch == ')';
     }
-    
+
     /** get arguments to a function */
-    private int Arguments(List argumentPointers) {
+    private ParseNode[] Arguments() {
+        //average 2 args per function
+        List temp = new ArrayList(2);
         SkipWhite();
         if(look == ')') {
-            return 0;
+            return ParseNode.EMPTY_ARRAY;
         }
-        
+
         boolean missedPrevArg = true;
-        
         int numArgs = 0;
-        while(true) {
+        while (true) {
             SkipWhite();
-            if(isArgumentDelimiter(look)) {
-                if(missedPrevArg) {
-                    tokens.add(new MissingArgPtg());
-                    addArgumentPointer(argumentPointers);
+            if (isArgumentDelimiter(look)) {
+                if (missedPrevArg) {
+                    temp.add(new ParseNode(MissingArgPtg.instance));
                     numArgs++;
                 }
-                if(look == ')') {
+                if (look == ')') {
                     break;
                 }
                 Match(',');
                 missedPrevArg = true;
                 continue;
             }
-            comparisonExpression();
-            addArgumentPointer(argumentPointers);
+            temp.add(comparisonExpression());
             numArgs++;
             missedPrevArg = false;
+            SkipWhite();
+            if (!isArgumentDelimiter(look)) {
+                throw expected("',' or ')'");
+            }
         }
-        return numArgs;
+        ParseNode[] result = new ParseNode[temp.size()];
+        temp.toArray(result);
+        return result;
     }
 
    /** Parse and Translate a Math Factor  */
-    private void powerFactor() {
-        percentFactor();
+    private ParseNode powerFactor() {
+        ParseNode result = percentFactor();
         while(true) {
             SkipWhite();
             if(look != '^') {
-                return;
+                return result;
             }
             Match('^');
-            percentFactor();
-            tokens.add(new PowerPtg());
+            ParseNode other = percentFactor();
+            result = new ParseNode(PowerPtg.instance, result, other);
         }
     }
-    
-    private void percentFactor() {
-        tokens.add(parseSimpleFactor());
+
+    private ParseNode percentFactor() {
+        ParseNode result = parseSimpleFactor();
         while(true) {
             SkipWhite();
             if(look != '%') {
-                return;
+                return result;
             }
             Match('%');
-            tokens.add(new PercentPtg());
+            result = new ParseNode(PercentPtg.instance, result);
         }
     }
-    
-    
+
+
     /**
      * factors (without ^ or % )
      */
-    private Ptg parseSimpleFactor() {
+    private ParseNode parseSimpleFactor() {
         SkipWhite();
         switch(look) {
             case '#':
-                return parseErrorLiteral();
+                return new ParseNode(parseErrorLiteral());
             case '-':
                 Match('-');
-                powerFactor();
-                return new UnaryMinusPtg();
+                return new ParseNode(UnaryMinusPtg.instance, powerFactor());
             case '+':
                 Match('+');
-                powerFactor();
-                return new UnaryPlusPtg();
+                return new ParseNode(UnaryPlusPtg.instance, powerFactor());
             case '(':
                 Match('(');
-                comparisonExpression();
+                ParseNode inside = comparisonExpression();
                 Match(')');
-                return new ParenthesisPtg();
+                return new ParseNode(ParenthesisPtg.instance, inside);
             case '"':
-                return parseStringLiteral();
-            case ',':
-            case ')':
-                return new MissingArgPtg(); // TODO - not quite the right place to recognise a missing arg
+                return new ParseNode(parseStringLiteral());
         }
         if (IsAlpha(look) || look == '\''){
-            return parseIdent();
+            return parseFunctionOrIdentifier();
         }
         // else - assume number
-        return parseNumber();
+        return new ParseNode(parseNumber());
     }
 
 
@@ -704,10 +606,9 @@
     }
 
 
-    private StringPtg parseStringLiteral()
-    {
+    private StringPtg parseStringLiteral() {
         Match('"');
-        
+
         StringBuffer token = new StringBuffer();
         while (true) {
             if (look == '"') {
@@ -723,28 +624,30 @@
     }
 
     /** Parse and Translate a Math Term */
-    private void  Term() {
-        powerFactor();
+    private ParseNode  Term() {
+        ParseNode result = powerFactor();
         while(true) {
             SkipWhite();
+            Ptg operator;
             switch(look) {
                 case '*':
                     Match('*');
-                    powerFactor();
-                    tokens.add(new MultiplyPtg());
-                    continue;
+                    operator = MultiplyPtg.instance;
+                    break;
                 case '/':
                     Match('/');
-                    powerFactor();
-                    tokens.add(new DividePtg());
-                    continue;
+                    operator = DividePtg.instance;
+                    break;
+                default:
+                    return result; // finished with Term
             }
-            return; // finished with Term
+            ParseNode other = powerFactor();
+            result = new ParseNode(operator, result, other);
         }
     }
-    
-    private void comparisonExpression() {
-        concatExpression();
+
+    private ParseNode comparisonExpression() {
+        ParseNode result = concatExpression();
         while (true) {
             SkipWhite();
             switch(look) {
@@ -752,72 +655,75 @@
                 case '>':
                 case '<':
                     Ptg comparisonToken = getComparisonToken();
-                    concatExpression();
-                    tokens.add(comparisonToken);
+                    ParseNode other = concatExpression();
+                    result = new ParseNode(comparisonToken, result, other);
                     continue;
             }
-            return; // finished with predicate expression
+            return result; // finished with predicate expression
         }
     }
 
     private Ptg getComparisonToken() {
         if(look == '=') {
             Match(look);
-            return new EqualPtg();
+            return EqualPtg.instance;
         }
         boolean isGreater = look == '>';
         Match(look);
         if(isGreater) {
             if(look == '=') {
                 Match('=');
-                return new GreaterEqualPtg();
+                return GreaterEqualPtg.instance;
             }
-            return new GreaterThanPtg();
+            return GreaterThanPtg.instance;
         }
         switch(look) {
             case '=':
                 Match('=');
-                return new LessEqualPtg();
+                return LessEqualPtg.instance;
             case '>':
                 Match('>');
-                return new NotEqualPtg();
+                return NotEqualPtg.instance;
         }
-        return new LessThanPtg();
+        return LessThanPtg.instance;
     }
-    
 
-    private void concatExpression() {
-        additiveExpression();
+
+    private ParseNode concatExpression() {
+        ParseNode result = additiveExpression();
         while (true) {
             SkipWhite();
             if(look != '&') {
                 break; // finished with concat expression
             }
             Match('&');
-            additiveExpression();
-            tokens.add(new ConcatPtg());
+            ParseNode other = additiveExpression();
+            result = new ParseNode(ConcatPtg.instance, result, other);
         }
+        return result;
     }
-    
+
 
     /** Parse and Translate an Expression */
-    private void additiveExpression() {
-        Term();
+    private ParseNode additiveExpression() {
+        ParseNode result = Term();
         while (true) {
             SkipWhite();
+            Ptg operator;
             switch(look) {
                 case '+':
                     Match('+');
-                    Term();
-                    tokens.add(new AddPtg());
-                    continue;
+                    operator = AddPtg.instance;
+                    break;
                 case '-':
                     Match('-');
-                    Term();
-                    tokens.add(new SubtractPtg());
-                    continue;
+                    operator = SubtractPtg.instance;
+                    break;
+                default:
+                    return result; // finished with additive expression
             }
-            return; // finished with additive expression
+            ParseNode other = Term();
+            result = new ParseNode(operator, result, other);
         }
     }
 
@@ -835,17 +741,18 @@
      **/
 
 
-    /** API call to execute the parsing of the formula
-     *
+    /**
+     *  API call to execute the parsing of the formula
+     * @deprecated use Ptg[] FormulaParser.parse(String, HSSFWorkbook) directly
      */
     public void parse() {
         pointer=0;
         GetChar();
-        comparisonExpression();
+        _rootNode = comparisonExpression();
 
         if(pointer <= formulaLength) {
-            String msg = "Unused input [" + formulaString.substring(pointer-1) 
-                + "] after attempting to parse the formula [" + formulaString + "]"; 
+            String msg = "Unused input [" + formulaString.substring(pointer-1)
+                + "] after attempting to parse the formula [" + formulaString + "]";
             throw new FormulaParseException(msg);
         }
     }
@@ -860,92 +767,18 @@
      * a result of the parsing
      */
     public Ptg[] getRPNPtg() {
-     return getRPNPtg(FORMULA_TYPE_CELL);
+        return getRPNPtg(FORMULA_TYPE_CELL);
     }
 
     public Ptg[] getRPNPtg(int formulaType) {
-        Node node = createTree();
-        setRootLevelRVA(node, formulaType);
-        setParameterRVA(node,formulaType);
-        return (Ptg[]) tokens.toArray(new Ptg[0]);
+        OperandClassTransformer oct = new OperandClassTransformer(formulaType);
+        // RVA is for 'operand class': 'reference', 'value', 'array'
+        oct.transformFormula(_rootNode);
+        return ParseNode.toTokenArray(_rootNode);
     }
 
-    private void setRootLevelRVA(Node n, int formulaType) {
-        //Pg 16, excelfileformat.pdf @ openoffice.org
-        Ptg p = n.getValue();
-            if (formulaType == FormulaParser.FORMULA_TYPE_NAMEDRANGE) {
-                if (p.getDefaultOperandClass() == Ptg.CLASS_REF) {
-                    setClass(n,Ptg.CLASS_REF);
-                } else {
-                    setClass(n,Ptg.CLASS_ARRAY);
-                }
-            } else {
-                setClass(n,Ptg.CLASS_VALUE);
-            }
-
-    }
-
-    private void setParameterRVA(Node n, int formulaType) {
-        Ptg p = n.getValue();
-        int numOperands = n.getNumChildren();
-        if (p instanceof AbstractFunctionPtg) {
-            for (int i =0;i<numOperands;i++) {
-                setParameterRVA(n.getChild(i),((AbstractFunctionPtg)p).getParameterClass(i),formulaType);
-//                if (n.getChild(i).getValue() instanceof AbstractFunctionPtg) {
-//                    setParameterRVA(n.getChild(i),formulaType);
-//                }
-                setParameterRVA(n.getChild(i),formulaType);
-            }
-        } else {
-            for (int i =0;i<numOperands;i++) {
-                setParameterRVA(n.getChild(i),formulaType);
-            }
-        }
-    }
-    private void setParameterRVA(Node n, int expectedClass,int formulaType) {
-        Ptg p = n.getValue();
-        if (expectedClass == Ptg.CLASS_REF) { //pg 15, table 1
-            if (p.getDefaultOperandClass() == Ptg.CLASS_REF ) {
-                setClass(n, Ptg.CLASS_REF);
-            }
-            if (p.getDefaultOperandClass() == Ptg.CLASS_VALUE) {
-                if (formulaType==FORMULA_TYPE_CELL || formulaType == FORMULA_TYPE_SHARED) {
-                    setClass(n,Ptg.CLASS_VALUE);
-                } else {
-                    setClass(n,Ptg.CLASS_ARRAY);
-                }
-            }
-            if (p.getDefaultOperandClass() == Ptg.CLASS_ARRAY ) {
-                setClass(n, Ptg.CLASS_ARRAY);
-            }
-        } else if (expectedClass == Ptg.CLASS_VALUE) { //pg 15, table 2
-            if (formulaType == FORMULA_TYPE_NAMEDRANGE) {
-                setClass(n,Ptg.CLASS_ARRAY) ;
-            } else {
-                setClass(n,Ptg.CLASS_VALUE);
-            }
-        } else { //Array class, pg 16.
-            if (p.getDefaultOperandClass() == Ptg.CLASS_VALUE &&
-                 (formulaType==FORMULA_TYPE_CELL || formulaType == FORMULA_TYPE_SHARED)) {
-                 setClass(n,Ptg.CLASS_VALUE);
-            } else {
-                setClass(n,Ptg.CLASS_ARRAY);
-            }
-        }
-    }
-
-     private void setClass(Node n, byte theClass) {
-        Ptg p = n.getValue();
-        if (p instanceof AbstractFunctionPtg || !(p instanceof OperationPtg)) {
-            p.setClass(theClass);
-        } else {
-            for (int i =0;i<n.getNumChildren();i++) {
-                setClass(n.getChild(i),theClass);
-            }
-        }
-     }
     /**
-     * Convience method which takes in a list then passes it to the
+     * Convenience method which takes in a list then passes it to the
      *  other toFormulaString signature.
      * @param book   workbook for 3D and named references
      * @param lptgs  list of Ptg, can be null or empty
@@ -960,7 +793,7 @@
         return retval;
     }
     /**
-     * Convience method which takes in a list then passes it to the
+     * Convenience method which takes in a list then passes it to the
      *  other toFormulaString signature. Works on the current
      *  workbook for 3D and named references
      * @param lptgs  list of Ptg, can be null or empty
@@ -993,11 +826,11 @@
                 // TODO - put comment and throw exception in toFormulaString() of these classes
                 continue;
             }
-            if (! (ptg instanceof OperationPtg)) {
-                stack.push(ptg.toFormulaString(book));
+            if (ptg instanceof ParenthesisPtg) {
+                String contents = (String)stack.pop();
+                stack.push ("(" + contents + ")");
                 continue;
             }
-
             if (ptg instanceof AttrPtg) {
                 AttrPtg attrPtg = ((AttrPtg) ptg);
                 if (attrPtg.isOptimizedIf() || attrPtg.isOptimizedChoose() || attrPtg.isGoto()) {
@@ -1008,34 +841,31 @@
                     continue;
                     // but if it ever did, care must be taken:
                     // tAttrSpace comes *before* the operand it applies to, which may be consistent
-                    // with how the formula text appears but is against the RPN ordering assumed here 
+                    // with how the formula text appears but is against the RPN ordering assumed here
                 }
                 if (attrPtg.isSemiVolatile()) {
                     // similar to tAttrSpace - RPN is violated
                     continue;
                 }
-                if (!attrPtg.isSum()) {
-                    throw new RuntimeException("Unexpected tAttr: " + attrPtg.toString());
+                if (attrPtg.isSum()) {
+                    String[] operands = getOperands(stack, attrPtg.getNumberOfOperands());
+                    stack.push(attrPtg.toFormulaString(operands));
+                    continue;
                 }
+                throw new RuntimeException("Unexpected tAttr: " + attrPtg.toString());
             }
 
-            final OperationPtg o = (OperationPtg) ptg;
-            int nOperands = o.getNumberOfOperands();
-            final String[] operands = new String[nOperands];
-
-            for (int j = nOperands-1; j >= 0; j--) { // reverse iteration because args were pushed in-order
-                if(stack.isEmpty()) {
-                   String msg = "Too few arguments suppled to operation token ("
-                        + o.getClass().getName() + "). Expected (" + nOperands
-                        + ") operands but got (" + (nOperands - j - 1) + ")";
-                    throw new IllegalStateException(msg);
-                }
-                operands[j] = (String) stack.pop();
+            if (! (ptg instanceof OperationPtg)) {
+                stack.push(ptg.toFormulaString(book));
+                continue;
             }
+
+            OperationPtg o = (OperationPtg) ptg;
+            String[] operands = getOperands(stack, o.getNumberOfOperands());
             stack.push(o.toFormulaString(operands));
         }
         if(stack.isEmpty()) {
-            // inspection of the code above reveals that every stack.pop() is followed by a 
+            // inspection of the code above reveals that every stack.pop() is followed by a
             // stack.push(). So this is either an internal error or impossible.
             throw new IllegalStateException("Stack underflow");
         }
@@ -1047,6 +877,20 @@
         }
         return result;
     }
+    
+    private static String[] getOperands(Stack stack, int nOperands) {
+        String[] operands = new String[nOperands];
+
+        for (int j = nOperands-1; j >= 0; j--) { // reverse iteration because args were pushed in-order
+            if(stack.isEmpty()) {
+               String msg = "Too few arguments supplied to operation. Expected (" + nOperands
+                    + ") operands but got (" + (nOperands - j - 1) + ")";
+                throw new IllegalStateException(msg);
+            }
+            operands[j] = (String) stack.pop();
+        }
+        return operands;
+    }
     /**
      * Static method to convert an array of Ptgs in RPN order
      *  to a human readable string format in infix mode. Works
@@ -1057,59 +901,4 @@
     public String toFormulaString(Ptg[] ptgs) {
         return toFormulaString(book, ptgs);
     }
-
-
-    /** Create a tree representation of the RPN token array
-     *used to run the class(RVA) change algo
-     */
-    private Node createTree() {
-        Stack stack = new Stack();
-        int numPtgs = tokens.size();
-        OperationPtg o;
-        int numOperands;
-        Node[] operands;
-        for (int i=0;i<numPtgs;i++) {
-            if (tokens.get(i) instanceof OperationPtg) {
-
-                o = (OperationPtg) tokens.get(i);
-                numOperands = o.getNumberOfOperands();
-                operands = new Node[numOperands];
-                for (int j=0;j<numOperands;j++) {
-                    operands[numOperands-j-1] = (Node) stack.pop();
-                }
-                Node result = new Node(o);
-                result.setChildren(operands);
-                stack.push(result);
-            } else {
-                stack.push(new Node((Ptg)tokens.get(i)));
-            }
-        }
-        return (Node) stack.pop();
-    }
-
-    /** toString on the parser instance returns the RPN ordered list of tokens
-     *   Useful for testing
-     */
-    public String toString() {
-        StringBuffer buf = new StringBuffer();
-           for (int i=0;i<tokens.size();i++) {
-            buf.append( ( (Ptg)tokens.get(i)).toFormulaString(book));
-            buf.append(' ');
-        }
-        return buf.toString();
-    }
-
-    /** Private helper class, used to create a tree representation of the formula*/
-    private static final class Node {
-        private Ptg value=null;
-        private Node[] children=new Node[0];
-        private int numChild=0;
-        public Node(Ptg val) {
-            value = val;
-        }
-        public void setChildren(Node[] child) {children = child;numChild=child.length;}
-        public int getNumChildren() {return numChild;}
-        public Node getChild(int number) {return children[number];}
-        public Ptg getValue() {return value;}
-    }
 }

Modified: poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/LinkTable.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/LinkTable.java?rev=670186&r1=670185&r2=670186&view=diff
==============================================================================
--- poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/LinkTable.java (original)
+++ poi/tags/REL_3_1_FINAL/src/java/org/apache/poi/hssf/model/LinkTable.java Sat Jun 21 05:03:44 2008
@@ -41,7 +41,7 @@
  *
  *  In BIFF8 the Link Table consists of
  *  <ul>
- *  <li>one or more EXTERNALBOOK Blocks<p/>
+ *  <li>zero or more EXTERNALBOOK Blocks<p/>
  *  	each consisting of
  *  	<ul>
  *  	<li>exactly one EXTERNALBOOK (0x01AE) record</li>
@@ -55,7 +55,7 @@
  *  	</li>
  *  	</ul>
  *  </li>
- *  <li>exactly one EXTERNSHEET (0x0017) record</li>
+ *  <li>zero or one EXTERNSHEET (0x0017) record</li>
  *  <li>zero or more DEFINEDNAME (0x0018) records</li>
  *  </ul>
  *
@@ -63,6 +63,7 @@
  * @author Josh Micich
  */
 final class LinkTable {
+	// TODO make this class into a record aggregate
 
 	private static final class CRNBlock {
 
@@ -79,8 +80,8 @@
 			_crns = crns;
 		}
 		public CRNRecord[] getCrns() {
-            return (CRNRecord[]) _crns.clone();
-        }
+			return (CRNRecord[]) _crns.clone();
+		}
 	}
 
 	private static final class ExternalBookBlock {
@@ -136,16 +137,19 @@
 		while(rs.peekNextClass() == SupBookRecord.class) {
 		   temp.add(new ExternalBookBlock(rs));
 		}
-		if(temp.size() < 1) {
-			throw new RuntimeException("Need at least one EXTERNALBOOK blocks");
-		}
+		
 		_externalBookBlocks = new ExternalBookBlock[temp.size()];
 		temp.toArray(_externalBookBlocks);
 		temp.clear();
-
-		// If link table is present, there is always 1 of ExternSheetRecord
-		Record next = rs.getNext();
-		_externSheetRecord = (ExternSheetRecord)next;
+		
+		if (_externalBookBlocks.length > 0) {
+			// If any ExternalBookBlock present, there is always 1 of ExternSheetRecord
+			Record next = rs.getNext();
+			_externSheetRecord = (ExternSheetRecord) next;
+		} else {
+			_externSheetRecord = null;
+		}
+		
 		_definedNames = new ArrayList();
 		// collect zero or more DEFINEDNAMEs id=0x18
 		while(rs.peekNextClass() == NameRecord.class) {
@@ -222,7 +226,7 @@
 	public void addName(NameRecord name) {
 		_definedNames.add(name);
 
-	   // TODO - this is messy
+		// TODO - this is messy
 		// Not the most efficient way but the other way was causing too many bugs
 		int idx = findFirstRecordLocBySid(ExternSheetRecord.sid);
 		if (idx == -1) idx = findFirstRecordLocBySid(SupBookRecord.sid);
@@ -242,8 +246,8 @@
 
 	public int getSheetIndexFromExternSheetIndex(int externSheetNumber) {
 		if (externSheetNumber >= _externSheetRecord.getNumOfREFStructures()) {
-            return -1;
-        }
+			return -1;
+		}
 		return _externSheetRecord.getREFRecordAt(externSheetNumber).getIndexToFirstSupBook();
 	}
 
@@ -265,7 +269,7 @@
 			ExternSheetSubRecord esr = _externSheetRecord.getREFRecordAt(i);
 
 			if (esr.getIndexToFirstSupBook() ==  sheetNumber
-			        && esr.getIndexToLastSupBook() == sheetNumber){
+					&& esr.getIndexToLastSupBook() == sheetNumber){
 				return i;
 			}
 		}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message