Fix bug #51061 - Correct target URI for new XSSF Tables

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1092281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2011-04-14 14:29:04 +00:00
parent ade6735c43
commit b3fee7f7e6
4 changed files with 40 additions and 3 deletions

View File

@ -34,6 +34,7 @@
<changes> <changes>
<release version="3.8-beta3" date="2011-??-??"> <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="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="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> <action dev="poi-developers" type="add">Support for adding a table to a XSSFSheet</action>

View File

@ -138,14 +138,14 @@ public final class XSSFRelation extends POIXMLRelation {
public static final XSSFRelation SINGLE_XML_CELLS = new XSSFRelation( public static final XSSFRelation SINGLE_XML_CELLS = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml", "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells",
"/tables/tableSingleCells#.xml", "/xl/tables/tableSingleCells#.xml",
SingleXmlCells.class SingleXmlCells.class
); );
public static final XSSFRelation TABLE = new XSSFRelation( public static final XSSFRelation TABLE = new XSSFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml", "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",
"/tables/table#.xml", "/xl/tables/table#.xml",
Table.class Table.class
); );
@ -247,6 +247,12 @@ public final class XSSFRelation extends POIXMLRelation {
"/xl/calcChain.xml", "/xl/calcChain.xml",
CalculationChain.class 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) { private XSSFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {

View File

@ -3030,7 +3030,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
CTTableParts tblParts = worksheet.getTableParts(); CTTableParts tblParts = worksheet.getTableParts();
CTTablePart tbl = tblParts.addNewTablePart(); 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()); tbl.setId(table.getPackageRelationship().getId());
tables.put(tbl.getId(), table); tables.put(tbl.getId(), table);

View File

@ -924,6 +924,33 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
t = s3.getTables().get(0); t = s3.getTables().get(0);
assertEquals("New 3", t.getName()); assertEquals("New 3", t.getName());
assertEquals("New 3", t.getDisplayName()); 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()
);
} }
/** /**