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

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


      String contents = TextExtractor
          .getText((TextParagraphElementBase) nextPElement);
      if (!contents
          .startsWith("This is a picture from the source document:"))
        Assert.fail();
      TextSpanElement spanEle = (TextSpanElement) pElement
          .getElementsByTagName("text:span").item(0);
      Span span = Span.getInstanceof(spanEle);
      FontStyle fontStyle = span.getStyleHandler()
          .getTextPropertiesForRead().getFontStyle();
      Assert.assertEquals(FontStyle.BOLD, fontStyle);
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

    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);
      newTextSpanElement = doc.newParagraph("Show Simple Variable Field:").newTextSpanElement();
      simpleVariableField.displayField(newTextSpanElement);

      // declare user variable
View Full Code Here

  @Test
  public void testCreateReferenceField() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));
      TextSpanElement newTextSpanElement = doc.newParagraph("Reference Content:").newTextSpanElement();
      newTextSpanElement.setTextContent("This is a test reference content.");
      ReferenceField referenceField = Fields.createReferenceField(newTextSpanElement, "test-ref");
      Assert.assertNotNull(referenceField);
      referenceField
          .appendReferenceTo(doc.newParagraph("User Reference Field:"), ReferenceField.DisplayType.TEXT);
    } catch (Exception e) {
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

    }
  }

  // package constructor, only called by Fields
  ChapterField(OdfElement odfElement) {
    TextSpanElement spanElement = ((OdfFileDom) odfElement.getOwnerDocument()).newOdfElement(TextSpanElement.class);
    odfElement.appendChild(spanElement);
    chapterElement = spanElement.newTextChapterElement(null, 1);
    setDisplayPage(DisplayType.NUMBER_AND_NAME);
    Component.registerComponent(this, getOdfElement());
  }
View Full Code Here

public class SubjectField extends Field {
  private TextSubjectElement subjectElement;

  // package constructor, only called by Fields
  SubjectField(OdfElement odfElement) {
    TextSpanElement spanElement = ((OdfFileDom) odfElement.getOwnerDocument()).newOdfElement(TextSpanElement.class);
    odfElement.appendChild(spanElement);
    subjectElement = spanElement.newTextSubjectElement();
    try {
      OdfFileDom dom = (OdfFileDom) odfElement.getOwnerDocument();
      Meta meta = ((Document) dom.getDocument()).getOfficeMetadata();
      subjectElement.setTextContent(meta.getSubject());
    } catch (Exception e) {
View Full Code Here

   *            the reference OdfElement. The variable field will be appended
   *            after this element.
   */
  public void displayField(OdfElement refElement) {
    if (refElement instanceof TextSpanElement) {
      TextSpanElement spanEle = (TextSpanElement) refElement;
      switch (type) {
      case SIMPLE:
        spanEle.newTextVariableGetElement(name);
        break;
      case USER:
        spanEle.newTextUserFieldGetElement(name);
        break;
      case SEQUENCE:
        throw new IllegalArgumentException("Simple Java API for ODF doesn't support this type now.");
      }
    } else {
View Full Code Here

  private TextAuthorInitialsElement authorInitialsElement;

  // package constructor, only called by Fields
  AuthorField(OdfElement odfElement, boolean isAuthorInitials) {
    isInitials = isAuthorInitials;
    TextSpanElement spanElement = ((OdfFileDom) odfElement.getOwnerDocument()).newOdfElement(TextSpanElement.class);
    odfElement.appendChild(spanElement);
    if (isAuthorInitials) {
      authorInitialsElement = spanElement.newTextAuthorInitialsElement();
      authorInitialsElement.setTextFixedAttribute(false);
    } else {
      authorNameElement = spanElement.newTextAuthorNameElement();
      authorNameElement.setTextFixedAttribute(false);
    }
    Component.registerComponent(this, getOdfElement());
  }
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.