diff options
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java index bfceacf4ee..fadb24dae8 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java @@ -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; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java index 501d10e8ab..e000ed3dc9 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java @@ -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); |