Examples of OfficePresentationElement


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

  @Test
  public void testNotCompressImages() throws Exception {
    //create test presentation
    OdfPresentationDocument odp = OdfPresentationDocument.newPresentationDocument();
    OfficePresentationElement officePresentation = odp.getContentRoot();
    DrawPageElement page = officePresentation.newDrawPageElement(null);
    DrawFrameElement frame = page.newDrawFrameElement();
    OdfDrawImage image = (OdfDrawImage) frame.newDrawImageElement();
    image.newImage(ResourceUtilities.getURI(IMAGE_TEST_FILE));
    odp.save(ResourceUtilities.newTestOutputFile(IMAGE_PRESENTATION));
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

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

   *
   * @return  the number of slides
   */
  public int getSlideCount() {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return 0;
    }
    NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    return slideNodes.getLength();
  }
View Full Code Here

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

  public OdfSlide getSlideByName(String name) {
    checkAllSlideName();
    if (name == null) {
      return null;
    }
    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");
    for (int i = 0; i < slideNodes.getLength(); i++) {
      DrawPageElement slideElement = (DrawPageElement) slideNodes.item(i);
      OdfSlide slide = OdfSlide.getInstance(slideElement);
      String slideName = slide.getSlideName();
      if (slideName.equals(name)) {
View Full Code Here

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

    //check if this function is called or not
    if (hasCheckSlideName) {
      return;
    }
    List<String> slideNameList = new ArrayList<String>();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return;
    }
    NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    for (int i = 0; i < slideNodes.getLength(); i++) {
      DrawPageElement slideElement = (DrawPageElement) slideNodes.item(i);
      String slideName = slideElement.getDrawNameAttribute();
      if ((slideName == null) || slideNameList.contains(slideName)) {
        slideName = "page" + (i + 1) + "-" + makeUniqueName();
View Full Code Here

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

   *
   * @return  a list iterator containing all slides in this presentation
   */
  public Iterator<OdfSlide> getSlides() {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      return null;
    }
    ArrayList<OdfSlide> slideList = new ArrayList<OdfSlide>();
    NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
    for (int i = 0; i < slideNodes.getLength(); i++) {
      DrawPageElement slideElement = (DrawPageElement) slideNodes.item(i);
      slideList.add(OdfSlide.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(OdfPresentationDocument.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 &= deleteLinkRef(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);
    //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(OdfPresentationDocument.class.getName()).log(Level.SEVERE, null, e);
      success = false;
      return success;
    }
    OdfSlide 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 &= deleteLinkRef(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

   * Throw IndexOutOfBoundsException if the slide index is out of the presentation document slide count.
   * If copy the slide at the end of document, destIndex should set the same value with the slide count.
   */
  public OdfSlide copySlide(int source, int dest, String newName) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(OdfPresentationDocument.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;
    checkAllSlideName();
View Full Code Here

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

   * <p>
   * 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(OdfPresentationDocument.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
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.