Package org.odftoolkit.simple.text

Examples of org.odftoolkit.simple.text.Paragraph


  @Test
  public void testSetRectangle() {
    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"));
     
      FrameRectangle rectangle = new FrameRectangle(5.13, 4.21, 3.76, 3.51, StyleTypeDefinitions.SupportedLinearMeasure.CM);
      image.setRectangle(rectangle);
     
View Full Code Here


      Form form = doc.createForm("Test Form");
      // textbox1
      form.createTextBox(doc, textBoxRtg, "TextBox1", "TextBox1", true);

      // textbox2
      Paragraph para = doc.addParagraph("Insert a text box here.");
      FormControl textBox = form.createTextBox(para, textBoxRtg,
          "TextBox2", "TextBox2", false);
      textBox.setAnchorType(AnchorType.TO_CHARACTER);

      // textbox3
View Full Code Here

 
  @Test
  public void testAddTextbox() {
    try {
      TextDocument textDoc = TextDocument.newTextDocument();
      Paragraph p = textDoc.addParagraph("abc");
      Textbox box1 = p.addTextbox();
      box1.setTextContent("content XXXX");
      textDoc.save(ResourceUtilities.newTestOutputFile("textsample.odt"));
     
    } catch (Exception e) {
      Logger.getLogger(AbstractTextboxContainerTest.class.getName()).log(Level.SEVERE, null, e);
View Full Code Here

  @Test
  public void testGetDesc() {
    String content = "This is a text box";
    try {
      TextDocument textDoc = TextDocument.newTextDocument();
      Paragraph p = textDoc.addParagraph("paragraph demo");
      FrameRectangle frameR = new FrameRectangle(4.21, 1.32, 4.41, 3.92, SupportedLinearMeasure.CM);
      Assert.assertEquals("4.21cm", frameR.getXDesc());
      Assert.assertEquals("1.32cm", frameR.getYDesc());
      Assert.assertEquals("4.41cm", frameR.getWidthDesc());
      Assert.assertEquals("3.92cm", frameR.getHeigthDesc());
     
      Textbox box = p.addTextbox(frameR);
      box.setName("tbox name");
      box.setTextContent(content);
      textDoc.save(ResourceUtilities.newTestOutputFile("textsample.odt"));

    } catch (Exception e) {
View Full Code Here

  @Test
  public void testSet() {
    String content = "This is a text box";
    try {
      TextDocument textDoc = TextDocument.newTextDocument();
      Paragraph p = textDoc.addParagraph("paragraph demo");
      FrameRectangle frameR = new FrameRectangle(4.21, 1.32, 4.41, 3.92, SupportedLinearMeasure.CM);
      frameR.setHeight(3.22);
      Assert.assertEquals(3.22, frameR.getHeight());
      frameR.setWidth(4.44);
      Assert.assertEquals(4.44, frameR.getWidth());
     
      Assert.assertEquals(SupportedLinearMeasure.CM, frameR.getLinearMeasure());
      frameR.setLinearMeasure(SupportedLinearMeasure.IN);
      Assert.assertEquals(SupportedLinearMeasure.IN, frameR.getLinearMeasure());
     
      Textbox box = p.addTextbox(frameR);
      box.setName("tbox name");
      box.setTextContent(content);
      textDoc.save(ResourceUtilities.newTestOutputFile("textsample.odt"));

    } catch (Exception e) {
View Full Code Here

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

      // list box2
      Paragraph para = doc.addParagraph("Insert a list box here.");
      listBox = form
          .createListBox(para, listBoxRtg, "list2", false, true);
      form.setDataSource("Bibliography");
      form.setCommandType(FormCommandType.TABLE);
      form.setCommand("biblio");
View Full Code Here

      // checkbox 1
      CheckBox checkbox = (CheckBox) form.createCheckBox(doc,
          checkBoxRtg, "CheckBox 1", "CheckBox 1", "1");

      // checkbox 2
      Paragraph para = doc.addParagraph("CheckBox2 anchor to heading.");
      para.applyHeading();
      form.createCheckBox(para, checkBoxRtg, "CheckBox 2", "CheckBox 2",
          "2");

      // checkbox 3
      para = doc.addParagraph("Insert checkbox3 here, as_char.");
View Full Code Here

  @Test
  public void testAddTextbox() {
    String content = "This is a 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.setTextContent(content);
      textDoc.save(ResourceUtilities.newTestOutputFile("textsample.odt"));

      textDoc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("textsample.odt"));
      Paragraph p1 = textDoc.getParagraphByIndex(0, true);
      Assert.assertNotNull(p1);
      Textbox aBox = p1.getTextboxByName("box1");
      Assert.assertNotNull(aBox);
      String textContent = aBox.getTextContent();
      Assert.assertEquals(content, textContent);

      PresentationDocument presentDoc = PresentationDocument.newPresentationDocument();
View Full Code Here

    search = new TextNavigation("SIMPLE", doc);
    int i = 0;
    while (search.hasNext()) {
        TextSelection item = (TextSelection) search.nextSelection();
        ParagraphSelection nextParagraphSelection=new ParagraphSelection(item);
        Paragraph paragraph=sourcedoc.getParagraphByIndex(0, true);
        nextParagraphSelection.replaceWithParagraph(paragraph);
      i++;
    }
    search = new TextNavigation("Hello1 from SIMPLE source document!", doc);
    int j = 0;
    while (search.hasNext()) {
      search.nextSelection();
      j++;
    }
    Assert.assertTrue(i == j);
   
    //2 Task1, #1 at the start of original Paragraph, #2 replace original Paragraph 
        search = new TextNavigation("Task1", doc);
         i = 0;
        while (search.hasNext()) {
            TextSelection item = (TextSelection) search.nextSelection();
            ParagraphSelection nextParagraphSelection=new ParagraphSelection(item);
            Paragraph paragraph=sourcedoc.getParagraphByIndex(1, true);
            nextParagraphSelection.replaceWithParagraph(paragraph);
          i++;
        }
        search = new TextNavigation("Hello2 from source document!", doc);
         j = 0;
        while (search.hasNext()) {
          search.nextSelection();
          j++;
        }
        Assert.assertTrue(i == j);
   
        //1 Container, #1 at the end of original Paragraph,
        search = new TextNavigation("Container", doc);
         i = 0;
        while (search.hasNext()) {
            TextSelection item = (TextSelection) search.nextSelection();
            ParagraphSelection nextParagraphSelection=new ParagraphSelection(item);
            Paragraph paragraph=sourcedoc.getParagraphByIndex(2, true);
            nextParagraphSelection.replaceWithParagraph(paragraph);
          i++;
        }
        search = new TextNavigation("Hello3 from source document!", doc);
         j = 0;
View Full Code Here

      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("SampleBox.odt"));
      count = countAllTextbox(doc);
      Assert.assertEquals(8, count);

      int c = 0;
      Paragraph p = doc.getParagraphByIndex(1, true);
      Iterator<Textbox> boxIter = p.getTextboxIterator();
      while (boxIter.hasNext()) {
        Textbox box = boxIter.next();
        if (p.removeTextbox(box))
          ;
        c++;
      }

      count = countAllTextbox(doc);
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.