Package org.odftoolkit.odfdom.dom.element.text

Examples of org.odftoolkit.odfdom.dom.element.text.TextSpanElement


    // set date
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
    StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
    styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");
    styleTextPropertiesElement.setFoFontSizeAttribute("10pt");
    styleTextPropertiesElement.setStyleFontNameAsianAttribute("Lucida Sans Unicode");
    styleTextPropertiesElement.setStyleFontSizeAsianAttribute("12pt");
    noteSpanElement.setStyleName(textStyle.getStyleNameAttribute());
    // set comment content
    noteSpanElement.setTextContent(content);
    // insert comment to its position
    insertOdfElement(annotationElement, mIndexInContainer, parentElement);
    // three text length plus two '\r'
    int offset = content.length() + 1 + dcDate.length() + 1 + creator.length();
    SelectionManager.refresh(getContainerElement(), offset, getIndex());
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

      embDoc2.getStylesDom();
      OdfStyle documentStyle2 = embDoc2.getDocumentStyles().getStyle("myStyle", OdfStyleFamily.Paragraph);
      String prop2 = documentStyle2.getProperty(StyleTextPropertiesElement.FontWeight);
      Assert.assertEquals(prop2, "bold");

      TextSpanElement spanTest = (TextSpanElement) xpath.evaluate("//text:p[1]/text:span[1]", contentDom, XPathConstants.NODE);
      Assert.assertEquals(spanTest.getTextContent(), TEST_SPAN_TEXT);

    } catch (Exception ex) {
      Logger.getLogger(DocumentCreationTest.class.getName()).log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
    }
View Full Code Here

      OdfDocument docWithdoubleEmbeddedDoc = OdfDocument.loadDocument(TEST_FILE_EMBEDDED_EMBEDDED);
      OdfDocument doubleEmbeddedDoc =docWithdoubleEmbeddedDoc.loadSubDocument("Object 1/Object in Object1");

      OdfContentDom dEDcontentDom = doubleEmbeddedDoc.getContentDom();
      TextSpanElement spanTest = (TextSpanElement) xpath.evaluate("//text:span[last()]", dEDcontentDom, XPathConstants.NODE);
      Assert.assertEquals(spanTest.getTextContent(), TEST_SPAN_TEXT);

    } catch (Exception ex) {
      Logger.getLogger(DocumentCreationTest.class.getName()).log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
    }
View Full Code Here

    // set date
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
    StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
    styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");
    styleTextPropertiesElement.setFoFontSizeAttribute("10pt");
    styleTextPropertiesElement.setStyleFontNameAsianAttribute("Lucida Sans Unicode");
    styleTextPropertiesElement.setStyleFontSizeAsianAttribute("12pt");
    noteSpanElement.setStyleName(textStyle.getStyleNameAttribute());
    // set comment content
    noteSpanElement.setTextContent(content);
  }
View Full Code Here

      embDoc2.getStylesDom();
      OdfStyle documentStyle2 = embDoc2.getDocumentStyles().getStyle("myStyle", OdfStyleFamily.Paragraph);
      String prop2 = documentStyle2.getProperty(StyleTextPropertiesElement.FontWeight);
      Assert.assertEquals(prop2, "bold");

      TextSpanElement spanTest = (TextSpanElement) xpath.evaluate("//text:p[1]/text:span[1]", contentDom,
          XPathConstants.NODE);
      Assert.assertEquals(spanTest.getTextContent(), TEST_SPAN_TEXT);

    } catch (Exception ex) {
      Logger.getLogger(DocumentCreationTest.class.getName()).log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
    }
View Full Code Here

      Document docWithdoubleEmbeddedDoc = Document.loadDocument(TEST_FILE_EMBEDDED_EMBEDDED);
      Document embeddedDoc = docWithdoubleEmbeddedDoc.getEmbeddedDocument("Object 1");
      Document doubleEmbeddedDoc = embeddedDoc.getEmbeddedDocument("Object in Object1");

      OdfContentDom dEDcontentDom = doubleEmbeddedDoc.getContentDom();
      TextSpanElement spanTest = (TextSpanElement) xpath.evaluate("//text:span[last()]", dEDcontentDom,
          XPathConstants.NODE);
      Assert.assertEquals(spanTest.getTextContent(), TEST_SPAN_TEXT);

    } catch (Exception ex) {
      ex.printStackTrace();
      Logger.getLogger(DocumentCreationTest.class.getName()).log(Level.SEVERE, null, ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
View Full Code Here

    // set date
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
    } else if (dom instanceof OdfStylesDom) {
      styles = ((OdfStylesDom) dom).getAutomaticStyles();
    }
    OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
    StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
    styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");
    styleTextPropertiesElement.setFoFontSizeAttribute("10pt");
    styleTextPropertiesElement.setStyleFontNameAsianAttribute("Lucida Sans Unicode");
    styleTextPropertiesElement.setStyleFontSizeAsianAttribute("12pt");
    noteSpanElement.setStyleName(textStyle.getStyleNameAttribute());
    // set comment content
    noteSpanElement.setTextContent(content);
  }
View Full Code Here

  @Test
  public void testReplaceWithReferenceField() {
    try {
      search = new TextNavigation("ReplaceReferenceTarget", doc);
      TextSpanElement newTextSpanElement = doc.newParagraph("Selection Reference Content:").newTextSpanElement();
      newTextSpanElement.setTextContent("This is a test selection reference content.");
      ReferenceField referenceField = Fields.createReferenceField(newTextSpanElement, "selection-test-ref");
      // count the initial reference field count.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextReferenceRefElement.ELEMENT_NAME.getQName());
      int i = nodeList.getLength();
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

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.text.TextSpanElement

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.