Package org.odftoolkit.odfdom.pkg

Examples of org.odftoolkit.odfdom.pkg.OdfElement


  /*
   * Find next TextSelection which match specified style
   */
  private TextSelection findnext(TextSelection selected) {
    OdfElement element = null;
    if (selected == null) {

      try {
        mNode = getNextMatchElement((Node) mTextDocument.getContentRoot());
      } catch (Exception ex) {
View Full Code Here


    /**
     * Remove the selection from repository.
     * @param item  selection item
     */
    static public void unregisterItem(Selection item) {
      OdfElement element = item.getElement();
      if (repository.containsKey(element)) {
        Vector<Selection> selections = repository.get(element);
        selections.remove(item);
      }
    }
View Full Code Here

   */
  private boolean validate() {
    if (getContainerElement() == null) {
      return false;
    }
    OdfElement container = getContainerElement();
    if (container == null) {
      return false;
    }
    OdfWhitespaceProcessor textProcessor = new OdfWhitespaceProcessor();
    String content = textProcessor.getText(container);
View Full Code Here

  @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

  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

  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);
    /*if (startElement instanceof OdfStyleBase)
    textSpan.setProperties(((OdfStyleBase) startElement)
    .getStyleProperties());*/
    mIsInserted = false;
View Full Code Here

  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

  public void pasteAtEndOf(Selection positionItem) throws InvalidNavigationException {
    if (validate() == false) {
      throw new InvalidNavigationException("No matched string at this position");
    }
    int indexOfNew = 0;//TODO: think about and test if searchitem is a element selection
    OdfElement newElement = positionItem.getElement();
    if (positionItem instanceof TextSelection) {
      indexOfNew = ((TextSelection) positionItem).getIndex() + ((TextSelection) positionItem).getText().length();
      newElement = ((TextSelection) positionItem).getContainerElement();
    }
View Full Code Here

   */
  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

  }

  // return a new span that cover this selection
  // and keep the original style of this selection
  private OdfTextSpan getSpan(OdfFileDom ownerDoc) {
    OdfElement parentElement = getContainerElement();

    if (parentElement != null) {
      Node copyParentNode = parentElement.cloneNode(true);
      if (ownerDoc != parentElement.getOwnerDocument()) {
        copyParentNode = ownerDoc.adoptNode(copyParentNode);
      }
      OdfTextSpan textSpan = new OdfTextSpan(ownerDoc);
      int sIndex = mIndexInContainer;
      int eIndex = sIndex + mMatchedText.length();
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.pkg.OdfElement

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.