From 92396054a43e3625005ba45228d29b5dace44421 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sat, 5 Apr 2008 13:07:22 +0000 Subject: [PATCH] Merged revisions 642878-642946 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r642878 | josh | 2008-03-31 06:10:35 +0100 (Mon, 31 Mar 2008) | 1 line More work on Conditional Formatting (bug 30311) junit and fixes from Dmitriy. Some other clean-up. ........ r642880 | josh | 2008-03-31 06:19:00 +0100 (Mon, 31 Mar 2008) | 1 line removed incorrect test case methods ........ r642891 | josh | 2008-03-31 06:56:11 +0100 (Mon, 31 Mar 2008) | 1 line silenced noisy tests ........ r642904 | josh | 2008-03-31 07:55:04 +0100 (Mon, 31 Mar 2008) | 1 line changes/status for #44675, #44695, #44691 ........ r642946 | yegor | 2008-03-31 10:58:27 +0100 (Mon, 31 Mar 2008) | 1 line Implement Sheet.removeShape(Shape shape) in HSLF ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@645088 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 4 + src/documentation/content/xdocs/status.xml | 4 + .../apache/poi/hssf/model/FormulaParser.java | 6 +- .../poi/hssf/record/CFHeaderRecord.java | 121 +- .../apache/poi/hssf/record/CFRuleRecord.java | 1027 ++++++++--------- .../poi/hssf/record/ExternalNameRecord.java | 2 +- .../record/aggregates/CFRecordsAggregate.java | 162 ++- .../apache/poi/hssf/record/cf/CellRange.java | 478 ++++++-- .../record/formula/AbstractFunctionPtg.java | 46 +- .../poi/hssf/record/formula/FuncPtg.java | 22 +- .../poi/hssf/record/formula/FuncVarPtg.java | 23 +- .../formula/function/FunctionDataBuilder.java | 2 +- .../formula/function/FunctionMetadata.java | 3 +- .../function/FunctionMetadataReader.java | 2 +- .../function/FunctionMetadataRegistry.java | 7 +- .../hssf/record/formula/functions/Pmt.java | 14 +- .../hssf/usermodel/HSSFBorderFormatting.java | 200 ++-- .../usermodel/HSSFConditionalFormatting.java | 161 +-- .../HSSFConditionalFormattingRule.java | 230 +--- .../poi/hssf/usermodel/HSSFPatriarch.java | 48 +- .../apache/poi/hssf/usermodel/HSSFSheet.java | 138 +-- .../src/org/apache/poi/hslf/model/Sheet.java | 25 + .../org/apache/poi/hslf/model/TestShapes.java | 28 + .../poi/hssf/model/TestFormulaParser.java | 176 +-- .../poi/hssf/record/AllRecordTests.java | 7 +- .../poi/hssf/record/TestCFHeaderRecord.java | 199 ++-- .../poi/hssf/record/TestCFRuleRecord.java | 399 ++++--- .../hssf/record/TestExternalNameRecord.java | 2 +- .../aggregates/AllRecordAggregateTests.java | 40 + .../aggregates/TestCFRecordsAggregate.java | 130 +-- .../TestColumnInfoRecordsAggregate.java | 4 +- .../poi/hssf/record/cf/TestCellRange.java | 105 +- .../hssf/record/formula/AllFormulaTests.java | 8 +- .../function/AllFormulaFunctionTests.java | 2 +- .../ExcelFileFormatDocFunctionExtractor.java | 79 +- .../TestFunctionMetadataRegistry.java | 33 +- .../TestParseMissingBuiltInFuncs.java | 4 +- .../function/TestReadMissingBuiltInFuncs.java | 16 +- .../AllIndividualFunctionEvaluationTests.java | 3 +- .../record/formula/functions/TestPmt.java | 6 +- .../apache/poi/hssf/usermodel/TestBugs.java | 4 +- .../TestHSSFConfditionalFormatting.java | 90 ++ 42 files changed, 2171 insertions(+), 1889 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/record/aggregates/AllRecordAggregateTests.java create mode 100644 src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConfditionalFormatting.java diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index ab9a4c796e..5722a7be45 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -26,6 +26,7 @@ + @@ -36,6 +37,9 @@ + Implement Sheet.removeShape(Shape shape) in HSLF + Various fixes: Recognising var-arg built-in functions #44675, ExternalNameRecord serialisation bug #44695, PMT() bug #44691 + 30311 - More work on Conditional Formatting Move the Formula Evaluator code out of scratchpad Move the missing record aware eventusermodel code out of scratchpad 44652 / 44603 - Improved handling of Pictures in Word Documents diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 14c7b817a1..9d35cb7fd1 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -22,6 +22,7 @@ + @@ -33,6 +34,9 @@ + Implement Sheet.removeShape(Shape shape) in HSLF + Various fixes: Recognising var-arg built-in functions #44675, ExternalNameRecord serialisation bug #44695, PMT() bug #44691 + 30311 - More work on Conditional Formatting Move the Formula Evaluator code out of scratchpad Move the missing record aware eventusermodel code out of scratchpad 44652 / 44603 - Improved handling of Pictures in Word Documents diff --git a/src/java/org/apache/poi/hssf/model/FormulaParser.java b/src/java/org/apache/poi/hssf/model/FormulaParser.java index e6eb296702..7219284743 100644 --- a/src/java/org/apache/poi/hssf/model/FormulaParser.java +++ b/src/java/org/apache/poi/hssf/model/FormulaParser.java @@ -28,8 +28,6 @@ import org.apache.poi.hssf.record.formula.*; import org.apache.poi.hssf.record.formula.function.FunctionMetadata; import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry; - - /** * This class parses a formula string into a List of tokens in RPN order. * Inspired by @@ -48,11 +46,11 @@ import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry; * @author Pavel Krupets (pkrupets at palmtreebusiness dot com) */ public final class FormulaParser { - + /** * Specific exception thrown when a supplied formula does not parse properly.
* Primarily used by test cases when testing for specific parsing exceptions.

