View | Details | Raw Unified | Return to bug 59806
Collapse All | Expand All

(-)src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java (+39 lines)
Lines 32-37 Link Here
32
import java.awt.image.BufferedImage;
32
import java.awt.image.BufferedImage;
33
import java.io.File;
33
import java.io.File;
34
import java.io.IOException;
34
import java.io.IOException;
35
import java.io.InputStream;
36
import java.io.OutputStream;
35
import java.net.URI;
37
import java.net.URI;
36
import java.util.Collection;
38
import java.util.Collection;
37
39
Lines 51-56 Link Here
51
import org.apache.poi.xslf.usermodel.DrawingTextBody;
53
import org.apache.poi.xslf.usermodel.DrawingTextBody;
52
import org.apache.poi.xslf.usermodel.XMLSlideShow;
54
import org.apache.poi.xslf.usermodel.XMLSlideShow;
53
import org.apache.poi.xslf.usermodel.XSLFAutoShape;
55
import org.apache.poi.xslf.usermodel.XSLFAutoShape;
56
import org.apache.poi.xslf.usermodel.XSLFChart;
54
import org.apache.poi.xslf.usermodel.XSLFHyperlink;
57
import org.apache.poi.xslf.usermodel.XSLFHyperlink;
55
import org.apache.poi.xslf.usermodel.XSLFPictureData;
58
import org.apache.poi.xslf.usermodel.XSLFPictureData;
56
import org.apache.poi.xslf.usermodel.XSLFPictureShape;
59
import org.apache.poi.xslf.usermodel.XSLFPictureShape;
Lines 479-484 Link Here
479
    
482
    
480
        ppt2.close();
483
        ppt2.close();
481
    }
484
    }
485
    
486
    @Test
487
    public void bug59806() throws IOException {
488
        String inputPath = "59806.pptx";
489
        XMLSlideShow pptx = null;
490
        try {
491
            XSLFChart chart = bug59806_getChartFromTitle(inputPath);
492
            // embedded Excel workbook that holds the chart data
493
            POIXMLDocumentPart xlsPart = chart.getRelations().get(0);
494
            
495
            // updated the embedded workbook with the data
496
            // This is where the exception is thrown
497
            OutputStream xlsOut = xlsPart.getPackagePart().getOutputStream();
498
            
499
        } finally {
500
            if (pptx != null) pptx.close();
501
        }
502
    }
503
    
504
    private static XSLFChart bug59806_getChartFromTitle(String inputPath) throws IOException {
505
        InputStream stream = POIDataSamples.getSlideShowInstance().openResourceAsStream(inputPath);
506
        XMLSlideShow pptx = new XMLSlideShow(stream);
507
        try {
508
            XSLFSlide slide = pptx.getSlides().get(0);
509
            // find chart in the slide
510
            for (POIXMLDocumentPart part : slide.getRelations()) {
511
                if (part instanceof XSLFChart) {
512
                    return (XSLFChart) part;
513
                }
514
            }
515
            return null;
516
        } finally {
517
            // This is the source of the Rule M2.4 exception
518
            if (pptx != null) pptx.close();
519
        }
520
    }
482
521
483
    @Test
522
    @Test
484
    public void bug58217() throws IOException {
523
    public void bug58217() throws IOException {

Return to bug 59806