==================================================================== */
package org.apache.poi.xslf.usermodel;
+import java.awt.Dimension;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
import org.apache.poi.POIXMLDocument;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLException;
-import org.apache.poi.xslf.XSLFSlideShow;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.TargetMode;
-import org.apache.poi.sl.usermodel.Slide;
-import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.PackageHelper;
import org.apache.poi.util.Units;
+import org.apache.poi.xslf.XSLFSlideShow;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideSize;
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
-import java.awt.*;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
/**
* High level representation of a ooxml slideshow.
* This is the first object most users will construct whether
*/
@Beta
public class XMLSlideShow extends POIXMLDocument {
-
private static POILogger _logger = POILogFactory.getLogger(XMLSlideShow.class);
private CTPresentation _presentation;
private List<XSLFSlide> _slides;
private Map<String, XSLFSlideMaster> _masters;
+ private XSLFNotesMaster _notesMaster;
protected List<XSLFPictureData> _pictures;
public XMLSlideShow() {
for (POIXMLDocumentPart p : getRelations()) {
if (p instanceof XSLFSlide) {
shIdMap.put(p.getPackageRelationship().getId(), (XSLFSlide) p);
- } else if (p instanceof XSLFSlideMaster){
+ } else if (p instanceof XSLFSlideMaster) {
XSLFSlideMaster master = (XSLFSlideMaster)p;
_masters.put(p.getPackageRelationship().getId(), master);
+ } else if (p instanceof XSLFNotesMaster) {
+ _notesMaster = (XSLFNotesMaster)p;
}
}
_slides.add(slide);
return slide;
}
+
+ public XSLFNotesMaster getNotesMaster() {
+ return _notesMaster;
+ }
public XSLFSlideMaster[] getSlideMasters() {
return _masters.values().toArray(new XSLFSlideMaster[_masters.size()]);
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.xslf.usermodel;
+
+import java.io.IOException;
+
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.util.Beta;
+import org.apache.xmlbeans.XmlException;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
+import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
+
+@Beta
+public final class XSLFNotes extends XSLFSheet {
+ private CTNotesSlide _notes;
+
+ /**
+ * Create a new slide
+ */
+ XSLFNotes() {
+ super();
+ _notes = prototype();
+ setCommonSlideData(_notes.getCSld());
+ }
+
+ /**
+ * Construct a SpreadsheetML drawing from a package part
+ *
+ * @param part the package part holding the drawing data,
+ * the content type must be <code>application/vnd.openxmlformats-officedocument.drawing+xml</code>
+ * @param rel the package relationship holding this drawing,
+ * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
+ */
+ XSLFNotes(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
+ super(part, rel);
+
+ NotesDocument doc =
+ NotesDocument.Factory.parse(getPackagePart().getInputStream());
+ _notes = doc.getNotes();
+ setCommonSlideData(_notes.getCSld());
+ }
+
+
+ private static CTNotesSlide prototype(){
+ CTNotesSlide ctNotes = CTNotesSlide.Factory.newInstance();
+ CTCommonSlideData cSld = ctNotes.addNewCSld();
+
+ // TODO What else is needed for a mininum notes?
+
+ return ctNotes;
+ }
+
+ @Override
+ public CTNotesSlide getXmlObject() {
+ return _notes;
+ }
+
+ @Override
+ protected String getRootElementName(){
+ return "notes";
+ }
+}
public static final XSLFRelation NOTES = new XSLFRelation(
"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
- null, null
+ "/ppt/notesSlides/notesSlide#.xml",
+ XSLFNotes.class
);
public static final XSLFRelation SLIDE = new XSLFRelation(
==================================================================== */
package org.apache.poi.xslf.usermodel;
+import java.io.IOException;
+
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.openxml4j.opc.PackagePartName;
-import org.apache.poi.openxml4j.opc.TargetMode;
-import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.util.Beta;
-import org.apache.poi.util.IOUtils;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideLayoutIdListEntry;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.regex.Pattern;
@Beta
public final class XSLFSlide extends XSLFSheet {
- private final CTSlide _slide;
- private XSLFSlideLayout _layout;
+ private final CTSlide _slide;
+ private XSLFSlideLayout _layout;
+ private XSLFNotes _notes;
/**
* Create a new slide
XSLFSlide() {
super();
_slide = prototype();
+ setCommonSlideData(_slide.getCSld());
}
/**
}
return _layout;
}
+
+ public XSLFNotes getNotes() {
+ if(_notes == null) {
+ for (POIXMLDocumentPart p : getRelations()) {
+ if (p instanceof XSLFNotes){
+ _notes = (XSLFNotes)p;
+ }
+ }
+ }
+ if(_notes == null) {
+ // This slide lacks notes
+ // Not al have them, sorry...
+ return null;
+ }
+ return _notes;
+ }
public void setFollowMasterBackground(boolean value){
_slide.setShowMasterSp(value);
// Now get those objects
assertNotNull(xml.getSlides()[0]);
- assertNotNull(xml.getSlides()[0]);
+ assertNotNull(xml.getSlides()[1]);
// And check they have notes as expected
- // TODO
-// assertNotNull(xml.getNotes(slides[0]));
-// assertNotNull(xml.getNotes(slides[1]));
+ assertNotNull(xml.getSlides()[0].getNotes());
+ assertNotNull(xml.getSlides()[1].getNotes());
// Next up look for the slide master
CTSlideMasterIdListEntry[] masters = new CTSlideMasterIdListEntry[
CTNotesMasterIdListEntry notesMaster =
xml.getCTPresentation().getNotesMasterIdLst().getNotesMasterId();
assertNotNull(notesMaster);
- // TODO Get the wrapper
- }
+
+ assertNotNull(xml.getNotesMaster());
+ }
public void testMetadataBasics() throws Exception {
XMLSlideShow xml = new XMLSlideShow(pack);