Examples of OdfStylableElement


Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

   * deal with the style, the inserted span will also have the style of
   * <code>parentNode</code>.
   */
  private void adjustStyle(Node parentNode, OdfTextSpan textSpan, Map<OdfStyleProperty, String> styleMap) {
    if (parentNode instanceof OdfStylableElement) {
      OdfStylableElement pStyleNode = (OdfStylableElement) parentNode;
      if (styleMap == null) {
        styleMap = getTextStylePropertiesDeep(pStyleNode);
      }
      Node node = parentNode.getFirstChild();
      while (node != null) {
        if (node.getNodeType() == Node.TEXT_NODE) {
          if (node.getTextContent().length() > 0) {
            Node nextNode = node.getNextSibling();
            OdfTextSpan span = new OdfTextSpan((OdfFileDom) node.getOwnerDocument());
            span.appendChild(node);
            if (nextNode != null) {
              parentNode.insertBefore(span, nextNode);
            } else {
              parentNode.appendChild(span);
            }
            node = span;
            applyTextStyleProperties(styleMap, (OdfStylableElement) node);
          }
        } else if ((node instanceof OdfStylableElement)) {
          if (!node.equals(textSpan)) {
            Map<OdfStyleProperty, String> styles = getTextStylePropertiesDeep(pStyleNode);
            Map<OdfStyleProperty, String> styles1 = getTextStylePropertiesDeep((OdfStylableElement) node);
            if (styles == null) {
              styles = styles1;
            } else if (styles1 != null) {
              styles.putAll(styles1);
            }
            int comp = node.compareDocumentPosition(textSpan);
            // if node contains textSpan, then recurse the node
            if ((comp & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0) {
              adjustStyle(node, textSpan, styles);
            } else {
              applyTextStyleProperties(styles, (OdfStylableElement) node);
            }
          }
        }
        node = node.getNextSibling();
      }
      // change the parentNode to default style
      // here we don't know the default style name, so here just
      // remove the text:style-name attribute
      pStyleNode.removeAttributeNS(OdfDocumentNamespace.TEXT.getUri(), "style-name");
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

  @Override
  public boolean match(Node element) {
    boolean match = false;
    if (element.getNodeType() == Node.TEXT_NODE && !element.getNodeValue().trim().equals("")) {
      if (element.getParentNode() instanceof OdfStylableElement) {
        OdfStylableElement parStyleElement = (OdfStylableElement) element.getParentNode();
        String parStyleName = getStyleName(parStyleElement);
        if (getMatchStyleNames().contains(parStyleName)) {
          match = true;
          mText = element.getNodeValue();
          NodeList nodes = getPHElement(element.getParentNode()).getChildNodes();
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

  // Set the text content in this cell. If content is null, it will display
  // the empty string instead.
  private void setDisplayTextContent(String content, String stylename) {
    WhitespaceProcessor textProcessor = new WhitespaceProcessor();
    OdfStylableElement element = OdfElement.findFirstChildNode(OdfTextParagraph.class, mCellElement);
    if (element == null) {
      removeContent();
      element = new OdfTextParagraph((OdfFileDom) mCellElement.getOwnerDocument());
      mCellElement.appendChild(element);
    } else {
      String formerContent = element.getTextContent();
      while (formerContent == null || "".equals(formerContent)) {
        OdfTextSpan span = OdfElement.findFirstChildNode(OdfTextSpan.class, element);
        if (span == null) {
          break;
        }
        formerContent = span.getTextContent();
        element = span;
      }
    }
    if ((stylename != null) && (stylename.length() > 0)) {
      element.setStyleName(stylename);
    }
    element.setTextContent(null);
    textProcessor.append(element, content);
    optimizeCellSize(content);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

  @Override
  public boolean match(Node element) {
    boolean match = false;
    if (element.getNodeType() == Node.TEXT_NODE && !element.getNodeValue().trim().equals("")) {
      if (element.getParentNode() instanceof OdfStylableElement) {
        OdfStylableElement parStyleElement = (OdfStylableElement) element.getParentNode();

        String parStyleName = getStyleName(parStyleElement);

        if (getMatchStyleNames().contains(parStyleName)) {
          match = true;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

   * if we don't deal with the style, the inserted span will also have the style of parentNode
   *
   */
  private void adjustStyle(Node parentNode, OdfTextSpan textSpan, Map<OdfStyleProperty, String> styleMap) {
    if (parentNode instanceof OdfStylableElement) {
      OdfStylableElement pStyleNode = (OdfStylableElement) parentNode;
      if (styleMap == null) {
        styleMap = getTextStylePropertiesDeep(pStyleNode);
      }
      Node node = parentNode.getFirstChild();
      while (node != null) {
        if (node.getNodeType() == Node.TEXT_NODE) {
          if (node.getTextContent().length() > 0) {
            Node nextNode = node.getNextSibling();
            OdfTextSpan span = new OdfTextSpan((OdfFileDom) node.getOwnerDocument());
            span.appendChild(node);
            if (nextNode != null) {
              parentNode.insertBefore(span, nextNode);
            } else {
              parentNode.appendChild(span);
            }
            node = span;
            applyTextStyleProperties(styleMap, (OdfStylableElement) node);
          }
        } else if ((node instanceof OdfStylableElement)) {
          if (!node.equals(textSpan)) {
            Map<OdfStyleProperty, String> styles = getTextStylePropertiesDeep(pStyleNode);
            Map<OdfStyleProperty, String> styles1 = getTextStylePropertiesDeep((OdfStylableElement) node);
            if (styles == null) {
              styles = styles1;
            } else if (styles1 != null) {
              styles.putAll(styles1);
            }
            int comp = node.compareDocumentPosition(textSpan);
            //if node contains textSpan, then recurse the node
            if ((comp & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0) {
              adjustStyle(node, textSpan, styles);
            } else {
              applyTextStyleProperties(styles, (OdfStylableElement) node);
            }
          }

        }
        node = node.getNextSibling();
      }
      //change the parentNode to default style
      //here we don't know the default style name, so here just
      //remove the text:style-name attribute
      pStyleNode.removeAttributeNS(OdfDocumentNamespace.TEXT.getUri(), "style-name");
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

  // Set the text content in this cell. If content is null, it will display
  // the empty string instead.
  private void setDisplayTextContent(String content, String stylename) {
    WhitespaceProcessor textProcessor = new WhitespaceProcessor();
    OdfStylableElement element = OdfElement.findFirstChildNode(OdfTextParagraph.class, mCellElement);
    if (element == null) {
      removeContent();
      element = new OdfTextParagraph((OdfFileDom) mCellElement.getOwnerDocument());
      mCellElement.appendChild(element);
    } else {
      String formerContent = element.getTextContent();
      while (formerContent == null || "".equals(formerContent)) {
        OdfTextSpan span = OdfElement.findFirstChildNode(OdfTextSpan.class, element);
        if (span == null) {
          break;
        }
        formerContent = span.getTextContent();
        element = span;
      }
    }
    if ((stylename != null) && (stylename.length() > 0)) {
      element.setStyleName(stylename);
    }
    element.setTextContent(null);
    textProcessor.append(element, content);
    optimizeCellSize(content);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

   * if we don't deal with the style, the inserted span will also have the style of parentNode
   *
   */
  private void adjustStyle(Node parentNode, OdfTextSpan textSpan, Map<OdfStyleProperty, String> styleMap) {
    if (parentNode instanceof OdfStylableElement) {
      OdfStylableElement pStyleNode = (OdfStylableElement) parentNode;
      if (styleMap == null) {
        styleMap = getTextStylePropertiesDeep(pStyleNode);
      }
      Node node = parentNode.getFirstChild();
      while (node != null) {
        if (node.getNodeType() == Node.TEXT_NODE) {
          if (node.getTextContent().length() > 0) {
            Node nextNode = node.getNextSibling();
            OdfTextSpan span = new OdfTextSpan((OdfFileDom) node.getOwnerDocument());
            span.appendChild(node);
            if (nextNode != null) {
              parentNode.insertBefore(span, nextNode);
            } else {
              parentNode.appendChild(span);
            }
            node = span;
            applyTextStyleProperties(styleMap, (OdfStylableElement) node);
          }
        } else if ((node instanceof OdfStylableElement)) {
          if (!node.equals(textSpan)) {
            Map<OdfStyleProperty, String> styles = getTextStylePropertiesDeep(pStyleNode);
            Map<OdfStyleProperty, String> styles1 = getTextStylePropertiesDeep((OdfStylableElement) node);
            if (styles == null) {
              styles = styles1;
            } else if (styles1 != null) {
              styles.putAll(styles1);
            }
            int comp = node.compareDocumentPosition(textSpan);
            //if node contains textSpan, then recurse the node
            if ((comp & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0) {
              adjustStyle(node, textSpan, styles);
            } else {
              applyTextStyleProperties(styles, (OdfStylableElement) node);
            }
          }

        }
        node = node.getNextSibling();
      }
      //change the parentNode to default style
      //here we don't know the default style name, so here just
      //remove the text:style-name attribute
      pStyleNode.removeAttributeNS(OdfDocumentNamespace.TEXT.getUri(), "style-name");
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

        while (styleUsersIter.hasNext()) {
          styleUsers.add(styleUsersIter.next());
        }
        styleUsersIter = styleUsers.iterator();
        while (styleUsersIter.hasNext()) {
          OdfStylableElement elem = styleUsersIter.next();
          OdfStyle autoStyle = elem.getAutomaticStyle();
          if (autoStyle != null) {
            elem.setStyleName(found.getStyleNameAttribute());
          }
        }
      } else {
        stylesSet.add(cur);
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

  @Override
  public boolean match(Node element) {
    boolean match = false;
    if (element.getNodeType() == Node.TEXT_NODE && !element.getNodeValue().trim().equals("")) {
      if (element.getParentNode() instanceof OdfStylableElement) {
        OdfStylableElement parStyleElement = (OdfStylableElement) element.getParentNode();

        String parStyleName = getStyleName(parStyleElement);

        if (getMatchStyleNames().contains(parStyleName)) {
          match = true;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.OdfStylableElement

            LOG.log(INFO, ": {0}\n", node.getNodeValue());
          }
          if (node instanceof OdfStylableElement) {
            try {
              //LOG.info(indent + "-style info...");
              OdfStylableElement se = (OdfStylableElement) node;
              OdfStyleBase as = se.getAutomaticStyle();
              OdfStyle ds = se.getDocumentStyle();
              if (as != null) {
                LOG.log(INFO, "{0}-AutomaticStyle: {1}", new Object[]{indent, as});
              }
              if (ds != null) {
                LOG.log(INFO, "{0}-OdfDocumentStyle: {1}", new Object[]{indent, ds});
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.