Package org.odftoolkit.simple.text

Examples of org.odftoolkit.simple.text.Paragraph


 
  private int countAllTextbox(TextDocument doc) {
    int count = 0;
    Iterator<Paragraph> pIter = doc.getParagraphIterator();
    while (pIter.hasNext()) {
      Paragraph p = pIter.next();
      Iterator<Textbox> boxIter = p.getTextboxIterator();
      while (boxIter.hasNext()) {
        Textbox box = boxIter.next();
        System.out.println(box.getTextContent());
        count++;
      }
View Full Code Here


  @Test
  public void testClearContent() {
    String content = "welcome to text box";
    try {
      TextDocument textDoc = TextDocument.newTextDocument();
      Paragraph p = textDoc.addParagraph("abc");
      Textbox box = p.addTextbox(new FrameRectangle(1, 1, 2, 3, SupportedLinearMeasure.IN));
      box.setName("box1");
      box.addParagraph("test paragraph");
      box.clearContent();
      box.setTextContent(content);
      textDoc.save(ResourceUtilities.newTestOutputFile("textsample.odt"));
View Full Code Here

      TextDocument doc = TextDocument.newTextDocument();
      Form form = doc.createForm("Test Form");
      form.createButton(doc, btnRtg, "Button1", "Push Button 1");
      form.createButton(doc, btnRtg, "Button2", "Push Button 2");

      Paragraph para = doc.addParagraph("Insert a button here.");
      form.createButton(para, btnRtg, "Button3", "Push Button 3");

      Table table1 = Table.newTable(doc, 2, 2);
      Cell cell = table1.getCellByPosition("A1");
      para = cell.addParagraph("Insert a button here:");
View Full Code Here

  @Test
  public void testAddPageBreak() {
    try {
      // test new creation document.
      TextDocument newDoc = TextDocument.newTextDocument();
      Paragraph paragraph = newDoc.addParagraph("before page break");
      newDoc.addPageBreak();
      validPageBreakExist(newDoc, paragraph);
      Paragraph refParagraph = newDoc.addParagraph("after page break");
      newDoc.addParagraph("end page");
      newDoc.addPageBreak(refParagraph);
      validPageBreakExist(newDoc, refParagraph);
      newDoc.save(ResourceUtilities.newTestOutputFile("AddPageBreakOutput.odt"));
View Full Code Here

    try {

      TextDocument newDoc = TextDocument.newTextDocument();

      // create a new master page
      Paragraph paragraph = newDoc
          .addParagraph("before page break - original Landscape");
      MasterPage master1 = MasterPage.getOrCreateMasterPage(newDoc,
          "Landscape");
      master1.setPageWidth(279.4);
      master1.setPageHeight(215.9);
View Full Code Here

  public void testAddComment() {
    try {
      // test new creation document.
      TextDocument newDoc = TextDocument.newTextDocument();
     
      Paragraph paragraph = newDoc.addParagraph("Paragraph1");
      paragraph.addComment("This is a comment for Paragraph1", "Simple ODF");
      Node firstChildNode = paragraph.getOdfElement().getFirstChild();
      Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
      OfficeAnnotationElement comment = (OfficeAnnotationElement) firstChildNode;
      Assert.assertEquals("Simple ODF", comment.getFirstChild().getTextContent());
      Assert.assertEquals("This is a comment for Paragraph1", comment.getLastChild().getTextContent());
      Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
     
      paragraph = newDoc.addParagraph("Paragraph2");
      paragraph.addComment("This is a comment for Paragraph2", null);
      firstChildNode = paragraph.getOdfElement().getFirstChild();
      Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
      comment = (OfficeAnnotationElement) firstChildNode;
      Assert.assertEquals(System.getProperty("user.name"), comment.getFirstChild().getTextContent());
      Assert.assertEquals("This is a comment for Paragraph2", comment.getLastChild().getTextContent());
     
View Full Code Here

      String filePath = ResourceUtilities.getAbsolutePath("headerFooterHidden.odt");
      File file = new File(filePath);
      TextDocument tdoc = TextDocument.loadDocument(file);
      Assert.assertNotNull(tdoc);
     
      Paragraph para = tdoc.addParagraph("paragraph1");
      Assert.assertEquals("paragraph1", para.getTextContent());
      boolean flag = tdoc.removeParagraph(para);
      Document doc = para.getOwnerDocument();
      Assert.assertNotSame(doc, tdoc);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

  public void testinsertContentFromDocumentBefore() throws Exception {
    TextDocument src1 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    TextDocument src2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    TextDocument target1 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    TextDocument target2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    Paragraph p1 = target1.getParagraphByIndex(2, true);
    target1.insertContentFromDocumentBefore(src1, p1, true);
    Iterable<OdfStyle> pstyles1 = target1.getStylesDom().getOfficeStyles().getStylesForFamily(OdfStyleFamily.Paragraph);
    Iterator<OdfStyle> ite = pstyles1.iterator();
    int i=0;
    System.out.println("Custom Styles in TestInsertDocumentWithStyleBefore.odt");
    while(ite.hasNext()){
      OdfStyle odfStyle = ite.next();
      String sname = odfStyle.getAttribute("style:name");
      if(sname.startsWith("style"))
      {
        i++;
        System.out.println(sname);
      }
    } 
    Assert.assertEquals(6, i);
    target1.save(ResourceUtilities.newTestOutputFile("TestInsertDocumentWithStyleBefore.odt"));
   
    target2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    Paragraph p2 = target2.getParagraphByIndex(2, true);
    target2.insertContentFromDocumentBefore(src2, p2, false);
   
    Iterable<OdfStyle> pstyles2 = target2.getStylesDom().getOfficeStyles().getStylesForFamily(OdfStyleFamily.Paragraph);
    Iterator<OdfStyle> ite2 = pstyles2.iterator();
    i=0;
View Full Code Here

  public void testinsertContentFromDocumentAfter() throws Exception {
    TextDocument src1 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    TextDocument src2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    TextDocument target1 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    TextDocument target2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    Paragraph p1 = target1.getParagraphByIndex(2, true);
    target1.insertContentFromDocumentAfter(src1, p1, true);
    Iterable<OdfStyle> pstyles1 = target1.getStylesDom().getOfficeStyles().getStylesForFamily(OdfStyleFamily.Paragraph);
    Iterator<OdfStyle> ite = pstyles1.iterator();
    int i=0;
    System.out.println("Custom Styles in TestInsertDocumentWithStyleAfter.odt:");
    while(ite.hasNext()){
      OdfStyle odfStyle = ite.next();
      String sname = odfStyle.getAttribute("style:name");
      if(sname.startsWith("style"))
      {
        i++;
        System.out.println(sname);
      }
    } 
    Assert.assertEquals(6, i);
    target1.save(ResourceUtilities.newTestOutputFile("TestInsertDocumentWithStyleAfter.odt"));
   
   
   
    target2 = TextDocument.loadDocument(ResourceUtilities.getAbsolutePath("TestInsertDocument.odt"));
    Paragraph p2 = target2.getParagraphByIndex(2, true);
    target2.insertContentFromDocumentAfter(src2, p2, false);
   
    Iterable<OdfStyle> pstyles2 = target2.getStylesDom().getOfficeStyles().getStylesForFamily(OdfStyleFamily.Paragraph);
    Iterator<OdfStyle> ite2 = pstyles2.iterator();
    i=0;
View Full Code Here

          "combo1", "dd", true);
      String[] items = { "aa", "bb", "cc", "dd", "ee", "ff", "gg", "hh",
          "ii", "jj" };
      ((ComboBox) comboBox).addItems(items);

      Paragraph para = doc.addParagraph("Insert a combo box here.");
      comboBox = form.createComboBox(para, comboRtg, "combo2",
          "default text", true);
      form.setDataSource("Bibliography");
      form.setCommandType(FormCommandType.TABLE);
      form.setCommand("biblio");
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.