Author: nick
Date: Tue Aug  5 10:51:04 2008
New Revision: 682833

URL: http://svn.apache.org/viewvc?rev=682833&view=rev
Log:
Start on more XSLF support

Added:
    
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java  
 (with props)
    
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java  
 (with props)
Modified:
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java
    
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java

Modified: 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java?rev=682833&r1=682832&r2=682833&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java 
(original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java 
Tue Aug  5 10:51:04 2008
@@ -26,6 +26,7 @@
 import org.openxml4j.opc.PackagePart;
 import org.openxml4j.opc.PackageRelationship;
 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.CTPresentation;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
@@ -34,6 +35,7 @@
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
 import 
org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList;
 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.PresentationDocument;
 import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
@@ -56,6 +58,7 @@
        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 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;
        
@@ -106,49 +109,55 @@
                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
         *  the supplied slide master reference
         */
        public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) 
throws IOException, XmlException {
+               PackagePart masterPart = getSlideMasterPart(master);
+               SldMasterDocument masterDoc =
+                       
SldMasterDocument.Factory.parse(masterPart.getInputStream());
+               return masterDoc.getSldMaster();
+       }
+
+       public PackagePart getSlidePart(CTSlideIdListEntry slide) throws 
IOException, XmlException {
                try {
-                       PackagePart masterPart =
-                               
getTargetPart(getCorePart().getRelationship(master.getId2()));
-                               
-                       SldMasterDocument masterDoc =
-                               
SldMasterDocument.Factory.parse(masterPart.getInputStream());
-                       return masterDoc.getSldMaster();
+                       return getTargetPart(
+                                       
getCorePart().getRelationship(slide.getId2())
+                       );
                } catch(InvalidFormatException e) {
                        throw new XmlException(e);
                }
        }
-       
        /**
         * Returns the low level slide object from
         *  the supplied slide reference
         */
        public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, 
XmlException {
-               try {
-                       PackagePart slidePart =
-                               
getTargetPart(getCorePart().getRelationship(slide.getId2()));
-                       SldDocument slideDoc =
-                               
SldDocument.Factory.parse(slidePart.getInputStream());
-                       return slideDoc.getSld();
-               } catch(InvalidFormatException e) {
-                       throw new XmlException(e);
-               }
+               PackagePart slidePart = getSlidePart(slide);
+               SldDocument slideDoc =
+                       SldDocument.Factory.parse(slidePart.getInputStream());
+               return slideDoc.getSld();
        }
-       
+
        /**
-        * Returns the low level notes object for the given
-        *  slide, as found from the supplied slide reference
+        * Gets the PackagePart of the notes for the
+        *  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;
-               try {
-                       PackagePart slidePart =
-                               
getTargetPart(getCorePart().getRelationship(slide.getId2()));
+               PackagePart slidePart = getSlidePart(parentSlide);
                
+               try {
                        notes = 
slidePart.getRelationshipsByType(NOTES_RELATION_TYPE);
                } catch(InvalidFormatException e) {
                        throw new IllegalStateException(e);
@@ -163,12 +172,54 @@
                }
                
                try {
-                       PackagePart notesPart =
-                               getTargetPart(notes.getRelationship(0));
-                       NotesDocument notesDoc =
-                               
NotesDocument.Factory.parse(notesPart.getInputStream());
-                       
-                       return notesDoc.getNotes();
+                       return 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.Factory.parse(notesPart.getInputStream());
+               
+               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) {
                        throw new IllegalStateException(e);
                }

Modified: 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=682833&r1=682832&r2=682833&view=diff
==============================================================================
--- 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
 (original)
+++ 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
 Tue Aug  5 10:51:04 2008
@@ -16,7 +16,17 @@
 ==================================================================== */
 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.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.
@@ -24,17 +34,52 @@
  *  they are reading or writing a slideshow. It is also the
  *  top level object for creating new slides/etc.
  */
-public class XMLSlideShow {
+public class XMLSlideShow implements SlideShow {
        private XSLFSlideShow slideShow;
+       private XSLFSlide[] slides;
        
-       public XMLSlideShow(XSLFSlideShow xml) {
+       public XMLSlideShow(XSLFSlideShow xml) throws XmlException, IOException 
{
                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() {
                return slideShow;
        }
 
-       // TODO: Get slides
-       // TODO: Get notes
+       public MasterSheet createMasterSheet() throws IOException {
+               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;
+       }
 }

Added: 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=682833&view=auto
==============================================================================
--- 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java 
(added)
+++ 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java 
Tue Aug  5 10:51:04 2008
@@ -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;
+       }
+}
\ No newline at end of file

Propchange: 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=682833&view=auto
==============================================================================
--- 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java 
(added)
+++ 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java 
Tue Aug  5 10:51:04 2008
@@ -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
+
+       }
+}

Propchange: 
poi/branches/ooxml/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to