Package org.odftoolkit.odfdom.dom.element.table

Examples of org.odftoolkit.odfdom.dom.element.table.TableTableRowElement


    }

    for (Node m : new DomNodeList(group.getChildNodes())) {
      if (m instanceof TableTableHeaderRowsElement) {
        TableTableHeaderRowsElement headers = (TableTableHeaderRowsElement) m;
        TableTableRowElement returnEle = findRowInTableHeaderRows(headers, tr, resultIndexs);
        result += resultIndexs[0];
        if (returnEle != null) {//find
          indexs[0] = result;
          return returnEle;
        }
      } else if (m instanceof TableTableRowGroupElement) {
        TableTableRowGroupElement aGroup = (TableTableRowGroupElement) m;
        TableTableRowElement returnEle = findRowInTableRowGroup(aGroup, tr, resultIndexs);
        result += resultIndexs[0];
        if (returnEle != null) {//find
          indexs[0] = result;
          return returnEle;
        }
      } else if (m instanceof TableTableRowsElement) {
        TableTableRowsElement rows = (TableTableRowsElement) m;
        TableTableRowElement returnEle = findRowInTableRows(rows, tr, resultIndexs);
        result += resultIndexs[0];
        if (returnEle != null) {//find
          indexs[0] = result;
          return returnEle;
        }
View Full Code Here


   * Get the index of the table row which contains this cell.
   * @return the index of the row containing this cell
   */
  public int getRowIndex() {
    TableTableElement table = getTableElement();
    TableTableRowElement tr = getTableRowElement();
    int[] indexs = new int[1];

    TableTableRowElement returnEle = findRowInTableRowGroup(table, tr, indexs);
    if (returnEle != null) {
      return (indexs[0] + mnRepeatedRowIndex);
    } else {
      return -1;
    }
View Full Code Here

  /**
   * Get the index of the table column which contains this cell.
   * @return the index of the column containing this cell
   */
  public int getColumnIndex() {
    TableTableRowElement tr = (TableTableRowElement) mCellElement.getParentNode();
    int result = 0;
    for (Node n : new DomNodeList(tr.getChildNodes())) {
      if (n == mCellElement) {
        return result + mnRepeatedColIndex;
      }
      if (n instanceof TableTableCellElementBase) {
        result += ((TableTableCellElementBase) n).getTableNumberColumnsRepeatedAttribute().intValue();
View Full Code Here

    }

    for (Node m : new DomNodeList(group.getChildNodes())) {
      if (m instanceof TableTableHeaderRowsElement) {
        TableTableHeaderRowsElement headers = (TableTableHeaderRowsElement) m;
        TableTableRowElement returnEle = findRowInTableHeaderRows(headers, tr, resultIndexs);
        result += resultIndexs[0];
        if (returnEle != null) {// find
          indexs[0] = result;
          return returnEle;
        }
      } else if (m instanceof TableTableRowGroupElement) {
        TableTableRowGroupElement aGroup = (TableTableRowGroupElement) m;
        TableTableRowElement returnEle = findRowInTableRowGroup(aGroup, tr, resultIndexs);
        result += resultIndexs[0];
        if (returnEle != null) {// find
          indexs[0] = result;
          return returnEle;
        }
      } else if (m instanceof TableTableRowsElement) {
        TableTableRowsElement rows = (TableTableRowsElement) m;
        TableTableRowElement returnEle = findRowInTableRows(rows, tr, resultIndexs);
        result += resultIndexs[0];
        if (returnEle != null) {// find
          indexs[0] = result;
          return returnEle;
        }
View Full Code Here

   *
   * @return the index of the row containing this cell
   */
  public int getRowIndex() {
    TableTableElement table = getTableElement();
    TableTableRowElement tr = getTableRowElement();
    int[] indexs = new int[1];

    TableTableRowElement returnEle = findRowInTableRowGroup(table, tr, indexs);
    if (returnEle != null) {
      return (indexs[0] + mnRepeatedRowIndex);
    } else {
      return -1;
    }
View Full Code Here

   * Get the index of the table column which contains this cell.
   *
   * @return the index of the column containing this cell
   */
  public int getColumnIndex() {
    TableTableRowElement tr = (TableTableRowElement) mCellElement.getParentNode();
    int result = 0;
    for (Node n : new DomNodeList(tr.getChildNodes())) {
      if (n == mCellElement) {
        return result + mnRepeatedColIndex;
      }
      if (n instanceof TableTableCellElementBase) {
        result += ((TableTableCellElementBase) n).getTableNumberColumnsRepeatedAttribute().intValue();
View Full Code Here

  // splitRepeatedCells must be called first in order to
  // 1. update parent row if the row is the repeated rows.
  // 2. update the cell itself if the cell is the column repeated cells.
  void splitRepeatedCells() {
    Table table = getTable();
    TableTableRowElement ownerRowElement = getTableRowElement();
    // 1.if the parent row is the repeated row
    // the repeated row has to be separated
    // after this the cell element and repeated index will be updated
    // according to the new parent row
    Row ownerRow = table.getRowInstance(ownerRowElement, mnRepeatedRowIndex);
    if (ownerRow.getRowsRepeatedNumber() > 1) {
      ownerRow.splitRepeatedRows();
      // update row element, new row element maybe created.
      ownerRowElement = ownerRow.maRowElement;
      mnRepeatedRowIndex = 0;
    }
    // 2.if the cell is the column repeated cell
    // this repeated cell has to be separated
    int repeateNum = getColumnsRepeatedNumber();
    if (repeateNum > 1) {
      // change this repeated cell to three parts: repeated cell before,
      // new single cell and repeated cell after.
      Map<TableTableCellElementBase, Vector<Cell>> cellRepository = table.mCellRepository;
      String tableNamespaceURI = OdfDocumentNamespace.TABLE.getUri();
      Vector<Cell> oldList = null;
      if (cellRepository.containsKey(mCellElement)) {
        oldList = cellRepository.remove(mCellElement);
      }
      int offetAfterCurrentCell = repeateNum - mnRepeatedColIndex - 1;
      TableTableCellElementBase currentCellElement = mCellElement;
      TableTableCellElementBase newBeforeCellElement = null;
      TableTableCellElementBase newAfterCellElement = null;
      if (mnRepeatedColIndex > 0) {
        newBeforeCellElement = (TableTableCellElementBase) mCellElement.cloneNode(true);
        if (mnRepeatedColIndex > 1) {
          newBeforeCellElement.setTableNumberColumnsRepeatedAttribute(mnRepeatedColIndex);
        } else {
          newBeforeCellElement.removeAttributeNS(tableNamespaceURI, "number-columns-repeated");
        }
        // insert new before repeated cell
        ownerRowElement.insertBefore(newBeforeCellElement, currentCellElement);
        // update cell cache
        if (oldList != null) {
          Vector<Cell> newBeforeList = new Vector<Cell>(mnRepeatedColIndex);
          for (int i = 0; i < mnRepeatedColIndex && i < oldList.size(); i++) {
            Cell beforeCell = oldList.get(i);
            if (beforeCell != null) {
              beforeCell.mCellElement = newBeforeCellElement;
              newBeforeList.add(i, beforeCell);
            }
          }
          cellRepository.put(newBeforeCellElement, newBeforeList);
        }
      }
      currentCellElement.removeAttributeNS(tableNamespaceURI, "number-columns-repeated");
      if (offetAfterCurrentCell > 0) {
        newAfterCellElement = (TableTableCellElementBase) currentCellElement.cloneNode(true);
        ownerRowElement.insertBefore(newAfterCellElement, currentCellElement);
        currentCellElement = newAfterCellElement;
        newAfterCellElement = (TableTableCellElementBase) currentCellElement.getNextSibling();
        if (offetAfterCurrentCell > 1) {
          newAfterCellElement.setTableNumberColumnsRepeatedAttribute(offetAfterCurrentCell);
        }
View Full Code Here

      Vector<Row> oldList = null;
      if (rowRepository.containsKey(maRowElement)) {
        oldList = rowRepository.remove(maRowElement);
      }
      int offetAfterCurrentRow = repeateNum - mnRepeatedIndex - 1;
      TableTableRowElement currentRowElement = null;
      TableTableRowElement newBeforeRowElement = null;
      TableTableRowElement newAfterRowElement = null;
      List<TableTableCellElementBase> newBeforeCellElements = new ArrayList<TableTableCellElementBase>();
      List<TableTableCellElementBase> newCurrentCellElements = new ArrayList<TableTableCellElementBase>();
      List<TableTableCellElementBase> newAfterCellElements = new ArrayList<TableTableCellElementBase>();
      if (mnRepeatedIndex > 0) {
        newBeforeRowElement = (TableTableRowElement) maRowElement.cloneNode(true);
        if (mnRepeatedIndex > 1) {
          newBeforeRowElement.setTableNumberRowsRepeatedAttribute(mnRepeatedIndex);
        } else {
          newBeforeRowElement.removeAttributeNS(tableNameSpaceURI, "number-rows-repeated");
        }
        // insert new before repeated row
        rowOwnerElement.insertBefore(newBeforeRowElement, maRowElement);
        // update row cache
        if (oldList != null) {
          Vector<Row> newBeforeList = new Vector<Row>(mnRepeatedIndex);
          for (int i = 0; i < mnRepeatedIndex && i < oldList.size(); i++) {
            Row beforeRow = oldList.get(i);
            if (beforeRow != null) {
              beforeRow.maRowElement = newBeforeRowElement;
              beforeRow.mRowsRepeatedNumber = -1;
              newBeforeList.add(i, beforeRow);
            }
          }
          rowRepository.put(newBeforeRowElement, newBeforeList);
          // create new cell element map.
          for (Node n : new DomNodeList(newBeforeRowElement.getChildNodes())) {
            int columnsRepeatedNumber = ((TableTableCellElementBase) n)
                .getTableNumberColumnsRepeatedAttribute();
            for (int i = 0; i < columnsRepeatedNumber; i++) {
              newBeforeCellElements.add((TableTableCellElementBase) n);
            }
          }
        }
      }
      currentRowElement = (TableTableRowElement) maRowElement.cloneNode(true);
      currentRowElement.removeAttributeNS(tableNameSpaceURI, "number-rows-repeated");
      rowOwnerElement.insertBefore(currentRowElement, maRowElement);
      // create new cell element map.
      for (Node n : new DomNodeList(currentRowElement.getChildNodes())) {
        int columnsRepeatedNumber = ((TableTableCellElementBase) n).getTableNumberColumnsRepeatedAttribute();
        for (int i = 0; i < columnsRepeatedNumber; i++) {
          newCurrentCellElements.add((TableTableCellElementBase) n);
        }
      }
      if (offetAfterCurrentRow > 0) {
        newAfterRowElement = (TableTableRowElement) maRowElement.cloneNode(true);
        if (offetAfterCurrentRow > 1) {
          newAfterRowElement.setTableNumberRowsRepeatedAttribute(offetAfterCurrentRow);
        } else {
          newAfterRowElement.removeAttributeNS(tableNameSpaceURI, "number-rows-repeated");
        }
        rowOwnerElement.insertBefore(newAfterRowElement, maRowElement);
        // update row cache
        if (oldList != null) {
          Vector<Row> newAfterList = new Vector<Row>(offetAfterCurrentRow);
          for (int i = mnRepeatedIndex + 1; i < repeateNum && i < oldList.size(); i++) {
            Row afterRow = oldList.get(i);
            if (afterRow != null) {
              afterRow.maRowElement = newAfterRowElement;
              afterRow.mnRepeatedIndex = i - mnRepeatedIndex - 1;
              afterRow.mRowsRepeatedNumber = -1;
              newAfterList.add(afterRow.mnRepeatedIndex, afterRow);
            }
          }
          rowRepository.put(newAfterRowElement, newAfterList);
          // create new cell element map.
          for (Node n : new DomNodeList(newAfterRowElement.getChildNodes())) {
            int columnsRepeatedNumber = ((TableTableCellElementBase) n)
                .getTableNumberColumnsRepeatedAttribute();
            for (int i = 0; i < columnsRepeatedNumber; i++) {
              newAfterCellElements.add((TableTableCellElementBase) n);
            }
View Full Code Here

    }
    // the row has repeated row number > 1 && the index is 0
    // or the row has repeated row num = 1
    Node aPrevNode = maRowElement.getPreviousSibling();
    Node aCurNode = maRowElement;
    TableTableRowElement lastRow;
    while (true) {
      if (aPrevNode == null) {
        // does not have previous sibling, then get the parent
        // because aCurNode might be the child element of
        // table-header-rows, table-rows, table-row-group
        Node parentNode = aCurNode.getParentNode();
        // if the parent is table, then it means that this row is the
        // first row in this table
        // it has no previous row
        if (parentNode instanceof TableTableElement) {
          return null;
        }
        aPrevNode = parentNode.getPreviousSibling();
      }
      // else the previous node might be table-header-rows, table-rows,
      // table-row-group
      if (aPrevNode != null) {
        try {
          if (aPrevNode instanceof TableTableRowElement) {
            return table
                .getRowInstance((TableTableRowElement) aPrevNode, ((TableTableRowElement) aPrevNode)
                    .getTableNumberRowsRepeatedAttribute().intValue() - 1);
          } else if (aPrevNode instanceof TableTableRowsElement
              || aPrevNode instanceof TableTableHeaderRowsElement
              || aPrevNode instanceof TableTableRowGroupElement) {
            XPath xpath = ((OdfContentDom) aPrevNode.getOwnerDocument()).getXPath();
            synchronized (mDocument) {
              lastRow = (TableTableRowElement) xpath.evaluate(".//table:table-row[last()]", aPrevNode,
                  XPathConstants.NODE);
            }
            if (lastRow != null) {
              return table.getRowInstance(lastRow, lastRow.getTableNumberRowsRepeatedAttribute()
                  .intValue() - 1);
            }
          } else {
            aCurNode = aPrevNode;
            aPrevNode = aPrevNode.getPreviousSibling();
View Full Code Here

        return table.getRowInstance(maRowElement, mnRepeatedIndex + 1);
      }
    }
    Node aNextNode = maRowElement.getNextSibling();
    Node aCurNode = maRowElement;
    TableTableRowElement firstRow;
    while (true) {
      if (aNextNode == null) {
        // does not have next sibling, then get the parent
        // because aCurNode might be the child element of
        // table-header-rows, table-rows, table-row-group
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.table.TableTableRowElement

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.