- * + * */ static final class FormulaParseException extends RuntimeException { // This class was given package scope until it would become clear that it is useful to diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java index 00a8646b4f..7f2d5c3197 100644 --- a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java +++ b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java @@ -15,18 +15,10 @@ limitations under the License. ==================================================================== */ -/* - * ConditionalFormattingHeaderRecord.java - * - * Created on January 17, 2008, 3:05 AM - */ package org.apache.poi.hssf.record; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import org.apache.poi.hssf.record.cf.CellRange; +import org.apache.poi.hssf.util.Region; import org.apache.poi.util.LittleEndian; /** @@ -34,19 +26,27 @@ import org.apache.poi.util.LittleEndian; * * @author Dmitriy Kumshayev */ -public class CFHeaderRecord extends Record +public final class CFHeaderRecord extends Record { public static final short sid = 0x1B0; + private static final CellRange[] EMPTY_CELL_RANGE_ARRAY = { }; + private int field_1_numcf; private int field_2_need_recalculation; private CellRange field_3_enclosing_cell_range; - private List field_4_cell_ranges; + private CellRange[] field_4_cell_ranges; /** Creates new CFHeaderRecord */ public CFHeaderRecord() { - field_4_cell_ranges = new ArrayList(5); + field_4_cell_ranges = EMPTY_CELL_RANGE_ARRAY; + } + public CFHeaderRecord(Region[] regions) + { + CellRange[] unmergedRanges = CellRange.convertRegionsToCellRanges(regions); + CellRange[] mergeCellRanges = CellRange.mergeCellRanges(unmergedRanges); + setCellRanges(mergeCellRanges); } public CFHeaderRecord(RecordInputStream in) @@ -60,11 +60,12 @@ public class CFHeaderRecord extends Record field_2_need_recalculation = in.readShort(); field_3_enclosing_cell_range = new CellRange(in.readShort(),in.readShort(),in.readShort(),in.readShort()); int numCellRanges = in.readShort(); - field_4_cell_ranges = new ArrayList(5); + CellRange[] crs = new CellRange[numCellRanges]; for( int i=0; i0) + buffer.append(" .id = ").append(Integer.toHexString(sid)).append("\n"); + buffer.append(" .numCF = ").append(getNumberOfConditionalFormats()).append("\n"); + buffer.append(" .needRecalc = ").append(getNeedRecalculation()).append("\n"); + buffer.append(" .enclosingCellRange= ").append(getEnclosingCellRange()).append("\n"); + if( field_4_cell_ranges.length>0) { - buffer.append(" .cfranges=["); - for( int i=0; i