Package org.odftoolkit.odfdom.dom.element.text

Examples of org.odftoolkit.odfdom.dom.element.text.TextParagraphElementBase


    private static boolean isTableNode(Node item) {
        return item instanceof TableTableElement;
    }

    private static String parseTextNode(Node item) {
        TextParagraphElementBase textItem = (TextParagraphElementBase) item;
        return newOdfTextExtractor(textItem).getText();
    }
View Full Code Here


  @Test
  public void testCellReplacementWithParagraph() throws Exception {
    replace(new ReplacementAction() {

      public void replace(TextSelection selection, String value) throws Exception {
        TextParagraphElementBase paragraphElement = new TextPElement(doc.getContentDom());
        Paragraph para = Paragraph.getInstanceof(paragraphElement);
        para.setTextContent(value);
        selection.replaceWith(para);
      }
    });
View Full Code Here

      ImageSelection nextImageSelection=null;
      while (search.hasNext()) {
        TextSelection item= (TextSelection) search.nextSelection();
        nextImageSelection=new ImageSelection(item);
        Paragraph paragraph=sourcedoc.getParagraphByIndex(0, true);
        TextParagraphElementBase textParaEleBase = paragraph.getOdfElement();
        NodeList nodeImages = textParaEleBase.getElementsByTagName("draw:image");
        Node nodeImage = nodeImages.item(0);
        DrawImageElement im = (DrawImageElement)nodeImage;
        Image ima = Image.getInstanceof(im);
        Image image = nextImageSelection.replaceWithImage(ima);
        Assert.assertNotNull(image);
View Full Code Here

          }
        } while (contents.startsWith("#"));
      }
      search = new TextNavigation("#3", doc);
      OdfElement description = search.nextSelection().getElement();
      TextParagraphElementBase replacement = (TextParagraphElementBase) description
          .getNextSibling();
      Assert.assertEquals("Hello2 from source document!",
          TextExtractor.getText(replacement));
      Paragraph para = Paragraph.getInstanceof(replacement);
      String breakBefore = para.getStyleHandler()
          .getParagraphPropertiesForRead().getBreakBefore();
      Assert.assertNotNull(breakBefore);
      description = search.nextSelection().getElement();
      replacement = (TextParagraphElementBase) description
          .getNextSibling();
      Assert.assertEquals("prefix", TextExtractor.getText(replacement));
      para = Paragraph.getInstanceof(replacement);
      breakBefore = para.getStyleHandler()
          .getParagraphPropertiesForRead().getBreakBefore();
      Assert.assertNotNull(breakBefore);
      replacement = (TextParagraphElementBase) replacement
          .getNextSibling();
      Assert.assertEquals("Hello2 from source document!",
          TextExtractor.getText(replacement));
      para = Paragraph.getInstanceof(replacement);
      breakBefore = para.getStyleHandler()
          .getParagraphPropertiesForRead().getBreakBefore();
      Assert.assertNull(breakBefore);
      replacement = (TextParagraphElementBase) replacement
          .getNextSibling();
      Assert.assertEquals("suffix", TextExtractor.getText(replacement));
      para = Paragraph.getInstanceof(replacement);
      breakBefore = para.getStyleHandler()
          .getParagraphPropertiesForRead().getBreakBefore();
View Full Code Here

    try {
      doc = (TextDocument) Document.loadDocument(ResourceUtilities
          .getAbsolutePath(fileName));
      search = new TextNavigation("This is the first paragraph", doc);
      Assert.assertNotNull(search.hasNext());
      TextParagraphElementBase pElement = (TextParagraphElementBase) search
          .nextSelection().getElement();
      Node nextPElement = pElement.getNextSibling();
      Assert.assertTrue(nextPElement instanceof TextParagraphElementBase);
      String contents = TextExtractor
          .getText((TextParagraphElementBase) nextPElement);
      if (!contents
          .startsWith("This is a picture from the source document:"))
        Assert.fail();
      TextSpanElement spanEle = (TextSpanElement) pElement
          .getElementsByTagName("text:span").item(0);
      Span span = Span.getInstanceof(spanEle);
      FontStyle fontStyle = span.getStyleHandler()
          .getTextPropertiesForRead().getFontStyle();
      Assert.assertEquals(FontStyle.BOLD, fontStyle);
View Full Code Here

     
      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
            Assert.fail();
View Full Code Here

    int i = 0;
    TextSelection item = null;
    while (search.hasNext()) {
      item = (TextSelection) search.nextSelection();
      Paragraph paragraph = sourcedoc.getParagraphByIndex(0, true);
      TextParagraphElementBase textParaEleBase = paragraph.getOdfElement();
      NodeList nodeImages = textParaEleBase.getElementsByTagName("draw:image");
      Node nodeImage = nodeImages.item(0);
      DrawImageElement im = (DrawImageElement) nodeImage;
      Image ima = Image.getInstanceof(im);
      image = item.replaceWith(ima);
      Assert.assertNotNull(image);
View Full Code Here

      }
      nextElement.remove();
    }

    private Paragraph findNext(Paragraph thisBox) {
      TextParagraphElementBase nextParagraph = null;
      if (thisBox == null) {
        nextParagraph = OdfElement.findFirstChildNode(TextParagraphElementBase.class, containerElement);
      } else {
        nextParagraph = OdfElement.findNextChildNode(TextParagraphElementBase.class, thisBox.getOdfElement());
      }
View Full Code Here

          }
          ceateIndexBodyEntry(textIndexBody, stylename, text);
        }
        // end of Outline support
        // Index Makes support
        TextParagraphElementBase podf = paragraph.getOdfElement();
        NodeList cns = podf.getChildNodes();
        for (int i = 0; i < cns.getLength(); i++) {
          Node node = cns.item(i);
          if (node instanceof TextTocMarkElement) {
            TextTocMarkElement textTocMarkElement = (TextTocMarkElement) node;
            text = textTocMarkElement.getTextStringValueAttribute();
View Full Code Here

          stylename = "Contents_20_" + headingLevel;
          ceateIndexBodyEntry(textIndexBody, stylename, text);
        }
        // end of Additional Styles support
        // Index Makes support
        TextParagraphElementBase podf = paragraph.getOdfElement();
        NodeList cns = podf.getChildNodes();
        for (int i = 0; i < cns.getLength(); i++) {
          Node node = cns.item(i);
          if (node instanceof TextTocMarkElement) {
            TextTocMarkElement textTocMarkElement = (TextTocMarkElement) node;
            text = textTocMarkElement.getTextStringValueAttribute();
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.text.TextParagraphElementBase

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.