Package org.odftoolkit.odfdom.incubator.doc.office

Examples of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles


      // Add frame and image element
      TextPElement paraLast = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
      addImageToDocument(contentDom, paraLast);

      // Access/Update automatic styles
      OdfOfficeAutomaticStyles autoStyles = embDoc.getContentDom().getAutomaticStyles();
      OdfStyle autoStyle = autoStyles.getStyle("P1", OdfStyleFamily.Paragraph);
      Assert.assertEquals(autoStyle.getStyleNameAttribute(), "P1");
      Assert.assertEquals(autoStyle.getFamilyName(), "paragraph");

      // Access/Update styles.xml
      OdfStyle documentStyle = embDoc.getDocumentStyles().getStyle("myStyle", OdfStyleFamily.Paragraph);
View Full Code Here


    OdfTextListStyle style = null;

    String listName = getTextStyleNameAttribute();
    if (listName != null && listName.length() > 0) {
      OdfFileDom fileDom = (OdfFileDom) this.ownerDocument;
      OdfOfficeAutomaticStyles autoStyles = fileDom.getAutomaticStyles();
      if (autoStyles != null) {
        style = autoStyles.getListStyle(listName);
      }

      if (style == null) {
        OdfOfficeStyles styles = ((OdfSchemaDocument) fileDom.getDocument()).getDocumentStyles();
        if (styles != null) {
View Full Code Here

   * @return the <code>OdfTextListStyle</code> element
   */
  public OdfTextListStyle getOrCreateLocalListStyle() {
    OdfTextListStyle listStyle = getListStyle();
    if (listStyle == null) {
      OdfOfficeAutomaticStyles autoStyles = ((OdfFileDom) this.ownerDocument).getOrCreateAutomaticStyles();
      if (autoStyles != null) {
        listStyle = autoStyles.newListStyle();
      }
    }
    return listStyle;
  }
View Full Code Here

    }
    if (styleName == null || (styleName.equals(""))) {
      return null;
    }

    OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles();
    OdfStyle styleElement = styles.getStyle(styleName, mCellElement.getStyleFamily());

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

    return datadisplayStylename;
  }

  private String getUniqueNumberStyleName() {
    String unique_name;
    OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles();
    do {
      unique_name = String.format("n%06x", (int) (Math.random() * 0xffffff));
    } while (styles.getNumberStyle(unique_name) != null);
    return unique_name;
  }
View Full Code Here

    return unique_name;
  }

  private String getUniqueDateStyleName() {
    String unique_name;
    OdfOfficeAutomaticStyles styles = mCellElement.getAutomaticStyles();
    do {
      unique_name = String.format("d%06x", (int) (Math.random() * 0xffffff));
    } while (styles.getDateStyle(unique_name) != null);
    return unique_name;
  }
View Full Code Here

   */
  public StyleStyleElement getOrCreateUnqiueAutomaticStyle() {
    if ((mAutomaticStyle == null)
        || (mAutomaticStyle.getStyleUserCount() > 1)) {
      // we need a new automatic style
      OdfOfficeAutomaticStyles automatic_styles = getAutomaticStyles();
      if (automatic_styles != null) {
        StyleNameRef sParentStyleName = null;
        if (mAutomaticStyle == null) {
          mAutomaticStyle = automatic_styles.newStyle(getStyleFamily());
          sParentStyleName = new StyleNameRef(getStyleName());
        } else {
          String nameAttr = mAutomaticStyle.getStyleParentStyleNameAttribute();
          sParentStyleName = new StyleNameRef(nameAttr == null ? "" : nameAttr);
          mAutomaticStyle.removeStyleUser(this);
          mAutomaticStyle = automatic_styles.makeStyleUnique(mAutomaticStyle);
        }

        mAutomaticStyle.addStyleUser(this);

        if ((sParentStyleName != null)
View Full Code Here

      if ((mAutomaticStyle != null)
          && (mAutomaticStyle.getStyleNameAttribute().equals(value))) {
        // nothing todo
      } else {
        // register new automatic style
        OdfOfficeAutomaticStyles automatic_styles = getAutomaticStyles();
        if (automatic_styles != null) {
          autoStyle = automatic_styles.getStyle(value,
              getStyleFamily());
        }

        if (mAutomaticStyle != null) {
          mAutomaticStyle.removeStyleUser(this);
View Full Code Here

        mAutomaticStyle.removeStyleUser(this);
        mAutomaticStyle = null;
      }

      OdfOfficeAutomaticStyles automatic_styles = getAutomaticStyles();
      if (automatic_styles != null) {
        mAutomaticStyle = automatic_styles.getStyle(stylename,
            getStyleFamily());

        if (mAutomaticStyle != null) {
          mAutomaticStyle.addStyleUser(this);
        }
View Full Code Here

        || headerColumnNumber > numCols) {
      throw new IllegalArgumentException("Can not create table with the given parameters:\n"
          + "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)
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles

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.