Package org.odftoolkit.simple.draw

Examples of org.odftoolkit.simple.draw.Image


   *  
   * @return the new Image in the TextDocument,the image name is set to "replace" + System.currentTimeMillis(), please update the name to others by yourself
   *
   */
  public Image replaceWithImage(URI imageUri) {
    Image mImage =null;
    if(search instanceof TextNavigation){
      TextNavigation textSearch = (TextNavigation) search;
    int leftLength = textSelection.getText().length();
    int index = textSelection.getIndex();
    mIsInserted = false;
    OdfElement parentElement = textSelection.getContainerElement();
    OdfFileDom ownerDom = (OdfFileDom) parentElement.getOwnerDocument();
      int nodeLength = TextExtractor.getText(
          this.textSelection.getContainerElement()).length();
      if (this.textSelection.getText().length() != nodeLength)
        this.textSelection.setSelectionReplaced(true);
    try{
      if (imageContainer == null) {
        delete(index, leftLength, parentElement);
        // PrepareContainer
        imageContainer = ownerDom.newOdfElement(DrawFrameElement.class);
        insertOdfElement(imageContainer, index, parentElement);
      } else {
        NodeList nodeImages = imageContainer.getElementsByTagName("draw:image");
        Node nodeImage = nodeImages.item(0);
        DrawImageElement im = (DrawImageElement) nodeImage;
        Image oldimage = Image.getInstanceof(im);
        oldimage.remove();
        // PrepareContainer
        imageContainer = ownerDom.newOdfElement(DrawFrameElement.class);
        insertOdfElement(imageContainer, index, parentElement);
      }
      // Insert Image resource to package
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.draw.Image

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.