Examples of OfficePresentationElement


Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   *
   * @return a list iterator containing all slides in this presentation
   */
  public Iterator<Slide> getSlides() {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return null;
    }
    ArrayList<Slide> slideList = new ArrayList<Slide>();
    NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    for (int i = 0; i < slideNodes.getLength(); i++) {
      DrawPageElement slideElement = (DrawPageElement) slideNodes.item(i);
      slideList.add(Slide.getInstance(slideElement));
    }
    return slideList.iterator();
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   * @return false if the operation was not successful
   */
  public boolean deleteSlideByIndex(int index) {
    boolean success = true;
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      success = false;
      return success;
    }
    NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    if ((index >= slideNodes.getLength()) || (index < 0)) {
      throw new IndexOutOfBoundsException(
          "the specified Index is out of slide count when call deleteSlideByIndex method.");
    }
    DrawPageElement slideElement = (DrawPageElement) slideNodes.item(index);
    // remove all the content of the current page
    // 1. the reference of the path that contained in this slide is 1, then
    // remove it
    // success &= deleteLinkedRef(slideElement);
    // 2.the reference of the style is 1, then remove it
    // in order to save time, do not delete the style here
    // success &= deleteStyleRef(slideElement);
    // these two methods have been merged into 1 method
    success &= removeElementLinkedResource(slideElement);
    // remove the current page element
    contentRoot.removeChild(slideElement);
    adjustNotePageNumber(index);
    return success;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   * @return false if the operation was not successful
   */
  public boolean deleteSlideByName(String name) {
    boolean success = true;
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      success = false;
      return success;
    }
    Slide slide = getSlideByName(name);
    DrawPageElement slideElement = slide.getOdfElement();
    // remove all the content of the current page
    // 1. the reference of the path that contained in this slide is 1, then
    // remove its
    success &= deleteLinkedRef(slideElement);
    // 2.the reference of the style is 1, then remove it
    // in order to save time, do not delete style here
    success &= deleteStyleRef(slideElement);
    // remove the current page element
    contentRoot.removeChild(slideElement);
    adjustNotePageNumber(0);
    return success;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   *         of document, destIndex should set the same value with the slide
   *         count.
   */
  public Slide copySlide(int source, int dest, String newName) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return null;
    }
    NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    int slideCount = slideList.getLength();
    if ((source < 0) || (source >= slideCount) || (dest < 0) || (dest > slideCount)) {
      throw new IndexOutOfBoundsException("the specified Index is out of slide count when call copySlide method.");
    }
    DrawPageElement sourceSlideElement = (DrawPageElement) slideList.item(source);
    DrawPageElement cloneSlideElement = (DrawPageElement) sourceSlideElement.cloneNode(true);
    cloneSlideElement.setDrawNameAttribute(newName);
    if (dest == slideCount) {
      contentRoot.appendChild(cloneSlideElement);
    } else {
      DrawPageElement refSlide = (DrawPageElement) slideList.item(dest);
      contentRoot.insertBefore(cloneSlideElement, refSlide);
    }
    adjustNotePageNumber(Math.min(source, dest));
    // in case that the appended new slide have the same name with the
    // original slide
    hasCheckSlideName = false;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   *            Throw IndexOutOfBoundsException if the slide index is out of
   *            the presentation document slide count.
   */
  public void moveSlide(int source, int dest) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return;
    }
    NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    int slideCount = slideList.getLength();
    if ((source < 0) || (source >= slideCount) || (dest < 0) || (dest > slideCount)) {
      throw new IndexOutOfBoundsException("the specified Index is out of slide count when call moveSlide method.");
    }
    DrawPageElement sourceSlide = (DrawPageElement) slideList.item(source);
    if (dest == slideCount) {
      contentRoot.appendChild(sourceSlide);
    } else {
      DrawPageElement refSlide = (DrawPageElement) slideList.item(dest);
      contentRoot.insertBefore(sourceSlide, refSlide);
    }
    adjustNotePageNumber(Math.min(source, dest));
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   *            the specified <code>PresentationDocument</code> that need to
   *            be appended
   */
  public void appendPresentation(PresentationDocument srcDoc) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    OdfFileDom contentDom = null;
    OfficePresentationElement srcContentRoot = null;
    try {
      contentRoot = getContentRoot();
      contentDom = getContentDom();
      srcContentRoot = srcDoc.getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
    }
    NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    int slideNum = slideList.getLength();
    // clone the srcContentRoot, and make a modification on this clone node.
    OfficePresentationElement srcCloneContentRoot = (OfficePresentationElement) srcContentRoot.cloneNode(true);
    // copy all the referred xlink:href here
    copyLinkedRefInBatch(srcCloneContentRoot, srcDoc);
    // copy all the referred style definition here
    copyForeignStyleRef(srcCloneContentRoot, srcDoc);
    Node child = srcCloneContentRoot.getFirstChild();
    while (child != null) {
      Node cloneElement = cloneForeignElement_(child, contentDom, true);
      contentRoot.appendChild(cloneElement);
      child = child.getNextSibling();
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   *         the end of document, destIndex should set the same value with the
   *         slide count of the current presentation document.
   */
  public Slide copyForeignSlide(int destIndex, PresentationDocument srcDoc, int srcIndex) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    OdfFileDom contentDom = null;
    try {
      contentRoot = getContentRoot();
      contentDom = getContentDom();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return null;
    }
    NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    int slideCount = slideList.getLength();
    if ((destIndex < 0) || (destIndex > slideCount)) {
      throw new IndexOutOfBoundsException(
          "the specified Index is out of slide count when call copyForeignSlide method.");
    }
    Slide sourceSlide = srcDoc.getSlideByIndex(srcIndex);
    DrawPageElement sourceSlideElement = sourceSlide.getOdfElement();
    // clone the sourceSlideEle, and make a modification on this clone node.
    DrawPageElement sourceCloneSlideElement = (DrawPageElement) sourceSlideElement.cloneNode(true);

    // copy all the referred xlink:href here
    copyLinkedRefInBatch(sourceCloneSlideElement, srcDoc);
    // copy all the referred style definition here
    copyForeignStyleRef(sourceCloneSlideElement, srcDoc);
    // clone the sourceCloneSlideEle, and this cloned element should in the
    // current dom tree
    DrawPageElement cloneSlideElement = (DrawPageElement) cloneForeignElement_(sourceCloneSlideElement, contentDom,
        true);
    if (destIndex == slideCount) {
      contentRoot.appendChild(cloneSlideElement);
    } else {
      DrawPageElement refSlide = (DrawPageElement) slideList.item(destIndex);
      contentRoot.insertBefore(cloneSlideElement, refSlide);
    }
    adjustNotePageNumber(destIndex);
    // in case that the appended new slide have the same name with the
    // original slide
    hasCheckSlideName = false;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   *         Throw IndexOutOfBoundsException if index is out of the
   *         presentation document slide count.
   */
  public Slide newSlide(int index, String name, Slide.SlideLayout slideLayout) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return null;
    }
    NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    int slideCount = slideList.getLength();
    if ((index < 0) || (index > slideCount)) {
      throw new IndexOutOfBoundsException("the specified Index is out of slide count when call newSlide method.");
    }
    // if insert page at the beginning of the document,
    // get the next page style as the new page style
    // else get the previous page style as the new page style
    DrawPageElement refStyleSlide = null;
    int refSlideIndex = 0;
    if (index > 0) {
      refSlideIndex = index - 1;
    }
    refStyleSlide = (DrawPageElement) slideList.item(refSlideIndex);
    String masterPageStyleName = "Default";
    String masterName = refStyleSlide.getDrawMasterPageNameAttribute();
    if (masterName != null) {
      masterPageStyleName = masterName;
    }
    DrawPageElement newSlideElement = contentRoot.newDrawPageElement(masterPageStyleName);
    newSlideElement.setDrawNameAttribute(name);
    String drawStyleName = refStyleSlide.getDrawStyleNameAttribute();
    if (drawStyleName != null) {
      newSlideElement.setDrawStyleNameAttribute(drawStyleName);
    }
    String pageLayoutName = refStyleSlide.getPresentationPresentationPageLayoutNameAttribute();
    if (pageLayoutName != null) {
      newSlideElement.setPresentationPresentationPageLayoutNameAttribute(pageLayoutName);
    }
    setSlideLayout(newSlideElement, slideLayout);
    // insert notes page
    NodeList noteNodes = refStyleSlide.getElementsByTagNameNS(OdfDocumentNamespace.PRESENTATION.getUri(), "notes");
    if (noteNodes.getLength() > 0) {
      PresentationNotesElement notePage = (PresentationNotesElement) noteNodes.item(0);
      PresentationNotesElement cloneNotePage = (PresentationNotesElement) notePage.cloneNode(true);
      newSlideElement.appendChild(cloneNotePage);
    }
    if (index < slideCount) {
      DrawPageElement refSlide = (DrawPageElement) slideList.item(index);
      contentRoot.insertBefore(newSlideElement, refSlide);
    }
    adjustNotePageNumber(index);
    // in case that the appended new slide have the same name with the
    // original slide
    hasCheckSlideName = false;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

  // this function is used to adjust note page referred slide index since
  // startIndex
  // when the slide at startIndex has been delete or insert
  private void adjustNotePageNumber(int startIndex) {
    try {
      OfficePresentationElement contentRoot = getContentRoot();
      NodeList slideList = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
      for (int i = startIndex; i < getSlideCount(); i++) {
        DrawPageElement page = (DrawPageElement) slideList.item(i);
        NodeList noteNodes = page.getElementsByTagNameNS(OdfDocumentNamespace.PRESENTATION.getUri(), "notes");
        if (noteNodes.getLength() > 0) {
          PresentationNotesElement notePage = (PresentationNotesElement) noteNodes.item(0);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.office.OfficePresentationElement

   * @param index  the index of the slide to be returned
   * @return  a draw slide at the specified position
   */
  public OdfSlide getSlideByIndex(int index) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return null;
    }
    NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    if ((index >= slideNodes.getLength()) || (index < 0)) {
      return null;
    }
    DrawPageElement slideElement = (DrawPageElement) slideNodes.item(index);
    return OdfSlide.getInstance(slideElement);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.