poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r782402 [8/8] - in /poi/tags/REL_3_5_BETA6: ./ src/contrib/src/org/apache/poi/contrib/poibrowser/ src/documentation/ src/documentation/content/xdocs/ src/documentation/content/xdocs/hpsf/ src/documentation/content/xdocs/news/ src/documentat...
Date Sun, 07 Jun 2009 15:39:55 GMT
Modified: poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java
(original)
+++ poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingsBlock.java
Sun Jun  7 15:39:51 2009
@@ -26,14 +26,18 @@
 import org.apache.poi.hssf.model.RecordStream;
 import org.apache.poi.hssf.model.Sheet;
 import org.apache.poi.hssf.record.BOFRecord;
+import org.apache.poi.hssf.record.BottomMarginRecord;
 import org.apache.poi.hssf.record.DimensionsRecord;
 import org.apache.poi.hssf.record.EOFRecord;
 import org.apache.poi.hssf.record.FooterRecord;
+import org.apache.poi.hssf.record.HCenterRecord;
 import org.apache.poi.hssf.record.HeaderRecord;
 import org.apache.poi.hssf.record.IndexRecord;
 import org.apache.poi.hssf.record.NumberRecord;
 import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.RecordFormatException;
 import org.apache.poi.hssf.record.UnknownRecord;
+import org.apache.poi.hssf.record.VCenterRecord;
 import org.apache.poi.hssf.record.WindowTwoRecord;
 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -135,7 +139,7 @@
 		Sheet sheet = Sheet.createSheet(rs);
 
 		RecordCollector rv = new RecordCollector();
-		sheet.visitContainedRecords(rv, rowIx);
+		sheet.visitContainedRecords(rv, 0);
 		Record[] outRecs = rv.getRecords();
 		if (outRecs[4] == EOFRecord.instance) {
 			throw new AssertionFailedError("Identified bug 46953 - EOF incorrectly appended to PSB");
@@ -151,8 +155,122 @@
 		assertEquals(WindowTwoRecord.class, outRecs[6].getClass());
 		assertEquals(EOFRecord.instance, outRecs[7]);
 	}
+	/**
+	 * Bug 47199 was due to the margin records being located well after the initial PSB records.
+	 * The example file supplied (attachment 23710) had three non-PSB record types 
+	 * between the PRINTSETUP record and first MARGIN record:
+	 * <ul>
+	 * <li>PRINTSETUP(0x00A1)</li>
+	 * <li>DEFAULTCOLWIDTH(0x0055)</li>
+	 * <li>COLINFO(0x007D)</li>
+	 * <li>DIMENSIONS(0x0200)</li>
+	 * <li>BottomMargin(0x0029)</li>
+	 * </ul>
+	 */
+	public void testLateMargins_bug47199() {
+
+		Record[] recs = {
+				BOFRecord.createSheetBOF(),
+				new HeaderRecord("&LSales Figures"),
+				new FooterRecord("&LJanuary"),
+				new DimensionsRecord(),
+				createBottomMargin(0.787F),
+				new WindowTwoRecord(),
+				EOFRecord.instance,
+		};
+		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
+
+		Sheet sheet;
+		try {
+			sheet = Sheet.createSheet(rs);
+		} catch (RuntimeException e) {
+			if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
+				throw new AssertionFailedError("Identified bug 47199a - failed to process late margings
records");
+			}
+			throw e;
+		}
+
+		RecordCollector rv = new RecordCollector();
+		sheet.visitContainedRecords(rv, 0);
+		Record[] outRecs = rv.getRecords();
+		assertEquals(recs.length+1, outRecs.length); // +1 for index record
+
+		assertEquals(BOFRecord.class, outRecs[0].getClass());
+		assertEquals(IndexRecord.class, outRecs[1].getClass());
+		assertEquals(HeaderRecord.class, outRecs[2].getClass());
+		assertEquals(FooterRecord.class, outRecs[3].getClass());
+		assertEquals(DimensionsRecord.class, outRecs[5].getClass());
+		assertEquals(WindowTwoRecord.class, outRecs[6].getClass());
+		assertEquals(EOFRecord.instance, outRecs[7]);
+	}
+
+	private Record createBottomMargin(float value) {
+		BottomMarginRecord result = new BottomMarginRecord();
+		result.setMargin(value);
+		return result;
+	}
+
+	/**
+	 * The PageSettingsBlock should not allow multiple copies of the same record.  This extra
assertion
+	 * was added while fixing bug 47199.  All existing POI test samples comply with this requirement.
+	 */
+	public void testDuplicatePSBRecord_bug47199() {
+
+		// Hypothetical setup of PSB records which should cause POI to crash
+		Record[] recs = {
+				new HeaderRecord("&LSales Figures"),
+				new HeaderRecord("&LInventory"),
+		};
+		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
+
+		try {
+			new PageSettingsBlock(rs);
+			throw new AssertionFailedError("Identified bug 47199b - duplicate PSB records should not
be allowed");
+		} catch (RecordFormatException e) {
+			if (e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x14)")) {
+				// expected during successful test
+			} else {
+				throw new AssertionFailedError("Expected RecordFormatException due to duplicate PSB record");
+			}
+		}
+	}
 
 	private static UnknownRecord ur(int sid, String hexData) {
 		return new UnknownRecord(sid, HexRead.readFromString(hexData));
 	}
