Examples of OfficePresentationElement


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 = OdfPresentationDocument.loadDocument(ResourceUtilities.getAbsolutePath(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");
      OdfSlide slide7 = doc.getSlideByIndex(7);
View Full Code Here

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

  @Test
  public void testCreatChildrenForPresentation() {
    try {
      OdfPresentationDocument odfdoc = (OdfPresentationDocument) OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath("presentation.odp"));
      OfficePresentationElement presentation = odfdoc.getContentRoot();
      Assert.assertNotNull(presentation);

      DrawPageElement page = presentation.newDrawPageElement("NewPage");

      OdfFileDom contentDom = odfdoc.getContentDom();
      XPath xpath = contentDom.getXPath();
      DrawPageElement presentationTest = (DrawPageElement) xpath.evaluate("//draw:page[last()]", contentDom, XPathConstants.NODE);
View Full Code Here

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

  @Test
  public void testCreatChildrenForAnimation() {
    try {
      OdfPresentationDocument odfdoc = OdfPresentationDocument.newPresentationDocument();
      OfficePresentationElement presentation = odfdoc.getContentRoot();
      Assert.assertNotNull(presentation);

      DrawPageElement page = presentation.newDrawPageElement("NewPage");

      AnimAnimateElement anim = page.newAnimAnimateElement("new");
      OdfFileDom contentDom = odfdoc.getContentDom();
      XPath xpath = contentDom.getXPath();
      AnimAnimateElement animTest = (AnimAnimateElement) xpath.evaluate("//anim:animate[last()]", contentDom, XPathConstants.NODE);
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.