mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Clone only content of imported chart
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886087 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aa9ec651ea
commit
e367148e09
@ -271,8 +271,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
XSSFClientAnchor destAnchor = new XSSFClientAnchor(from, to);
|
||||
destAnchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
||||
XSSFChart destChart = createChart(destAnchor);
|
||||
destChart.getCTChartSpace().set(srcChart.getCTChartSpace().copy());
|
||||
destChart.getCTChart().set(destChart.getCTChartSpace().getChart());
|
||||
destChart.getCTChart().set(srcChart.getCTChartSpace().getChart().copy());
|
||||
return destChart;
|
||||
}
|
||||
|
||||
|
||||
@ -913,6 +913,21 @@ class TestXSSFDrawing {
|
||||
wb2.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBug63901() {
|
||||
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
|
||||
XSSFSheet sheet = workbook.getSheet("Sheet1");
|
||||
XSSFDrawing drawing = sheet.createDrawingPatriarch();
|
||||
assert(drawing.getCharts().size() > 0);
|
||||
|
||||
XSSFWorkbook workbook2 = new XSSFWorkbook();
|
||||
XSSFSheet sheet2 = workbook2.createSheet();
|
||||
XSSFDrawing drawing2 = sheet2.createDrawingPatriarch();
|
||||
|
||||
drawing.getCharts().forEach(drawing2::importChart);
|
||||
|
||||
assertEquals(drawing.getCharts().size(), drawing2.getCharts().size());
|
||||
}
|
||||
|
||||
private static void checkRewrite(XSSFWorkbook wb) throws IOException {
|
||||
XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user