Package org.odftoolkit.odfdom.dom.element.text

Examples of org.odftoolkit.odfdom.dom.element.text.TextAElement


      //doc.save(ResourceUtilities.getAbsolutePath(TEXT_FILE));
     
      //validate
      OdfElement parentElement = item.getContainerElement();
      Node node = parentElement.getFirstChild().getFirstChild().getNextSibling();
      TextAElement textAele = (TextAElement)node;
      System.out.println(textAele.getXlinkTypeAttribute());
      System.out.println(textAele.getXlinkHrefAttribute());
      Assert.assertEquals("simple", textAele.getXlinkTypeAttribute());
      Assert.assertEquals("http://www.IBM.com", textAele.getXlinkHrefAttribute());
     
    } else {
      Assert.fail("Navigation search nothing.");
    }
   
View Full Code Here


          int nextLength = value.length() - endLength;

          Node nextNode = node.getNextSibling();
          Node parNode = node.getParentNode();
          // init text:a
          TextAElement textLink = new TextAElement((OdfFileDom) node.getOwnerDocument());
          Node newNode = null;
          if (nextLength >= 0) {
            textLink.setTextContent(value.substring(fromIndex, endLength));
            newNode = node.cloneNode(true);
            newNode.setNodeValue(value.substring(endLength, value.length()));
            leftLength = 0;
          } else {
            textLink.setTextContent(value.substring(fromIndex, value.length()));
            leftLength = endLength - value.length();
          }
          textLink.setXlinkTypeAttribute("simple");
          textLink.setXlinkHrefAttribute(href);

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

          int nextLength = value.length() - endLength;

          Node nextNode = node.getNextSibling();
          Node parNode = node.getParentNode();
          // init text:a
          TextAElement textLink = new TextAElement(
              (OdfFileDom) node.getOwnerDocument());
          Node newNode = null;
          if (nextLength >= 0) {
            textLink.setTextContent(value.substring(fromindex,
                endLength));
            newNode = node.cloneNode(true);
            newNode.setNodeValue(value.substring(endLength, value.length()));
            leftLength = 0;
          } else {
            textLink.setTextContent(value.substring(fromindex,
                value.length()));
            leftLength = endLength - value.length();
          }
          textLink.setXlinkTypeAttribute("simple");
          textLink.setXlinkHrefAttribute(href);

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

          int nextLength = value.length() - endLength;

          Node nextNode = node.getNextSibling();
          Node parNode = node.getParentNode();
          // init text:a
          TextAElement textLink = new TextAElement(
              (OdfFileDom) node.getOwnerDocument());
          Node newNode = null;
          if (nextLength >= 0) {
            textLink.setTextContent(value.substring(fromindex,
                endLength));
            newNode = node.cloneNode(true);
            newNode.setNodeValue(value.substring(endLength, value.length()));
            leftLength = 0;
          } else {
            textLink.setTextContent(value.substring(fromindex,
                value.length()));
            leftLength = endLength - value.length();
          }
          textLink.setXlinkTypeAttribute("simple");
          textLink.setXlinkHrefAttribute(href);

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

      //doc.save(ResourceUtilities.getAbsolutePath(TEXT_FILE));
     
      //validate
      OdfElement parentElement = item.getContainerElement();
      Node node = parentElement.getFirstChild().getFirstChild().getNextSibling();
      TextAElement textAele = (TextAElement)node;
      System.out.println(textAele.getXlinkTypeAttribute());
      System.out.println(textAele.getXlinkHrefAttribute());
      Assert.assertEquals("simple", textAele.getXlinkTypeAttribute());
      Assert.assertEquals("http://www.IBM.com", textAele.getXlinkHrefAttribute());
     
    } else {
      Assert.fail("Navigation search nothing.");
    }
   
View Full Code Here

  public TextHyperlink applyHyperlink(URI linkto) {
    // new a text:a element, move all the child under text:p to text:a
    OdfElement parent = linkContainer;
    removeHyperlinks();
    TextAElement aElement;
    aElement = ((OdfContentDom) (parent.getOwnerDocument())).newOdfElement(TextAElement.class);
    aElement.setXlinkTypeAttribute("simple");
    aElement.setXlinkHrefAttribute(linkto.toString());
    Node node = parent.getFirstChild();
    while (node != null) {
      Node thisNode = node;
      node = node.getNextSibling();
      parent.removeChild(thisNode);
      aElement.appendChild(thisNode);
    }
    parent.appendChild(aElement);
    return TextHyperlink.getInstanceof(aElement);
  }
View Full Code Here

    return TextHyperlink.getInstanceof(aElement);
  }

  public void removeHyperlinks() {
    OdfElement parent = linkContainer;
    TextAElement aElement = OdfElement.findFirstChildNode(TextAElement.class, parent);
    while (aElement != null) {
      Node node = aElement.getFirstChild();
      while (node != null) {
        Node thisNode = node;
        node = node.getNextSibling();
        aElement.removeChild(thisNode);
        parent.insertBefore(thisNode, aElement);
      }
      TextAElement thisElement = aElement;
      aElement = OdfElement.findNextChildNode(TextAElement.class, aElement);
      parent.removeChild(thisElement);
    }
  }
View Full Code Here

    return new SimpleHyperlinkIterator(linkContainer);
  }

  public TextHyperlink appendHyperlink(String text, URI linkto) {
    OdfElement parent = linkContainer;
    TextAElement aElement;
    aElement = ((OdfContentDom) (parent.getOwnerDocument())).newOdfElement(TextAElement.class);
    aElement.setXlinkTypeAttribute("simple");
    aElement.setXlinkHrefAttribute(linkto.toString());
    aElement.setTextContent(text);
    parent.appendChild(aElement);
    return TextHyperlink.getInstanceof(aElement);
  }
View Full Code Here

      }
      containerElement.removeChild(nextElement.getOdfElement());
    }

    private TextHyperlink findNext(TextHyperlink thisLink) {
      TextAElement nextLink = null;
      if (thisLink == null) {
        nextLink = OdfElement.findFirstChildNode(TextAElement.class, containerElement);
      } else {
        nextLink = OdfElement.findNextChildNode(TextAElement.class, thisLink.getOdfElement());
      }
View Full Code Here

          int nextLength = value.length() - endLength;

          Node nextNode = node.getNextSibling();
          Node parNode = node.getParentNode();
          // init text:a
          TextAElement textLink = new TextAElement((OdfFileDom) node.getOwnerDocument());
          Node newNode = null;
          if (nextLength >= 0) {
            textLink.setTextContent(value.substring(fromIndex, endLength));
            newNode = node.cloneNode(true);
            newNode.setNodeValue(value.substring(endLength, value.length()));
            leftLength = 0;
          } else {
            textLink.setTextContent(value.substring(fromIndex, value.length()));
            leftLength = endLength - value.length();
          }
          textLink.setXlinkTypeAttribute("simple");
          textLink.setXlinkHrefAttribute(href);

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

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.text.TextAElement

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.