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

(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (-14 / +17 lines)
Lines 57-62 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListE Link Here
57
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
57
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
58
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
58
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
59
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
59
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
60
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
60
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideSize;
61
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideSize;
61
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
62
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
62
63
Lines 72-78 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
72
73
73
    private CTPresentation _presentation;
74
    private CTPresentation _presentation;
74
    private List<XSLFSlide> _slides;
75
    private List<XSLFSlide> _slides;
75
    private Map<String, XSLFSlideMaster> _masters;
76
    private List<XSLFSlideMaster> _masters;
76
    private List<XSLFPictureData> _pictures;
77
    private List<XSLFPictureData> _pictures;
77
    private XSLFTableStyles _tableStyles;
78
    private XSLFTableStyles _tableStyles;
78
    private XSLFNotesMaster _notesMaster;
79
    private XSLFNotesMaster _notesMaster;
Lines 126-140 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
126
            PresentationDocument doc =
127
            PresentationDocument doc =
127
                    PresentationDocument.Factory.parse(getCorePart().getInputStream());
128
                    PresentationDocument.Factory.parse(getCorePart().getInputStream());
128
            _presentation = doc.getPresentation();
129
            _presentation = doc.getPresentation();
129
            Map<String, XSLFSlide> shIdMap = new HashMap<String, XSLFSlide>();
130
130
131
            _masters = new HashMap<String, XSLFSlideMaster>();
131
            Map<String, XSLFSlideMaster> masterMap = new HashMap<String, XSLFSlideMaster>();
132
            Map<String, XSLFSlide> shIdMap = new HashMap<String, XSLFSlide>();
132
            for (POIXMLDocumentPart p : getRelations()) {
133
            for (POIXMLDocumentPart p : getRelations()) {
133
                if (p instanceof XSLFSlide) {
134
                if (p instanceof XSLFSlide) {
134
                    shIdMap.put(p.getPackageRelationship().getId(), (XSLFSlide) p);
135
                    shIdMap.put(p.getPackageRelationship().getId(), (XSLFSlide) p);
135
                } else if (p instanceof XSLFSlideMaster) {
136
                } else if (p instanceof XSLFSlideMaster) {
136
                    XSLFSlideMaster master = (XSLFSlideMaster)p;
137
                    masterMap.put(p.getPackageRelationship().getId(), (XSLFSlideMaster) p);
137
                    _masters.put(p.getPackageRelationship().getId(), master);
138
                } else if (p instanceof XSLFTableStyles){
138
                } else if (p instanceof XSLFTableStyles){
139
                    _tableStyles = (XSLFTableStyles)p;
139
                    _tableStyles = (XSLFTableStyles)p;
140
                } else if (p instanceof XSLFNotesMaster) {
140
                } else if (p instanceof XSLFNotesMaster) {
Lines 144-152 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
144
                }
144
                }
145
            }
145
            }
146
146
147
            _slides = new ArrayList<XSLFSlide>();
147
            _masters = new ArrayList<XSLFSlideMaster>(masterMap.size());
148
            for (CTSlideMasterIdListEntry masterId : _presentation.getSldMasterIdLst().getSldMasterIdList()) {
149
                XSLFSlideMaster master = masterMap.get(masterId.getId2());
150
                _masters.add(master);
151
            }
152
153
            _slides = new ArrayList<XSLFSlide>(shIdMap.size());
148
            if (_presentation.isSetSldIdLst()) {
154
            if (_presentation.isSetSldIdLst()) {
149
                for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdArray()) {
155
                for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdList()) {
150
                    XSLFSlide sh = shIdMap.get(slId.getId2());
156
                    XSLFSlide sh = shIdMap.get(slId.getId2());
151
                    if (sh == null) {
157
                    if (sh == null) {
152
                        _logger.log(POILogger.WARN, "Slide with r:id " + slId.getId() + " was defined, but didn't exist in package, skipping");
158
                        _logger.log(POILogger.WARN, "Slide with r:id " + slId.getId() + " was defined, but didn't exist in package, skipping");
Lines 239-251 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
239
    }
245
    }
240
    
246
    
241
    /**
247
    /**
242
     * Create a blank slide.
248
     * Create a blank slide using the default (first) master.
243
     */
249
     */
250
    @Override
244
    public XSLFSlide createSlide() {
251
    public XSLFSlide createSlide() {
245
        String masterId = _presentation.getSldMasterIdLst().getSldMasterIdArray(0).getId2();
252
        XSLFSlideLayout layout = _masters.get(0).getLayout(SlideLayout.BLANK);
246
        XSLFSlideMaster master = _masters.get(masterId);
247
248
        XSLFSlideLayout layout = master.getLayout(SlideLayout.BLANK);
249
        if(layout == null) throw new IllegalArgumentException("Blank layout was not found");
253
        if(layout == null) throw new IllegalArgumentException("Blank layout was not found");
250
254
251
        return createSlide(layout);
255
        return createSlide(layout);
Lines 350-356 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
350
354
351
    @Override
355
    @Override
352
    public List<XSLFSlideMaster> getSlideMasters() {
356
    public List<XSLFSlideMaster> getSlideMasters() {
353
        return new ArrayList<XSLFSlideMaster>(_masters.values());
357
        return _masters;
354
    }
358
    }
355
359
356
    /**
360
    /**
357
- 

Return to bug 58205