Examples of OdfTextSpan


Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      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);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

   */
  private void prepareSpanContainer(int leftLength, int index) {
    if (spanContainer == null) {
      OdfElement parentElement = textSelection.getContainerElement();
      delete(index, leftLength, parentElement);
      spanContainer = new OdfTextSpan((OdfFileDom) parentElement.getOwnerDocument());
      mIsInserted = false;
      insertSpan(spanContainer, index, parentElement);
    } else {
      Node childNode = spanContainer.getFirstChild();
      while (childNode != null) {
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    }
    OdfElement parentElement = getContainerElement();
    int leftLength = getText().length();
    int index = mIndexInContainer;
    delete(index, leftLength, parentElement);
    OdfTextSpan textSpan = new OdfTextSpan((OdfFileDom) parentElement.getOwnerDocument());
    textSpan.addContentWhitespace(newText);
    mIsInserted = false;
    insertOdfElement(textSpan, index, parentElement);
    // optimize the parent element
    optimize(parentElement);
    int offset = newText.length() - leftLength;
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    }
    OdfElement parentElement = getContainerElement();
    int leftLength = getText().length();
    int index = mIndexInContainer;
    delete(index, leftLength, parentElement);
    OdfTextSpan textSpan = new OdfTextSpan((OdfFileDom) parentElement.getOwnerDocument());
    textSpan.addContentWhitespace(getText());
    mIsInserted = false;
    insertOdfElement(textSpan, index, parentElement);
    // optimize the parent element
    optimize(parentElement);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    if (positionItem instanceof TextSelection) {
      indexOfNew = ((TextSelection) positionItem).getIndex();
      newElement = ((TextSelection) positionItem).getContainerElement();
    }

    OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument());
    mIsInserted = false;
    insertOdfElement(textSpan, indexOfNew, newElement);
    adjustStyle(newElement, textSpan, null);
    SelectionManager.refreshAfterPasteAtFrontOf(this, positionItem);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    OdfElement newElement = positionItem.getElement();
    if (positionItem instanceof TextSelection) {
      indexOfNew = ((TextSelection) positionItem).getIndex() + ((TextSelection) positionItem).getText().length();
      newElement = ((TextSelection) positionItem).getContainerElement();
    }
    OdfTextSpan textSpan = getSpan((OdfFileDom) positionItem.getElement().getOwnerDocument());
    mIsInserted = false;
    insertOdfElement(textSpan, indexOfNew, newElement);
    adjustStyle(newElement, textSpan, null);
    SelectionManager.refreshAfterPasteAtEndOf(this, positionItem);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

    if (parentElement != null) {
      OdfElement copyParentNode = (OdfElement) parentElement.cloneNode(true);
      if (ownerDoc != parentElement.getOwnerDocument()) {
        copyParentNode = (OdfElement) ownerDoc.adoptNode(copyParentNode);
      }
      OdfTextSpan textSpan = new OdfTextSpan(ownerDoc);
      int sIndex = mIndexInContainer;
      int eIndex = sIndex + mMatchedText.length();
      // delete the content except the selection string
      // delete from the end to start, so that the postion will not be
      // impact by delete action
      delete(eIndex, TextExtractor.getText(copyParentNode).length() - eIndex, copyParentNode);
      delete(0, sIndex, copyParentNode);
      optimize(copyParentNode);
      Node childNode = copyParentNode.getFirstChild();
      while (childNode != null) {
        textSpan.appendChild(childNode.cloneNode(true));
        childNode = childNode.getNextSibling();
      }
      // apply text style for the textSpan
      if (copyParentNode instanceof OdfStylableElement) {
        applyTextStyleProperties(getTextStylePropertiesDeep((OdfStylableElement) copyParentNode), textSpan);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      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);
            }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

          int nextLength = value.length() - endLength;

          Node nextNode = node.getNextSibling();
          Node parNode = node.getParentNode();
          // init text:a
          OdfTextSpan textSpan = new OdfTextSpan((OdfFileDom) node.getOwnerDocument());
          Node newNode = null;
          if (nextLength >= 0) {
            textSpan.setTextContent(value.substring(fromIndex, endLength));
            newNode = node.cloneNode(true);
            newNode.setNodeValue(value.substring(endLength, value.length()));
            leftLength = 0;
          } else {
            textSpan.setTextContent(value.substring(fromIndex, value.length()));
            leftLength = endLength - value.length();
          }
          textSpan.setProperties(style.getStyleProperties());

          if (nextNode != null) {
            parNode.insertBefore(textSpan, nextNode);
            if (newNode != null) {
              parNode.insertBefore(newNode, nextNode);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextSpan

      //modify content of "Object 1"
      OdfFileDom embedContentDom = embeddedDoc.getContentDom();
      XPath xpath = embedContentDom.getXPath();
      TextHElement header = (TextHElement) xpath.evaluate("//text:h[1]", embedContentDom, XPathConstants.NODE);
      LOG.log(Level.INFO, "First para: {0}", header.getTextContent());
      OdfTextSpan spanElem = new OdfTextSpan(embedContentDom);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      header.appendChild(spanElem);
      //insert image to "Object 1"
      embeddedDoc.newImage(ResourceUtilities.getURI(TEST_PIC));
      //embed "Object 1" to TestModifiedEmbeddedDoc.odt as the path /DocA
      String embedPath = "DocA";
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.