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

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


  public void decorateListItem(ListItem item) {
    TextListItemElement listItemElement = item.getOdfElement();
    Node child = listItemElement.getFirstChild();
    while (child != null) {
      if (child instanceof TextPElement) {
        TextPElement pElement = (TextPElement) child;
        pElement.setTextStyleNameAttribute(paragraphStyle.getStyleNameAttribute());
      }
      child = child.getNextSibling();
    }
  }
View Full Code Here


  public void decorateListItem(ListItem item) {
    TextListItemElement listItemElement = item.getOdfElement();
    Node child = listItemElement.getFirstChild();
    while (child != null) {
      if (child instanceof TextPElement) {
        TextPElement pElement = (TextPElement) child;
        // user can realize defined style for specifies item.
        /*
         * if (pElement.getTextContent().contains("item1")) { OdfStyle
         * sParagraphStyle = styles.newStyle(OdfStyleFamily.Paragraph);
         * sParagraphStyle
         * .setStyleParentStyleNameAttribute("Default_20_Text");
         * sParagraphStyle
         * .newStyleTextPropertiesElement(null).setFoColorAttribute
         * ("#ff3333");
         * pElement.setTextStyleNameAttribute(sParagraphStyle
         * .getStyleNameAttribute()); } else
         */
        pElement.setTextStyleNameAttribute(paragraphStyle.getStyleNameAttribute());
      }
      child = child.getNextSibling();
    }
  }
View Full Code Here

      if (refElement instanceof TextPElement) {
        textVariableSetElement = ((TextPElement) refElement).newTextVariableSetElement(0, "string", name);
      } else if (refElement instanceof TextSpanElement) {
        textVariableSetElement = ((TextSpanElement) refElement).newTextVariableSetElement(0, "string", name);
      } else {
        TextPElement pElement = ((OdfFileDom) refElement.getOwnerDocument()).newOdfElement(TextPElement.class);
        OdfElement parentEle = (OdfElement) refElement.getParentNode();
        parentEle.insertBefore(pElement, refElement.getNextSibling());
        textVariableSetElement = pElement.newTextVariableSetElement(0, "string", name);
      }
      textVariableSetElement.removeAttributeNS(officeNS, "value");
      textVariableSetElement.setOfficeStringValueAttribute(value);
      textVariableSetElement.setTextContent(value);
      break;
View Full Code Here

        break;
      case SEQUENCE:
        throw new IllegalArgumentException("Simple Java API for ODF doesn't support this type now.");
      }
    } else {
      TextPElement textPElement;
      if (refElement instanceof TextPElement) {
        textPElement = (TextPElement) refElement;
      } else {
        textPElement = ((OdfFileDom) refElement.getOwnerDocument()).newOdfElement(TextPElement.class);
        OdfElement parentEle = (OdfElement) refElement.getParentNode();
        parentEle.insertBefore(textPElement, refElement.getNextSibling());
      }
      switch (type) {
      case SIMPLE:
        textPElement.newTextVariableGetElement(name);
        break;
      case USER:
        textPElement.newTextUserFieldGetElement(name);
        break;
      case SEQUENCE:
        throw new IllegalArgumentException("Simple Java API for ODF doesn't support this type now.");
      }
    }
View Full Code Here

          falseText, trueText);
    } else if (odfElement instanceof TextSpanElement) {
      conditionalTextElement = ((TextSpanElement) odfElement).newTextConditionalTextElement("ooow:" + condition,
          falseText, trueText);
    } else {
      TextPElement pElement = ((OdfFileDom) odfElement.getOwnerDocument()).newOdfElement(TextPElement.class);
      odfElement.appendChild(pElement);
      conditionalTextElement = pElement.newTextConditionalTextElement("ooow:" + condition, falseText, trueText);
    }
    conditionalTextElement.setTextCurrentValueAttribute(true);
    this.isHiddenTextField = isHiddenTextField;
    Component.registerComponent(this, getOdfElement());
  }
View Full Code Here

   */
  public static Paragraph newParagraph(ParagraphContainer container) {
    Paragraph para = null;
    OdfElement parent = container.getParagraphContainerElement();
    OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument();
    TextPElement pEle = ownerDom.newOdfElement(TextPElement.class);
    parent.appendChild(pEle);
    para = new Paragraph(pEle);
    Component.registerComponent(para, pEle);

    return para;
View Full Code Here

    dcCreatorElement.setTextContent(creator);
    // 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) {
View Full Code Here

   * Create child element {@odf.element text:p}.
   *
   * @return the element {@odf.element text:p}
   */
  public TextPElement newTextPElement() {
    TextPElement textP = ((OdfFileDom) this.ownerDocument).newOdfElement(TextPElement.class);
    this.appendChild(textP);
    return textP;
  }
View Full Code Here

    if (odfEle instanceof TextPElement) {
      odfEle.appendChild(spanElement);
    } else {
      OdfElement parentEle = (OdfElement) odfEle.getParentNode();
      Node nextSiblingEle =  odfEle.getNextSibling();
      TextPElement pElement = ((OdfFileDom) odfEle.getOwnerDocument()).newOdfElement(TextPElement.class);
      pElement.appendChild(spanElement);
      if (nextSiblingEle == null) {
        parentEle.appendChild(pElement);
      } else {
        parentEle.insertBefore(pElement, nextSiblingEle);
      }
View Full Code Here

    } else {
      headerEle.setStyleDisplayAttribute(false);
    }
    NodeList nodeList = headerEle.getElementsByTagName(TextPElement.ELEMENT_NAME.getQName());
    for (int i = 0; i < nodeList.getLength(); i++) {
      TextPElement textEle = (TextPElement) nodeList.item(i);
      String stylename = textEle.getStyleName();
      OdfFileDom dom = (OdfFileDom) headerEle.getOwnerDocument();
      OdfOfficeAutomaticStyles styles = null;
      if (dom instanceof OdfContentDom) {
        styles = ((OdfContentDom) dom).getAutomaticStyles();
      } else if (dom instanceof OdfStylesDom) {
        styles = ((OdfStylesDom) dom).getAutomaticStyles();
      }

      OdfStyle newStyle = styles.newStyle(OdfStyleFamily.Paragraph);
      OdfStyle style = styles.getStyle(stylename, OdfStyleFamily.Paragraph);
      if (style != null) {
        String styleName = newStyle.getStyleNameAttribute();
        styles.removeChild(newStyle);
        newStyle = (OdfStyle) style.cloneNode(true);
        newStyle.setStyleNameAttribute(styleName);
        styles.appendChild(newStyle);
      }
      if (isVisible) {
        if (newStyle.hasProperty(StyleTextPropertiesElement.Display)) {
          newStyle.removeProperty(StyleTextPropertiesElement.Display);
        }
      } else {
        newStyle.setProperty(StyleTextPropertiesElement.Display, "none");
      }
      textEle.setStyleName(newStyle.getStyleNameAttribute());
    }
  }
View Full Code Here

TOP

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

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.