Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.PresentationDocument$ChartContainerImpl


  }

  @Test
  public void testNavigationInOdfElement() {
    try {
      PresentationDocument document = PresentationDocument.loadDocument(ResourceUtilities
          .getAbsolutePath(NAVIGATION_ODFELEMENT_FILE));
      TextNavigation navigation = new TextNavigation("RANDOM COLORED TEXTBOX", document);
      int count = 0;
      while (navigation.hasNext()) {
        navigation.nextSelection();
        count++;
      }
      Assert.assertEquals(3, count);

      Slide slide = document.getSlideByIndex(0);
      navigation = new TextNavigation("RANDOM COLORED TEXTBOX", slide.getOdfElement());
      count = 0;
      while (navigation.hasNext()) {
        navigation.nextSelection();
        count++;
      }
      Assert.assertEquals(1, count);
      document.close();
    } catch (Exception e) {
      Logger.getLogger(TextNavigationTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
  }
View Full Code Here


      Assert.assertEquals(chart.getChartTitle(), "Chart with local-data");
      Assert.assertTrue(chart.isUseLegend() == false);
      Assert.assertEquals(chart.getChartType(), ChartType.RADAR);
      doc.save(ResourceUtilities.newTestOutputFile(CHART_FILE_ODT));

      PresentationDocument pDoc = PresentationDocument.newPresentationDocument();
      pDoc.createChart(title, lables, legends, data, rect);
      pDoc.save(ResourceUtilities.newTestOutputFile(CHART_FILE_ODP));

    } catch (Exception e) {
      Logger.getLogger(DataSetTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
View Full Code Here

   */
  @Test
  public void testCopyThreeDoc() {
    try {
      // testdoc1 contain "dp1" for draw page style
      PresentationDocument testdoc1 = PresentationDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_PRESENTATION_DOCUMENT1));
      // testdoc1 contain "dp1" for draw page style
      PresentationDocument testdoc2 = PresentationDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_PRESENTATION_DOCUMENT2));
      // testdoc1 contain "dp1" for draw page style
      PresentationDocument testdoc3 = PresentationDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(TEST_PRESENTATION_DOCUMENT3));
      testdoc1.copyForeignSlide(1, testdoc2, 0);
      testdoc1.copyForeignSlide(2, testdoc3, 0);
      // after copy foreign slide, the each slide should has its own draw
      // page style
View Full Code Here

        Image aImage = iter.next();
        Assert.assertEquals(image, aImage);
      }

      // new image in presentation
      PresentationDocument pDoc = PresentationDocument.newPresentationDocument();
      Slide slide = pDoc.newSlide(0, "test", SlideLayout.TITLE_OUTLINE);
      Textbox box = slide.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
      box.setImage(ResourceUtilities.getURI("image_list_item.png"));
      pDoc.save(ResourceUtilities.newTestOutputFile("imagep.odp"));

      // new image in a table
      TextDocument sDoc = TextDocument.newTextDocument();
      Table table1 = sDoc.addTable(2, 2);
      Cell cell1 = table1.getCellByPosition(0, 0);
