Bug 56467: Fix cloning of sheets with pictures
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1665959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
51fdb9434d
commit
b7c14b3a8f
@ -576,13 +576,17 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
||||
// copy drawing contents
|
||||
clonedDg.getCTDrawing().set(dg.getCTDrawing());
|
||||
|
||||
clonedDg = clonedSheet.createDrawingPatriarch();
|
||||
|
||||
// Clone drawing relations
|
||||
List<POIXMLDocumentPart> srcRels = srcSheet.createDrawingPatriarch().getRelations();
|
||||
for (POIXMLDocumentPart rel : srcRels) {
|
||||
PackageRelationship relation = rel.getPackageRelationship();
|
||||
clonedSheet
|
||||
.createDrawingPatriarch()
|
||||
.getPackagePart()
|
||||
|
||||
clonedDg.addRelation(relation.getId(), rel);
|
||||
|
||||
clonedDg
|
||||
.getPackagePart()
|
||||
.addRelationship(relation.getTargetURI(), relation.getTargetMode(),
|
||||
relation.getRelationshipType(), relation.getId());
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
@ -2262,4 +2263,31 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test56467() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("picture.xlsx");
|
||||
try {
|
||||
Sheet orig = wb.getSheetAt(0);
|
||||
assertNotNull(orig);
|
||||
|
||||
Sheet sheet = wb.cloneSheet(0);
|
||||
Drawing drawing = sheet.createDrawingPatriarch();
|
||||
for (XSSFShape shape : ((XSSFDrawing) drawing).getShapes()) {
|
||||
if (shape instanceof XSSFPicture) {
|
||||
XSSFPictureData pictureData = ((XSSFPicture) shape).getPictureData();
|
||||
assertNotNull(pictureData);
|
||||
}
|
||||
}
|
||||
|
||||
// OutputStream out = new FileOutputStream("/tmp/56467.xls");
|
||||
// try {
|
||||
// wb.write(out);
|
||||
// } finally {
|
||||
// out.close();
|
||||
// }
|
||||
} finally {
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user