Package org.odftoolkit.odfdom.pkg

Examples of org.odftoolkit.odfdom.pkg.OdfFileDom


   * Process text that may have a currency symbol ($) in it.
   * @param text string to be processed
   * @param currencySymbol the currency symbol under consideration
   */
  private void processText(String text, String currencySymbol) {
    OdfFileDom dom = (OdfFileDom) this.getOwnerDocument();
    int currencyPos = text.indexOf(currencySymbol);
    if (currencyPos >= 0) {
      emitText(text.substring(0, currencyPos));
      NumberCurrencySymbolElement cSymbol = new NumberCurrencySymbolElement(dom);
      cSymbol.appendChild(dom.createTextNode(currencySymbol));
      this.appendChild(cSymbol);
      emitText(text.substring(currencyPos + currencySymbol.length()));
    } else {
      emitText(text);
    }
View Full Code Here


   *         is no such element.
   */
  public OdfOfficeStyles getDocumentStyles() {
    if (mDocumentStyles == null) {
      try {
        OdfFileDom stylesDom = getStylesDom();
        if (stylesDom != null) {
          mDocumentStyles = OdfElement.findFirstChildNode(OdfOfficeStyles.class, stylesDom.getFirstChild());
        } else {
          return null;
        }
      } catch (Exception ex) {
        Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

   * return the office:master-styles element of this document.
   * @return the office:master-styles element
   */
  public OdfOfficeMasterStyles getOfficeMasterStyles() {
    try {
      OdfFileDom fileDom = getStylesDom();
      if (fileDom != null) {
        return OdfElement.findFirstChildNode(OdfOfficeMasterStyles.class, fileDom.getFirstChild());
      }
    } catch (Exception ex) {
      Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
View Full Code Here

   *         yet such an element, it is created.
   */
  public OdfOfficeStyles getOrCreateDocumentStyles() {
    if (mDocumentStyles == null) {
      try {
        OdfFileDom stylesDom = getStylesDom();
        Node parent = stylesDom != null ? stylesDom.getFirstChild() : null;
        if (parent != null) {
          mDocumentStyles = OdfElement.findFirstChildNode(OdfOfficeStyles.class, parent);
          if (mDocumentStyles == null) {
            mDocumentStyles = stylesDom.newOdfElement(OdfOfficeStyles.class);
            parent.insertBefore(mDocumentStyles, parent.getFirstChild());
          }
        }
      } catch (Exception ex) {
        Logger.getLogger(OdfSchemaDocument.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

   *
   * @return the <code>OdfOfficeAutomaticStyles</code> element that contains
   *         the automatic style for this element, or null if not available.
   */
  public OdfOfficeAutomaticStyles getAutomaticStyles() {
    OdfFileDom fileDom = (OdfFileDom) this.ownerDocument;
    if (fileDom != null) {
      return fileDom.getAutomaticStyles();
    } else {
      return null;
    }
  }
View Full Code Here

        || headerColumnNumber < 0 || headerRowNumber > numRows
        || 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);
View Full Code Here

  /**
   * This method is invoked by appendRow.
   * When a table has no row, the first row is a default row.
   */
  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) {
View Full Code Here

   */
  public void setCellRangeName(String cellRangeName) {
    try {
      OdfElement contentRoot = maOwnerTable.mDocument.getContentRoot();
      //create name range element
      OdfFileDom contentDom = ((OdfFileDom) maOwnerTable.getOdfElement().getOwnerDocument());
      TableNamedExpressionsElement nameExpress = (TableNamedExpressionsElement) OdfXMLFactory.newOdfElement(
          contentDom,
          OdfName.newName(OdfDocumentNamespace.TABLE, "named-expressions"));
      String startCellRange = "$" + maOwnerTable.getTableName() + "." + maOwnerTable.getAbsoluteCellAddress(mnStartColumn, mnStartRow);
      String endCellRange = "$" + maOwnerTable.getTableName() + "." + maOwnerTable.getAbsoluteCellAddress(mnEndColumn, mnEndRow);
View Full Code Here

   * These elements are built "by hand" rather than
   * @param ch the formatting character to process
   * @param count the number of occurrences of this character
   */
  private void processChar(char ch, int count) {
    OdfFileDom ownerDoc = (OdfFileDom) this.getOwnerDocument();
    switch (ch) {
      case 'G':
        NumberEraElement era =
            new NumberEraElement(ownerDoc);
        era.setNumberStyleAttribute(isLongIf(count > 3));
View Full Code Here

  /**
   * Remove this item from its owner list.
   */
  public void remove() {
    Node parentElement = listItemElement.getParentNode();
    OdfFileDom ownerDocument = (OdfFileDom) listItemElement.getOwnerDocument();
    Document doc = (Document) ownerDocument.getDocument();
    doc.removeElementLinkedResource(listItemElement);
    parentElement.removeChild(listItemElement);
  }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.pkg.OdfFileDom

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.