Examples of OdfElement


Examples of org.odftoolkit.odfdom.pkg.OdfElement

   * Return the matched text might exist in header/footer.
   */
  private TextSelection findInHeaderFooter(TextSelection selected) {
    OdfFileDom styledom = null;
    OdfOfficeMasterStyles masterpage = null;
    OdfElement element = null;

    if (selected != null) {
      OdfElement containerElement = selected.getContainerElement();
      int index = selected.getIndex();
      String content = TextExtractor.getText(containerElement);

      int nextIndex = -1;
      Matcher matcher = mPattern.matcher(content);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

        }
      }
      selected = null;
      mbFinishFindInHeaderFooter = true;
    }
    OdfElement rootElement = null;
    try {
      if (mElement != null) {
        rootElement = mElement;
      } else {
        rootElement = mDocument.getContentRoot();
      }
    } catch (Exception ex) {
      Logger.getLogger(TextNavigation.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
    if (selected == null) {
      OdfElement element = (OdfElement) getNextMatchElementInTree(rootElement, rootElement);
      if (element != null) {
        return createSelection(element, mNextIndex);
      } else {
        return null;
      }
    }
    OdfElement containerElement = selected.getContainerElement();
    int index = selected.getIndex();
    String content = TextExtractor.getText(containerElement);

    int nextIndex = -1;
    Matcher matcher = mPattern.matcher(content);
    // start from the end index of the selected item
    if (((content.length() > index + selected.getText().length()))
        && (matcher.find(index + selected.getText().length()))) {
      // here just consider \n\r\t occupy one char
      nextIndex = matcher.start();
      int eIndex = matcher.end();
      mNextText = content.substring(nextIndex, eIndex);
    }
    if (nextIndex != -1) {
      return createSelection(selected.getContainerElement(), nextIndex);
    } else {
      OdfElement element = (OdfElement) getNextMatchElementInTree(containerElement, rootElement);
      if (element != null) {
        return createSelection(element, mNextIndex);
      } else {
        return null;
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

  }

  private class TableContainerImpl extends AbstractTableContainer {

    public OdfElement getTableContainerElement() {
      OdfElement containerElement = null;
      try {
        containerElement = getContentRoot();
      } catch (Exception e) {
        Logger.getLogger(Document.class.getName()).log(Level.SEVERE, null, e);
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

  @Override
  public void cut() throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    OdfElement container = getContainerElement();
    delete(mIndexInContainer, mMatchedText.length(), container);
    SelectionManager.refreshAfterCut(this);
    mMatchedText = "";
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

  public void applyStyle(OdfStyleBase style) throws InvalidNavigationException {
    // append the specified style to the selection
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    OdfElement parentElement = getContainerElement();

    int leftLength = getText().length();
    int index = mIndexInContainer;

    appendStyle(index, leftLength, parentElement, style);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

   */
  public void replaceWith(String newText) throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    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);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

   */
  public TextSpanElement createSpanElement() throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    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.pkg.OdfElement

  public void pasteAtFrontOf(Selection positionItem) throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    int indexOfNew = 0;
    OdfElement newElement = positionItem.getElement();
    if (positionItem instanceof TextSelection) {
      indexOfNew = ((TextSelection) positionItem).getIndex();
      newElement = ((TextSelection) positionItem).getContainerElement();
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    // TODO: think about and test if search item is a element selection
    int indexOfNew = 0;
    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());
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

   */
  public void addHref(URL url) throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    OdfElement parentElement = getContainerElement();
    int leftLength = getText().length();
    int index = mIndexInContainer;
    addHref(index, leftLength, parentElement, url.toString());
  }
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.