+	
+	/**
+	 * Excel tolerates missing header / footer records, but adds them (empty) in when re-saving.
+	 * This is not critical functionality but it has been decided to keep POI consistent with
+	 * Excel in this regard.
+	 */
+	public void testMissingHeaderFooter() {
+		// initialise PSB with some records, but not the header / footer
+		Record[] recs = {
+				new HCenterRecord(),
+				new VCenterRecord(),
+		};
+		RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
+		PageSettingsBlock psb = new PageSettingsBlock(rs);
+
+		// serialize the PSB to see what records come out
+		RecordCollector rc = new RecordCollector();
+		psb.visitContainedRecords(rc);
+		Record[] outRecs = rc.getRecords();
+		
+		if (outRecs.length == 2) {
+			throw new AssertionFailedError("PageSettingsBlock didn't add missing header/footer records");
+		}
+		assertEquals(4, outRecs.length);
+		assertEquals(HeaderRecord.class, outRecs[0].getClass());
+		assertEquals(FooterRecord.class, outRecs[1].getClass());
+		assertEquals(HCenterRecord.class, outRecs[2].getClass());
+		assertEquals(VCenterRecord.class, outRecs[3].getClass());
+		
+		// make sure the added header / footer records are empty 
+		HeaderRecord hr = (HeaderRecord) outRecs[0];
+		assertEquals("", hr.getText());
+		FooterRecord fr = (FooterRecord) outRecs[1];
+		assertEquals("", fr.getText());
+	}
 }

Modified: poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sun Jun
 7 15:39:51 2009
@@ -17,16 +17,20 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 
+import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.OldExcelFormatException;
-import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.model.Workbook;
 import org.apache.poi.hssf.record.CellValueRecordInterface;
 import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
@@ -34,11 +38,7 @@
 import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
 import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
 import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.RichTextString;
