diff options
author | Yegor Kozlov <yegor@apache.org> | 2011-07-20 12:29:27 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2011-07-20 12:29:27 +0000 |
commit | 31624647c29cec6f858bbfe29c79e0323fd7ac74 (patch) | |
tree | a21a7b38af3f8bf8ec17e2c13b6e4628afe42d1f /src/ooxml/java | |
parent | 0b356585f5d9aeaf3f4a8c2ee4094578fb2b184f (diff) | |
download | poi-31624647c29cec6f858bbfe29c79e0323fd7ac74.tar.gz poi-31624647c29cec6f858bbfe29c79e0323fd7ac74.zip |
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
Diffstat (limited to 'src/ooxml/java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java | 2 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java b/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java index d81391035d..311573618a 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java +++ b/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java @@ -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(); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index d8689d87ad..9b0c7219af 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -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; } |