Package org.odftoolkit.simple.text

Examples of org.odftoolkit.simple.text.Paragraph


  @Test
  public void testNewImage() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      image.setName("this image");
      image.setHyperlink(new URI("http://odftoolkit.org"));
      doc.save(ResourceUtilities.newTestOutputFile("imagetest.odt"));
      Iterator<Image> iter = Image.imageIterator(para);
View Full Code Here


  @Test
  public void testGetInstanceof() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      image.setName("this image");
      image.setHyperlink(new URI("http://odftoolkit.org"));
     
      DrawImageElement imageElement = image.getOdfElement();
View Full Code Here

  @Test
  public void testGetFrame() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      image.setName("this image");
      image.setHyperlink(new URI("http://odftoolkit.org"));
     
      Frame imageFrame = image.getFrame();
View Full Code Here

  @Test
  public void testRemove() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("imagePara");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      image.setName("this test image");
      image.setHyperlink(new URI("http://odftoolkit.org"));
      //image.remove();
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("imageFretest.odt"));
     
      TextDocument doc1 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("imageFretest.odt"));
      Iterator parasIter = doc1.getParagraphIterator();
     
      while(parasIter.hasNext()){
        Paragraph parac = (Paragraph)parasIter.next();
        String text = parac.getTextContent();
        if("imagePara".equals(text)){
          TextParagraphElementBase textParaEleBase = parac.getOdfElement();
          NodeList nodeImages = textParaEleBase.getElementsByTagName("draw:image");
          Node nodeImage = nodeImages.item(0);
          OdfDrawImage im = (OdfDrawImage)nodeImage;
          Image ima = Image.getInstanceof(im);
          ima.getName();
          boolean flag = ima.remove();
          if(!flag)
            Assert.fail("remove() method was executed failed.");
        }
      }
     
      //save
      doc1.save(ResourceUtilities.newTestOutputFile("imageEndtest.odt"));
     
      //validate
      TextDocument doc2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("imageEndtest.odt"));
      Iterator parasIter2 = doc2.getParagraphIterator();
     
      while(parasIter2.hasNext()){
        Paragraph parac = (Paragraph)parasIter2.next();
        String text = parac.getTextContent();
        if("imagePara".equals(text)){
          TextParagraphElementBase textParaEleBase = parac.getOdfElement();
          NodeList nodeImages = textParaEleBase.getElementsByTagName("draw:image");
          Node nodeImage = nodeImages.item(0);
          if(nodeImage == null)
            Assert.assertTrue(true);
          else
View Full Code Here

  @Test
  public void testUpdateImage() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("updateImage test");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      Assert.assertEquals("image/png", image.getMediaTypeString());

      //change the piceture of image.
      image.updateImage(ResourceUtilities.getURI("testA.jpg"));
View Full Code Here

  @Test
  public void testGetImageInputStream() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("updateImage test");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      InputStream inImage = image.getImageInputStream();
      int size = inImage.available();
      Assert.assertTrue(size > 0);
     
View Full Code Here

  @Test
  public void testGetInternalPath() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("updateImage test");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      String internalPath = image.getInternalPath();
     
      Assert.assertEquals("Pictures/image_list_item.png", internalPath);
     
View Full Code Here

  @Test
  public void testGetMediaTypeString() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("updateImage test");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      String mediaType = image.getMediaTypeString();
     
      Assert.assertEquals("image/png", mediaType);
     
View Full Code Here

  @Test
  public void testSetTitle() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("updateImage test");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      image.setTitle("ibm_title");
      String title = image.getTitle();
     
      Assert.assertEquals("ibm_title", title);
View Full Code Here

  @Test
  public void testSetDescription() {
    try {
      // new image in text document
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph para = doc.addParagraph("updateImage test");
      Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png"));
      image.setDescription("description");
      String description = image.getDesciption();
     
      Assert.assertEquals("description", description);
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.text.Paragraph

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.