You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/09/09 18:49:34 UTC
svn commit: r693510 - in /poi/branches/ooxml: ./
src/documentation/content/xdocs/ src/java/org/apache/poi/ddf/
src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/
src/java/org/apache/poi/hssf/record/formula/ src/java/org/apache/poi...
Author: nick
Date: Tue Sep 9 09:49:30 2008
New Revision: 693510
URL: http://svn.apache.org/viewvc?rev=693510&view=rev
Log:
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,
649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-657701,657703-657874,657876-658032,658034-658284,658286,658288-658301,658303-658307,658309-658321,658323-658335,658337-658348,658351,658353-658832,658834-658983,658985,658987-659066,659068-659402,659404-659428,659430-659451,659453-659454,659456-659461,659463-659477,659479-659524,659526-65
9571,659574,659576-660255,660257-660262,660264-660279,660281-660343,660345-660473,660475-660827,660829-660833,660835-660888,660890-663321,663323-663435,663437-663764,663766-663854,663856-664219,664221-664489,664494-664514,664516-668013,668015-668142,668144-668152,668154,668156-668256,668258,668260-669139,669141-669455,669457-669657,669659-669808,669810-670189,670191-671321,671323-672229,672231-672549,672551-672552,672554-672561,672563-672566,672568,672571-673049,673051-673852,673854-673862,673864-673986,673988-673996,673998-674347,674349-674890,674892-674910,674912-674936,674938-674952,674954-675078,675080-675085,675087-675217,675219-675660,675662-675670,675672-675716,675718-675726,675728-675733,675735-675775,675777-675782,675784,675786-675791,675794-675852,675854-676200,676202,676204,676206-676220,676222-676309,676311-676456,676458-676994,676996-677027,677030-677040,677042-677056,677058-677375,677377-677968,677970-677971,677973,677975-677994,677996-678286,678288-678538,6785
40-680393,680395-680469,680471-680529,680531-680852,680854-681529,681531-681571,681573-682224,682226,682228,682231-682281,682283-682335,682337-682507,682509,682512-682517,682519-682532,682534-682619,682622-682777,682779-682998,683000-683019,683021-683022,683024-683080,683082-683092,683094-683095,683097-683127,683129-683131,683133-683166,683168-683698,683700-683705,683707-683757,683759-683787,683789-683870,683872-683879,683881-683900,683902-684066,684068-684074,684076-684222,684224-684254,684257-684281,684283-684286,684288-684292,684294-684298,684300-684301,684303-684308,684310-684317,684320,684323-684335,684337-684348,684350-684354,684356-684361,684363-684369,684371-684453,684455-684883,684885-684937,684940-684958,684960-684970,684972-684985,684987-685053,685055-685063,685065-685259,685261-685262,685264-685266,685268-685282,685285-686035,686037-686045,686047-686052,686054-686206,686208-686215,686217-686277,686279-686289,686291-686620,686622-686623,686626-686627,686629-686639
,686641-686843,686845-686976,686978-687402,687404-687422,687424-687428,687430-687442,687444-688425,688427-688641,688643-688649,688651-688654,688656-688824,688826-688909,688911-689543,689545-689558,689560-689635,689637-689703,689705-689715,689717-689718,689720,689722-689972,689974-690090,690092-690093,690095-690111,690113-690258,690260-690261,690263-690403,690405-690410,690412-690460,690462-690516,690518-690533,690535,690537-690625,690627-690635,690637-690720,690722-690725,690727-690728,690730-690738,690740-690760,690762-690771,690773-690824,690826-690834,690838-691016,691018-691179,691181,691183-691532,691534-691686,691688-691739,691741-692238,692240,692242,692244-692254,692256-692299,692301-692505,692507-692537,692539-692540,692542-692611,692613,692615-692892,692894-693438 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk
........
r692918 | nick | 2008-09-07 19:32:51 +0100 (Sun, 07 Sep 2008) | 1 line
Patch from bug #45738 - Initial HWPF support for Office Art Shapes
........
r693085 | yegor | 2008-09-08 14:02:21 +0100 (Mon, 08 Sep 2008) | 1 line
always call Workbook.cloneDrawings when cloning sheets
........
r693175 | nick | 2008-09-08 18:43:31 +0100 (Mon, 08 Sep 2008) | 1 line
Fix bug #45761 - Support for Very Hidden excel sheets in HSSF
........
r693203 | josh | 2008-09-08 20:13:09 +0100 (Mon, 08 Sep 2008) | 1 line
cosmetic fix for Area3DPtg.toString()
........
r693221 | josh | 2008-09-08 20:49:03 +0100 (Mon, 08 Sep 2008) | 1 line
Additional fix for 45720 - bug in HSSFWorkbook.findExistingBuiltinNameRecordIdx
........
r693250 | josh | 2008-09-08 21:28:05 +0100 (Mon, 08 Sep 2008) | 1 line
Fixes for DAY/MONTH/YEAR functions (junit cases added)
........
r693289 | josh | 2008-09-08 22:34:45 +0100 (Mon, 08 Sep 2008) | 1 line
Refactored OperandResolver coerce functions to convert BlankEval to 0.0
........
r693309 | josh | 2008-09-08 23:46:41 +0100 (Mon, 08 Sep 2008) | 1 line
Common refactoring for one arg numeric functions
........
r693383 | yegor | 2008-09-09 07:58:35 +0100 (Tue, 09 Sep 2008) | 1 line
don't increment the number of shapes when cloning a sheet with drawings
........
Added:
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java
- copied unchanged from r693383, poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/NumericFunctionOneArg.java
- copied unchanged from r693383, poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/NumericFunctionOneArg.java
poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/ShapesTable.java
- copied unchanged from r693383, poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ShapesTable.java
poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Shape.java
- copied unchanged from r693383, poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Shape.java
poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/data/WithArtShapes.doc
- copied unchanged from r693383, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/WithArtShapes.doc
poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java
- copied unchanged from r693383, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45761.xls
- copied unchanged from r693383, poi/trunk/src/testcases/org/apache/poi/hssf/data/45761.xls
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/testRRaC.xls
- copied unchanged from r693383, poi/trunk/src/testcases/org/apache/poi/hssf/data/testRRaC.xls
Removed:
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Abs.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Acos.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Acosh.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Asin.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Asinh.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Atan.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Atanh.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Cos.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Cosh.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Day.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Degrees.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Dollar.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Exp.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Fact.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Int.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Ln.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Log10.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Month.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Radians.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Sign.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Sin.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Sinh.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Sqrt.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Tan.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Tanh.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Year.java
Modified:
poi/branches/ooxml/ (props changed)
poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
poi/branches/ooxml/src/documentation/content/xdocs/status.xml
poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherContainerRecord.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/NameRecord.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/PercentEval.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Even.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Mid.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Odd.java
poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/externalFunctionExample.xls
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestExternalFunctionFormulas.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Sep 9 09:49:30 2008
@@ -1 +1 @@
-/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-692908
+/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-693438
Modified: poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/changes.xml?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Tue Sep 9 09:49:30 2008
@@ -65,8 +65,10 @@
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
</release>
<release version="3.1.1-alpha1" date="2008-??-??">
- <action dev="POI-DEVELOPERS" type="fix">45720 Fixed HSSFWorkbook.cloneSheet to correctly clone sheets with drawings</action>
- <action dev="POI-DEVELOPERS" type="fix">45728 Fix for SlideShow.reorderSlide in HSLF</action>
+ <action dev="POI-DEVELOPERS" type="add">45761 - Support for Very Hidden excel sheets in HSSF</action>
+ <action dev="POI-DEVELOPERS" type="add">45738 - Initial HWPF support for Office Art Shapes</action>
+ <action dev="POI-DEVELOPERS" type="fix">45720 - Fixed HSSFWorkbook.cloneSheet to correctly clone sheets with drawings</action>
+ <action dev="POI-DEVELOPERS" type="fix">45728 - Fix for SlideShow.reorderSlide in HSLF</action>
<action dev="POI-DEVELOPERS" type="add">Initial support for embedded movies and controls in HSLF</action>
<action dev="POI-DEVELOPERS" type="fix">45358 - signed/unsigned error when parsing 3-d area refs, performance problem evaluating area refs, and ClassCastExcecption in IF()</action>
<action dev="POI-DEVELOPERS" type="add">Support for HPBF Publisher hyperlinks, including during text extraction</action>
Modified: poi/branches/ooxml/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/status.xml?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Tue Sep 9 09:49:30 2008
@@ -62,8 +62,10 @@
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
</release>
<release version="3.1.1-alpha1" date="2008-??-??">
- <action dev="POI-DEVELOPERS" type="fix">45720 Fixed HSSFWorkbook.cloneSheet to correctly clone sheets with drawings</action>
- <action dev="POI-DEVELOPERS" type="fix">45728 Fix for SlideShow.reorderSlide in HSLF</action>
+ <action dev="POI-DEVELOPERS" type="add">45761 - Support for Very Hidden excel sheets in HSSF</action>
+ <action dev="POI-DEVELOPERS" type="add">45738 - Initial HWPF support for Office Art Shapes</action>
+ <action dev="POI-DEVELOPERS" type="fix">45720 - Fixed HSSFWorkbook.cloneSheet to correctly clone sheets with drawings</action>
+ <action dev="POI-DEVELOPERS" type="fix">45728 - Fix for SlideShow.reorderSlide in HSLF</action>
<action dev="POI-DEVELOPERS" type="add">Initial support for embedded movies and controls in HSLF</action>
<action dev="POI-DEVELOPERS" type="fix">45358 - signed/unsigned error when parsing 3-d area refs, performance problem evaluating area refs, and ClassCastExcecption in IF()</action>
<action dev="POI-DEVELOPERS" type="add">Support for HPBF Publisher hyperlinks, including during text extraction</action>
Modified: poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherContainerRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherContainerRecord.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherContainerRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherContainerRecord.java Tue Sep 9 09:49:30 2008
@@ -243,10 +243,11 @@
public void getRecordsById(short recordId, List out){
for(Iterator it = childRecords.iterator(); it.hasNext();) {
Object er = it.next();
- if(er instanceof EscherContainerRecord) {
- EscherContainerRecord c = (EscherContainerRecord)er;
+ EscherRecord r = (EscherRecord)er;
+ if(r instanceof EscherContainerRecord) {
+ EscherContainerRecord c = (EscherContainerRecord)r;
c.getRecordsById(recordId, out );
- } else if (er instanceof EscherSpRecord){
+ } else if (r.getRecordId() == recordId){
out.add(er);
}
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java Tue Sep 9 09:49:30 2008
@@ -560,32 +560,72 @@
}
/**
- * gets the hidden flag for a given sheet.
+ * Gets the hidden flag for a given sheet.
+ * Note that a sheet could instead be
+ * set to be very hidden, which is different
+ * ({@link #isSheetVeryHidden(int)})
*
* @param sheetnum the sheet number (0 based)
* @return True if sheet is hidden
*/
-
public boolean isSheetHidden(int sheetnum) {
return getBoundSheetRec(sheetnum).isHidden();
}
/**
+ * Gets the very hidden flag for a given sheet.
+ * This is different from the normal
+ * hidden flag
+ * ({@link #isSheetHidden(int)})
+ *
+ * @param sheetnum the sheet number (0 based)
+ * @return True if sheet is very hidden
+ */
+ public boolean isSheetVeryHidden(int sheetnum) {
+ return getBoundSheetRec(sheetnum).isVeryHidden();
+ }
+
+ /**
* Hide or unhide a sheet
*
* @param sheetnum The sheet number
* @param hidden True to mark the sheet as hidden, false otherwise
*/
-
public void setSheetHidden(int sheetnum, boolean hidden) {
getBoundSheetRec(sheetnum).setHidden(hidden);
}
+
+ /**
+ * Hide or unhide a sheet.
+ * 0 = not hidden
+ * 1 = hidden
+ * 2 = very hidden.
+ *
+ * @param sheetnum The sheet number
+ * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
+ */
+ public void setSheetHidden(int sheetnum, int hidden) {
+ BoundSheetRecord bsr = getBoundSheetRec(sheetnum);
+ boolean h = false;
+ boolean vh = false;
+ if(hidden == 0) {
+ } else if(hidden == 1) {
+ h = true;
+ } else if(hidden == 2) {
+ vh = true;
+ } else {
+ throw new IllegalArgumentException("Invalid hidden flag " + hidden + " given, must be 0, 1 or 2");
+ }
+ bsr.setHidden(h);
+ bsr.setVeryHidden(vh);
+ }
+
+
/**
* get the sheet's index
* @param name sheet name
* @return sheet index or -1 if it was not found.
*/
-
public int getSheetIndex(String name) {
int retval = -1;
@@ -2426,6 +2466,10 @@
int aggLoc = sheet.aggregateDrawingRecords(drawingManager, false);
if(aggLoc != -1) {
EscherAggregate agg = (EscherAggregate) sheet.findFirstRecordBySid(EscherAggregate.sid);
+ EscherContainerRecord escherContainer = agg.getEscherContainer();
+ if (escherContainer == null) {
+ return;
+ }
EscherDggRecord dgg = drawingManager.getDgg();
@@ -2435,7 +2479,7 @@
dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
EscherDgRecord dg = null;
- for(Iterator it = agg.getEscherContainer().getChildRecords().iterator(); it.hasNext();) {
+ for(Iterator it = escherContainer.getChildRecords().iterator(); it.hasNext();) {
Object er = it.next();
if(er instanceof EscherDgRecord) {
dg = (EscherDgRecord)er;
@@ -2449,6 +2493,8 @@
for(Iterator spIt = spRecords.iterator(); spIt.hasNext();) {
EscherSpRecord sp = (EscherSpRecord)spIt.next();
int shapeId = drawingManager.allocateShapeId((short)dgId, dg);
+ //allocateShapeId increments the number of shapes. roll back to the previous value
+ dg.setNumShapes(dg.getNumShapes()-1);
sp.setShapeId(shapeId);
}
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java Tue Sep 9 09:49:30 2008
@@ -36,6 +36,7 @@
public final static short sid = 0x0085;
private static final BitField hiddenFlag = BitFieldFactory.getInstance(0x01);
+ private static final BitField veryHiddenFlag = BitFieldFactory.getInstance(0x02);
private int field_1_position_of_BOF;
private short field_2_option_flags;
private byte field_3_sheetname_length;
@@ -301,11 +302,31 @@
return sid;
}
+ /**
+ * Is the sheet hidden? Different from very hidden
+ */
public boolean isHidden() {
return hiddenFlag.isSet(field_2_option_flags);
}
+ /**
+ * Is the sheet hidden? Different from very hidden
+ */
public void setHidden(boolean hidden) {
field_2_option_flags = hiddenFlag.setShortBoolean(field_2_option_flags, hidden);
}
+
+ /**
+ * Is the sheet very hidden? Different from (normal) hidden
+ */
+ public boolean isVeryHidden() {
+ return veryHiddenFlag.isSet(field_2_option_flags);
+ }
+
+ /**
+ * Is the sheet very hidden? Different from (normal) hidden
+ */
+ public void setVeryHidden(boolean veryHidden) {
+ field_2_option_flags = veryHiddenFlag.setShortBoolean(field_2_option_flags, veryHidden);
+ }
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/NameRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/NameRecord.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/NameRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/NameRecord.java Tue Sep 9 09:49:30 2008
@@ -82,8 +82,9 @@
private short field_1_option_flag;
private byte field_2_keyboard_shortcut;
- private short field_5_index_to_sheet; // unused: see field_6
- /** the one based sheet number. Zero if this is a global name */
+ /** One-based extern index of sheet (resolved via LinkTable). Zero if this is a global name */
+ private short field_5_externSheetIndex_plus1;
+ /** the one based sheet number. */
private int field_6_sheetNumber;
private boolean field_11_nameIsMultibyte;
private byte field_12_built_in_code;
@@ -144,7 +145,7 @@
/**
* For named ranges, and built-in names
- * @return the 1-based sheet number. Zero if this is a global name
+ * @return the 1-based sheet number.
*/
public int getSheetNumber()
{
@@ -384,7 +385,7 @@
LittleEndian.putByte(data, 7 + offset, getNameTextLength());
// Note -
LittleEndian.putUShort(data, 8 + offset, Ptg.getEncodedSizeWithoutArrayData(field_13_name_definition));
- LittleEndian.putUShort(data, 10 + offset, field_5_index_to_sheet);
+ LittleEndian.putUShort(data, 10 + offset, field_5_externSheetIndex_plus1);
LittleEndian.putUShort(data, 12 + offset, field_6_sheetNumber);
LittleEndian.putByte(data, 14 + offset, field_7_length_custom_menu);
LittleEndian.putByte(data, 15 + offset, field_8_length_description_text);
@@ -557,7 +558,7 @@
field_2_keyboard_shortcut = in.readByte();
int field_3_length_name_text = in.readByte();
int field_4_length_name_definition = in.readShort();
- field_5_index_to_sheet = in.readShort();
+ field_5_externSheetIndex_plus1 = in.readShort();
field_6_sheetNumber = in.readUShort();
int field_7_length_custom_menu = in.readUByte();
int field_8_length_description_text = in.readUByte();
@@ -649,8 +650,8 @@
sb.append(" .option flags = ").append(HexDump.shortToHex(field_1_option_flag)).append("\n");
sb.append(" .keyboard shortcut = ").append(HexDump.byteToHex(field_2_keyboard_shortcut)).append("\n");
sb.append(" .length of the name = ").append(getNameTextLength()).append("\n");
- sb.append(" .unused = ").append( field_5_index_to_sheet ).append("\n");
- sb.append(" .index to sheet (1-based, 0=Global) = ").append( field_6_sheetNumber ).append("\n");
+ sb.append(" .extSheetIx(1-based, 0=Global)= ").append( field_5_externSheetIndex_plus1 ).append("\n");
+ sb.append(" .sheetTabIx = ").append(field_6_sheetNumber ).append("\n");
sb.append(" .Menu text length = ").append(field_14_custom_menu_text.length()).append("\n");
sb.append(" .Description text length= ").append(field_15_description_text.length()).append("\n");
sb.append(" .Help topic text length = ").append(field_16_help_topic_text.length()).append("\n");
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java Tue Sep 9 09:49:30 2008
@@ -59,6 +59,7 @@
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(getClass().getName());
+ sb.append(" [");
sb.append("sheetIx=").append(getExternSheetIndex());
sb.append(" ! ");
sb.append(formatReferenceAsString());
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java Tue Sep 9 09:49:30 2008
@@ -61,9 +61,6 @@
private static int evaluateArgParity(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException {
ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
- if (ve == BlankEval.INSTANCE) {
- return 0;
- }
double d = OperandResolver.coerceValueToDouble(ve);
if (d < 0) {
d = -d;
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java Tue Sep 9 09:49:30 2008
@@ -97,9 +97,6 @@
Calendar date = parseDate(strVal);
return DateUtil.getExcelDate(date, false);
}
- if (ve instanceof BlankEval) {
- return 0.0;
- }
return OperandResolver.coerceValueToDouble(ve);
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java Tue Sep 9 09:49:30 2008
@@ -90,20 +90,20 @@
retval[10] = new Na(); // NA
retval[11] = new Npv(); // NPV
retval[12] = new Stdev(); // STDEV
- retval[13] = new Dollar(); // DOLLAR
+ retval[13] = NumericFunctionOneArg.DOLLAR;
retval[14] = new Fixed(); // FIXED
- retval[15] = new Sin(); // SIN
- retval[16] = new Cos(); // COS
- retval[17] = new Tan(); // TAN
- retval[18] = new Atan(); // ATAN
+ retval[15] = NumericFunctionOneArg.SIN;
+ retval[16] = NumericFunctionOneArg.COS;
+ retval[17] = NumericFunctionOneArg.TAN;
+ retval[18] = NumericFunctionOneArg.ATAN;
retval[19] = new Pi(); // PI
- retval[20] = new Sqrt(); // SQRT
- retval[21] = new Exp(); // EXP
- retval[22] = new Ln(); // LN
- retval[23] = new Log10(); // LOG10
- retval[24] = new Abs(); // ABS
- retval[25] = new Int(); // INT
- retval[26] = new Sign(); // SIGN
+ retval[20] = NumericFunctionOneArg.SQRT;
+ retval[21] = NumericFunctionOneArg.EXP;
+ retval[22] = NumericFunctionOneArg.LN;
+ retval[23] = NumericFunctionOneArg.LOG10;
+ retval[24] = NumericFunctionOneArg.ABS;
+ retval[25] = NumericFunctionOneArg.INT;
+ retval[26] = NumericFunctionOneArg.SIGN;
retval[27] = new Round(); // ROUND
retval[28] = new Lookup(); // LOOKUP
retval[29] = new Index(); // INDEX
@@ -143,9 +143,9 @@
retval[64] = new Match(); // MATCH
retval[65] = new Date(); // DATE
retval[66] = new Time(); // TIME
- retval[67] = new Day(); // DAY
- retval[68] = new Month(); // MONTH
- retval[69] = new Year(); // YEAR
+ retval[67] = CalendarFieldFunction.DAY; // DAY
+ retval[68] = CalendarFieldFunction.MONTH; // MONTH
+ retval[69] = CalendarFieldFunction.YEAR; // YEAR
retval[70] = new Weekday(); // WEEKDAY
retval[71] = new Hour(); // HOUR
retval[72] = new Minute(); // MINUTE
@@ -174,8 +174,8 @@
retval[95] = new NotImplementedFunction(); // SELECTION
retval[96] = new Result(); // RESULT
retval[97] = new Atan2(); // ATAN2
- retval[98] = new Asin(); // ASIN
- retval[99] = new Acos(); // ACOS
+ retval[98] = NumericFunctionOneArg.ASIN;
+ retval[99] = NumericFunctionOneArg.ACOS;
retval[100] = new Choose(); // CHOOSE
retval[101] = new Hlookup(); // HLOOKUP
retval[102] = new Vlookup(); // VLOOKUP
@@ -256,7 +256,7 @@
retval[181] = new Help(); // HELP
retval[182] = new NotImplementedFunction(); // GETBAR
retval[183] = new Product(); // PRODUCT
- retval[184] = new Fact(); // FACT
+ retval[184] = NumericFunctionOneArg.FACT;
retval[185] = new NotImplementedFunction(); // GETCELL
retval[186] = new NotImplementedFunction(); // GETWORKSPACE
retval[187] = new NotImplementedFunction(); // GETWINDOW
@@ -293,12 +293,12 @@
retval[222] = new Vdb(); // VDB
retval[227] = new Median(); // MEDIAN
retval[228] = new Sumproduct(); // SUMPRODUCT
- retval[229] = new Sinh(); // SINH
- retval[230] = new Cosh(); // COSH
- retval[231] = new Tanh(); // TANH
- retval[232] = new Asinh(); // ASINH
- retval[233] = new Acosh(); // ACOSH
- retval[234] = new Atanh(); // ATANH
+ retval[229] = NumericFunctionOneArg.SINH;
+ retval[230] = NumericFunctionOneArg.COSH;
+ retval[231] = NumericFunctionOneArg.TANH;
+ retval[232] = NumericFunctionOneArg.ASINH;
+ retval[233] = NumericFunctionOneArg.ACOSH;
+ retval[234] = NumericFunctionOneArg.ATANH;
retval[235] = new Dget(); // DGET
retval[236] = new NotImplementedFunction(); // CREATEOBJECT
retval[237] = new Volatile(); // VOLATILE
@@ -403,8 +403,8 @@
retval[339] = new NotImplementedFunction(); // GETPIVOTTABLE
retval[340] = new NotImplementedFunction(); // GETPIVOTFIELD
retval[341] = new NotImplementedFunction(); // GETPIVOTITEM
- retval[342] = new Radians(); // RADIANS
- retval[343] = new Degrees(); // DEGREES
+ retval[342] = NumericFunctionOneArg.RADIANS;
+ retval[343] = NumericFunctionOneArg.DEGREES;
retval[344] = new Subtotal(); // SUBTOTAL
retval[345] = new Sumif(); // SUMIF
retval[346] = new Countif(); // COUNTIF
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java Tue Sep 9 09:49:30 2008
@@ -171,7 +171,8 @@
/**
* Applies some conversion rules if the supplied value is not already an integer.<br/>
- * Value is first coerced to a <tt>double</tt> ( See <tt>coerceValueToDouble()</tt> ).<p/>
+ * Value is first coerced to a <tt>double</tt> ( See <tt>coerceValueToDouble()</tt> ).
+ * Note - <tt>BlankEval</tt> is converted to <code>0</code>.<p/>
*
* Excel typically converts doubles to integers by truncating toward negative infinity.<br/>
* The equivalent java code is:<br/>
@@ -181,6 +182,9 @@
*
*/
public static int coerceValueToInt(ValueEval ev) throws EvaluationException {
+ if (ev == BlankEval.INSTANCE) {
+ return 0;
+ }
double d = coerceValueToDouble(ev);
// Note - the standard java type conversion from double to int truncates toward zero.
// but Math.floor() truncates toward negative infinity
@@ -189,16 +193,20 @@
/**
* Applies some conversion rules if the supplied value is not already a number.
- * Note - <tt>BlankEval</tt> is not supported and must be handled by the caller.
- * @param ev must be a <tt>NumberEval</tt>, <tt>StringEval</tt> or <tt>BoolEval</tt>
+ * Note - <tt>BlankEval</tt> is converted to {@link NumberEval#ZERO}.
+ * @param ev must be a {@link NumberEval}, {@link StringEval}, {@link BoolEval} or
+ * {@link BlankEval}
* @return actual, parsed or interpreted double value (respectively).
* @throws EvaluationException(#VALUE!) only if a StringEval is supplied and cannot be parsed
* as a double (See <tt>parseDouble()</tt> for allowable formats).
- * @throws RuntimeException if the supplied parameter is not <tt>NumberEval</tt>,
- * <tt>StringEval</tt> or <tt>BoolEval</tt>
+ * @throws RuntimeException if the supplied parameter is not {@link NumberEval},
+ * {@link StringEval}, {@link BoolEval} or {@link BlankEval}
*/
public static double coerceValueToDouble(ValueEval ev) throws EvaluationException {
+ if (ev == BlankEval.INSTANCE) {
+ return 0.0;
+ }
if (ev instanceof NumericValueEval) {
// this also handles booleans
return ((NumericValueEval)ev).getNumberValue();
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/PercentEval.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/PercentEval.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/PercentEval.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/PercentEval.java Tue Sep 9 09:49:30 2008
@@ -33,12 +33,9 @@
if (args.length != 1) {
return ErrorEval.VALUE_INVALID;
}
- double d0;
+ double d0;
try {
ValueEval ve = OperandResolver.getSingleValue(args[0], srcRow, srcCol);
- if (ve instanceof BlankEval) {
- return NumberEval.ZERO;
- }
d0 = OperandResolver.coerceValueToDouble(ve);
} catch (EvaluationException e) {
return e.getErrorEval();
@@ -50,7 +47,7 @@
return 1;
}
public final int getType() {
- // TODO - remove
- throw new RuntimeException("obsolete code should not be called");
- }
+ // TODO - remove
+ throw new RuntimeException("obsolete code should not be called");
+ }
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java Tue Sep 9 09:49:30 2008
@@ -23,18 +23,15 @@
abstract class TwoOperandNumericOperation implements OperationEval {
public final int getType() {
- // TODO - remove
- throw new RuntimeException("obsolete code should not be called");
- }
- protected final double singleOperandEvaluate(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException {
- ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
- if (ve instanceof BlankEval) {
- return 0.0;
- }
- return OperandResolver.coerceValueToDouble(ve);
- }
-
- public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+ // TODO - remove
+ throw new RuntimeException("obsolete code should not be called");
+ }
+ protected final double singleOperandEvaluate(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException {
+ ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
+ return OperandResolver.coerceValueToDouble(ve);
+ }
+
+ public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
double result;
try {
double d0 = singleOperandEvaluate(args[0], srcCellRow, srcCellCol);
@@ -46,8 +43,8 @@
} catch (EvaluationException e) {
return e.getErrorEval();
}
- return new NumberEval(result);
- }
+ return new NumberEval(result);
+ }
protected abstract double evaluate(double d0, double d1) throws EvaluationException;
public final int getNumberOfOperands() {
return 2;
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java Tue Sep 9 09:49:30 2008
@@ -33,12 +33,9 @@
if (args.length != 1) {
return ErrorEval.VALUE_INVALID;
}
- double d;
+ double d;
try {
ValueEval ve = OperandResolver.getSingleValue(args[0], srcRow, srcCol);
- if (ve instanceof BlankEval) {
- return NumberEval.ZERO;
- }
d = OperandResolver.coerceValueToDouble(ve);
} catch (EvaluationException e) {
return e.getErrorEval();
@@ -50,7 +47,7 @@
return 1;
}
public final int getType() {
- // TODO - remove
- throw new RuntimeException("obsolete code should not be called");
- }
+ // TODO - remove
+ throw new RuntimeException("obsolete code should not be called");
+ }
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java Tue Sep 9 09:49:30 2008
@@ -24,21 +24,18 @@
*/
public final class UnaryPlusEval implements OperationEval {
- public static final OperationEval instance = new UnaryPlusEval();
-
- private UnaryPlusEval() {
- }
+ public static final OperationEval instance = new UnaryPlusEval();
+
+ private UnaryPlusEval() {
+ }
- public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
- if(args.length != 1) {
- return ErrorEval.VALUE_INVALID;
- }
- double d;
+ public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+ if(args.length != 1) {
+ return ErrorEval.VALUE_INVALID;
+ }
+ double d;
try {
ValueEval ve = OperandResolver.getSingleValue(args[0], srcCellRow, srcCellCol);
- if(ve instanceof BlankEval) {
- return NumberEval.ZERO;
- }
if(ve instanceof StringEval) {
// Note - asymmetric with UnaryMinus
// -"hello" evaluates to #VALUE!
@@ -49,14 +46,14 @@
} catch (EvaluationException e) {
return e.getErrorEval();
}
- return new NumberEval(+d);
- }
+ return new NumberEval(+d);
+ }
- public int getNumberOfOperands() {
- return 1;
- }
+ public int getNumberOfOperands() {
+ return 1;
+ }
- public int getType() {
- throw new RuntimeException("obsolete code should not be called");
- }
+ public int getType() {
+ throw new RuntimeException("obsolete code should not be called");
+ }
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Even.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Even.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Even.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Even.java Tue Sep 9 09:49:30 2008
@@ -1,73 +1,49 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Created on May 6, 2005
- *
- */
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
package org.apache.poi.hssf.record.formula.functions;
-import org.apache.poi.hssf.record.formula.eval.BlankEval;
-import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.Eval;
-import org.apache.poi.hssf.record.formula.eval.NumberEval;
-import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
/**
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
*
*/
-public class Even extends NumericFunction {
+public final class Even extends NumericFunctionOneArg {
+
+ private static final long PARITY_MASK = 0xFFFFFFFFFFFFFFFEL;
- public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
- double d = 0;
- ValueEval retval = null;
-
- switch (operands.length) {
- default:
- retval = ErrorEval.VALUE_INVALID;
- break;
- case 1:
- ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
- if (ve instanceof NumericValueEval) {
- NumericValueEval ne = (NumericValueEval) ve;
- d = ne.getNumberValue();
- }
- else if (ve instanceof BlankEval) {
- // do nothing
- }
- else {
- retval = ErrorEval.NUM_ERROR;
- }
- }
-
- if (retval == null) {
- if (!Double.isNaN(d) && !Double.isInfinite(d)) {
- d = (d==0)
- ? 0
- : (((long) (d/2))*2 == d)
- ? d
- : (d < 0)
- ? ((((long) (d/2))<<1)-2)
- : ((((long) (d/2))<<1)+2);
- }
- retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
- }
- return retval;
- }
+ protected double evaluate(double d) {
+ if (d==0) {
+ return 0;
+ }
+ long result;
+ if (d>0) {
+ result = calcEven(d);
+ } else {
+ result = -calcEven(-d);
+ }
+ return result;
+ }
+ private static long calcEven(double d) {
+ long x = ((long) d) & PARITY_MASK;
+ if (x == d) {
+ return x;
+ }
+ return x + 2;
+ }
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java Tue Sep 9 09:49:30 2008
@@ -339,23 +339,19 @@
throw EvaluationException.invalidRef();
}
int oneBasedIndex;
- if(veRowColIndexArg instanceof BlankEval) {
- oneBasedIndex = 0;
- } else {
- if(veRowColIndexArg instanceof StringEval) {
- StringEval se = (StringEval) veRowColIndexArg;
- String strVal = se.getStringValue();
- Double dVal = OperandResolver.parseDouble(strVal);
- if(dVal == null) {
- // String does not resolve to a number. Raise #REF! error.
- throw EvaluationException.invalidRef();
- // This includes text booleans "TRUE" and "FALSE". They are not valid.
- }
- // else - numeric value parses OK
+ if(veRowColIndexArg instanceof StringEval) {
+ StringEval se = (StringEval) veRowColIndexArg;
+ String strVal = se.getStringValue();
+ Double dVal = OperandResolver.parseDouble(strVal);
+ if(dVal == null) {
+ // String does not resolve to a number. Raise #REF! error.
+ throw EvaluationException.invalidRef();
+ // This includes text booleans "TRUE" and "FALSE". They are not valid.
}
- // actual BoolEval values get interpreted as FALSE->0 and TRUE->1
- oneBasedIndex = OperandResolver.coerceValueToInt(veRowColIndexArg);
+ // else - numeric value parses OK
}
+ // actual BoolEval values get interpreted as FALSE->0 and TRUE->1
+ oneBasedIndex = OperandResolver.coerceValueToInt(veRowColIndexArg);
if (oneBasedIndex < 1) {
// note this is asymmetric with the errors when the index is too large (#REF!)
throw EvaluationException.invalidValue();
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Mid.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Mid.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Mid.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Mid.java Tue Sep 9 09:49:30 2008
@@ -17,7 +17,6 @@
package org.apache.poi.hssf.record.formula.functions;
-import org.apache.poi.hssf.record.formula.eval.BlankEval;
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
import org.apache.poi.hssf.record.formula.eval.Eval;
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
@@ -81,12 +80,8 @@
private static int evaluateNumberArg(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException {
ValueEval ev = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
- if (ev instanceof BlankEval) {
- // Note - for start_num arg, blank causes error(#VALUE!),
- // but for num_chars causes empty string to be returned.
- return 0;
- }
-
+ // Note - for start_num arg, blank/zero causes error(#VALUE!),
+ // but for num_chars causes empty string to be returned.
return OperandResolver.coerceValueToInt(ev);
}
}
\ No newline at end of file
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Odd.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Odd.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Odd.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Odd.java Tue Sep 9 09:49:30 2008
@@ -1,73 +1,49 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Created on May 6, 2005
- *
- */
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
package org.apache.poi.hssf.record.formula.functions;
-import org.apache.poi.hssf.record.formula.eval.BlankEval;
-import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.Eval;
-import org.apache.poi.hssf.record.formula.eval.NumberEval;
-import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
/**
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
*
*/
-public class Odd extends NumericFunction {
+public final class Odd extends NumericFunctionOneArg {
+ private static final long PARITY_MASK = 0xFFFFFFFFFFFFFFFEL;
- public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
- double d = 0;
- ValueEval retval = null;
-
- switch (operands.length) {
- default:
- retval = ErrorEval.VALUE_INVALID;
- break;
- case 1:
- ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
- if (ve instanceof NumericValueEval) {
- NumericValueEval ne = (NumericValueEval) ve;
- d = ne.getNumberValue();
- }
- else if (ve instanceof BlankEval) {
- // do nothing
- }
- else {
- retval = ErrorEval.NUM_ERROR;
- }
- }
-
- if (retval == null) {
- if (!Double.isNaN(d) && !Double.isInfinite(d)) {
- d = (d==0)
- ? 1
- : ((((long) d) - 1) % 2 == 0)
- ? d
- : (d < 0)
- ? ((((long) (d/2))<<1)-1)
- : ((((long) (d/2))<<1)+1);
- }
- retval = (Double.isNaN(d) || Double.isInfinite(d)) ? (ValueEval) ErrorEval.VALUE_INVALID : new NumberEval(d);
- }
- return retval;
+ protected double evaluate(double d) {
+ if (d==0) {
+ return 1;
+ }
+ long result;
+ if (d>0) {
+ result = calcOdd(d);
+ } else {
+ result = -calcOdd(-d);
+ }
+ return result;
}
+ private static long calcOdd(double d) {
+ double dpm1 = d+1;
+ long x = ((long) dpm1) & PARITY_MASK;
+ if (x == dpm1) {
+ return x-1;
+ }
+ return x + 1;
+ }
}
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Tue Sep 9 09:49:30 2008
@@ -582,7 +582,10 @@
}
/**
- * check whether a sheet is hidden
+ * Check whether a sheet is hidden.
+ * Note that a sheet could instead be
+ * set to be very hidden, which is different
+ * ({@link #isSheetVeryHidden(int)})
* @param sheetIx Number
* @return True if sheet is hidden
*/
@@ -590,6 +593,18 @@
validateSheetIndex(sheetIx);
return workbook.isSheetHidden(sheetIx);
}
+ /**
+ * Check whether a sheet is very hidden.
+ * This is different from the normal
+ * hidden status
+ * ({@link #isSheetHidden(int)})
+ * @param sheetIx Number
+ * @return True if sheet is very hidden
+ */
+ public boolean isSheetVeryHidden(int sheetIx) {
+ validateSheetIndex(sheetIx);
+ return workbook.isSheetVeryHidden(sheetIx);
+ }
/**
* Hide or unhide a sheet
@@ -601,6 +616,19 @@
validateSheetIndex(sheetIx);
workbook.setSheetHidden(sheetIx, hidden);
}
+ /**
+ * Hide or unhide a sheet.
+ * 0 = not hidden
+ * 1 = hidden
+ * 2 = very hidden.
+ *
+ * @param sheetIx The sheet number
+ * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
+ */
+ public void setSheetHidden(int sheetIx, int hidden) {
+ validateSheetIndex(sheetIx);
+ workbook.setSheetHidden(sheetIx, hidden);
+ }
/*
* get the sheet's index
@@ -708,8 +736,8 @@
HSSFName newName = new HSSFName(this, newNameRecord);
names.add(newName);
- workbook.cloneDrawings(clonedSheet.getSheet());
}
+ workbook.cloneDrawings(clonedSheet.getSheet());
// TODO - maybe same logic required for other/all built-in name records
return clonedSheet;
@@ -1020,13 +1048,7 @@
if (!r.isBuiltInName() || r.getBuiltInName() != builtinCode) {
continue;
}
- if(r.getSheetNumber() == 0) {
- //ignore "GLOBAL" name records
- continue;
- }
- int externIndex = r.getSheetNumber() -1;
- int nameRecordSheetIndex = workbook.getSheetIndexFromExternSheetIndex(externIndex);
- if (nameRecordSheetIndex == sheetIndex) {
+ if (r.getSheetNumber() -1 == sheetIndex) {
return defNameIndex;
}
}
Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java Tue Sep 9 09:49:30 2008
@@ -103,6 +103,9 @@
/** Escher Drawing Group information */
protected EscherRecordHolder _dgg;
+ /** Holds Office Art objects */
+ protected ShapesTable _officeArts;
+
protected HWPFDocument()
{
super(null, null);
@@ -252,6 +255,8 @@
// read in the pictures stream
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspa, _dgg);
+ // And the art shapes stream
+ _officeArts = new ShapesTable(_tableStream, _fib);
_st = new SectionTable(_mainStream, _tableStream, _fib.getFcPlcfsed(), _fib.getLcbPlcfsed(), fcMin, _tpt, _cpSplit);
_ss = new StyleSheet(_tableStream, _fib.getFcStshf());
@@ -392,6 +397,13 @@
public PicturesTable getPicturesTable() {
return _pictures;
}
+
+ /**
+ * @return ShapesTable object, that is able to extract office are shapes from this document
+ */
+ public ShapesTable getShapesTable() {
+ return _officeArts;
+ }
/**
* Writes out the word file that is represented by an instance of this class.
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/externalFunctionExample.xls
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/externalFunctionExample.xls?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestExternalFunctionFormulas.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestExternalFunctionFormulas.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestExternalFunctionFormulas.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestExternalFunctionFormulas.java Tue Sep 9 09:49:30 2008
@@ -77,8 +77,9 @@
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb);
confirmCellEval(sheet, 0, 0, fe, "YEARFRAC(B1,C1)", 29.0/90.0);
confirmCellEval(sheet, 1, 0, fe, "YEARFRAC(B2,C2)", 0.0);
- confirmCellEval(sheet, 2, 0, fe, "IF(ISEVEN(3),1.2,1.6)", 1.6);
- confirmCellEval(sheet, 3, 0, fe, "IF(ISODD(3),1.2,1.6)", 1.2);
+ confirmCellEval(sheet, 2, 0, fe, "YEARFRAC(B3,C3,D3)", 0.0);
+ confirmCellEval(sheet, 3, 0, fe, "IF(ISEVEN(3),1.2,1.6)", 1.6);
+ confirmCellEval(sheet, 4, 0, fe, "IF(ISODD(3),1.2,1.6)", 1.2);
}
private static void confirmCellEval(HSSFSheet sheet, int rowIx, int colIx,
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Sep 9 09:49:30 2008
@@ -1383,4 +1383,31 @@
assertFalse(nwb.getSheetAt(1).getForceFormulaRecalculation());
assertTrue(nwb.getSheetAt(2).getForceFormulaRecalculation());
}
+
+ /**
+ * Very hidden sheets not displaying as such
+ */
+ public void test45761() {
+ HSSFWorkbook wb = openSample("45761.xls");
+ assertEquals(3, wb.getNumberOfSheets());
+
+ assertFalse(wb.isSheetHidden(0));
+ assertFalse(wb.isSheetVeryHidden(0));
+ assertTrue(wb.isSheetHidden(1));
+ assertFalse(wb.isSheetVeryHidden(1));
+ assertFalse(wb.isSheetHidden(2));
+ assertTrue(wb.isSheetVeryHidden(2));
+
+ // Change 0 to be very hidden, and re-load
+ wb.setSheetHidden(0, 2);
+
+ HSSFWorkbook nwb = writeOutAndReadBack(wb);
+
+ assertFalse(nwb.isSheetHidden(0));
+ assertTrue(nwb.isSheetVeryHidden(0));
+ assertTrue(nwb.isSheetHidden(1));
+ assertFalse(nwb.isSheetVeryHidden(1));
+ assertFalse(nwb.isSheetHidden(2));
+ assertTrue(nwb.isSheetVeryHidden(2));
+ }
}
Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java?rev=693510&r1=693509&r2=693510&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java Tue Sep 9 09:49:30 2008
@@ -527,4 +527,33 @@
}
}
}
+
+ /**
+ * Test to make sure that NameRecord.getSheetNumber() is interpreted as a
+ * 1-based sheet tab index (not a 1-based extern sheet index)
+ */
+ public void testFindBuiltInNameRecord() {
+ // testRRaC has multiple (3) built-in name records
+ // The second print titles name record has getSheetNumber()==4
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testRRaC.xls");
+ NameRecord nr;
+ assertEquals(3, wb.getWorkbook().getNumNames());
+ nr = wb.getWorkbook().getNameRecord(2);
+ // TODO - render full row and full column refs properly
+ assertEquals("Sheet2!$A$1:$IV$1", nr.getAreaReference(wb)); // 1:1
+
+ try {
+ wb.setRepeatingRowsAndColumns(3, 4, 5, 8, 11);
+ } catch (RuntimeException e) {
+ if (e.getMessage().equals("Builtin (7) already exists for sheet (4)")) {
+ // there was a problem in the code which locates the existing print titles name record
+ throw new RuntimeException("Identified bug 45720b");
+ }
+ throw e;
+ }
+ wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
+ assertEquals(3, wb.getWorkbook().getNumNames());
+ nr = wb.getWorkbook().getNameRecord(2);
+ assertEquals("Sheet2!E:F,Sheet2!$A$9:$IV$12", nr.getAreaReference(wb)); // E:F,9:12
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org