-import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
-import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.TempFile;
 
 /**
@@ -1247,16 +1247,18 @@
     }
 
     /**
-     * header / footer text too long
+     * The resolution for bug 45777 assumed that the maximum text length in a header / footer
+     * record was 256 bytes.  This assumption appears to be wrong.  Since the fix for bug
47244,
+     * POI now supports header / footer text lengths beyond 256 bytes.  
      */
     public void test45777() {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet s = wb.createSheet();
 
-        String s248 = "";
-        for(int i=0; i<248; i++) {
-            s248 += "x";
-        }
+        char[] cc248 = new char[248];
+        Arrays.fill(cc248, 'x');
+        String s248 = new String(cc248);
+
         String s249 = s248 + "1";
         String s250 = s248 + "12";
         String s251 = s248 + "123";
@@ -1268,42 +1270,45 @@
 
         // Try on headers
         s.getHeader().setCenter(s248);
-        assertEquals(254, s.getHeader().getRawHeader().length());
+        assertEquals(254, s.getHeader().getRawText().length());
         writeOutAndReadBack(wb);
 
-        s.getHeader().setCenter(s249);
-        assertEquals(255, s.getHeader().getRawHeader().length());
+        s.getHeader().setCenter(s251);
+        assertEquals(257, s.getHeader().getRawText().length());
         writeOutAndReadBack(wb);
 
         try {
-            s.getHeader().setCenter(s250); // 256
-            fail();
-        } catch(IllegalArgumentException e) {}
+            s.getHeader().setCenter(s250); // 256 bytes required
+        } catch(IllegalArgumentException e) {
+            throw new AssertionFailedError("Identified bug 47244b - header can be more than
256 bytes");
+        }
 
         try {
-            s.getHeader().setCenter(s251); // 257
-            fail();
-        } catch(IllegalArgumentException e) {}
-
+            s.getHeader().setCenter(s251); // 257 bytes required
+        } catch(IllegalArgumentException e) {
+            throw new AssertionFailedError("Identified bug 47244b - header can be more than
256 bytes");
+        }
 
         // Now try on footers
         s.getFooter().setCenter(s248);
-        assertEquals(254, s.getFooter().getRawFooter().length());
+        assertEquals(254, s.getFooter().getRawText().length());
         writeOutAndReadBack(wb);
 
-        s.getFooter().setCenter(s249);
-        assertEquals(255, s.getFooter().getRawFooter().length());
+        s.getFooter().setCenter(s251);
+        assertEquals(257, s.getFooter().getRawText().length());
         writeOutAndReadBack(wb);
 
         try {
-            s.getFooter().setCenter(s250); // 256
-            fail();
-        } catch(IllegalArgumentException e) {}
+            s.getFooter().setCenter(s250); // 256 bytes required
+        } catch(IllegalArgumentException e) {
+            throw new AssertionFailedError("Identified bug 47244b - footer can be more than
256 bytes");
+        }
 
         try {
-            s.getFooter().setCenter(s251); // 257
-            fail();
-        } catch(IllegalArgumentException e) {}
+            s.getFooter().setCenter(s251); // 257 bytes required
+        } catch(IllegalArgumentException e) {
+            throw new AssertionFailedError("Identified bug 47244b - footer can be more than
256 bytes");
+        }
     }
 
     /**
@@ -1469,24 +1474,24 @@
      * java.io.IOException: block[ 0 ] already removed
      * (is an excel 95 file though)
      */
