Examples of TableTableElement


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

  //the maRowElement/mnRepeatedIndex should also be updated according to the original index in the repeated column
  void splitRepeatedRows() {
    int repeateNum = getRowsRepeatedNumber();
    if (repeateNum > 1) {
      OdfTable table = getTable();
      TableTableElement tableEle = table.getOdfElement();
      //change this repeated row to several single rows
      TableTableRowElement ownerRowElement = null;
      int repeatedRowIndex = mnRepeatedIndex;
      Node refElement = maRowElement;
      Node oldRowElement = maRowElement;
      for (int i = repeateNum - 1; i >= 0; i--) {
        TableTableRowElement newRow = (TableTableRowElement) maRowElement.cloneNode(true);
        newRow.removeAttributeNS(OdfDocumentNamespace.TABLE.getUri(), "number-rows-repeated");
        tableEle.insertBefore(newRow, refElement);
        refElement = newRow;
        if (repeatedRowIndex == i) {
          ownerRowElement = newRow;
        } else {
          table.updateRowRepository(maRowElement, i, newRow, 0);
        }
      }

      if (ownerRowElement != null) {
        table.updateRowRepository(maRowElement, mnRepeatedIndex, ownerRowElement, 0);
      }
      tableEle.removeChild(oldRowElement);
      mRowsRepeatedNumber = -1;
    }
  }
