Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.TextDocument.newParagraph()


  @Test
  public void testAddDateField() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      DateField dateField = Fields.createDateField(doc.newParagraph("Date:"));
      Assert.assertNotNull(dateField);

      TextDateElement dateEle = dateField.getOdfElement();
      String oldContent = dateEle.getTextContent();
      SimpleDateFormat oldFormat = new SimpleDateFormat("yyyy-MM-dd");
View Full Code Here


  @Test
  public void testAddTimeField() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      TimeField timeField = Fields.createTimeField(doc.newParagraph("Time:"));
      Assert.assertNotNull(timeField);

      TextTimeElement timeEle = timeField.getOdfElement();
      String oldContent = timeEle.getTextContent();
      SimpleDateFormat oldFormat = new SimpleDateFormat("HH:mm:ss");
View Full Code Here

  @Test
  public void testGetFieldType() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      SubjectField subjectField = Fields.createSubjectField(doc.newParagraph("The Subject:"));
     
      FieldType fieldType = subjectField.getFieldType();
      Assert.assertNotNull(subjectField);
      Assert.assertEquals(fieldType, FieldType.SUBJECT_FIELD);
    } catch (Exception e) {
View Full Code Here

  @Test
  public void testGetFieldType() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      TitleField titleField = Fields.createTitleField(doc.newParagraph("The Title:"));
      Assert.assertNotNull(titleField);
      FieldType fType = titleField.getFieldType();
      Assert.assertEquals(fType, FieldType.TITLE_FIELD);
    } catch (Exception e) {
      Logger.getLogger(TitleFieldTest.class.getName()).log(Level.SEVERE, null, e);
View Full Code Here

    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));
      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_simple_variable");
      Assert.assertNotNull(simpleVariableField);
      TextSpanElement newTextSpanElement = doc.newParagraph("Update Simple Variable Field:").newTextSpanElement();
      simpleVariableField.updateField("simple variable content", newTextSpanElement);
     
      FieldType fieldType = simpleVariableField.getFieldType();
      Assert.assertNotNull(fieldType);
      Assert.assertEquals(FieldType.SIMPLE_VARIABLE_FIELD, fieldType);
View Full Code Here

      simpleVariableField.updateField("simple variable content", newTextSpanElement);
     
      FieldType fieldType = simpleVariableField.getFieldType();
      Assert.assertNotNull(fieldType);
      Assert.assertEquals(FieldType.SIMPLE_VARIABLE_FIELD, fieldType);
      newTextSpanElement = doc.newParagraph("Show Simple Variable Field:").newTextSpanElement();
      simpleVariableField.displayField(newTextSpanElement);
      simpleVariableField.updateField("aaaa", newTextSpanElement);
      try {
        doc.save(ResourceUtilities.newTestOutputFile("TextFieldSampleDocumentVariableField.odt"));
      } catch (Exception e) {
View Full Code Here

    sourcedoc.addParagraph("Hello1 from SIMPLE source document!");
    sourcedoc.addParagraph("Hello2 from source document!");
    sourcedoc.addParagraph("Hello3 from source document!");
    VariableField variableField = Fields.createUserVariableField(sourcedoc, "test_simple_variable","testReplacewithField");
    Assert.assertNotNull(variableField);
    TextSpanElement newTextSpanElement = sourcedoc.newParagraph("Update Variable Field:").newTextSpanElement();
    variableField.updateField("simple variable content", newTextSpanElement);
    newTextSpanElement = sourcedoc.newParagraph("Show Variable Field:").newTextSpanElement();
    variableField.displayField(newTextSpanElement);
    Field orgField = sourcedoc.getVariableFieldByName("test_simple_variable");
    // 6 Simple, at the middle of original Paragraph, split original
View Full Code Here

    sourcedoc.addParagraph("Hello3 from source document!");
    VariableField variableField = Fields.createUserVariableField(sourcedoc, "test_simple_variable","testReplacewithField");
    Assert.assertNotNull(variableField);
    TextSpanElement newTextSpanElement = sourcedoc.newParagraph("Update Variable Field:").newTextSpanElement();
    variableField.updateField("simple variable content", newTextSpanElement);
    newTextSpanElement = sourcedoc.newParagraph("Show Variable Field:").newTextSpanElement();
    variableField.displayField(newTextSpanElement);
    Field orgField = sourcedoc.getVariableFieldByName("test_simple_variable");
    // 6 Simple, at the middle of original Paragraph, split original
    // Paragraph, insert before the second Paragraph.
    search = new TextNavigation("SIMPLE", doc);
View Full Code Here

 
  @Test
  public void testGetFieldType() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));
      ChapterField chapterField = Fields.createChapterField(doc.newParagraph("Chapter:"));
      FieldType fieldType = chapterField.getFieldType();
      Assert.assertNotNull(fieldType);
      Assert.assertEquals(FieldType.CHAPTER_FIELD, fieldType);
    } catch (Exception e) {
      Logger.getLogger(ChapterFieldTest.class.getName()).log(Level.SEVERE, null, e);
View Full Code Here

  @Test
  public void testGetFieldType() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      PageNumberField numberField = Fields.createCurrentPageNumberField(doc.newParagraph("Current Page Number:"));
      Assert.assertNotNull(numberField);
      FieldType fieldType = numberField.getFieldType();
      Assert.assertNotNull(fieldType);
      Assert.assertEquals(fieldType, FieldType.CURRENT_PAGE_NUMBER_FIELD);
      numberField.setDisplayPage(DisplayType.PREVIOUS_PAGE);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.