Package org.odftoolkit.odfdom.incubator.doc.style

Examples of org.odftoolkit.odfdom.incubator.doc.style.OdfStyle


  public void setAttributeNS(String uri, String qname, String value) {
    super.setAttributeNS(uri, qname, value);

    // check if style has changed
    if (mStyleNameAttrib.equals(uri, qname)) {
      OdfStyle autoStyle = null;

      // optimization: check if we already know this automatic style
      if ((mAutomaticStyle != null)
          && (mAutomaticStyle.getStyleNameAttribute().equals(value))) {
        // nothing todo
View Full Code Here


   *
   * @return The <code>OdfStyle</code> element
   *
   * */
  public OdfStyle reuseDocumentStyle(String styleName) {
    OdfStyle style = null;
    if (styleName != null) {
      style = mOdfSchemaDocument.getDocumentStyles().getStyle(styleName,
          getStyleFamily());
      if (style != null) {
        setDocumentStyle(style);
View Full Code Here

   * @param style
   *       the cell style of the document
   */
  public void setDefaultCellStyle(OdfStyle style) {
    splitRepeatedColumns();
    OdfStyle defaultStyle = getDefaultCellStyle();
    if (defaultStyle != null) {
      defaultStyle.removeStyleUser(maColumnElement);
    }

    if (style != null) {
      style.addStyleUser(maColumnElement);
      maColumnElement.setTableDefaultCellStyleNameAttribute(
View Full Code Here

   * Get the default cell style of this column.
   * @return the default cell style of this column
   */
  public OdfStyle getDefaultCellStyle() {
    String styleName = maColumnElement.getTableDefaultCellStyleNameAttribute();
    OdfStyle style = maColumnElement.getAutomaticStyles().getStyle(
        styleName, OdfStyleFamily.TableCell);

    if (style == null) {
      style = mDocument.getDocumentStyles().getStyle(styleName, OdfStyleFamily.TableCell);
    }
View Full Code Here

    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());
          }
View Full Code Here

   */
  private TableTableRowElement createDefaultRow(int columnCount) {
    OdfFileDom dom = (OdfFileDom) mTableElement.getOwnerDocument();
    //3. create row elements
    //3.0 create 4 kinds of styles
    OdfStyle lefttopStyle=null,righttopStyle=null;
   
    if (!mIsSpreadsheet) {
      lefttopStyle = mTableElement.getAutomaticStyles().newStyle(OdfStyleFamily.TableCell);
      setLeftTopBorderStyleProperties(lefttopStyle);
 
      righttopStyle = mTableElement.getAutomaticStyles().newStyle(OdfStyleFamily.TableCell);
      setRightTopBorderStyleProperties(righttopStyle);
    }

    //3.1 create header row elements
    TableTableRowElement aRow = (TableTableRowElement) OdfXMLFactory.newOdfElement(dom,
        OdfName.newName(OdfDocumentNamespace.TABLE, "table-row"));
    for (int j = 0; j < columnCount; 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 (!mIsSpreadsheet) {
        if (j + 1 == columnCount) {
          aCell.setStyleName(righttopStyle.getStyleNameAttribute());
        } else {
          aCell.setStyleName(lefttopStyle.getStyleNameAttribute());
        }
      }
      aRow.appendChild(aCell);
    }

View Full Code Here

    }   

    //insert columns secondly
    if (columnList.size() == 0) //no column, create a new column
    {
      OdfStyle columnStyle = mTableElement.getAutomaticStyles().newStyle(OdfStyleFamily.TableColumn);
      String columnStylename = columnStyle.getStyleNameAttribute();
      columnStyle.setProperty(StyleTableColumnPropertiesElement.ColumnWidth, DEFAULT_TABLE_WIDTH + "in");
      columnStyle.setProperty(StyleTableColumnPropertiesElement.RelColumnWidth, DEFAULT_REL_TABLE_WIDTH + "*");

      newColumn = (TableTableColumnElement) OdfXMLFactory.newOdfElement((OdfFileDom) mTableElement.getOwnerDocument(),
          OdfName.newName(OdfDocumentNamespace.TABLE, "table-column"));
      newColumn.setStyleName(columnStylename);
      mTableElement.insertBefore(newColumn, positonElement);
View Full Code Here

      OdfTableCell cell = oldTopRow.getCellByIndex(i);
      if (cell.isCoveredElement()) {
        i = i + cell.getColumnsRepeatedNumber();
        continue;
      }
      OdfStyle styleEle = cell.getCellStyleElementForWrite();
      if (i < length - 1) {
        setLeftBottomBorderStylesProperties(styleEle);
      } else {
        setRightBottomBorderStylesProperties(styleEle);
      }
View Full Code Here

      OdfTableCell cell = newTopRow.getCellByIndex(i);
      if (cell.isCoveredElement()) {
        i = i + cell.getColumnsRepeatedNumber();
        continue;
      }
      OdfStyle styleEle = cell.getCellStyleElementForWrite();
      if (i < length - 1) {
        setLeftTopBorderStyleProperties(styleEle);
      } else {
        setRightTopBorderStyleProperties(styleEle);
      }
View Full Code Here

  public String getCurrencySymbol() {
    if (getTypeAttr() != OfficeValueTypeAttribute.Value.CURRENCY) {
      throw new IllegalArgumentException();
    }

    OdfStyle style = getCellStyleElement();
    if (style != null) {
      String dataStyleName = style.getOdfAttributeValue(OdfName.newName(OdfDocumentNamespace.STYLE, "data-style-name"));
      OdfNumberCurrencyStyle dataStyle = mCellElement.getAutomaticStyles().getCurrencyStyle(dataStyleName);
      if (dataStyle == null) {
        dataStyle = mDocument.getDocumentStyles().getCurrencyStyle(dataStyleName);
      }
      if ((dataStyle != null) && (dataStyle.getCurrencySymbolElement() != null)) {
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.incubator.doc.style.OdfStyle

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.