diff options
author | Alain Béarez <abearez@apache.org> | 2021-02-01 00:46:25 +0000 |
---|---|---|
committer | Alain Béarez <abearez@apache.org> | 2021-02-01 00:46:25 +0000 |
commit | e367148e09cbbb61e5b48b5deacdf85b5096d1cc (patch) | |
tree | 32b7af03c9f48cc5b8e802c562afdb2f587fa0f8 /src | |
parent | aa9ec651ea09abf21612ff768bd7b2b555087430 (diff) | |
download | poi-e367148e09cbbb61e5b48b5deacdf85b5096d1cc.tar.gz poi-e367148e09cbbb61e5b48b5deacdf85b5096d1cc.zip |
Clone only content of imported chart
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-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); |