Package org.odftoolkit.simple.common.field

Examples of org.odftoolkit.simple.common.field.Field


    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);
    while (search.hasNext()) {
      TextSelection item = (TextSelection) search.nextSelection();
      try {
        Field newField = item.replaceWith(orgField);
      } catch (InvalidNavigationException e) {
        e.printStackTrace();
      }
    }
    try {
View Full Code Here


   */
  public Field replaceWithSimpleField(Field.FieldType fieldType) {
    int leftLength = textSelection.getText().length();
    int index = textSelection.getIndex();
    prepareSpanContainer(leftLength, index);
    Field field = null;
    switch (fieldType) {
    case DATE_FIELD:
      field = Fields.createDateField(spanContainer);
      break;
    case FIXED_DATE_FIELD:
      field = Fields.createFixedDateField(spanContainer);
      break;
    case TIME_FIELD:
      field = Fields.createTimeField(spanContainer);
      break;
    case FIXED_TIME_FIELD:
      field = Fields.createFixedTimeField(spanContainer);
      break;
    case PREVIOUS_PAGE_NUMBER_FIELD:
      field = Fields.createPreviousPageNumberField(spanContainer);
      break;
    case CURRENT_PAGE_NUMBER_FIELD:
      field = Fields.createCurrentPageNumberField(spanContainer);
      break;
    case NEXT_PAGE_NUMBER_FIELD:
      field = Fields.createNextPageNumberField(spanContainer);
      break;
    case PAGE_COUNT_FIELD:
      field = Fields.createPageCountField(spanContainer);
      break;
    case TITLE_FIELD:
      field = Fields.createTitleField(spanContainer);
      break;
    case SUBJECT_FIELD:
      field = Fields.createSubjectField(spanContainer);
      break;
    case AUTHOR_NAME_FIELD:
      field = Fields.createAuthorNameField(spanContainer);
      break;
    case AUTHOR_INITIALS_FIELD:
      field = Fields.createAuthorInitialsField(spanContainer);
      break;
    case CHAPTER_FIELD:
      field = Fields.createChapterField(spanContainer);
      break;
    case REFERENCE_FIELD:
    case SIMPLE_VARIABLE_FIELD:
    case USER_VARIABLE_FIELD:
    case CONDITION_FIELD:
    case HIDDEN_TEXT_FIELD:
      throw new IllegalArgumentException("this is not a vaild simple field type.");
    }
    textSelection.mMatchedText = field.getOdfElement().getTextContent();
    int textLength = textSelection.mMatchedText.length();
    int offset = textLength - leftLength;
    SelectionManager.refresh(textSelection.getContainerElement(), offset, index + textLength);
    return field;
  }
View Full Code Here

   */
  public Field replaceWith(Field orgField) throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    Field newfield=null;
    OdfElement parentElement = getContainerElement();
    Paragraph orgparagraph = Paragraph.getInstanceof((TextParagraphElementBase) parentElement);
    TextDocument document = (TextDocument) orgparagraph.getOwnerDocument();
   
    FieldSelection nextFieldSelection=new FieldSelection(this);
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.common.field.Field

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.