poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r894081 - in /poi/trunk/src: java/org/apache/poi/hssf/model/InternalSheet.java testcases/org/apache/poi/hssf/record/TestFeatRecord.java testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java
Date Sun, 27 Dec 2009 17:13:45 GMT
Author: nick
Date: Sun Dec 27 17:13:44 2009
New Revision: 894081

URL: http://svn.apache.org/viewvc?rev=894081&view=rev
Log:
Make InternalSheet capture the feature related records

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java?rev=894081&r1=894080&r2=894081&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java Sun Dec 27 17:13:44 2009
@@ -35,6 +35,8 @@
 import org.apache.poi.hssf.record.DrawingRecord;
 import org.apache.poi.hssf.record.EOFRecord;
 import org.apache.poi.hssf.record.EscherAggregate;
+import org.apache.poi.hssf.record.FeatHdrRecord;
+import org.apache.poi.hssf.record.FeatRecord;
 import org.apache.poi.hssf.record.GridsetRecord;
 import org.apache.poi.hssf.record.GutsRecord;
 import org.apache.poi.hssf.record.IndexRecord;
@@ -265,6 +267,12 @@
                 continue;
             }
 
+            if (recSid == FeatRecord.sid ||
+            		recSid == FeatHdrRecord.sid) {
+                records.add(rec);
+                continue;
+            }
+            
             if (recSid == EOFRecord.sid) {
                 records.add(rec);
                 break;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java?rev=894081&r1=894080&r2=894081&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java Sun Dec 27 17:13:44
2009
@@ -18,7 +18,9 @@
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.model.InternalSheet;
 import org.apache.poi.hssf.model.InternalWorkbook;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFTestHelper;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
@@ -34,8 +36,12 @@
 			HSSFTestDataSamples.openSampleWorkbook("46136-WithWarnings.xls");
 		InternalWorkbook wb = HSSFTestHelper.getWorkbookForTest(hssf);
 		
+		assertEquals(1, hssf.getNumberOfSheets());
+		
 		int countFR = 0;
 		int countFRH = 0;
+		
+		// Check on the workbook, but shouldn't be there!
 		for(Record r : wb.getRecords()) {
 			if(r instanceof FeatRecord) {
 				countFR++;
@@ -51,19 +57,41 @@
 		
 		assertEquals(0, countFR);
 		assertEquals(0, countFRH);
+		
+		// Now check on the sheet
+		HSSFSheet s = hssf.getSheetAt(0);
+		InternalSheet sheet = HSSFTestHelper.getSheetForTest(s);
+		
+		for(RecordBase rb : sheet.getRecords()) {
+			if(rb instanceof Record) {
+				Record r = (Record)rb;
+				if(r instanceof FeatRecord) {
+					countFR++;
+				} else if (r.getSid() == FeatRecord.sid) {
+					countFR++;
+				}
+				if(r instanceof FeatHdrRecord) {
+					countFRH++;
+				} else if (r.getSid() == FeatHdrRecord.sid) {
+					countFRH++;
+				}
+			}
+		}
+		
+		assertEquals(0, countFR);
+		assertEquals(0, countFRH);
 	}
 
-	/**
-	 * TODO - make this work!
-	 * (Need to have the Internal Workbook capture it or something)
-	 */
-	public void DISABLEDtestReadFeatRecord() throws Exception {
+	public void testReadFeatRecord() throws Exception {
 		HSSFWorkbook hssf = 
 			HSSFTestDataSamples.openSampleWorkbook("46136-NoWarnings.xls");
 		InternalWorkbook wb = HSSFTestHelper.getWorkbookForTest(hssf);
 		
 		FeatRecord fr = null;
 		
+		assertEquals(1, hssf.getNumberOfSheets());
+		
+		// First check it isn't on the Workbook
 		int countFR = 0;
 		int countFRH = 0;
 		for(Record r : wb.getRecords()) {
@@ -80,6 +108,30 @@
 			}
 		}
 		
+		assertEquals(0, countFR);
+		assertEquals(0, countFRH);
+		
+		// Now find it on our sheet
+		HSSFSheet s = hssf.getSheetAt(0);
+		InternalSheet sheet = HSSFTestHelper.getSheetForTest(s);
+		
+		for(RecordBase rb : sheet.getRecords()) {
+			if(rb instanceof Record) {
+				Record r = (Record)rb;
+				if(r instanceof FeatRecord) {
+					fr = (FeatRecord)r;
+					countFR++;
+				} else if (r.getSid() == FeatRecord.sid) {
+					countFR++;
+				}
+				if(r instanceof FeatHdrRecord) {
+					countFRH++;
+				} else if (r.getSid() == FeatHdrRecord.sid) {
+					countFRH++;
+				}
+			}
+		}
+		
 		assertEquals(1, countFR);
 		assertEquals(1, countFRH);
 		assertNotNull(fr);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java?rev=894081&r1=894080&r2=894081&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java Sun Dec 27 17:13:44
2009
@@ -16,6 +16,7 @@
 ==================================================================== */
 
 package org.apache.poi.hssf.usermodel;
+import org.apache.poi.hssf.model.InternalSheet;
 import org.apache.poi.hssf.model.InternalWorkbook;
 
 /**
@@ -30,4 +31,7 @@
 	public static InternalWorkbook getWorkbookForTest(HSSFWorkbook wb) {
 		return wb.getWorkbook();
 	}
+	public static InternalSheet getSheetForTest(HSSFSheet sheet) {
+		return sheet.getSheet();
+	}
 }



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


Mime
View raw message