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

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


   * @return the added items.
   */
  public java.util.List<ListItem> addItems(String[] items) {
    java.util.List<ListItem> itemList = new java.util.ArrayList<ListItem>();
    for (String itemString : items) {
      TextListItemElement listItemElement = listElement.newTextListItemElement();
      ListItem item = new ListItem(listItemElement);
      item.setTextContent(itemString);
      itemList.add(item);
    }
    return itemList;
View Full Code Here


  public java.util.List<ListItem> addItems(int location, String[] items) {
    java.util.List<ListItem> listCollection = new ArrayList<ListItem>();
    OdfFileDom ownerDocument = (OdfFileDom) listElement.getOwnerDocument();
    Node refNode = getItemByLocation(location);
    for (int i = items.length - 1; i >= 0; i--) {
      TextListItemElement listItemElement = ownerDocument.newOdfElement(TextListItemElement.class);
      listElement.insertBefore(listItemElement, refNode);
      ListItem item = new ListItem(listItemElement);
      item.setParagraphDecorator(decorator);
      item.setTextContent(items[i]);
      refNode = listItemElement;
View Full Code Here

   *            the list items to be added.
   */
  public java.util.List<ListItem> addItems(ListItem[] items) {
    java.util.List<ListItem> itemList = new java.util.ArrayList<ListItem>();
    for (ListItem itemClone : items) {
      TextListItemElement itemElement = (TextListItemElement) (itemClone.getOdfElement().cloneNode(true));
      listElement.appendChild(itemElement);
      itemList.add(new ListItem(itemElement));
    }
    return itemList;
  }
View Full Code Here

   */
  public java.util.List<ListItem> addItems(int location, ListItem[] items) {
    java.util.List<ListItem> listCollection = new ArrayList<ListItem>();
    Node refNode = getItemByLocation(location);
    for (int i = items.length - 1; i >= 0; i--) {
      TextListItemElement itemElement = (TextListItemElement) (items[i].getOdfElement().cloneNode(true));
      listElement.insertBefore(itemElement, refNode);
      ListItem item = new ListItem(itemElement);
      refNode = itemElement;
      listCollection.add(item);
    }
View Full Code Here

   * @return the previous element at the index.
   * @exception IndexOutOfBoundsException
   *                when the <code>location</code> is out of the List range.
   */
  public ListItem set(int location, ListItem item) {
    TextListItemElement itemElement = (TextListItemElement) (item.getOdfElement().cloneNode(true));
    Node oldNode = getItemByLocation(location);
    listElement.replaceChild(itemElement, oldNode);
    ListItem newItem = new ListItem(itemElement);
    newItem.setParagraphDecorator(decorator);
    return newItem;
View Full Code Here

   * @exception IndexOutOfBoundsException
   *                when the <code>location</code> is out of the List range.
   */
  public ListItem set(int location, String itemContent) {
    OdfFileDom ownerDocument = (OdfFileDom) listElement.getOwnerDocument();
    TextListItemElement listItemElement = ownerDocument.newOdfElement(TextListItemElement.class);
    Node oldNode = getItemByLocation(location);
    listElement.replaceChild(listItemElement, oldNode);
    ListItem item = new ListItem(listItemElement);
    item.setParagraphDecorator(decorator);
    item.setTextContent(itemContent);
View Full Code Here

   * @return true if this List is modified, false otherwise.
   * @exception IndexOutOfBoundsException
   *                when the <code>location</code> is out of the List range.
   */
  public boolean removeItem(int location) {
    TextListItemElement itemElement = getItemByLocation(location);
    if (itemElement == null) {
      return false;
    } else {
      OdfFileDom ownerDocument = (OdfFileDom) listElement.getOwnerDocument();
      Document doc = (Document) ownerDocument.getDocument();
View Full Code Here

   * @param item
   *            the item to be removed.
   * @return true if this List is modified, false otherwise.
   */
  public boolean removeItem(ListItem item) {
    TextListItemElement itemElement = item.getOdfElement();
    OdfFileDom ownerDocument = (OdfFileDom) listElement.getOwnerDocument();
    Document doc = (Document) ownerDocument.getDocument();
    doc.removeElementLinkedResource(itemElement);
    Node removedNode = listElement.removeChild(itemElement);
    if (removedNode == null) {
View Full Code Here

   * @return true if this List is modified, false otherwise.
   */
  public boolean removeItems(java.util.List<ListItem> items) {
    boolean listChanged = false;
    for (ListItem item : items) {
      TextListItemElement itemElement = item.getOdfElement();
      OdfFileDom ownerDocument = (OdfFileDom) listElement.getOwnerDocument();
      Document doc = (Document) ownerDocument.getDocument();
      doc.removeElementLinkedResource(itemElement);
      Node removedNode = listElement.removeChild(itemElement);
      if (removedNode != null) {
View Full Code Here

  private TextListItemElement getItemByLocation(int location) {
    if (location < 0) {
      throw new IndexOutOfBoundsException("the location " + location + " is is out of the List range.");
    }
    Node firstNode = listElement.getFirstChild();
    TextListItemElement positionNode = null;
    int i = 0;
    while (firstNode != null) {
      if (firstNode instanceof TextListItemElement) {
        if (i == location) {
          break;
View Full Code Here

TOP

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

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.