View Full Code Here

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

   *
   * @return the index of the row
   */
  public int getRowIndex() {
    int result = 0;
    TableTableElement mTableElement = getTableElement();
    TableTableRowElement rowEle = null;
    for (Node n : new DomNodeList(mTableElement.getChildNodes())) {
      if (n instanceof TableTableHeaderRowsElement) {
        TableTableHeaderRowsElement headers = (TableTableHeaderRowsElement) n;
        for (Node m : new DomNodeList(headers.getChildNodes())) {
          if (m instanceof TableTableRowElement) {
            rowEle = (TableTableRowElement) m;
View Full Code Here

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

   *
   * @param cellElement  the cell element that need to get the corresponding <code>OdfTableCell</code> instance
   * @return the <code>OdfTableCell</code> instance that represents a specified cell element
   */
  public static OdfTableCell getInstance(TableTableCellElementBase cellElement) {
    TableTableElement tableElement = null;
    Node node = cellElement.getParentNode();
    while (node != null) {
      if (node instanceof TableTableElement) {
        tableElement = (TableTableElement) node;
      }
View Full Code Here

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

  /**
   * 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) {
View Full Code Here

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

  /**
   * Get an instance of table feature which contains this cell.
   * @return the table containing this cell
   */
  public OdfTable getTable() {
    TableTableElement tableElement = getTableElement();
    if (tableElement != null) {
      return OdfTable.getInstance(tableElement);
    }
    return null;
  }
View Full Code Here

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

    return table.getColumnByIndex(index);
  }

  TableTableColumnElement getTableColumnElement() {
    //return OdfTableCellBaseImpl.getTableColumn((OdfTableCellBase) mCellElement);
    TableTableElement tableElement = getTableElement();
    int columnindex = getColumnIndex();
    OdfTable fTable = OdfTable.getInstance(tableElement);
    return fTable.getColumnElementByIndex(columnindex);
  }
View Full Code Here

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

          + "Rows " + numRows + ", Columns " + numCols + ", HeaderRows " + headerRowNumber + ", HeaderColumns " + headerColumnNumber);
    }
    OdfFileDom dom = document.getContentDom();
    OdfOfficeAutomaticStyles styles = dom.getAutomaticStyles();
    //1. create table element
    TableTableElement newTEle = (TableTableElement) OdfXMLFactory.newOdfElement(dom,
        OdfName.newName(OdfDocumentNamespace.TABLE, "table"));
    String tablename = getUniqueTableName(document);
    newTEle.setTableNameAttribute(tablename);
    //create style
    OdfStyle tableStyle = styles.newStyle(OdfStyleFamily.Table);
    String stylename = tableStyle.getStyleNameAttribute();
    tableStyle.setProperty(StyleTablePropertiesElement.Width, DEFAULT_TABLE_WIDTH + "in");
    tableStyle.setProperty(StyleTablePropertiesElement.Align, DEFAULT_TABLE_ALIGN);
    newTEle.setStyleName(stylename);

    // 2. create column elements
    // 2.0 create column style
    OdfStyle columnStyle = styles.newStyle(OdfStyleFamily.TableColumn);
    String columnStylename = columnStyle.getStyleNameAttribute();
    columnStyle.setProperty(StyleTableColumnPropertiesElement.ColumnWidth,
        new DecimalFormat("000.0000").format(DEFAULT_TABLE_WIDTH / numCols) + "in");
    columnStyle.setProperty(StyleTableColumnPropertiesElement.RelColumnWidth, Math.round(DEFAULT_REL_TABLE_WIDTH / numCols) + "*");
    // 2.1 create header column elements
    if (headerColumnNumber > 0) {
      TableTableHeaderColumnsElement headercolumns = (TableTableHeaderColumnsElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(OdfDocumentNamespace.TABLE, "table-header-columns"));
      TableTableColumnElement headercolumn = (TableTableColumnElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(OdfDocumentNamespace.TABLE, "table-column"));
      headercolumn.setTableNumberColumnsRepeatedAttribute(headerColumnNumber);
      headercolumns.appendChild(headercolumn);
      newTEle.appendChild(headercolumns);
      headercolumn.setStyleName(columnStylename);
    }
    //2.2 create common column elements
    TableTableColumnElement columns = (TableTableColumnElement) OdfXMLFactory.newOdfElement(dom,
        OdfName.newName(OdfDocumentNamespace.TABLE, "table-column"));
    columns.setTableNumberColumnsRepeatedAttribute(numCols - headerColumnNumber);
    columns.setStyleName(columnStylename);
    newTEle.appendChild(columns);

    //3. create row elements
    //3.0 create 4 kinds of styles
    OdfStyle lefttopStyle=null,leftbottomStyle=null,righttopStyle=null,rightbottomStyle=null;
   
    if (!document.getMediaTypeString().equals(OdfMediaType.SPREADSHEET.getMediaTypeString())) {
      lefttopStyle = styles.newStyle(OdfStyleFamily.TableCell);
      setLeftTopBorderStyleProperties(lefttopStyle);
 
      leftbottomStyle = styles.newStyle(OdfStyleFamily.TableCell);
      setLeftBottomBorderStylesProperties(leftbottomStyle);
 
      righttopStyle = styles.newStyle(OdfStyleFamily.TableCell);
      setRightTopBorderStyleProperties(righttopStyle);
 
      rightbottomStyle = styles.newStyle(OdfStyleFamily.TableCell);
      setRightBottomBorderStylesProperties(rightbottomStyle);
    }

    //3.1 create header row elements
    if( headerRowNumber > 0)
    {
      TableTableHeaderRowsElement headerrows = (TableTableHeaderRowsElement) OdfXMLFactory.newOdfElement(dom,
          OdfName.newName(OdfDocumentNamespace.TABLE, "table-header-rows"));
      for (int i = 0; i < headerRowNumber; i++) {
        TableTableRowElement aRow = (TableTableRowElement) OdfXMLFactory.newOdfElement(dom,
            OdfName.newName(OdfDocumentNamespace.TABLE, "table-row"));
        for (int j = 0; j < numCols; j++) {
          TableTableCellElement aCell = (TableTableCellElement) OdfXMLFactory.newOdfElement(dom,
              OdfName.newName(OdfDocumentNamespace.TABLE, "table-cell"));
          TextPElement aParagraph = (TextPElement) OdfXMLFactory.newOdfElement(dom,
              OdfName.newName(OdfDocumentNamespace.TEXT, "p"));
          aCell.appendChild(aParagraph);
          if (!isSpreadsheet) {
            if ((j + 1 == numCols) && (i == 0)) {
              aCell.setStyleName(righttopStyle.getStyleNameAttribute());
            } else if (i == 0) {
              aCell.setStyleName(lefttopStyle.getStyleNameAttribute());
            } else if ((j + 1 == numCols) && (i > 0)) {
              aCell.setStyleName(rightbottomStyle.getStyleNameAttribute());
            } else {
              aCell.setStyleName(leftbottomStyle.getStyleNameAttribute());
            }
          }
          aRow.appendChild(aCell);
        }
        headerrows.appendChild(aRow);
      }
      newTEle.appendChild(headerrows);
    }

    //3.2 create common row elements
    for (int i = headerRowNumber; i < numRows; i++) {
      TableTableRowElement aRow = (TableTableRowElement) OdfXMLFactory.newOdfElement(dom,
          OdfName.newName(OdfDocumentNamespace.TABLE, "table-row"));
      for (int j = 0; j < numCols; j++) {
        TableTableCellElement aCell = (TableTableCellElement) OdfXMLFactory.newOdfElement(dom,
            OdfName.newName(OdfDocumentNamespace.TABLE, "table-cell"));
        TextPElement aParagraph = (TextPElement) OdfXMLFactory.newOdfElement(dom,
            OdfName.newName(OdfDocumentNamespace.TEXT, "p"));
        aCell.appendChild(aParagraph);
        if (!isSpreadsheet) {
          if ((j + 1 == numCols) && (i == 0)) {
            aCell.setStyleName(righttopStyle.getStyleNameAttribute());
          } else if (i == 0) {
            aCell.setStyleName(lefttopStyle.getStyleNameAttribute());
          } else if ((j + 1 == numCols) && (i > 0)) {
            aCell.setStyleName(rightbottomStyle.getStyleNameAttribute());
          } else {
            aCell.setStyleName(leftbottomStyle.getStyleNameAttribute());
          }
        }
        aRow.appendChild(aCell);
      }
      newTEle.appendChild(aRow);
    }

    return newTEle;
  }
View Full Code Here

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

   */
  public int getColumnIndex() {
    int result = 0;
    OdfTable table = getTable();
    TableTableColumnElement columnEle;
    TableTableElement mTableElement = table.getOdfElement();
    for (Node n : new DomNodeList(mTableElement.getChildNodes())) {
      if (n instanceof TableTableHeaderColumnsElement) {
        TableTableHeaderColumnsElement headers = (TableTableHeaderColumnsElement) n;
        for (Node m : new DomNodeList(headers.getChildNodes())) {
          if (m instanceof TableTableColumnElement) {
            columnEle = (TableTableColumnElement) m;
View Full Code Here

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

   * @param document  the ODF document that contains this feature
   * @return the created <code>OdfTable</code> feature instance
   */
  public static OdfTable newTable(OdfDocument document) {
    try {
      TableTableElement newTEle = createTable(document, DEFAULT_ROW_COUNT, DEFAULT_COLUMN_COUNT, 0, 0);

      //4. append to the end of document
      OdfElement root = document.getContentDom().getRootElement();
      OfficeBodyElement officeBody = OdfElement.findFirstChildNode(OfficeBodyElement.class, root);
      OdfElement typedContent = OdfElement.findFirstChildNode(OdfElement.class, officeBody);
View Full Code Here

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

   * @param numCols  the column number
   * @return a new instance of <code>OdfTable</code>
   */
  public static OdfTable newTable(OdfDocument document, int numRows, int numCols) {
    try {
      TableTableElement newTEle = createTable(document, numRows, numCols, 0, 0);

      //4. append to the end of document
      OdfElement root = document.getContentDom().getRootElement();
      OfficeBodyElement officeBody = OdfElement.findFirstChildNode(OfficeBodyElement.class, root);
      OdfElement typedContent = OdfElement.findFirstChildNode(OdfElement.class, officeBody);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.