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 2011/04/14 16:29:04 UTC

svn commit: r1092281 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/

Author: nick
Date: Thu Apr 14 14:29:04 2011
New Revision: 1092281

URL: http://svn.apache.org/viewvc?rev=1092281&view=rev
Log:
Fix bug #51061 - Correct target URI for new XSSF Tables

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.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=1092281&r1=1092280&r2=1092281&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Apr 14 14:29:04 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta3" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51061 - Correct target URI for new XSSF Tables</action>
            <action dev="poi-developers" type="add">Initial support for XSSF Charts. Provides easy access to the underlying CTChart object via the Sheet Drawing, but no high level interface onto the chart contents as yet.</action>
            <action dev="poi-developers" type="fix">50884 - XSSF and HSSF freeze panes now behave the same</action>
            <action dev="poi-developers" type="add">Support for adding a table to a XSSFSheet</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java?rev=1092281&r1=1092280&r2=1092281&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java Thu Apr 14 14:29:04 2011
@@ -138,14 +138,14 @@ public final class XSSFRelation extends 
 	public static final XSSFRelation SINGLE_XML_CELLS = new XSSFRelation(
 			"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml",
 			"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells",
-			"/tables/tableSingleCells#.xml",
+			"/xl/tables/tableSingleCells#.xml",
 			SingleXmlCells.class
 	);
 
 	public static final XSSFRelation TABLE = new XSSFRelation(
 			"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",
 			"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",
-			"/tables/table#.xml",
+			"/xl/tables/table#.xml",
 			Table.class
 	);
 
@@ -247,6 +247,12 @@ public final class XSSFRelation extends 
             "/xl/calcChain.xml",
             CalculationChain.class
     );
+    public static final XSSFRelation PRINTER_SETTINGS = new XSSFRelation(
+          "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings",
+          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings",
+          "/xl/printerSettings/printerSettings#.bin",
+          null
+   );
 
 
 	private XSSFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1092281&r1=1092280&r2=1092281&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Thu Apr 14 14:29:04 2011
@@ -3030,7 +3030,10 @@ public class XSSFSheet extends POIXMLDoc
        CTTableParts tblParts = worksheet.getTableParts();
        CTTablePart tbl = tblParts.addNewTablePart();
        
-       Table table = (Table)createRelationship(XSSFRelation.TABLE, XSSFFactory.getInstance(), tblParts.sizeOfTablePartArray());
+       // Table numbers need to be unique in the file, not just
+       //  unique within the sheet. Find the next one
+       int tableNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.TABLE.getContentType()).size() + 1;
+       Table table = (Table)createRelationship(XSSFRelation.TABLE, XSSFFactory.getInstance(), tableNumber);
        tbl.setId(table.getPackageRelationship().getId());
        
        tables.put(tbl.getId(), table);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1092281&r1=1092280&r2=1092281&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Thu Apr 14 14:29:04 2011
@@ -924,6 +924,33 @@ public final class TestXSSFBugs extends 
        t = s3.getTables().get(0);
        assertEquals("New 3", t.getName());
        assertEquals("New 3", t.getDisplayName());
+       
+       // Check the relationships
+       assertEquals(0, s1.getRelations().size());
+       assertEquals(3, s2.getRelations().size());
+       assertEquals(1, s3.getRelations().size());
+       assertEquals(0, s4.getRelations().size());
+       
+       assertEquals(
+             XSSFRelation.PRINTER_SETTINGS.getContentType(), 
+             s2.getRelations().get(0).getPackagePart().getContentType()
+       );
+       assertEquals(
+             XSSFRelation.TABLE.getContentType(), 
+             s2.getRelations().get(1).getPackagePart().getContentType()
+       );
+       assertEquals(
+             XSSFRelation.TABLE.getContentType(), 
+             s2.getRelations().get(2).getPackagePart().getContentType()
+       );
+       assertEquals(
+             XSSFRelation.TABLE.getContentType(), 
+             s3.getRelations().get(0).getPackagePart().getContentType()
+       );
+       assertEquals(
+             "/xl/tables/table3.xml",
+             s3.getRelations().get(0).getPackagePart().getPartName().toString()
+       );
     }
     
     /**



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