Lines 30-39
Link Here
|
30 |
import java.awt.geom.AffineTransform; |
30 |
import java.awt.geom.AffineTransform; |
31 |
import java.awt.geom.Rectangle2D; |
31 |
import java.awt.geom.Rectangle2D; |
32 |
import java.awt.image.BufferedImage; |
32 |
import java.awt.image.BufferedImage; |
|
|
33 |
import java.io.ByteArrayOutputStream; |
33 |
import java.io.File; |
34 |
import java.io.File; |
|
|
35 |
import java.io.FileInputStream; |
34 |
import java.io.IOException; |
36 |
import java.io.IOException; |
|
|
37 |
import java.io.InputStream; |
38 |
import java.io.OutputStream; |
35 |
import java.net.URI; |
39 |
import java.net.URI; |
36 |
import java.util.Collection; |
40 |
import java.util.Collection; |
|
|
41 |
import java.util.HashMap; |
42 |
import java.util.Map; |
37 |
|
43 |
|
38 |
import javax.imageio.ImageIO; |
44 |
import javax.imageio.ImageIO; |
39 |
|
45 |
|
Lines 47-56
Link Here
|
47 |
import org.apache.poi.sl.usermodel.PictureData.PictureType; |
53 |
import org.apache.poi.sl.usermodel.PictureData.PictureType; |
48 |
import org.apache.poi.sl.usermodel.ShapeType; |
54 |
import org.apache.poi.sl.usermodel.ShapeType; |
49 |
import org.apache.poi.sl.usermodel.VerticalAlignment; |
55 |
import org.apache.poi.sl.usermodel.VerticalAlignment; |
|
|
56 |
import org.apache.poi.ss.util.CellRangeAddress; |
57 |
import org.apache.poi.ss.util.CellReference; |
50 |
import org.apache.poi.xslf.usermodel.DrawingParagraph; |
58 |
import org.apache.poi.xslf.usermodel.DrawingParagraph; |
51 |
import org.apache.poi.xslf.usermodel.DrawingTextBody; |
59 |
import org.apache.poi.xslf.usermodel.DrawingTextBody; |
52 |
import org.apache.poi.xslf.usermodel.XMLSlideShow; |
60 |
import org.apache.poi.xslf.usermodel.XMLSlideShow; |
53 |
import org.apache.poi.xslf.usermodel.XSLFAutoShape; |
61 |
import org.apache.poi.xslf.usermodel.XSLFAutoShape; |
|
|
62 |
import org.apache.poi.xslf.usermodel.XSLFChart; |
54 |
import org.apache.poi.xslf.usermodel.XSLFHyperlink; |
63 |
import org.apache.poi.xslf.usermodel.XSLFHyperlink; |
55 |
import org.apache.poi.xslf.usermodel.XSLFPictureData; |
64 |
import org.apache.poi.xslf.usermodel.XSLFPictureData; |
56 |
import org.apache.poi.xslf.usermodel.XSLFPictureShape; |
65 |
import org.apache.poi.xslf.usermodel.XSLFPictureShape; |
Lines 60-67
Link Here
|
60 |
import org.apache.poi.xslf.usermodel.XSLFSlideLayout; |
69 |
import org.apache.poi.xslf.usermodel.XSLFSlideLayout; |
61 |
import org.apache.poi.xslf.usermodel.XSLFSlideMaster; |
70 |
import org.apache.poi.xslf.usermodel.XSLFSlideMaster; |
62 |
import org.apache.poi.xslf.usermodel.XSLFTextRun; |
71 |
import org.apache.poi.xslf.usermodel.XSLFTextRun; |
|
|
72 |
import org.apache.poi.xssf.usermodel.XSSFRow; |
73 |
import org.apache.poi.xssf.usermodel.XSSFSheet; |
74 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
63 |
import org.junit.Ignore; |
75 |
import org.junit.Ignore; |
64 |
import org.junit.Test; |
76 |
import org.junit.Test; |
|
|
77 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; |
78 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart; |
79 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer; |
80 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart; |
81 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumData; |
82 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; |
83 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumVal; |
84 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; |
85 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx; |
86 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrData; |
87 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrVal; |
88 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle; |
89 |
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTx; |
90 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody; |
91 |
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph; |
65 |
|
92 |
|
66 |
|
93 |
|
67 |
public class TestXSLFBugs { |
94 |
public class TestXSLFBugs { |
Lines 479-484
Link Here
|
479 |
|
506 |
|
480 |
ppt2.close(); |
507 |
ppt2.close(); |
481 |
} |
508 |
} |
|
|
509 |
|
510 |
@Test |
511 |
public void bug59806() throws IOException { |
512 |
String inputPath = "59806.pptx"; |
513 |
XMLSlideShow pptx = null; |
514 |
try { |
515 |
XSLFChart chart = bug59806_getChartFromTitle(inputPath); |
516 |
// embedded Excel workbook that holds the chart data |
517 |
POIXMLDocumentPart xlsPart = chart.getRelations().get(0); |
518 |
|
519 |
// updated the embedded workbook with the data |
520 |
// This is where the exception is thrown |
521 |
OutputStream xlsOut = xlsPart.getPackagePart().getOutputStream(); |
522 |
|
523 |
} finally { |
524 |
if (pptx != null) pptx.close(); |
525 |
} |
526 |
} |
527 |
|
528 |
private static XSLFChart bug59806_getChartFromTitle(String inputPath) throws IOException { |
529 |
InputStream stream = POIDataSamples.getSlideShowInstance().openResourceAsStream(inputPath); |
530 |
XMLSlideShow pptx = new XMLSlideShow(stream); |
531 |
try { |
532 |
XSLFSlide slide = pptx.getSlides().get(0); |
533 |
// find chart in the slide |
534 |
for (POIXMLDocumentPart part : slide.getRelations()) { |
535 |
if (part instanceof XSLFChart) { |
536 |
return (XSLFChart) part; |
537 |
} |
538 |
} |
539 |
return null; |
540 |
} finally { |
541 |
// This is the source of the Rule M2.4 exception |
542 |
if (pptx != null) pptx.close(); |
543 |
} |
544 |
} |
482 |
|
545 |
|
483 |
@Test |
546 |
@Test |
484 |
public void bug58217() throws IOException { |
547 |
public void bug58217() throws IOException { |