fixed bug 51470 - avoid exception when cloning XSSF sheets with background images
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1148724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03fe1959f2
commit
77277a7acd
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.8-beta4" date="2011-??-??">
|
||||
<action dev="poi-developers" type="fix">51470 - avoid exception when cloning XSSF sheets with background images</action>
|
||||
<action dev="poi-developers" type="fix">51481 - Fixed autofilters in HSSF to avoid warnings in Excel 2007</action>
|
||||
<action dev="poi-developers" type="fix">51533 - Avoid exception when changing name of a sheet containing shared formulas</action>
|
||||
<action dev="poi-developers" type="add">Support for appending images to existing drawings in HSSF</action>
|
||||
|
@ -233,7 +233,7 @@ public class POIXMLDocumentPart {
|
||||
*
|
||||
* @param part the child to add
|
||||
*/
|
||||
protected final void addRelation(String id,POIXMLDocumentPart part){
|
||||
public final void addRelation(String id,POIXMLDocumentPart part){
|
||||
relations.put(id,part);
|
||||
part.incrementRelationCounter();
|
||||
}
|
||||
|
@ -385,6 +385,15 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
||||
}
|
||||
|
||||
clonedSheet.setSelected(false);
|
||||
|
||||
// copy sheet's relations
|
||||
List<POIXMLDocumentPart> rels = srcSheet.getRelations();
|
||||
for(POIXMLDocumentPart r : rels) {
|
||||
PackageRelationship rel = r.getPackageRelationship();
|
||||
clonedSheet.getPackagePart().addRelationship(rel.getTargetURI(), rel.getTargetMode(),rel.getRelationshipType());
|
||||
clonedSheet.addRelation(rel.getId(), r);
|
||||
}
|
||||
|
||||
return clonedSheet;
|
||||
}
|
||||
|
||||
|
@ -1157,4 +1157,16 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
// assertEquals("FFEEECE1", cA4_EEECE1.getCellStyle().getFillForegroundXSSFColor().getARGBHex());
|
||||
// assertEquals("FF1F497D", cA5_1F497D.getCellStyle().getFillForegroundXSSFColor().getARGBHex());
|
||||
}
|
||||
|
||||
public void test51470() throws Exception {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx");
|
||||
XSSFSheet sh0 = wb.getSheetAt(0);
|
||||
XSSFSheet sh1 = wb.cloneSheet(0);
|
||||
List<POIXMLDocumentPart> rels0 = sh0.getRelations();
|
||||
List<POIXMLDocumentPart> rels1 = sh1.getRelations();
|
||||
assertEquals(1, rels0.size());
|
||||
assertEquals(1, rels1.size());
|
||||
|
||||
assertEquals(rels0.get(0).getPackageRelationship(), rels1.get(0).getPackageRelationship());
|
||||
}
|
||||
}
|
||||
|
BIN
test-data/spreadsheet/51470.xlsx
Normal file
BIN
test-data/spreadsheet/51470.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user