-    public void test46904() throws IOException {
-    	try {
-    		HSSFWorkbook wb = openSample("46904.xls");
-    		fail();
-    	} catch(OldExcelFormatException e) {
-    		assertTrue(e.getMessage().startsWith(
-    				"The supplied spreadsheet seems to be Excel"
-    		));
-    	}
+    public void test46904() {
+        try {
+            openSample("46904.xls");
+            fail();
+        } catch(OldExcelFormatException e) {
+            assertTrue(e.getMessage().startsWith(
+                    "The supplied spreadsheet seems to be Excel"
+            ));
+        }
     }
     
     /**
      * java.lang.NegativeArraySizeException reading long
      *  non-unicode data for a name record
      */
-    public void test47034() throws IOException {
-		HSSFWorkbook wb = openSample("47034.xls");
-		assertEquals(893, wb.getNumberOfNames());
-		assertEquals("Matthew\\Matthew11_1\\Matthew2331_1\\Matthew2351_1\\Matthew2361_1___lab",
wb.getNameName(300));
+    public void test47034() {
+        HSSFWorkbook wb = openSample("47034.xls");
+        assertEquals(893, wb.getNumberOfNames());
+        assertEquals("Matthew\\Matthew11_1\\Matthew2331_1\\Matthew2351_1\\Matthew2361_1___lab",
wb.getNameName(300));
     }
 }

Modified: poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java
(original)
+++ poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java
Sun Jun  7 15:39:51 2009
@@ -17,43 +17,43 @@
 
 package org.apache.poi.hssf.usermodel;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 
 /**
- * Tests row shifting capabilities.
- *
+ * Tests for {@link HSSFHeader} / {@link HSSFFooter}
  *
  * @author Shawn Laubach (slaubach at apache dot com)
  */
 public final class TestHSSFHeaderFooter extends TestCase {
 
 	/**
-	 * Tests that get header retreives the proper values.
+	 * Tests that get header retrieves the proper values.
 	 *
 	 * @author Shawn Laubach (slaubach at apache dot org)
 	 */
 	public void testRetrieveCorrectHeader() {
-		// Read initial file in
+
 		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("EmbeddedChartHeaderTest.xls");
 		HSSFSheet s = wb.getSheetAt( 0 );
-    	HSSFHeader head = s.getHeader();
-    
-    	assertEquals("Top Left", head.getLeft());
-    	assertEquals("Top Center", head.getCenter());
-    	assertEquals("Top Right", head.getRight());
+		HSSFHeader head = s.getHeader();
+
+		assertEquals("Top Left", head.getLeft());
+		assertEquals("Top Center", head.getCenter());
+		assertEquals("Top Right", head.getRight());
 	}
-	
+
 	public void testSpecialChars() {
 		assertEquals("&U", HSSFHeader.startUnderline());
 		assertEquals("&U", HSSFHeader.endUnderline());
 		assertEquals("&P", HSSFHeader.page());
-		
+
 		assertEquals("&22", HSSFFooter.fontSize((short)22));
 		assertEquals("&\"Arial,bold\"", HSSFFooter.font("Arial", "bold"));
 	}
-	
+
 	public void testStripFields() {
 		String simple = "I am a test header";
 		String withPage = "I am a&P test header";
@@ -61,54 +61,51 @@
 		String withFont = "I&22 am a&\"Arial,bold\" test header";
 		String withOtherAnds = "I am a&P test header&&";
 		String withOtherAnds2 = "I am a&P test header&a&b";
-		
+
 		assertEquals(simple, HSSFHeader.stripFields(simple));
 		assertEquals(simple, HSSFHeader.stripFields(withPage));
 		assertEquals(simple, HSSFHeader.stripFields(withLots));
 		assertEquals(simple, HSSFHeader.stripFields(withFont));
 		assertEquals(simple + "&&", HSSFHeader.stripFields(withOtherAnds));
 		assertEquals(simple + "&a&b", HSSFHeader.stripFields(withOtherAnds2));
-		
+
 		// Now test the default strip flag
 		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("EmbeddedChartHeaderTest.xls");
 		HSSFSheet s = wb.getSheetAt( 0 );
-    	HSSFHeader head = s.getHeader();
-    
-    	assertEquals("Top Left", head.getLeft());
-    	assertEquals("Top Center", head.getCenter());
-    	assertEquals("Top Right", head.getRight());
-    	
-    	head.setLeft("Top &P&F&D Left");
-    	assertEquals("Top &P&F&D Left", head.getLeft());
-    	assertFalse(head.areFieldsStripped());
-    	
-    	head.setAreFieldsStripped(true);
-    	assertEquals("Top  Left", head.getLeft());
-    	assertTrue(head.areFieldsStripped());
-    	
-    	// Now even more complex
-    	head.setCenter("HEADER TEXT &P&N&D&T&Z&F&F&A&G&X
END");
-    	assertEquals("HEADER TEXT  END", head.getCenter());
+		HSSFHeader head = s.getHeader();
+
+		assertEquals("Top Left", head.getLeft());
+		assertEquals("Top Center", head.getCenter());
+		assertEquals("Top Right", head.getRight());
+
+		head.setLeft("Top &P&F&D Left");
+		assertEquals("Top &P&F&D Left", head.getLeft());
+
+		assertEquals("Top  Left", HeaderFooter.stripFields(head.getLeft()));
+
+		// Now even more complex
+		head.setCenter("HEADER TEXT &P&N&D&T&Z&F&F&A&G&X
END");
+		assertEquals("HEADER TEXT  END",  HeaderFooter.stripFields(head.getCenter()));
 	}
 
 	/**
-	 * Tests that get header retreives the proper values.
+	 * Tests that get header retrieves the proper values.
 	 *
 	 * @author Shawn Laubach (slaubach at apache dot org)
 	 */
 	public void testRetrieveCorrectFooter() {
-		// Read initial file in
+
 		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("EmbeddedChartHeaderTest.xls");
-		HSSFSheet s = wb.getSheetAt( 0 );
-    	HSSFFooter foot = s.getFooter();
-    
-    	assertEquals("Bottom Left", foot.getLeft());
-    	assertEquals("Bottom Center", foot.getCenter());
-    	assertEquals("Bottom Right", foot.getRight());
+		HSSFSheet s = wb.getSheetAt(0);
+		HSSFFooter foot = s.getFooter();
+
+		assertEquals("Bottom Left", foot.getLeft());
+		assertEquals("Bottom Center", foot.getCenter());
+		assertEquals("Bottom Right", foot.getRight());
 	}
-	
+
 	/**
-	 * Testcase for Bug 17039 HSSFHeader  doesnot support DBCS 
+	 * Testcase for Bug 17039 HSSFHeader  does not support DBCS
 	 */
 	public void testHeaderHas16bitCharacter() {
 		HSSFWorkbook b = new HSSFWorkbook();
@@ -117,17 +114,17 @@
 		h.setLeft("\u0391");
 		h.setCenter("\u0392");
 		h.setRight("\u0393");
-		
+
 		HSSFWorkbook b2 = HSSFTestDataSamples.writeOutAndReadBack(b);
 		HSSFHeader h2 = b2.getSheet("Test").getHeader();
-		
+
 		assertEquals(h2.getLeft(),"\u0391");
 		assertEquals(h2.getCenter(),"\u0392");
 		assertEquals(h2.getRight(),"\u0393");
 	}
-	
+
 	/**
-	 * Testcase for Bug 17039 HSSFFooter doesnot support DBCS 
+	 * Testcase for Bug 17039 HSSFFooter does not support DBCS
 	 */
 	 public void testFooterHas16bitCharacter() {
 		HSSFWorkbook b = new HSSFWorkbook();
@@ -136,10 +133,10 @@
 		f.setLeft("\u0391");
 		f.setCenter("\u0392");
 		f.setRight("\u0393");
-		
+
 		HSSFWorkbook b2 = HSSFTestDataSamples.writeOutAndReadBack(b);
 		HSSFFooter f2 = b2.getSheet("Test").getFooter();
-		
+
 		assertEquals(f2.getLeft(),"\u0391");
 		assertEquals(f2.getCenter(),"\u0392");
 		assertEquals(f2.getRight(),"\u0393");
@@ -152,11 +149,38 @@
 		assertEquals("Header Left " ,h.getLeft(),"\u090f\u0915");
 		assertEquals("Header Center " ,h.getCenter(),"\u0939\u094b\u0917\u093e");
 		assertEquals("Header Right " ,h.getRight(),"\u091c\u093e");
-		
+
 		HSSFFooter f = s.getFooter();
 		assertEquals("Footer Left " ,f.getLeft(),"\u091c\u093e");
 		assertEquals("Footer Center " ,f.getCenter(),"\u091c\u093e");
 		assertEquals("Footer Right " ,f.getRight(),"\u091c\u093e");
 	}
-}
 
+	/**
+	 * Excel tolerates files with missing HEADER/FOOTER records.  POI should do the same.
+	 */
+	public void testMissingHeaderFooterRecord_bug47244() {
+		// noHeaderFooter47244.xls was created by a slightly modified POI
+		// which omitted the HEADER/FOOTER records
+		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("noHeaderFooter47244.xls");
+		HSSFSheet sheet = wb.getSheetAt(0);
+		HSSFFooter footer;
+		try {
+			footer = sheet.getFooter();
+		} catch (NullPointerException e) {
+			throw new AssertionFailedError("Identified bug 47244a");
+		}
+		assertEquals("", footer.getRawText());
+		HSSFHeader header = sheet.getHeader();
+		assertEquals("", header.getRawText());
+
+		// make sure header / footer is properly linked to underlying data 
+		HSSFHeader header2 = sheet.getHeader();
+		header.setCenter("foo");
+		assertEquals("foo", header2.getCenter());
+
+		HSSFFooter footer2 = sheet.getFooter();
+		footer.setCenter("bar");
+		assertEquals("bar", footer2.getCenter());
+	}
+}

Modified: poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/ss/util/TestCellReference.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/ss/util/TestCellReference.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/ss/util/TestCellReference.java (original)
+++ poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/ss/util/TestCellReference.java Sun
Jun  7 15:39:51 2009
@@ -17,15 +17,17 @@
 
 package org.apache.poi.ss.util;
 
+import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.util.CellReference;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 
 /**
  * Tests that the common CellReference works as we need it to
  */
-public class TestCellReference extends TestCase {
+public final class TestCellReference extends TestCase {
 	
 	public void testGetCellRefParts() {
 		CellReference cellReference;
@@ -168,4 +170,35 @@
 		String collRef4 = new CellReference(0, col4).formatAsString();
 		assertEquals("CBA1", collRef4);
 	}
+
+	public void testBadRowNumber() {
+		SpreadsheetVersion v97 = SpreadsheetVersion.EXCEL97;
+		SpreadsheetVersion v2007 = SpreadsheetVersion.EXCEL2007;
+
+		confirmCrInRange(true, "A", "1", v97);
+		confirmCrInRange(true, "IV", "65536", v97);
+		confirmCrInRange(false, "IV", "65537", v97);
+		confirmCrInRange(false, "IW", "65536", v97);
+
+		confirmCrInRange(true, "A", "1", v2007);
+		confirmCrInRange(true, "XFD", "1048576", v2007);
+		confirmCrInRange(false, "XFD", "1048577", v2007);
+		confirmCrInRange(false, "XFE", "1048576", v2007);
+
+		if (CellReference.cellReferenceIsWithinRange("B", "0", v97)) {
+			throw new AssertionFailedError("Identified bug 47312a");
+		}
+
+		confirmCrInRange(false, "A", "0", v97);
+		confirmCrInRange(false, "A", "0", v2007);
+	}
+
+	private static void confirmCrInRange(boolean expResult, String colStr, String rowStr,
+			SpreadsheetVersion sv) {
+		if (expResult == CellReference.cellReferenceIsWithinRange(colStr, rowStr, sv)) {
+			return;
+		}
+		throw new AssertionFailedError("expected (c='" + colStr + "', r='" + rowStr + "' to be
"
+				+ (expResult ? "within" : "out of") + " bounds for version " + sv.name());
+	}
 }

Modified: poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/util/AllPOIUtilTests.java
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/util/AllPOIUtilTests.java?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/util/AllPOIUtilTests.java (original)
+++ poi/tags/REL_3_5_BETA6/src/testcases/org/apache/poi/util/AllPOIUtilTests.java Sun Jun
 7 15:39:51 2009
@@ -35,8 +35,6 @@
         result.addTestSuite(TestHexDump.class);
         result.addTestSuite(TestIntegerField.class);
         result.addTestSuite(TestIntList.class);
-        result.addTestSuite(TestIntList2d.class);
-        result.addTestSuite(TestList2d.class);
         result.addTestSuite(TestLittleEndian.class);
         result.addTestSuite(TestLongField.class);
         result.addTestSuite(TestPOILogFactory.class);

Modified: poi/tags/REL_3_5_BETA6/src/types/styles/hdftype_document.xsl
URL: http://svn.apache.org/viewvc/poi/tags/REL_3_5_BETA6/src/types/styles/hdftype_document.xsl?rev=782402&r1=782401&r2=782402&view=diff
==============================================================================
--- poi/tags/REL_3_5_BETA6/src/types/styles/hdftype_document.xsl (original)
+++ poi/tags/REL_3_5_BETA6/src/types/styles/hdftype_document.xsl Sun Jun  7 15:39:51 2009
@@ -50,7 +50,6 @@
     <footer>
         <legal>
           Copyright (c) @year@ The Poi Project All rights reserved.
-          $Revision$ $Date$
         </legal>
     </footer>
 



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


Mime
View raw message