You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XMLSlideShow.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xslf.usermodel;
  16. import java.io.IOException;
  17. import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
  18. import org.apache.poi.openxml4j.opc.OPCPackage;
  19. import org.apache.poi.sl.usermodel.MasterSheet;
  20. import org.apache.poi.sl.usermodel.Resources;
  21. import org.apache.poi.sl.usermodel.Slide;
  22. import org.apache.poi.sl.usermodel.SlideShow;
  23. import org.apache.poi.xslf.XSLFSlideShow;
  24. import org.apache.xmlbeans.XmlException;
  25. import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
  26. import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
  27. import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
  28. import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList;
  29. /**
  30. * High level representation of a ooxml slideshow.
  31. * This is the first object most users will construct whether
  32. * they are reading or writing a slideshow. It is also the
  33. * top level object for creating new slides/etc.
  34. */
  35. public class XMLSlideShow implements SlideShow {
  36. private XSLFSlideShow slideShow;
  37. private XSLFSlide[] slides;
  38. public XMLSlideShow(XSLFSlideShow xml) throws XmlException, IOException {
  39. this.slideShow = xml;
  40. // Build the main masters list - TODO
  41. CTSlideMasterIdList masterIds = slideShow.getSlideMasterReferences();
  42. // Build the slides list
  43. CTSlideIdList slideIds = slideShow.getSlideReferences();
  44. slides = new XSLFSlide[slideIds.getSldIdList().size()];
  45. for(int i=0; i<slides.length; i++) {
  46. CTSlideIdListEntry slideId = slideIds.getSldIdArray(i);
  47. CTSlide slide = slideShow.getSlide(slideId);
  48. slides[i] = new XSLFSlide(slide, slideId, this);
  49. }
  50. // Build the notes list - TODO
  51. }
  52. public XMLSlideShow(OPCPackage pkg) throws XmlException, IOException, OpenXML4JException {
  53. this(new XSLFSlideShow(pkg));
  54. }
  55. public XSLFSlideShow _getXSLFSlideShow() {
  56. return slideShow;
  57. }
  58. public MasterSheet createMasterSheet() throws IOException {
  59. throw new IllegalStateException("Not implemented yet!");
  60. }
  61. public Slide createSlide() throws IOException {
  62. throw new IllegalStateException("Not implemented yet!");
  63. }
  64. public MasterSheet[] getMasterSheet() {
  65. // TODO Auto-generated method stub
  66. return null;
  67. }
  68. /**
  69. * Return all the slides in the slideshow
  70. */
  71. public XSLFSlide[] getSlides() {
  72. return slides;
  73. }
  74. public Resources getResources() {
  75. // TODO Auto-generated method stub
  76. return null;
  77. }
  78. }