You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/09/21 13:33:22 UTC

svn commit: r999320 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/java/org/apache/poi/hssf/usermodel/HeaderFooter.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/48325.xls

Author: nick
Date: Tue Sep 21 11:33:21 2010
New Revision: 999320

URL: http://svn.apache.org/viewvc?rev=999320&view=rev
Log:
Apply patch+test from bug #48325 - If a HSSF header or footer lacks left/right/centre information, assume it is a centre one

Added:
    poi/trunk/test-data/spreadsheet/48325.xls   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HeaderFooter.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=999320&r1=999319&r2=999320&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Sep 21 11:33:21 2010
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-beta3" date="2010-??-??">
+           <action dev="poi-developers" type="fix">48325 - If a HSSF header or footer lacks left/right/centre information, assume it is a centre one</action>
            <action dev="poi-developers" type="fix">49966 - Correctly remove calcChain entries for XSSF cells that stop holding formulas</action>
            <action dev="poi-developers" type="add">47582 - XSSFCellStyle support for creating a style in one workbook based on a style from a different one</action>
            <action dev="poi-developers" type="fix">49931 - Avoid concurrency problems when re-ordering multiple HSSF header records for a PageSettingsBlock</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HeaderFooter.java?rev=999320&r1=999319&r2=999320&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HeaderFooter.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HeaderFooter.java Tue Sep 21 11:33:21 2010
@@ -40,7 +40,13 @@ public abstract class HeaderFooter imple
 		String _center = "";
 		String _right = "";
 
+outer:
 		while (text.length() > 1) {
+			if (text.charAt(0) != '&') {
+				// Mimics the behaviour of Excel, which would put it in the center.
+				_center = text;
+				break;
+			}
 			int pos = text.length();
 			switch (text.charAt(1)) {
 			case 'L':
@@ -74,7 +80,9 @@ public abstract class HeaderFooter imple
 				text = text.substring(pos);
 				break;
 			default:
-				throw new IllegalStateException("bad text '" + getRawText() + "'.");
+				// Mimics the behaviour of Excel, which would put it in the center.
+				_center = text;
+				break outer;
 			}
 		}
 		return new String[] { _left, _center, _right, };

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=999320&r1=999319&r2=999320&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Sep 21 11:33:21 2010
@@ -1868,4 +1868,22 @@ if(1==2) {
        assertEquals(1, wb.getNumberOfSheets());
        assertEquals("Foo", wb.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().toString());
     }
+    
+    /**
+     * Missing left/right/centre options on a footer
+     */
+    public void test48325() throws Exception {
+       HSSFWorkbook wb = openSample("48325.xls");
+       HSSFSheet sh = wb.getSheetAt(0);
+       HSSFFooter f = sh.getFooter();
+
+       // Will show as the centre, as that is what excel does
+       //  with an invalid footer lacking left/right/centre details
+       assertEquals("Left text should be empty", "", f.getLeft());
+       assertEquals("Right text should be empty", "", f.getRight());
+       assertEquals(
+             "Center text should contain the illegal value", 
+             "BlahBlah blah blah  ", f.getCenter()
+       );
+    }
 }

Added: poi/trunk/test-data/spreadsheet/48325.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/48325.xls?rev=999320&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/48325.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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