Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.TextDocument$ParagraphContainerImpl


 
  @Test
  public void testGetTableBuilder() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      //Table tab = footer.addTable();
     
      TableBuilder tb = footer.getTableBuilder();
      Table tab = tb.newTable();
     
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("footerOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(FooterTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here


 
  @Test
  public void testGetVariableContainerElement() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      OdfElement odfEle = footer.getVariableContainerElement();
     
      TableBuilder tb = footer.getTableBuilder();
      Table tab = tb.newTable();
     
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      Node nod = odfEle.getFirstChild();
      Assert.assertEquals("table:table", nod.getNodeName());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("footerOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(FooterTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

 
 
  @Test
  public void testDeclareVariable() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      footer.declareVariable("footername", VariableType.USER);
     
      //validate
      StyleFooterElement styleFoot = footer.getOdfElement();
      Node nod = styleFoot.getFirstChild().getFirstChild();
      NamedNodeMap nameMap = nod.getAttributes();
      Node nodtext = nameMap.getNamedItem("text:name");
      Assert.assertEquals("footername", nodtext.getNodeValue());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("footerOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(FooterTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

 
 
  @Test
  public void testGetVariableFieldByName() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      footer.declareVariable("footername", VariableType.USER);
      VariableField vField = footer.getVariableFieldByName("footername");
      String vName = vField.getVariableName();
     
      //validate
View Full Code Here

  }

  @Test
  public void testAppendNewSection() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      Section sect = footer.appendSection("Section1");
      Assert.assertNotNull(sect);

      StyleFooterElement styleFoot = footer.getOdfElement();
      Node nod = styleFoot.getFirstChild();
View Full Code Here

public class SpanTest {

  @Test
  public void testSpan() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      doc.addParagraph("This is a test paragraph!");
      TextNavigation navigation = new TextNavigation("test", doc);
      TextSelection sel = (TextSelection) navigation.nextSelection();
      Span span = Span.newSpan(sel);
      TextHyperlink link = span.applyHyperlink(new URI("http://www.ibm.com"));
      DefaultStyleHandler handler = span.getStyleHandler();
      Font font1Base = new Font("Arial", FontStyle.ITALIC, 10, Color.BLACK, TextLinePosition.THROUGH);
      handler.getTextPropertiesForWrite().setFont(font1Base);
      doc.save(ResourceUtilities.newTestOutputFile("spantest.odt"));

      String content = span.getTextContent();
      Assert.assertEquals("test", content);
      span.setTextContent("new test");
      Assert.assertEquals("new test", span.getTextContent());
      doc.save(ResourceUtilities.newTestOutputFile("spantest.odt"));

    } catch (Exception e) {
      Logger.getLogger(SpanTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
View Full Code Here

  }
 
  @Test
  public void testRemoveTextContent() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
     
      Iterator<Paragraph> paraA = doc.getParagraphIterator();
      while(paraA.hasNext()){
        Paragraph pp = paraA.next();
        doc.removeParagraph(pp);
      }
     
      doc.addParagraph("This is a test paragraph!");
     
      TextNavigation navigation = new TextNavigation("test", doc);
      TextSelection sel = (TextSelection) navigation.nextSelection();
      Span span = Span.newSpan(sel);
     
      span.removeTextContent();
      boolean flag = false;
      Iterator<Paragraph> parai = doc.getParagraphIterator();
      while(parai.hasNext()){
        Paragraph pp = parai.next();
        if("This is a  paragraph!".equals(pp.getTextContent()))
          flag = true;
      }
      Assert.assertTrue(flag);

      //save
      doc.save(ResourceUtilities.newTestOutputFile("spantest.odt"));

    } catch (Exception e) {
      Logger.getLogger(SpanTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
    }
View Full Code Here

  }
 
  @Test
  public void testAppendTextContent() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      doc.addParagraph("This is a test paragraph!");
     
      TextNavigation navigation = new TextNavigation("test", doc);
      TextSelection sel = (TextSelection) navigation.nextSelection();
      Span span = Span.newSpan(sel);
     
View Full Code Here

 
 
  @Test
  public void testAppendTextContentPara() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      doc.addParagraph("This is a test paragraph!");
     
      TextNavigation navigation = new TextNavigation("test", doc);
      TextSelection sel = (TextSelection) navigation.nextSelection();
      Span span = Span.newSpan(sel);
     
View Full Code Here

     
      //save
      doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_REPLACE));
     
      //validate 
      TextDocument doc1 = (TextDocument) Document.loadDocument(ResourceUtilities.getAbsolutePath(SAVE_FILE_REPLACE));
      OdfContentDom contentDom1 = doc1.getContentDom();
     
      nodeList = contentDom1.getElementsByTagName(TextTimeElement.ELEMENT_NAME.getQName());
      for(int k =0;k<nodeList.getLength();k++){
        //
        Node nv = nodeList.item(k);
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.TextDocument$ParagraphContainerImpl

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.