View Full Code Here

  @Test
  public void testRemoveTextbox() {
    try {
      // new image in presentation
      PresentationDocument pDoc = PresentationDocument.newPresentationDocument();
      Slide slide = pDoc.newSlide(0, "slide name ", SlideLayout.TITLE_OUTLINE);
      java.util.List<Textbox> listTbox = slide.getTextboxByUsage(PresentationClass.TITLE);
      Textbox titleBox = listTbox.get(0);
      titleBox.setBackgroundColor(Color.BLUE);
      //titleBox.setImage(ResourceUtilities.getURI("image_list_item.png"));
      titleBox.setName("title");
      titleBox.setTextContent("this is title");
     
      //validate
      Textbox tbox = slide.getTextboxByName("title");
      Assert.assertEquals(titleBox, tbox);
     
      slide.removeTextbox(titleBox);
     
      Textbox tbox1 = slide.getTextboxByName("title");
      Assert.assertNull(tbox1);

      //save
      pDoc.save(ResourceUtilities.newTestOutputFile("imagep.odp"));
    } catch (Exception e) {
      Logger.getLogger(AbstractTextboxContainerTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
View Full Code Here

      Textbox aBox = p1.getTextboxByName("box1");
      Assert.assertNotNull(aBox);
      String textContent = aBox.getTextContent();
      Assert.assertEquals(content, textContent);

      PresentationDocument presentDoc = PresentationDocument.newPresentationDocument();
      Slide slide1 = presentDoc.newSlide(1, "slide1", SlideLayout.TITLE_PLUS_2_TEXT_BLOCK);
      Textbox titleTextbox = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
      Assert.assertNotNull(titleTextbox);
      titleTextbox.setTextContent("My Title1");
      java.util.List<Textbox> boxList = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.OUTLINE);
      Assert.assertNotNull(boxList);
      Assert.assertEquals(2, boxList.size());
      Textbox leftTextbox = boxList.get(0);
      List list1 = leftTextbox.addList();
      list1.addItem("Test outline1");
      list1.addItem("Test outline2");

      presentDoc.save(ResourceUtilities.newTestOutputFile("abc.odp"));
    } catch (Exception e) {
      Logger.getLogger(TextBoxTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
  }
View Full Code Here

 
 
  @Test
  public void testaddListListDecorator() {
    try {
      PresentationDocument presentDoc = PresentationDocument.newPresentationDocument();
      Slide slide1 = presentDoc.newSlide(1, "slide1", SlideLayout.TITLE_PLUS_2_TEXT_BLOCK);
      //title
      Textbox titleTextbox = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
      Assert.assertNotNull(titleTextbox);
      titleTextbox.setTextContent("This is Title");
      java.util.List<Textbox> boxList = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.OUTLINE);
      Assert.assertNotNull(boxList);
      Assert.assertEquals(2, boxList.size());
      Textbox leftTextbox = boxList.get(0);
      List list1 = leftTextbox.addList();
      list1.addItem("Test outline1");
      list1.addItem("Test outline2");
     
      //
      Textbox rightTextbox = boxList.get(1);
      Assert.assertNotNull(rightTextbox);
     
      ListDecorator decorator = new NumberDecorator(presentDoc);
      rightTextbox.setBackgroundColor(Color.RED);
      List list2 = rightTextbox.addList(decorator);
      list2.addItem("test one");
      list2.addItem("test two");
      list2.addItem("test three");
     
      //save
      presentDoc.save(ResourceUtilities.newTestOutputFile("abc.odp"));
    } catch (Exception e) {
      Logger.getLogger(TextBoxTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
  }
View Full Code Here

 
 
  @Test
  public void testClearList() {
    try {
      PresentationDocument presentDoc = PresentationDocument.newPresentationDocument();
      Slide slide1 = presentDoc.newSlide(1, "slide1", SlideLayout.TITLE_PLUS_2_TEXT_BLOCK);
      //title
      Textbox titleTextbox = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
      Assert.assertNotNull(titleTextbox);
      titleTextbox.setTextContent("This is Title");
      java.util.List<Textbox> boxList = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.OUTLINE);
      Assert.assertNotNull(boxList);
      Assert.assertEquals(2, boxList.size());
      Textbox leftTextbox = boxList.get(0);
      List list1 = leftTextbox.addList();
      list1.addItem("Test outline1");
      list1.addItem("Test outline2");
      leftTextbox.clearList();
      List list3 = leftTextbox.addList();
      list3.addItem("Test line3");
      list3.addItem("Test line3");
      //
      Textbox rightTextbox = boxList.get(1);
      Assert.assertNotNull(rightTextbox);
     
      ListDecorator decorator = new NumberDecorator(presentDoc);
      rightTextbox.setBackgroundColor(Color.RED);
      List list2 = rightTextbox.addList(decorator);
      list2.addItem("test one");
      list2.addItem("test two");
      list2.addItem("test three");
      rightTextbox.clearList();
      Iterator iterator = rightTextbox.getListIterator();
      Assert.assertEquals(false, iterator.hasNext());
     
      //save
      presentDoc.save(ResourceUtilities.newTestOutputFile("abc.odp"));
    } catch (Exception e) {
      Logger.getLogger(TextBoxTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
  }
View Full Code Here

 
 
  @Test
  public void testGetListContainerElement() {
    try {
      PresentationDocument presentDoc = PresentationDocument.newPresentationDocument();
      Slide slide1 = presentDoc.newSlide(1, "slide1", SlideLayout.TITLE_PLUS_2_TEXT_BLOCK);
      //title
      Textbox titleTextbox = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
      Assert.assertNotNull(titleTextbox);
      titleTextbox.setTextContent("This is Title");
      java.util.List<Textbox> boxList = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.OUTLINE);
      Assert.assertNotNull(boxList);
      Assert.assertEquals(2, boxList.size());
      Textbox leftTextbox = boxList.get(0);
      List list1 = leftTextbox.addList();
      list1.addItem("Test outline1");
      list1.addItem("Test outline2");
      //
      Textbox rightTextbox = boxList.get(1);
      Assert.assertNotNull(rightTextbox);
     
      ListDecorator decorator = new NumberDecorator(presentDoc);
      rightTextbox.setBackgroundColor(Color.RED);
      List list2 = rightTextbox.addList(decorator);
      list2.addItem("test AAA");
      OdfElement odfEle = rightTextbox.getListContainerElement();
      NodeList nodes = odfEle.getChildNodes();
      for(int i=0;i<nodes.getLength();i++){
        Node node = nodes.item(i);
        Assert.assertEquals("test AAA", node.getTextContent());
      }
     
      //save
      presentDoc.save(ResourceUtilities.newTestOutputFile("abc.odp"));
    } catch (Exception e) {
      Logger.getLogger(TextBoxTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
   
View Full Code Here

 
 
  @Test
  public void testGetListIterator() {
    try {
      PresentationDocument presentDoc = PresentationDocument.newPresentationDocument();
      Slide slide1 = presentDoc.newSlide(1, "slide1", SlideLayout.TITLE_PLUS_2_TEXT_BLOCK);
      //title
      Textbox titleTextbox = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
      Assert.assertNotNull(titleTextbox);
      titleTextbox.setTextContent("This is Title");
      java.util.List<Textbox> boxList = slide1.getTextboxByUsage(PresentationDocument.PresentationClass.OUTLINE);
      Assert.assertNotNull(boxList);
      Assert.assertEquals(2, boxList.size());
      Textbox leftTextbox = boxList.get(0);
      List list1 = leftTextbox.addList();
      list1.addItem("Test outline1");
      list1.addItem("Test outline2");

      //
      Textbox rightTextbox = boxList.get(1);
      Assert.assertNotNull(rightTextbox);
     
      ListDecorator decorator = new NumberDecorator(presentDoc);
      rightTextbox.setBackgroundColor(Color.RED);
      List list2 = rightTextbox.addList();
      list2.addItem("test AAA");
      list2.addItem("test BBB");
      Iterator iterator = rightTextbox.getListIterator();
      while(iterator.hasNext()){
        List list = (List)iterator.next();
        Assert.assertEquals(2, list.size());
        Assert.assertEquals("test AAA", list.getItem(0).toString());
        Assert.assertEquals("test BBB", list.getItem(1).toString());
      }
     
      //save
      presentDoc.save(ResourceUtilities.newTestOutputFile("abc.odp"));
    } catch (Exception e) {
      Logger.getLogger(TextBoxTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
   
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.PresentationDocument$ChartContainerImpl

Copyright © 2018 www.massapicom. 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.