Examples of OfficePresentationElement


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

   * Append all the slides of the specified presentation document to the current document.
   * @param srcDoc  the specified <code>OdfPresentationDocument</code> that need to be appended
   */
  public void appendPresentation(OdfPresentationDocument srcDoc) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    OdfFileDom contentDom = null;
    OfficePresentationElement srcContentRoot = null;
    try {
      contentRoot = getContentRoot();
      contentDom = getContentDom();
      srcContentRoot = srcDoc.getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(OdfPresentationDocument.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
    copyForeignLinkRef(srcCloneContentRoot);
    //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

   * with the slide count of the current presentation document.
   */
  public OdfSlide copyForeignSlide(int destIndex,
      OdfPresentationDocument srcDoc, int srcIndex) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    OdfFileDom contentDom = null;
    try {
      contentRoot = getContentRoot();
      contentDom = getContentDom();
    } 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 ((destIndex < 0) || (destIndex > slideCount)) {
      throw new IndexOutOfBoundsException("the specified Index is out of slide count when call copyForeignSlide method.");
    }
    OdfSlide 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
    copyForeignLinkRef(sourceCloneSlideElement);
    //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;
    checkAllSlideName();
View Full Code Here

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

   * <p>
   * Throw IndexOutOfBoundsException if index is out of the presentation document slide count.
   */
  public OdfSlide newSlide(int index, String name, OdfSlide.SlideLayout slideLayout) {
    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 ((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;
    checkAllSlideName();
View Full Code Here

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

  //note page refer the slide index in order to show the corresponding slide notes view
  //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

  @Test
  public void testSlideName() {
    try {
      doc = PresentationDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_PRESENTATION_FILE_MAIN));
      OfficePresentationElement contentRoot = doc.getContentRoot();
      NodeList slideNodes = contentRoot.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "page");
      DrawPageElement slideEle4 = (DrawPageElement) slideNodes.item(4);
      Assert.assertEquals(slideEle4.getDrawNameAttribute(), "page5");
      DrawPageElement slideEle8 = (DrawPageElement) slideNodes.item(8);
      slideEle8.setDrawNameAttribute("page5");
      Slide slide7 = doc.getSlideByIndex(7);
View Full Code Here

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

   *            the index of the slide to be returned
   * @return a draw slide at the specified position
   */
  public Slide getSlideByIndex(int index) {
    checkAllSlideName();
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.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 Slide.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(PresentationDocument.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 Slide getSlideByName(String name) {
    checkAllSlideName();
    if (name == null) {
      return null;
    }
    OfficePresentationElement contentRoot = null;
    try {
      contentRoot = getContentRoot();
    } catch (Exception e) {
      Logger.getLogger(PresentationDocument.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);
      Slide slide = Slide.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(PresentationDocument.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
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.