Start on more XSLF support
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@682833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b50538a435
commit
4cc78b0c0e
@ -26,6 +26,7 @@ import org.openxml4j.opc.Package;
|
|||||||
import org.openxml4j.opc.PackagePart;
|
import org.openxml4j.opc.PackagePart;
|
||||||
import org.openxml4j.opc.PackageRelationship;
|
import org.openxml4j.opc.PackageRelationship;
|
||||||
import org.openxml4j.opc.PackageRelationshipCollection;
|
import org.openxml4j.opc.PackageRelationshipCollection;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
|
||||||
@ -34,6 +35,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
|
|||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
|
import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
|
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
|
import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
|
||||||
@ -56,6 +58,7 @@ public class XSLFSlideShow extends POIXMLDocument {
|
|||||||
public static final String SLIDE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
|
public static final String SLIDE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
|
||||||
public static final String SLIDE_LAYOUT_RELATION_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
public static final String SLIDE_LAYOUT_RELATION_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
||||||
public static final String NOTES_RELATION_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
|
public static final String NOTES_RELATION_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
|
||||||
|
public static final String COMMENT_RELATION_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
|
||||||
|
|
||||||
private PresentationDocument presentationDoc;
|
private PresentationDocument presentationDoc;
|
||||||
|
|
||||||
@ -106,49 +109,55 @@ public class XSLFSlideShow extends POIXMLDocument {
|
|||||||
return getPresentation().getSldMasterIdLst();
|
return getPresentation().getSldMasterIdLst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PackagePart getSlideMasterPart(CTSlideMasterIdListEntry master) throws IOException, XmlException {
|
||||||
|
try {
|
||||||
|
return getTargetPart(
|
||||||
|
getCorePart().getRelationship(master.getId2())
|
||||||
|
);
|
||||||
|
} catch(InvalidFormatException e) {
|
||||||
|
throw new XmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the low level slide master object from
|
* Returns the low level slide master object from
|
||||||
* the supplied slide master reference
|
* the supplied slide master reference
|
||||||
*/
|
*/
|
||||||
public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
|
public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
|
||||||
try {
|
PackagePart masterPart = getSlideMasterPart(master);
|
||||||
PackagePart masterPart =
|
|
||||||
getTargetPart(getCorePart().getRelationship(master.getId2()));
|
|
||||||
|
|
||||||
SldMasterDocument masterDoc =
|
SldMasterDocument masterDoc =
|
||||||
SldMasterDocument.Factory.parse(masterPart.getInputStream());
|
SldMasterDocument.Factory.parse(masterPart.getInputStream());
|
||||||
return masterDoc.getSldMaster();
|
return masterDoc.getSldMaster();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackagePart getSlidePart(CTSlideIdListEntry slide) throws IOException, XmlException {
|
||||||
|
try {
|
||||||
|
return getTargetPart(
|
||||||
|
getCorePart().getRelationship(slide.getId2())
|
||||||
|
);
|
||||||
} catch(InvalidFormatException e) {
|
} catch(InvalidFormatException e) {
|
||||||
throw new XmlException(e);
|
throw new XmlException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the low level slide object from
|
* Returns the low level slide object from
|
||||||
* the supplied slide reference
|
* the supplied slide reference
|
||||||
*/
|
*/
|
||||||
public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
|
public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
|
||||||
try {
|
PackagePart slidePart = getSlidePart(slide);
|
||||||
PackagePart slidePart =
|
|
||||||
getTargetPart(getCorePart().getRelationship(slide.getId2()));
|
|
||||||
SldDocument slideDoc =
|
SldDocument slideDoc =
|
||||||
SldDocument.Factory.parse(slidePart.getInputStream());
|
SldDocument.Factory.parse(slidePart.getInputStream());
|
||||||
return slideDoc.getSld();
|
return slideDoc.getSld();
|
||||||
} catch(InvalidFormatException e) {
|
|
||||||
throw new XmlException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the low level notes object for the given
|
* Gets the PackagePart of the notes for the
|
||||||
* slide, as found from the supplied slide reference
|
* given slide, or null if there isn't one.
|
||||||
*/
|
*/
|
||||||
public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException {
|
public PackagePart getNodesPart(CTSlideIdListEntry parentSlide) throws IOException, XmlException {
|
||||||
PackageRelationshipCollection notes;
|
PackageRelationshipCollection notes;
|
||||||
try {
|
PackagePart slidePart = getSlidePart(parentSlide);
|
||||||
PackagePart slidePart =
|
|
||||||
getTargetPart(getCorePart().getRelationship(slide.getId2()));
|
|
||||||
|
|
||||||
|
try {
|
||||||
notes = slidePart.getRelationshipsByType(NOTES_RELATION_TYPE);
|
notes = slidePart.getRelationshipsByType(NOTES_RELATION_TYPE);
|
||||||
} catch(InvalidFormatException e) {
|
} catch(InvalidFormatException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
@ -163,12 +172,54 @@ public class XSLFSlideShow extends POIXMLDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PackagePart notesPart =
|
return getTargetPart(notes.getRelationship(0));
|
||||||
getTargetPart(notes.getRelationship(0));
|
} catch(InvalidFormatException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns the low level notes object for the given
|
||||||
|
* slide, as found from the supplied slide reference
|
||||||
|
*/
|
||||||
|
public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException {
|
||||||
|
PackagePart notesPart = getNodesPart(slide);
|
||||||
|
if(notesPart == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
NotesDocument notesDoc =
|
NotesDocument notesDoc =
|
||||||
NotesDocument.Factory.parse(notesPart.getInputStream());
|
NotesDocument.Factory.parse(notesPart.getInputStream());
|
||||||
|
|
||||||
return notesDoc.getNotes();
|
return notesDoc.getNotes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the comments for the given slide
|
||||||
|
*/
|
||||||
|
public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException {
|
||||||
|
PackageRelationshipCollection commentRels;
|
||||||
|
PackagePart slidePart = getSlidePart(slide);
|
||||||
|
|
||||||
|
try {
|
||||||
|
commentRels = slidePart.getRelationshipsByType(COMMENT_RELATION_TYPE);
|
||||||
|
} catch(InvalidFormatException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(commentRels.size() == 0) {
|
||||||
|
// No comments for this slide
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(commentRels.size() > 1) {
|
||||||
|
throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
PackagePart cPart = getTargetPart(
|
||||||
|
commentRels.getRelationship(0)
|
||||||
|
);
|
||||||
|
CmLstDocument commDoc =
|
||||||
|
CmLstDocument.Factory.parse(cPart.getInputStream());
|
||||||
|
return commDoc.getCmLst();
|
||||||
} catch(InvalidFormatException e) {
|
} catch(InvalidFormatException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,17 @@
|
|||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.xslf.usermodel;
|
package org.apache.poi.xslf.usermodel;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.poi.sl.usermodel.MasterSheet;
|
||||||
|
import org.apache.poi.sl.usermodel.Resources;
|
||||||
|
import org.apache.poi.sl.usermodel.Slide;
|
||||||
|
import org.apache.poi.sl.usermodel.SlideShow;
|
||||||
import org.apache.poi.xslf.XSLFSlideShow;
|
import org.apache.poi.xslf.XSLFSlideShow;
|
||||||
|
import org.apache.xmlbeans.XmlException;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* High level representation of a ooxml slideshow.
|
* High level representation of a ooxml slideshow.
|
||||||
@ -24,17 +34,52 @@ import org.apache.poi.xslf.XSLFSlideShow;
|
|||||||
* they are reading or writing a slideshow. It is also the
|
* they are reading or writing a slideshow. It is also the
|
||||||
* top level object for creating new slides/etc.
|
* top level object for creating new slides/etc.
|
||||||
*/
|
*/
|
||||||
public class XMLSlideShow {
|
public class XMLSlideShow implements SlideShow {
|
||||||
private XSLFSlideShow slideShow;
|
private XSLFSlideShow slideShow;
|
||||||
|
private XSLFSlide[] slides;
|
||||||
|
|
||||||
public XMLSlideShow(XSLFSlideShow xml) {
|
public XMLSlideShow(XSLFSlideShow xml) throws XmlException, IOException {
|
||||||
this.slideShow = xml;
|
this.slideShow = xml;
|
||||||
|
|
||||||
|
// Build the main masters list - TODO
|
||||||
|
|
||||||
|
// Build the slides list
|
||||||
|
CTSlideIdList slideIds = slideShow.getSlideReferences();
|
||||||
|
slides = new XSLFSlide[slideIds.getSldIdArray().length];
|
||||||
|
for(int i=0; i<slides.length; i++) {
|
||||||
|
CTSlideIdListEntry slideId = slideIds.getSldIdArray(i);
|
||||||
|
CTSlide slide = slideShow.getSlide(slideId);
|
||||||
|
slides[i] = new XSLFSlide(slide, slideId, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the notes list - TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public XSLFSlideShow _getXSLFSlideShow() {
|
public XSLFSlideShow _getXSLFSlideShow() {
|
||||||
return slideShow;
|
return slideShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Get slides
|
public MasterSheet createMasterSheet() throws IOException {
|
||||||
// TODO: Get notes
|
throw new IllegalStateException("Not implemented yet!");
|
||||||
|
}
|
||||||
|
public Slide createSlide() throws IOException {
|
||||||
|
throw new IllegalStateException("Not implemented yet!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MasterSheet[] getMasterSheet() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all the slides in the slideshow
|
||||||
|
*/
|
||||||
|
public XSLFSlide[] getSlides() {
|
||||||
|
return slides;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resources getResources() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
59
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
Normal file
59
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
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 org.apache.poi.sl.usermodel.Background;
|
||||||
|
import org.apache.poi.sl.usermodel.MasterSheet;
|
||||||
|
import org.apache.poi.sl.usermodel.Shape;
|
||||||
|
import org.apache.poi.sl.usermodel.Sheet;
|
||||||
|
import org.apache.poi.sl.usermodel.SlideShow;
|
||||||
|
|
||||||
|
public abstract class XSLFSheet implements Sheet {
|
||||||
|
private SlideShow slideShow;
|
||||||
|
protected XSLFSheet(SlideShow parent) {
|
||||||
|
this.slideShow = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Background getBackground() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MasterSheet getMasterSheet() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SlideShow getSlideShow() {
|
||||||
|
return slideShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addShape(Shape shape) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shape[] getShapes() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeShape(Shape shape) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
88
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
Normal file
88
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
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 org.apache.poi.sl.usermodel.Notes;
|
||||||
|
import org.apache.poi.sl.usermodel.Slide;
|
||||||
|
import org.apache.poi.sl.usermodel.SlideShow;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
|
||||||
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
|
||||||
|
|
||||||
|
public class XSLFSlide extends XSLFSheet implements Slide {
|
||||||
|
private CTSlide slide;
|
||||||
|
private CTSlideIdListEntry slideId;
|
||||||
|
|
||||||
|
public XSLFSlide(CTSlide slide, CTSlideIdListEntry slideId, SlideShow parent) {
|
||||||
|
super(parent);
|
||||||
|
this.slide = slide;
|
||||||
|
this.slideId = slideId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While developing only!
|
||||||
|
*/
|
||||||
|
public CTSlide _getCTSlide() {
|
||||||
|
return slide;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* While developing only!
|
||||||
|
*/
|
||||||
|
public CTSlideIdListEntry _getCTSlideId() {
|
||||||
|
return slideId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean getFollowMasterBackground() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getFollowMasterColourScheme() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getFollowMasterObjects() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Notes getNotes() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFollowMasterBackground(boolean follow) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFollowMasterColourScheme(boolean follow) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFollowMasterObjects(boolean follow) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(Notes notes) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user