Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 67042 invoked from network); 13 Sep 2008 13:49:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Sep 2008 13:49:00 -0000 Received: (qmail 26325 invoked by uid 500); 13 Sep 2008 13:48:57 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 26275 invoked by uid 500); 13 Sep 2008 13:48:56 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 26266 invoked by uid 99); 13 Sep 2008 13:48:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Sep 2008 06:48:56 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Sep 2008 13:48:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 80BCD2388A51; Sat, 13 Sep 2008 06:48:36 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r694947 [5/6] - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/java/org/apache/poi/hssf/extractor/ src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/ src/java/org/apache/poi/hssf/record/aggregates/ src... Date: Sat, 13 Sep 2008 13:48:31 -0000 To: commits@poi.apache.org From: nick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080913134836.80BCD2388A51@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java (original) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java Sat Sep 13 06:48:27 2008 @@ -19,6 +19,7 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFSheet; /** * This is a JDK 1.4 compatible interface for HSSFCell. @@ -85,6 +86,7 @@ void setCellErrorValue(byte value); HSSFCellStyle getCellStyle(); + HSSFSheet getSheet(); boolean getBooleanCellValue(); double getNumericCellValue(); Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Comment.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Comment.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Comment.java (original) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Comment.java Sat Sep 13 06:48:27 2008 @@ -17,4 +17,7 @@ package org.apache.poi.ss.usermodel; -public interface Comment {} +public interface Comment { + public void setRow(short row); + public void setColumn(short row); +} Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java (original) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java Sat Sep 13 06:48:27 2008 @@ -106,6 +106,8 @@ int getRowIndex(); + Sheet getSheet(); + /** * set the cells type (numeric, formula or string) * @see #CELL_TYPE_NUMERIC Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java Sat Sep 13 06:48:27 2008 @@ -37,7 +37,7 @@ assertEquals( (short) 0x0001, r.getOptions() ); assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeWin32() ); assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeMacOS() ); - assertEquals( "[01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, ]", HexDump.toHex( r.getUid() ) ); + assertEquals( "[01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00]", HexDump.toHex( r.getUid() ) ); assertEquals( (short) 1, r.getTag() ); assertEquals( 2, r.getRef() ); assertEquals( 3, r.getOffset() ); @@ -57,7 +57,7 @@ assertEquals( 44, bytesWritten ); assertEquals( "[01, 00, 00, 00, 24, 00, 00, 00, 05, 05, 01, 02, 03, 04, " + "05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, 01, 00, 00, 00, " + - "00, 00, 02, 00, 00, 00, 03, 00, 00, 00, 04, 05, 06, 07, ]", + "00, 00, 02, 00, 00, 00, 03, 00, 00, 00, 04, 05, 06, 07]", HexDump.toHex( data ) ); } @@ -90,7 +90,7 @@ " Options: 0x0001" + nl + " BlipTypeWin32: 5" + nl + " BlipTypeMacOS: 5" + nl + - " SUID: [01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, ]" + nl + + " SUID: [01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00]" + nl + " Tag: 1" + nl + " Size: 0" + nl + " Ref: 2" + nl + Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBlipWMFRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -36,8 +35,7 @@ data = HexRead.readFromString(dataStr); } - public void testSerialize() throws Exception - { + public void testSerialize() { EscherBlipWMFRecord r = new EscherBlipWMFRecord(); r.setBoundaryLeft(1); r.setBoundaryHeight(2); @@ -72,14 +70,13 @@ "05, 00, 00, 00, " + // field_9_cacheOfSavedSize "08, " + // field_10_compressionFlag "07, " + // field_11_filter - "01, 02, ]", // field_12_data + "01, 02]", // field_12_data HexDump.toHex(buf)); assertEquals(60, r.getRecordSize() ); } - public void testFillFields() throws Exception - { + public void testFillFields() { EscherBlipWMFRecord r = new EscherBlipWMFRecord(); r.fillFields( data, 0, new DefaultEscherRecordFactory()); @@ -92,15 +89,14 @@ assertEquals( 6, r.getCacheOfSize() ); assertEquals( 7, r.getFilter() ); assertEquals( 8, r.getCompressionFlag() ); - assertEquals( "[01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, ]", HexDump.toHex(r.getSecondaryUID() ) ); + assertEquals( "[01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01]", HexDump.toHex(r.getSecondaryUID() ) ); assertEquals( 10, r.getWidth() ); assertEquals( 11, r.getHeight() ); assertEquals( (short)5420, r.getOptions() ); - assertEquals( "[01, 02, ]", HexDump.toHex( r.getData() ) ); + assertEquals( "[01, 02]", HexDump.toHex( r.getData() ) ); } - public void testToString() throws Exception - { + public void testToString() { EscherBlipWMFRecord r = new EscherBlipWMFRecord(); r.fillFields( data, 0, new DefaultEscherRecordFactory() ); @@ -109,7 +105,7 @@ assertEquals( "org.apache.poi.ddf.EscherBlipWMFRecord:" + nl + " RecordId: 0xF018" + nl + " Options: 0x152C" + nl + - " Secondary UID: [01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, ]" + nl + + " Secondary UID: [01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01]" + nl + " CacheOfSize: 6" + nl + " BoundaryTop: 3" + nl + " BoundaryLeft: 1" + nl + @@ -124,5 +120,5 @@ "00000000 01 02 .." + nl , r.toString() ); } - } + Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherChildAnchorRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherChildAnchorRecord r = createRecord(); byte[] data = new byte[8 + 16]; @@ -37,7 +35,7 @@ "01, 00, 00, 00, " + "02, 00, 00, 00, " + "03, 00, 00, 00, " + - "04, 00, 00, 00, ]", HexDump.toHex( data ) ); + "04, 00, 00, 00]", HexDump.toHex( data ) ); } public void testFillFields() throws Exception @@ -62,8 +60,7 @@ assertEquals( (short) 0x0001, r.getOptions() ); } - public void testToString() throws Exception - { + public void testToString(){ String nl = System.getProperty( "line.separator" ); String expected = "org.apache.poi.ddf.EscherChildAnchorRecord:" + nl + @@ -76,7 +73,7 @@ assertEquals( expected, createRecord().toString() ); } - private EscherChildAnchorRecord createRecord() + private static EscherChildAnchorRecord createRecord() { EscherChildAnchorRecord r = new EscherChildAnchorRecord(); r.setRecordId( EscherChildAnchorRecord.RECORD_ID ); @@ -87,5 +84,5 @@ r.setDy2( 4 ); return r; } - } + Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherClientAnchorRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherClientAnchorRecord r = createRecord(); byte[] data = new byte[8 + 18 + 2]; @@ -37,11 +35,10 @@ "4D, 00, 37, 00, 21, 00, 58, 00, " + "0B, 00, 2C, 00, 16, 00, 63, 00, " + "42, 00, " + - "FF, DD, ]", HexDump.toHex( data ) ); + "FF, DD]", HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "01 00 " + "10 F0 " + "14 00 00 00 " + @@ -68,8 +65,7 @@ assertEquals( (byte) 0xDD, r.getRemainingData()[1] ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherClientAnchorRecord:" + nl + Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherClientDataRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherClientDataRecord r = createRecord(); byte[] data = new byte[8]; @@ -33,12 +31,11 @@ assertEquals( 8, bytesWritten ); assertEquals( "[02, 00, " + "11, F0, " + - "00, 00, 00, 00, ]", + "00, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "02 00 " + "11 F0 " + "00 00 00 00 "; @@ -51,8 +48,7 @@ assertEquals( "[]", HexDump.toHex(r.getRemainingData()) ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherClientDataRecord:" + nl + @@ -63,7 +59,7 @@ assertEquals( expected, createRecord().toString() ); } - private EscherClientDataRecord createRecord() + private static EscherClientDataRecord createRecord() { EscherClientDataRecord r = new EscherClientDataRecord(); r.setOptions( (short) 0x0002 ); @@ -71,5 +67,4 @@ r.setRemainingData( new byte[] {} ); return r; } - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java Sat Sep 13 06:48:27 2008 @@ -30,13 +30,11 @@ { private String ESCHER_DATA_PATH; - protected void setUp() throws Exception { - super.setUp(); + protected void setUp() { ESCHER_DATA_PATH = System.getProperty("DDF.testdata.path"); } - public void testFillFields() throws Exception - { + public void testFillFields() { EscherRecordFactory f = new DefaultEscherRecordFactory(); byte[] data = HexRead.readFromString( "0F 02 11 F1 00 00 00 00" ); EscherRecord r = f.createRecord( data, 0 ); @@ -55,15 +53,14 @@ assertEquals( (short) 0xF222, c.getRecordId() ); } - public void testSerialize() throws Exception - { + public void testSerialize() { UnknownEscherRecord r = new UnknownEscherRecord(); r.setOptions( (short) 0x123F ); r.setRecordId( (short) 0xF112 ); byte[] data = new byte[8]; r.serialize( 0, data, new NullEscherSerializationListener() ); - assertEquals( "[3F, 12, 12, F1, 00, 00, 00, 00, ]", HexDump.toHex( data ) ); + assertEquals( "[3F, 12, 12, F1, 00, 00, 00, 00]", HexDump.toHex( data ) ); EscherRecord childRecord = new UnknownEscherRecord(); childRecord.setOptions( (short) 0x9999 ); @@ -72,12 +69,11 @@ data = new byte[16]; r.serialize( 0, data, new NullEscherSerializationListener() ); - assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00, ]", HexDump.toHex( data ) ); + assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testToString() throws Exception - { + public void testToString() { EscherContainerRecord r = new EscherContainerRecord(); r.setRecordId( EscherContainerRecord.SP_CONTAINER ); r.setOptions( (short) 0x000F ); @@ -134,8 +130,7 @@ assertEquals( expected, r.toString() ); } - public void testGetRecordSize() throws Exception - { + public void testGetRecordSize() { EscherContainerRecord r = new EscherContainerRecord(); r.addChildRecord(new EscherRecord() { Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherDgRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherDgRecord r = createRecord(); byte[] data = new byte[16]; @@ -35,12 +33,11 @@ "08, F0, " + "08, 00, 00, 00, " + "02, 00, 00, 00, " + // num shapes in drawing - "01, 04, 00, 00, ]", // The last MSOSPID given to an SP in this DG + "01, 04, 00, 00]", // The last MSOSPID given to an SP in this DG HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "10 00 " + "08 F0 " + "08 00 00 00 " + @@ -55,8 +52,7 @@ assertEquals( 1025, r.getLastMSOSPID() ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherDgRecord:" + nl + @@ -67,7 +63,7 @@ assertEquals( expected, createRecord().toString() ); } - private EscherDgRecord createRecord() + private static EscherDgRecord createRecord() { EscherDgRecord r = new EscherDgRecord(); r.setOptions( (short) 0x0010 ); @@ -76,5 +72,4 @@ r.setLastMSOSPID(1025); return r; } - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherDggRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherDggRecord r = createRecord(); byte[] data = new byte[32]; @@ -38,12 +36,11 @@ "02, 00, 00, 00, " + "02, 00, 00, 00, " + "01, 00, 00, 00, " + - "01, 00, 00, 00, 02, 00, 00, 00, ]", + "01, 00, 00, 00, 02, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "00 00 " + "06 F0 " + "18 00 00 00 " + @@ -66,8 +63,7 @@ assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed()); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherDggRecord:" + nl + @@ -82,7 +78,7 @@ assertEquals( expected, createRecord().toString() ); } - private EscherDggRecord createRecord() + private static EscherDggRecord createRecord() { EscherDggRecord r = new EscherDggRecord(); r.setOptions( (short) 0x0000 ); @@ -96,12 +92,9 @@ return r; } - public void testGetRecordSize() throws Exception - { + public void testGetRecordSize() { EscherDggRecord r = new EscherDggRecord(); r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } ); assertEquals(32,r.getRecordSize()); - } - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java Sat Sep 13 06:48:27 2008 @@ -24,20 +24,16 @@ import java.io.IOException; import java.util.Arrays; -import java.util.List; -import java.util.Iterator; public class TestEscherOptRecord extends TestCase { - public void testFillFields() throws Exception - { + public void testFillFields() { checkFillFieldsSimple(); checkFillFieldsComplex(); } - private void checkFillFieldsComplex() throws IOException - { + private void checkFillFieldsComplex() { String dataStr = "33 00 " + "0B F0 " + "14 00 00 00 " + @@ -60,9 +56,7 @@ } - private void checkFillFieldsSimple() - throws IOException - { + private void checkFillFieldsSimple() { String dataStr = "33 00 " + // options "0B F0 " + // recordid "12 00 00 00 " + // remaining bytes @@ -83,8 +77,7 @@ assertEquals( prop3, r.getEscherProperty( 2 ) ); } - public void testSerialize() throws Exception - { + public void testSerialize() { checkSerializeSimple(); checkSerializeComplex(); } @@ -111,7 +104,7 @@ "BF, 00, 01, 00, 00, 00, " + "01, 80, 02, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " + - "01, 02, ]"; + "01, 02]"; assertEquals( dataStr, HexDump.toHex(data) ); } @@ -135,13 +128,12 @@ "12, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " + "81, 01, 09, 00, 00, 08, " + - "C0, 01, 40, 00, 00, 08, ]"; + "C0, 01, 40, 00, 00, 08]"; assertEquals( dataStr, HexDump.toHex(data) ); assertEquals( 26, bytesWritten ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); EscherOptRecord r = new EscherOptRecord(); r.setOptions((short)0x000F); @@ -162,8 +154,8 @@ * Test serialisation of a particually complex example * This test is currently broken! */ - public void testComplexSerialise() throws Exception { - byte[] data = new byte[] { + public void testComplexSerialise() { + byte[] data = { 0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00, // Simple data follows 0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8 @@ -263,7 +255,7 @@ * * See Bug 41946 for details. */ - public void test41946() throws IOException { + public void test41946() { String dataStr1 = "03 08 0B F0 00 03 00 00 81 00 30 65 01 00 82 00 98 B2 00 00 83 00 30 65 01 " + "00 84 00 98 B2 00 00 85 00 00 00 00 00 87 00 01 00 00 00 88 00 00 00 00 00 " + @@ -315,7 +307,7 @@ * Test that EscherOptRecord can properly read/write array properties * with empty complex part. */ - public void testEmptyArrayProperty() throws IOException { + public void testEmptyArrayProperty() { EscherOptRecord r = new EscherOptRecord(); EscherArrayProperty p = new EscherArrayProperty((short)(EscherProperties.FILL__SHADECOLORS + 0x8000), new byte[0] ); assertEquals(0, p.getNumberOfElementsInArray()); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -30,8 +29,7 @@ */ public class TestEscherPropertyFactory extends TestCase { - public void testCreateProperties() throws Exception - { + public void testCreateProperties() { String dataStr = "41 C1 " + // propid, complex ind "03 00 00 00 " + // size of complex property "01 00 " + // propid, complex ind @@ -46,15 +44,11 @@ List props = f.createProperties( data, 0, (short)3 ); EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 ); assertEquals( (short)0xC141, p1.getId() ); - assertEquals( "[01, 02, 03, ]", HexDump.toHex( p1.getComplexData() ) ); + assertEquals( "[01, 02, 03]", HexDump.toHex( p1.getComplexData() ) ); EscherComplexProperty p3 = (EscherComplexProperty) props.get( 2 ); assertEquals( (short)0xC141, p3.getId() ); - assertEquals( "[01, 02, 03, ]", HexDump.toHex( p3.getComplexData() ) ); - - + assertEquals( "[01, 02, 03]", HexDump.toHex( p3.getComplexData() ) ); } - - - } + Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherSpRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherSpRecord r = createRecord(); byte[] data = new byte[16]; @@ -35,12 +33,11 @@ "0A, F0, " + "08, 00, 00, 00, " + "00, 04, 00, 00, " + - "05, 00, 00, 00, ]", + "05, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "02 00 " + "0A F0 " + "08 00 00 00 " + @@ -55,8 +52,7 @@ assertEquals( 0x05, r.getFlags() ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherSpRecord:" + nl + @@ -67,7 +63,7 @@ assertEquals( expected, createRecord().toString() ); } - private EscherSpRecord createRecord() + private static EscherSpRecord createRecord() { EscherSpRecord r = new EscherSpRecord(); r.setOptions( (short) 0x0002 ); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java Sat Sep 13 06:48:27 2008 @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.ddf; import junit.framework.TestCase; @@ -24,8 +23,7 @@ public class TestEscherSpgrRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherSpgrRecord r = createRecord(); byte[] data = new byte[24]; @@ -37,12 +35,11 @@ "01, 00, 00, 00, " + // x "02, 00, 00, 00, " + // y "03, 00, 00, 00, " + // width - "04, 00, 00, 00, ]", // height + "04, 00, 00, 00]", // height HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "10 00 " + "09 F0 " + "10 00 00 00 " + @@ -61,8 +58,7 @@ assertEquals( 4, r.getRectY2() ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherSpgrRecord:" + nl + @@ -72,11 +68,10 @@ " RectY: 2" + nl + " RectWidth: 3" + nl + " RectHeight: 4" + nl; - ; assertEquals( expected, createRecord().toString() ); } - private EscherSpgrRecord createRecord() + private static EscherSpgrRecord createRecord() { EscherSpgrRecord r = new EscherSpgrRecord(); r.setOptions( (short) 0x0010 ); @@ -87,5 +82,4 @@ r.setRectY2(4); return r; } - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java Sat Sep 13 06:48:27 2008 @@ -24,8 +24,7 @@ public class TestEscherSplitMenuColorsRecord extends TestCase { - public void testSerialize() throws Exception - { + public void testSerialize() { EscherSplitMenuColorsRecord r = createRecord(); byte[] data = new byte[24]; @@ -37,12 +36,11 @@ "02, 04, 00, 00, " + "02, 00, 00, 00, " + "02, 00, 00, 00, " + - "01, 00, 00, 00, ]", + "01, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testFillFields() throws Exception - { + public void testFillFields() { String hexData = "40 00 " + "1E F1 " + "10 00 00 00 " + @@ -61,8 +59,7 @@ assertEquals( 0x01, r.getColor4() ); } - public void testToString() throws Exception - { + public void testToString() { String nl = System.getProperty("line.separator"); String expected = "org.apache.poi.ddf.EscherSplitMenuColorsRecord:" + nl + @@ -76,7 +73,7 @@ assertEquals( expected, createRecord().toString() ); } - private EscherSplitMenuColorsRecord createRecord() + private static EscherSplitMenuColorsRecord createRecord() { EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord(); r.setOptions( (short) 0x0040 ); @@ -87,5 +84,4 @@ r.setColor4( 0x1 ); return r; } - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java Sat Sep 13 06:48:27 2008 @@ -24,8 +24,7 @@ public class TestUnknownEscherRecord extends TestCase { - public void testFillFields() throws Exception - { + public void testFillFields() { String testData = "0F 02 " + // options "11 F1 " + // record id @@ -82,15 +81,14 @@ } - public void testSerialize() throws Exception - { + public void testSerialize() { UnknownEscherRecord r = new UnknownEscherRecord(); r.setOptions( (short) 0x1234 ); r.setRecordId( (short) 0xF112 ); byte[] data = new byte[8]; r.serialize( 0, data, new NullEscherSerializationListener() ); - assertEquals( "[34, 12, 12, F1, 00, 00, 00, 00, ]", HexDump.toHex( data ) ); + assertEquals( "[34, 12, 12, F1, 00, 00, 00, 00]", HexDump.toHex( data ) ); EscherRecord childRecord = new UnknownEscherRecord(); childRecord.setOptions( (short) 0x9999 ); @@ -100,11 +98,10 @@ data = new byte[16]; r.serialize( 0, data, new NullEscherSerializationListener() ); - assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00, ]", HexDump.toHex( data ) ); + assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex( data ) ); } - public void testToString() throws Exception - { + public void testToString() { UnknownEscherRecord r = new UnknownEscherRecord(); r.setOptions( (short) 0x1234 ); r.setRecordId( (short) 0xF112 ); @@ -119,6 +116,4 @@ " numchildren: 0" + nl , r.toString() ); } - - } 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=694947&r1=694946&r2=694947&view=diff ============================================================================== Binary files - no diff available. Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/testRVA.xls URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/testRVA.xls?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== Binary files - no diff available. Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java Sat Sep 13 06:48:27 2008 @@ -22,10 +22,12 @@ import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.model.FormulaParser.FormulaParseException; +import org.apache.poi.hssf.record.constant.ErrorConstant; import org.apache.poi.hssf.record.formula.AbstractFunctionPtg; import org.apache.poi.hssf.record.formula.AddPtg; import org.apache.poi.hssf.record.formula.AreaI; import org.apache.poi.hssf.record.formula.AreaPtg; +import org.apache.poi.hssf.record.formula.ArrayPtg; import org.apache.poi.hssf.record.formula.AttrPtg; import org.apache.poi.hssf.record.formula.BoolPtg; import org.apache.poi.hssf.record.formula.ConcatPtg; @@ -48,6 +50,7 @@ import org.apache.poi.hssf.record.formula.UnaryMinusPtg; import org.apache.poi.hssf.record.formula.UnaryPlusPtg; import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFErrorConstants; import org.apache.poi.hssf.usermodel.HSSFName; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; @@ -862,4 +865,18 @@ assertEquals(65535, aptg.getLastRow()); } + public void testParseArray() { + Ptg[] ptgs; + ptgs = parseFormula("mode({1,2,2,#REF!;FALSE,3,3,2})"); + assertEquals(2, ptgs.length); + Ptg ptg0 = ptgs[0]; + assertEquals(ArrayPtg.class, ptg0.getClass()); + assertEquals("{1.0,2.0,2.0,#REF!;FALSE,3.0,3.0,2.0}", ptg0.toFormulaString(null)); + + ArrayPtg aptg = (ArrayPtg) ptg0; + Object[][] values = aptg.getTokenArrayValues(); + assertEquals(ErrorConstant.valueOf(HSSFErrorConstants.ERROR_REF), values[0][3]); + assertEquals(Boolean.FALSE, values[1][0]); + + } } \ No newline at end of file Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java Sat Sep 13 06:48:27 2008 @@ -85,7 +85,7 @@ sheet.createRow(32768).createCell(0).setCellValue(31); sheet.createRow(32769).createCell(0).setCellValue(11); - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue result; try { result = fe.evaluate(cell); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestRVA.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestRVA.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestRVA.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestRVA.java Sat Sep 13 06:48:27 2008 @@ -61,8 +61,10 @@ try { confirmCell(cell, formula, wb); } catch (AssertionFailedError e) { + System.out.flush(); System.err.println("Problem with row[" + rowIx + "] formula '" + formula + "'"); System.err.println(e.getMessage()); + System.err.flush(); countFailures++; } catch (RuntimeException e) { System.err.println("Problem with row[" + rowIx + "] formula '" + formula + "'"); @@ -104,8 +106,8 @@ if (excelPtg.getClass() != poiPtg.getClass()) { hasMismatch = true; sb.append(" mismatch token type[" + i + "] " + getShortClassName(excelPtg) + " " - + getOperandClassName(excelPtg) + " - " + getShortClassName(poiPtg) + " " - + getOperandClassName(poiPtg)); + + excelPtg.getRVAType() + " - " + getShortClassName(poiPtg) + " " + + poiPtg.getRVAType()); sb.append(NEW_LINE); continue; } @@ -113,16 +115,16 @@ continue; } sb.append(" token[" + i + "] " + excelPtg.toString() + " " - + getOperandClassName(excelPtg)); + + excelPtg.getRVAType()); if (excelPtg.getPtgClass() != poiPtg.getPtgClass()) { hasMismatch = true; - sb.append(" - was " + getOperandClassName(poiPtg)); + sb.append(" - was " + poiPtg.getRVAType()); } sb.append(NEW_LINE); } if (false) { // set 'true' to see trace of RVA values - System.out.println(formula); + System.out.println(formulaCell.getRowIndex() + " " + formula); System.out.println(sb.toString()); } if (hasMismatch) { @@ -135,14 +137,4 @@ int pos = cn.lastIndexOf('.'); return cn.substring(pos + 1); } - - private static String getOperandClassName(Ptg ptg) { - byte ptgClass = ptg.getPtgClass(); - switch (ptgClass) { - case Ptg.CLASS_REF: return "R"; - case Ptg.CLASS_VALUE: return "V"; - case Ptg.CLASS_ARRAY: return "A"; - } - throw new RuntimeException("Unknown operand class (" + ptgClass + ")"); - } } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheet.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheet.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheet.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheet.java Sat Sep 13 06:48:27 2008 @@ -214,7 +214,9 @@ records.add(new DimensionsRecord()); records.add(new RowRecord(0)); records.add(new RowRecord(1)); - records.add(new FormulaRecord()); + FormulaRecord formulaRecord = new FormulaRecord(); + formulaRecord.setCachedResultTypeString(); + records.add(formulaRecord); records.add(new StringRecord()); records.add(new RowRecord(2)); records.add(createWindow2Record()); @@ -357,7 +359,7 @@ xfindex = sheet.getXFIndexForColAt((short) 1); assertEquals(DEFAULT_IDX, xfindex); - ColumnInfoRecord nci = ColumnInfoRecordsAggregate.createColInfo(); + ColumnInfoRecord nci = new ColumnInfoRecord(); sheet._columnInfos.insertColumn(nci); // single column ColumnInfoRecord @@ -567,7 +569,7 @@ sheet.setMargin(HSSFSheet.LeftMargin, 0.3); try { - row.createCell((short) 0); + row.createCell(0); } catch (IllegalStateException e) { if (e.getMessage().equals("Cannot create value records before row records exist")) { throw new AssertionFailedError("Identified bug 45717"); @@ -576,4 +578,3 @@ } } } - Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java Sat Sep 13 06:48:27 2008 @@ -20,7 +20,6 @@ import junit.framework.TestCase; import org.apache.poi.hssf.record.ColumnInfoRecord; -import org.apache.poi.hssf.record.aggregates.ColumnInfoRecordsAggregate; /** * @author Tony Poppleton @@ -29,7 +28,7 @@ public void testGetCellWidth() { Sheet sheet = Sheet.createSheet(); - ColumnInfoRecord nci = ColumnInfoRecordsAggregate.createColInfo(); + ColumnInfoRecord nci = new ColumnInfoRecord(); // Prepare test model nci.setFirstColumn((short)5); @@ -55,5 +54,4 @@ assertEquals((short)100,sheet.getColumnWidth((short)9)); assertEquals((short)100,sheet.getColumnWidth((short)10)); } - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java Sat Sep 13 06:48:27 2008 @@ -22,14 +22,11 @@ import org.apache.poi.ddf.EscherSpRecord; import org.apache.poi.util.HexDump; -public class TestDrawingGroupRecord extends TestCase -{ - static final int MAX_RECORD_SIZE = 8228; +public final class TestDrawingGroupRecord extends TestCase { + private static final int MAX_RECORD_SIZE = 8228; private static final int MAX_DATA_SIZE = MAX_RECORD_SIZE - 4; - public void testGetRecordSize() - throws Exception - { + public void testGetRecordSize() { DrawingGroupRecord r = new DrawingGroupRecord(); assertEquals(4, r.getRecordSize()); @@ -48,7 +45,7 @@ byte[] data = new byte[28]; int size = r.serialize(0, data); - assertEquals("[EB, 00, 18, 00, 0F, 00, 00, F0, 10, 00, 00, 00, 11, 11, 0A, F0, 08, 00, 00, 00, FF, FF, FF, FF, FF, FF, FF, FF, ]", HexDump.toHex(data)); + assertEquals("[EB, 00, 18, 00, 0F, 00, 00, F0, 10, 00, 00, 00, 11, 11, 0A, F0, 08, 00, 00, 00, FF, FF, FF, FF, FF, FF, FF, FF]", HexDump.toHex(data)); assertEquals(28, size); assertEquals(24, dggContainer.getRecordSize()); @@ -65,8 +62,7 @@ assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() ); } - public void testSerialize() throws Exception - { + public void testSerialize() { // Check under max record size DrawingGroupRecord r = new DrawingGroupRecord(); byte[] rawData = new byte[100]; @@ -76,7 +72,7 @@ byte[] buffer = new byte[r.getRecordSize()]; int size = r.serialize( 0, buffer ); assertEquals( 104, size ); - assertEquals("[EB, 00, 64, 00, 64, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, C8, ]", HexDump.toHex(buffer)); + assertEquals("[EB, 00, 64, 00, 64, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, C8]", HexDump.toHex(buffer)); // check at max record size rawData = new byte[MAX_DATA_SIZE]; @@ -92,8 +88,8 @@ buffer = new byte[r.getRecordSize()]; size = r.serialize( 0, buffer ); assertEquals( MAX_RECORD_SIZE + 5, size ); - assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, 0, 4) )); - assertEquals( "[00, EB, 00, 01, 00, FF, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE - 1, MAX_RECORD_SIZE + 5) )); + assertEquals( "[EB, 00, 20, 20]", HexDump.toHex(cut(buffer, 0, 4) )); + assertEquals( "[00, EB, 00, 01, 00, FF]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE - 1, MAX_RECORD_SIZE + 5) )); // check continue record rawData = new byte[MAX_DATA_SIZE * 2 + 1]; @@ -103,9 +99,9 @@ size = r.serialize( 0, buffer ); assertEquals( MAX_RECORD_SIZE * 2 + 5, size ); assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() ); - assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, 0, 4) )); - assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE, MAX_RECORD_SIZE + 4) )); - assertEquals( "[3C, 00, 01, 00, FF, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE * 2, MAX_RECORD_SIZE * 2 + 5) )); + assertEquals( "[EB, 00, 20, 20]", HexDump.toHex(cut(buffer, 0, 4) )); + assertEquals( "[EB, 00, 20, 20]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE, MAX_RECORD_SIZE + 4) )); + assertEquals( "[3C, 00, 01, 00, FF]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE * 2, MAX_RECORD_SIZE * 2 + 5) )); // check continue record rawData = new byte[664532]; @@ -116,7 +112,7 @@ assertEquals( 664856, r.getRecordSize() ); } - private byte[] cut( byte[] data, int fromInclusive, int toExclusive ) + private static byte[] cut( byte[] data, int fromInclusive, int toExclusive ) { int length = toExclusive - fromInclusive; byte[] result = new byte[length]; @@ -124,8 +120,7 @@ return result; } - public void testGrossSizeFromDataSize() throws Exception - { + public void testGrossSizeFromDataSize() { for (int i = 0; i < MAX_RECORD_SIZE * 4; i += 11) { //System.out.print( "data size = " + i + ", gross size = " + DrawingGroupRecord.grossSizeFromDataSize( i ) ); @@ -139,6 +134,4 @@ assertEquals( MAX_RECORD_SIZE * 2, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 ) ); assertEquals( MAX_RECORD_SIZE * 2 + 5, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 + 1 ) ); } - - } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java Sat Sep 13 06:48:27 2008 @@ -133,7 +133,7 @@ byte[] data = new byte[112]; int bytesWritten = aggregate.serialize( 0, data ); assertEquals( 112, bytesWritten ); - assertEquals( "[EC, 00, 40, 00, 0F, 00, 00, 00, 58, 00, 00, 00, 0F, 00, 04, F0, 10, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, EC, 00, 20, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, ]", + assertEquals( "[EC, 00, 40, 00, 0F, 00, 00, 00, 58, 00, 00, 00, 0F, 00, 04, F0, 10, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, EC, 00, 20, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00]", HexDump.toHex( data ) ); } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java Sat Sep 13 06:48:27 2008 @@ -26,12 +26,14 @@ import org.apache.poi.hssf.record.formula.IntPtg; import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.record.formula.RefPtg; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFErrorConstants; /** * Tests the serialization and deserialization of the FormulaRecord - * class works correctly. + * class works correctly. * - * @author Andrew C. Oliver + * @author Andrew C. Oliver */ public final class TestFormulaRecord extends TestCase { @@ -40,52 +42,66 @@ record.setColumn((short)0); record.setRow(1); record.setXFIndex((short)4); - + assertEquals(record.getColumn(),0); assertEquals(record.getRow(), 1); assertEquals(record.getXFIndex(),4); } - + /** * Make sure a NAN value is preserved - * This formula record is a representation of =1/0 at row 0, column 0 + * This formula record is a representation of =1/0 at row 0, column 0 */ public void testCheckNanPreserve() { - byte[] formulaByte = new byte[29]; + byte[] formulaByte = { + 0, 0, 0, 0, + 0x0F, 0x00, + + // 8 bytes cached number is a 'special value' in this case + 0x02, // special cached value type 'error' + 0x00, + HSSFErrorConstants.ERROR_DIV_0, + 0x00, + 0x00, + 0x00, + (byte)0xFF, + (byte)0xFF, + + 0x00, + 0x00, + 0x00, + 0x00, + + (byte)0xE0, //18 + (byte)0xFC, + // Ptgs + 0x07, 0x00, // encoded length + 0x1E, 0x01, 0x00, // IntPtg(1) + 0x1E, 0x00, 0x00, // IntPtg(0) + 0x06, // DividePtg + + }; - formulaByte[4] = (byte)0x0F; - formulaByte[6] = (byte)0x02; - formulaByte[8] = (byte)0x07; - formulaByte[12] = (byte)0xFF; - formulaByte[13] = (byte)0xFF; - formulaByte[18] = (byte)0xE0; - formulaByte[19] = (byte)0xFC; - formulaByte[20] = (byte)0x07; - formulaByte[22] = (byte)0x1E; - formulaByte[23] = (byte)0x01; - formulaByte[25] = (byte)0x1E; - formulaByte[28] = (byte)0x06; - FormulaRecord record = new FormulaRecord(new TestcaseRecordInputStream(FormulaRecord.sid, (short)29, formulaByte)); assertEquals("Row", 0, record.getRow()); - assertEquals("Column", 0, record.getColumn()); - assertTrue("Value is not NaN", Double.isNaN(record.getValue())); - + assertEquals("Column", 0, record.getColumn()); + assertEquals(HSSFCell.CELL_TYPE_ERROR, record.getCachedResultType()); + byte[] output = record.serialize(); assertEquals("Output size", 33, output.length); //includes sid+recordlength - + for (int i = 5; i < 13;i++) { assertEquals("FormulaByte NaN doesn't match", formulaByte[i], output[i+4]); } } - + /** * Tests to see if the shared formula cells properly reserialize the expPtg * */ public void testExpFormula() { byte[] formulaByte = new byte[27]; - + formulaByte[4] =(byte)0x0F; formulaByte[14]=(byte)0x08; formulaByte[18]=(byte)0xE0; @@ -99,13 +115,13 @@ assertEquals("Output size", 31, output.length); //includes sid+recordlength assertEquals("Offset 22", 1, output[26]); } - + public void testWithConcat() { // =CHOOSE(2,A2,A3,A4) byte[] data = { 6, 0, 68, 0, 1, 0, 1, 0, 15, 0, 0, 0, 0, 0, 0, 0, 57, - 64, 0, 0, 12, 0, 12, -4, 46, 0, + 64, 0, 0, 12, 0, 12, -4, 46, 0, 30, 2, 0, // Int - 2 25, 4, 3, 0, // Attr 8, 0, 17, 0, 26, 0, // jumpTable @@ -115,14 +131,14 @@ 36, 2, 0, 0, -64, // Ref - A3 25, 8, 12, 0, // Attr 36, 3, 0, 0, -64, // Ref - A4 - 25, 8, 3, 0, // Attr + 25, 8, 3, 0, // Attr 66, 4, 100, 0 // CHOOSE }; RecordInputStream inp = new RecordInputStream( new ByteArrayInputStream(data)); inp.nextRecord(); - + FormulaRecord fr = new FormulaRecord(inp); - + Ptg[] ptgs = fr.getParsedExpression(); assertEquals(9, ptgs.length); assertEquals(IntPtg.class, ptgs[0].getClass()); @@ -134,7 +150,7 @@ assertEquals(RefPtg.class, ptgs[6].getClass()); assertEquals(AttrPtg.class, ptgs[7].getClass()); assertEquals(FuncVarPtg.class, ptgs[8].getClass()); - + FuncVarPtg choose = (FuncVarPtg)ptgs[8]; assertEquals("CHOOSE", choose.getName()); } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java Sat Sep 13 06:48:27 2008 @@ -17,9 +17,16 @@ package org.apache.poi.hssf.record.aggregates; +import java.util.ArrayList; +import java.util.List; + +import junit.framework.AssertionFailedError; import junit.framework.TestCase; + import org.apache.poi.hssf.record.ColumnInfoRecord; +import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.RecordBase; +import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor; /** * @author Glen Stampoultzis @@ -28,11 +35,11 @@ public void testGetRecordSize() { ColumnInfoRecordsAggregate agg = new ColumnInfoRecordsAggregate(); - agg.insertColumn(createColumn(1, 3)); - agg.insertColumn(createColumn(4, 7)); - agg.insertColumn(createColumn(8, 8)); + agg.insertColumn(createColInfo(1, 3)); + agg.insertColumn(createColInfo(4, 7)); + agg.insertColumn(createColInfo(8, 8)); agg.groupColumnRange((short) 2, (short) 5, true); - assertEquals(6, agg.getNumColumns()); + assertEquals(4, agg.getNumColumns()); confirmSerializedSize(agg); @@ -48,10 +55,91 @@ assertEquals(estimatedSize, serializedSize); } - private static ColumnInfoRecord createColumn(int firstCol, int lastCol) { + private static ColumnInfoRecord createColInfo(int firstCol, int lastCol) { ColumnInfoRecord columnInfoRecord = new ColumnInfoRecord(); columnInfoRecord.setFirstColumn((short) firstCol); columnInfoRecord.setLastColumn((short) lastCol); return columnInfoRecord; } -} \ No newline at end of file + + private static final class CIRCollector implements RecordVisitor { + + private List _list; + public CIRCollector() { + _list = new ArrayList(); + } + public void visitRecord(Record r) { + _list.add(r); + } + public static ColumnInfoRecord[] getRecords(ColumnInfoRecordsAggregate agg) { + CIRCollector circ = new CIRCollector(); + agg.visitContainedRecords(circ); + List list = circ._list; + ColumnInfoRecord[] result = new ColumnInfoRecord[list.size()]; + list.toArray(result); + return result; + } + } + + public void testGroupColumns_bug45639() { + ColumnInfoRecordsAggregate agg = new ColumnInfoRecordsAggregate(); + agg.groupColumnRange( 7, 9, true); + agg.groupColumnRange( 4, 12, true); + try { + agg.groupColumnRange( 1, 15, true); + } catch (ArrayIndexOutOfBoundsException e) { + throw new AssertionFailedError("Identified bug 45639"); + } + ColumnInfoRecord[] cirs = CIRCollector.getRecords(agg); + assertEquals(5, cirs.length); + confirmCIR(cirs, 0, 1, 3, 1, false, false); + confirmCIR(cirs, 1, 4, 6, 2, false, false); + confirmCIR(cirs, 2, 7, 9, 3, false, false); + confirmCIR(cirs, 3, 10, 12, 2, false, false); + confirmCIR(cirs, 4, 13, 15, 1, false, false); + } + + /** + * Check that an inner group remains hidden + */ + public void testHiddenAfterExpanding() { + ColumnInfoRecordsAggregate agg = new ColumnInfoRecordsAggregate(); + agg.groupColumnRange(1, 15, true); + agg.groupColumnRange(4, 12, true); + + ColumnInfoRecord[] cirs; + + // collapse both inner and outer groups + agg.collapseColumn(6); + agg.collapseColumn(3); + + cirs = CIRCollector.getRecords(agg); + assertEquals(5, cirs.length); + confirmCIR(cirs, 0, 1, 3, 1, true, false); + confirmCIR(cirs, 1, 4, 12, 2, true, false); + confirmCIR(cirs, 2, 13, 13, 1, true, true); + confirmCIR(cirs, 3, 14, 15, 1, true, false); + confirmCIR(cirs, 4, 16, 16, 0, false, true); + + // just expand the inner group + agg.expandColumn(6); + + cirs = CIRCollector.getRecords(agg); + assertEquals(4, cirs.length); + if (!cirs[1].getHidden()) { + throw new AssertionFailedError("Inner group should still be hidden"); + } + confirmCIR(cirs, 0, 1, 3, 1, true, false); + confirmCIR(cirs, 1, 4, 12, 2, true, false); + confirmCIR(cirs, 2, 13, 15, 1, true, false); + confirmCIR(cirs, 3, 16, 16, 0, false, true); + } + private static void confirmCIR(ColumnInfoRecord[] cirs, int ix, int startColIx, int endColIx, int level, boolean isHidden, boolean isCollapsed) { + ColumnInfoRecord cir = cirs[ix]; + assertEquals("startColIx", startColIx, cir.getFirstColumn()); + assertEquals("endColIx", endColIx, cir.getLastColumn()); + assertEquals("level", level, cir.getOutlineLevel()); + assertEquals("hidden", isHidden, cir.getHidden()); + assertEquals("collapsed", isCollapsed, cir.getCollapsed()); + } +} Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java Sat Sep 13 06:48:27 2008 @@ -30,6 +30,7 @@ public void testBasic() throws Exception { FormulaRecord f = new FormulaRecord(); + f.setCachedResultTypeString(); StringRecord s = new StringRecord(); s.setString("abc"); FormulaRecordAggregate fagg = new FormulaRecordAggregate(f, s, SharedValueManager.EMPTY); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java Sat Sep 13 06:48:27 2008 @@ -35,9 +35,8 @@ public final class TestArrayPtg extends TestCase { private static final byte[] ENCODED_PTG_DATA = { - 0x40, 0x00, - 0x08, 0x00, - 0, 0, 0, 0, 0, 0, 0, 0, + 0x40, + 0, 0, 0, 0, 0, 0, 0, }; private static final byte[] ENCODED_CONSTANT_DATA = { 2, // 3 columns @@ -60,15 +59,15 @@ ptg.readTokenValues(new TestcaseRecordInputStream(0, ENCODED_CONSTANT_DATA)); assertEquals(3, ptg.getColumnCount()); assertEquals(2, ptg.getRowCount()); - Object[] values = ptg.getTokenArrayValues(); - assertEquals(6, values.length); + Object[][] values = ptg.getTokenArrayValues(); + assertEquals(2, values.length); - assertEquals(Boolean.TRUE, values[0]); - assertEquals(new UnicodeString("ABCD"), values[1]); - assertEquals(new Double(0), values[3]); - assertEquals(Boolean.FALSE, values[4]); - assertEquals(new UnicodeString("FG"), values[5]); + assertEquals(Boolean.TRUE, values[0][0]); + assertEquals(new UnicodeString("ABCD"), values[0][1]); + assertEquals(new Double(0), values[1][0]); + assertEquals(Boolean.FALSE, values[1][1]); + assertEquals(new UnicodeString("FG"), values[1][2]); byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length]; ptg.writeTokenValueBytes(outBuf, 0); @@ -89,10 +88,10 @@ assertEquals(2, ptg.getRowCount()); assertEquals(0, ptg.getValueIndex(0, 0)); - assertEquals(2, ptg.getValueIndex(1, 0)); - assertEquals(4, ptg.getValueIndex(2, 0)); - assertEquals(1, ptg.getValueIndex(0, 1)); - assertEquals(3, ptg.getValueIndex(1, 1)); + assertEquals(1, ptg.getValueIndex(1, 0)); + assertEquals(2, ptg.getValueIndex(2, 0)); + assertEquals(3, ptg.getValueIndex(0, 1)); + assertEquals(4, ptg.getValueIndex(1, 1)); assertEquals(5, ptg.getValueIndex(2, 1)); } @@ -110,7 +109,7 @@ if (formula.equals("SUM({1.0,6.0,11.0;2.0,7.0,12.0;3.0,8.0,13.0;4.0,9.0,14.0;5.0,10.0,15.0})")) { throw new AssertionFailedError("Identified bug 42564 b"); } - assertEquals("SUM({1.0,2.0,3.0;4.0,5.0,6.0;7.0,8.0,9.0;10.0,11.0,12.0;13.0,14.0,15.0})", formula); + assertEquals("SUM({1.0,2.0,3.0,4.0,5.0;6.0,7.0,8.0,9.0,10.0;11.0,12.0,13.0,14.0,15.0})", formula); } public void testToFormulaString() { @@ -127,7 +126,7 @@ } throw e; } - assertEquals("{TRUE,\"ABCD\";\"E\",0.0;FALSE,\"FG\"}", actualFormula); + assertEquals("{TRUE,\"ABCD\",\"E\";0.0,FALSE,\"FG\"}", actualFormula); } /** @@ -150,6 +149,7 @@ RecordInputStream in = new TestcaseRecordInputStream(ArrayPtg.sid, fullData); Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in); + assertEquals(1, ptgs.length); ArrayPtg aPtg = (ArrayPtg) ptgs[0]; assertEquals(operandClass, aPtg.getPtgClass()); } 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=694947&r1=694946&r2=694947&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 Sat Sep 13 06:48:27 2008 @@ -74,7 +74,7 @@ public void testEvaluate() { HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls"); HSSFSheet sheet = wb.getSheetAt(0); - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(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, "YEARFRAC(B3,C3,D3)", 0.0); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculatorFromSpreadsheet.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculatorFromSpreadsheet.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculatorFromSpreadsheet.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/atp/TestYearFracCalculatorFromSpreadsheet.java Sat Sep 13 06:48:27 2008 @@ -56,7 +56,7 @@ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("yearfracExamples.xls"); HSSFSheet sheet = wb.getSheetAt(0); - HSSFFormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator(wb); int nSuccess = 0; int nFailures = 0; int nUnexpectedErrors = 0; Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java Sat Sep 13 06:48:27 2008 @@ -35,9 +35,9 @@ /** * Translates StackOverflowError into AssertionFailedError */ - private static CellValue evaluateWithCycles(HSSFWorkbook wb, HSSFSheet sheet, HSSFCell testCell) + private static CellValue evaluateWithCycles(HSSFWorkbook wb, HSSFCell testCell) throws AssertionFailedError { - HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); try { return evaluator.evaluate(testCell); } catch (StackOverflowError e) { @@ -75,7 +75,7 @@ // arguments before invoking operators, POI must handle such potential cycles gracefully. - CellValue cellValue = evaluateWithCycles(wb, sheet, testCell); + CellValue cellValue = evaluateWithCycles(wb, testCell); assertTrue(cellValue.getCellType() == HSSFCell.CELL_TYPE_NUMERIC); assertEquals(2, cellValue.getNumberValue(), 0); @@ -93,7 +93,7 @@ HSSFCell testCell = row.createCell(0); testCell.setCellFormula("A1"); - CellValue cellValue = evaluateWithCycles(wb, sheet, testCell); + CellValue cellValue = evaluateWithCycles(wb, testCell); confirmCycleErrorCode(cellValue); } @@ -113,7 +113,7 @@ HSSFCell testCell = row.createCell(3); testCell.setCellFormula("A1"); - CellValue cellValue = evaluateWithCycles(wb, sheet, testCell); + CellValue cellValue = evaluateWithCycles(wb, testCell); confirmCycleErrorCode(cellValue); } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestExternalFunction.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestExternalFunction.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestExternalFunction.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestExternalFunction.java Sat Sep 13 06:48:27 2008 @@ -65,7 +65,7 @@ String actualFormula=cell.getCellFormula(); assertEquals("myFunc()", actualFormula); - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue evalResult = fe.evaluate(cell); // Check the return value from ExternalFunction.evaluate() Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulaBugs.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulaBugs.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulaBugs.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulaBugs.java Sat Sep 13 06:48:27 2008 @@ -66,7 +66,7 @@ .getCellFormula()); // We might as well evaluate the formula - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue cv = fe.evaluate(cell); assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType()); @@ -111,7 +111,7 @@ } // use POI's evaluator as an extra sanity check - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue cv; cv = fe.evaluate(cell); assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType()); @@ -162,7 +162,7 @@ double expectedResult = (4.0 * 8.0 + 5.0 * 9.0) / 10.0; - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet1, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue cv = fe.evaluate(cell); assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType()); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulasFromSpreadsheet.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulasFromSpreadsheet.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulasFromSpreadsheet.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestFormulasFromSpreadsheet.java Sat Sep 13 06:48:27 2008 @@ -113,15 +113,6 @@ throw new AssertionFailedError(msg + " - actual value was null"); } - if (expected.getCellType() == Cell.CELL_TYPE_STRING) { - String value = expected.getRichStringCellValue().getString(); - if (value.startsWith("#")) { - // TODO - this code never called - expected.setCellType(Cell.CELL_TYPE_ERROR); - // expected.setCellErrorValue(...?); - } - } - switch (expected.getCellType()) { case Cell.CELL_TYPE_BLANK: assertEquals(msg, Cell.CELL_TYPE_BLANK, actual.getCellType()); @@ -132,32 +123,27 @@ break; case Cell.CELL_TYPE_ERROR: assertEquals(msg, Cell.CELL_TYPE_ERROR, actual.getCellType()); - if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values - assertEquals(msg, expected.getErrorCellValue(), actual.getErrorValue()); - } + assertEquals(msg, ErrorEval.getText(expected.getErrorCellValue()), ErrorEval.getText(actual.getErrorValue())); break; case Cell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation throw new AssertionFailedError("Cannot expect formula as result of formula evaluation: " + msg); case Cell.CELL_TYPE_NUMERIC: assertEquals(msg, Cell.CELL_TYPE_NUMERIC, actual.getCellType()); TestMathX.assertEquals(msg, expected.getNumericCellValue(), actual.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); -// double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue()); -// double pctExpected = Math.abs(0.00001*expected.getNumericCellValue()); -// assertTrue(msg, delta <= pctExpected); break; case Cell.CELL_TYPE_STRING: assertEquals(msg, Cell.CELL_TYPE_STRING, actual.getCellType()); - assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getRichTextStringValue().getString()); + assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue()); break; } } - protected void setUp() throws Exception { + protected void setUp() { if (workbook == null) { workbook = HSSFTestDataSamples.openSampleWorkbook(SS.FILENAME); sheet = workbook.getSheetAt( 0 ); - } + } _functionFailureCount = 0; _functionSuccessCount = 0; _evaluationFailureCount = 0; @@ -192,8 +178,7 @@ * Typically pass null to test all functions */ private void processFunctionGroup(int startRowIndex, String testFocusFunctionName) { - - FormulaEvaluator evaluator = new FormulaEvaluator(sheet, workbook); + FormulaEvaluator evaluator = new FormulaEvaluator(workbook); int rowIndex = startRowIndex; while (true) { @@ -263,7 +248,7 @@ result = Result.SOME_EVALUATIONS_FAILED; } } - return result; + return result; } /** Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java Sat Sep 13 06:48:27 2008 @@ -67,7 +67,7 @@ cell.setCellFormula("B1%"); row.createCell(1).setCellValue(50.0); - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue cv; try { cv = fe.evaluate(cell); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java Sat Sep 13 06:48:27 2008 @@ -34,6 +34,7 @@ result.addTestSuite(TestDate.class); result.addTestSuite(TestFinanceLib.class); result.addTestSuite(TestIndex.class); + result.addTestSuite(TestIndexFunctionFromSpreadsheet.class); result.addTestSuite(TestIsBlank.class); result.addTestSuite(TestLen.class); result.addTestSuite(TestLookupFunctionsFromSpreadsheet.class); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java Sat Sep 13 06:48:27 2008 @@ -27,14 +27,13 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval; /** * Tests for Excel function AVERAGE() - * + * * @author Josh Micich */ public final class TestAverage extends TestCase { - private static Eval invokeAverage(Eval[] args) { - return new Average().evaluate(args, -1, (short)-1); + return AggregateFunction.AVERAGE.evaluate(args, -1, (short)-1); } private void confirmAverage(Eval[] args, double expected) { @@ -48,56 +47,56 @@ assertEquals(ErrorEval.class, result.getClass()); assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode()); } - + public void testBasic() { - + ValueEval[] values = { - new NumberEval(1), - new NumberEval(2), - new NumberEval(3), - new NumberEval(4), + new NumberEval(1), + new NumberEval(2), + new NumberEval(3), + new NumberEval(4), }; - + confirmAverage(values, 2.5); - + values = new ValueEval[] { - new NumberEval(1), + new NumberEval(1), new NumberEval(2), BlankEval.INSTANCE, - new NumberEval(3), + new NumberEval(3), BlankEval.INSTANCE, - new NumberEval(4), + new NumberEval(4), BlankEval.INSTANCE, }; - + confirmAverage(values, 2.5); } - + /** * Valid cases where values are not pure numbers */ public void testUnusualArgs() { ValueEval[] values = { - new NumberEval(1), - new NumberEval(2), - BoolEval.TRUE, - BoolEval.FALSE, + new NumberEval(1), + new NumberEval(2), + BoolEval.TRUE, + BoolEval.FALSE, }; - + confirmAverage(values, 1.0); - + } // currently disabled because MultiOperandNumericFunction.getNumberArray(Eval[], int, short) // does not handle error values properly yet public void XtestErrors() { ValueEval[] values = { - new NumberEval(1), - ErrorEval.NAME_INVALID, - new NumberEval(3), - ErrorEval.DIV_ZERO, + new NumberEval(1), + ErrorEval.NAME_INVALID, + new NumberEval(3), + ErrorEval.DIV_ZERO, }; confirmAverage(values, ErrorEval.NAME_INVALID); - + } } Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java Sat Sep 13 06:48:27 2008 @@ -21,13 +21,11 @@ import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.hssf.record.formula.RefPtg; import org.apache.poi.hssf.record.formula.eval.AreaEval; import org.apache.poi.hssf.record.formula.eval.BlankEval; import org.apache.poi.hssf.record.formula.eval.BoolEval; 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.Ref2DEval; import org.apache.poi.hssf.record.formula.eval.StringEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate; @@ -270,7 +268,7 @@ int failureCount = 0; HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(FILE_NAME); HSSFSheet sheet = wb.getSheetAt(0); - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); int maxRow = sheet.getLastRowNum(); for (int rowIx=START_ROW_IX; rowIx Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestIsBlank.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestIsBlank.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestIsBlank.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestIsBlank.java Sat Sep 13 06:48:27 2008 @@ -44,7 +44,7 @@ cell.setCellFormula("isblank(Sheet2!A1:A1)"); - HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(sheet1, wb); + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); CellValue result = fe.evaluate(cell); assertEquals(HSSFCell.CELL_TYPE_BOOLEAN, result.getCellType()); assertEquals(true, result.getBooleanValue()); Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLen.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLen.java?rev=694947&r1=694946&r2=694947&view=diff ============================================================================== --- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLen.java (original) +++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/functions/TestLen.java Sat Sep 13 06:48:27 2008 @@ -35,7 +35,7 @@ private static Eval invokeLen(Eval text) { Eval[] args = new Eval[] { text, }; - return new Len().evaluate(args, -1, (short)-1); + return TextFunction.LEN.evaluate(args, -1, (short)-1); } private void confirmLen(Eval text, int expected) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org