Examples of OdfNumberDateStyle


Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

      if (style != null) {
        return style.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.DATE) {
      String name = getDataDisplayStyleName();
      OdfNumberDateStyle style = mCellElement.getAutomaticStyles().getDateStyle(name);
      if (style == null) {
        style = mDocument.getDocumentStyles().getDateStyle(name);
      }
      if (style != null) {
        return style.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.CURRENCY) {
      String name = getCurrencyDisplayStyleName();
      OdfNumberCurrencyStyle dataStyle = mCellElement.getAutomaticStyles().getCurrencyStyle(name);
      if (dataStyle == null) {
        dataStyle = mDocument.getDocumentStyles().getCurrencyStyle(name);
      }
      if (dataStyle != null) {
        return dataStyle.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.PERCENTAGE) {
      String name = getDataDisplayStyleName();
      OdfNumberPercentageStyle style = mCellElement.getAutomaticStyles().getPercentageStyle(name);
      if (style == null) {
        style = mDocument.getDocumentStyles().getPercentageStyle(name);
      }
      if (style != null) {
        return style.getFormat();
      }
    }
    return null;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

        mNumberStyles = new HashMap<String, OdfNumberStyle>();
      }

      mNumberStyles.put(numberStyle.getStyleNameAttribute(), numberStyle);
    } else if (node instanceof OdfNumberDateStyle) {
      OdfNumberDateStyle dateStyle = (OdfNumberDateStyle) node;

      if (mDateStyles == null) {
        mDateStyles = new HashMap<String, OdfNumberDateStyle>();
      }

      mDateStyles.put(dateStyle.getStyleNameAttribute(), dateStyle);
    } else if (node instanceof OdfNumberPercentageStyle) {
      OdfNumberPercentageStyle percentageStyle = (OdfNumberPercentageStyle) node;

      if (mPercentageStyles == null) {
        mPercentageStyles = new HashMap<String, OdfNumberPercentageStyle>();
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

        OdfNumberStyle numberStyle = (OdfNumberStyle) node;
        mNumberStyles.remove(numberStyle.getStyleNameAttribute());
      }
    } else if (node instanceof OdfNumberDateStyle) {
      if (mDateStyles != null) {
        OdfNumberDateStyle dateStyle = (OdfNumberDateStyle) node;
        mDateStyles.remove(dateStyle.getStyleNameAttribute());
      }
    } else if (node instanceof OdfNumberPercentageStyle) {
      if (mPercentageStyles != null) {
        OdfNumberPercentageStyle percentageStyle = (OdfNumberPercentageStyle) node;
        mPercentageStyles.remove(percentageStyle.getStyleNameAttribute());
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

    try {
      outputDocument = SpreadsheetDocument.newSpreadsheetDocument();
      contentDom = outputDocument.getContentDom();
      contentAutoStyles = contentDom.getOrCreateAutomaticStyles();

      OdfNumberDateStyle dateStyle = new OdfNumberDateStyle(contentDom, "yyyy-MM-dd", "numberDateStyle", null);
      OdfNumberStyle numberStyle = new OdfNumberStyle(contentDom, "#0.00", "numberTemperatureStyle");

      contentAutoStyles.appendChild(dateStyle);
      contentAutoStyles.appendChild(numberStyle);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

      Double value = getDoubleValue();
      if (value != null) {
        setDisplayTextContent((new DecimalFormat(formatStr)).format(value.doubleValue()), null);
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.DATE) {
      OdfNumberDateStyle dateStyle = new OdfNumberDateStyle((OdfFileDom) mCellElement.getOwnerDocument(),
          formatStr, getUniqueDateStyleName(), null);
      mCellElement.getAutomaticStyles().appendChild(dateStyle);
      setDataDisplayStyleName(dateStyle.getStyleNameAttribute());
      String dateStr = mCellElement.getOfficeDateValueAttribute();
      if (dateStr != null) {
        Calendar date = getDateValue();
        setDisplayTextContent((new SimpleDateFormat(formatStr)).format(date.getTime()), null);
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.TIME) {
      OdfNumberTimeStyle timeStyle = new OdfNumberTimeStyle((OdfFileDom) mCellElement.getOwnerDocument(),
          formatStr, getUniqueDateStyleName());
      mCellElement.getAutomaticStyles().appendChild(timeStyle);
      setDataDisplayStyleName(timeStyle.getStyleNameAttribute());
      String timeStr = mCellElement.getOfficeTimeValueAttribute();
      if (timeStr != null) {
        Calendar time = getTimeValue();
        setDisplayTextContent((new SimpleDateFormat(formatStr)).format(time.getTime()), null);
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.PERCENTAGE) {
      OdfNumberPercentageStyle dateStyle = new OdfNumberPercentageStyle((OdfFileDom) mCellElement
          .getOwnerDocument(), formatStr, getUniquePercentageStyleName());
      mCellElement.getAutomaticStyles().appendChild(dateStyle);
      setDataDisplayStyleName(dateStyle.getStyleNameAttribute());
      Double value = getPercentageValue();
      if (value != null) {
        setDisplayTextContent((new DecimalFormat(formatStr)).format(value.doubleValue()), null);
      }
    } else {
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

      if (style != null) {
        return style.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.DATE) {
      String name = getDataDisplayStyleName();
      OdfNumberDateStyle style = mCellElement.getAutomaticStyles().getDateStyle(name);
      if (style == null) {
        style = mDocument.getDocumentStyles().getDateStyle(name);
      }
      if (style != null) {
        return style.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.TIME) {
      String name = getDataDisplayStyleName();
      OdfNumberDateStyle style = mCellElement.getAutomaticStyles().getDateStyle(name);
      if (style == null) {
        style = mDocument.getDocumentStyles().getDateStyle(name);
      }
      if (style != null) {
        return style.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.CURRENCY) {
      String name = getCurrencyDisplayStyleName();
      OdfNumberCurrencyStyle dataStyle = mCellElement.getAutomaticStyles().getCurrencyStyle(name);
      if (dataStyle == null) {
        dataStyle = mDocument.getDocumentStyles().getCurrencyStyle(name);
      }
      if (dataStyle != null) {
        return dataStyle.getFormat();
      }
    } else if (typeValue == OfficeValueTypeAttribute.Value.PERCENTAGE) {
      String name = getDataDisplayStyleName();
      OdfNumberPercentageStyle style = mCellElement.getAutomaticStyles().getPercentageStyle(name);
      if (style == null) {
        style = mDocument.getDocumentStyles().getPercentageStyle(name);
      }
      if (style != null) {
        return style.getFormat();
      }
    }
    return null;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

   */
  public void setFormatString(String formatStr, String type) {
    OfficeValueTypeAttribute.Value typeValue = null;
    typeValue = OfficeValueTypeAttribute.Value.enumValueOf(type);
    if (typeValue == OfficeValueTypeAttribute.Value.DATE) {
      OdfNumberDateStyle dateStyle = new OdfNumberDateStyle(
          (OdfFileDom) mElement.getOwnerDocument(), formatStr,
          getUniqueDateStyleName(), null);
      dateStyle.setNumberLanguageAttribute("en");
      dateStyle.setNumberCountryAttribute("US");
      mElement.getAutomaticStyles().appendChild(dateStyle);
      setDataDisplayStyleName(dateStyle.getStyleNameAttribute());
    } else if (typeValue == OfficeValueTypeAttribute.Value.TIME) {
      OdfNumberTimeStyle timeStyle = new OdfNumberTimeStyle(
          (OdfFileDom) mElement.getOwnerDocument(), formatStr,
          getUniqueDateStyleName());
      mElement.getAutomaticStyles().appendChild(timeStyle);
      setDataDisplayStyleName(timeStyle.getStyleNameAttribute());
    } else if (typeValue == OfficeValueTypeAttribute.Value.PERCENTAGE) {
      OdfNumberPercentageStyle dateStyle = new OdfNumberPercentageStyle(
          (OdfFileDom) mElement.getOwnerDocument(), formatStr,
          getUniquePercentageStyleName());
      mElement.getAutomaticStyles().appendChild(dateStyle);
      setDataDisplayStyleName(dateStyle.getStyleNameAttribute());
    } else {
      throw new IllegalArgumentException("This function doesn't support "
          + type + "formatting.");
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

        "ELminutes", "T:", "ELseconds", "T ",
        "E-am-pm"} // "dd-MM-yyyy hh:mm:ss a"
    };

        LOG.info("buildFromFormat");
        OdfNumberDateStyle instance = null;

        for (i = 0; i < formatTest.length; i++)
    {
      LOG.info("Date format: " + formatTest[i]);
      instance = new OdfNumberDateStyle(dom,
        formatTest[i], "fstyle");
      Assert.assertNotNull(instance.getFirstChild());

      checkNodes(instance.getFirstChild(), expected[i], 0);
      Assert.assertEquals(expectedFormat[i], instance.getFormat());
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

  // package constructor, only called by Fields.
  DateField(OdfElement odfElement) {
    TextSpanElement spanElement = ((OdfFileDom) odfElement.getOwnerDocument()).newOdfElement(TextSpanElement.class);
    odfElement.appendChild(spanElement);
    dateElement = spanElement.newTextDateElement();
    OdfNumberDateStyle dateStyle = newDateStyle();
    String dateStyleName = dateStyle.getStyleNameAttribute();
    dateStyle.buildFromFormat(DEFAULT_DATE_FORMAT);
    dateStyle.setStyleNameAttribute(dateStyleName);
    dateElement.setStyleDataStyleNameAttribute(dateStyle.getStyleNameAttribute());
    Calendar calender = Calendar.getInstance();
    SimpleDateFormat simpleFormat = new SimpleDateFormat(DEFAULT_DATE_VALUE_FORMAT);
    Date date = calender.getTime();
    String svalue = simpleFormat.format(date);
    dateElement.setTextDateValueAttribute(svalue);
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.number.OdfNumberDateStyle

      if (dom instanceof OdfContentDom) {
        styles = ((OdfContentDom) dom).getAutomaticStyles();
      } else if (dom instanceof OdfStylesDom) {
        styles = ((OdfStylesDom) dom).getAutomaticStyles();
      }
      OdfNumberDateStyle dataStyle = styles.getDateStyle(dateElement.getStyleDataStyleNameAttribute());
      dataStyle.buildFromFormat(formatString);
    } catch (ParseException e) {
      Logger.getLogger(DateField.class.getName()).log(Level.SEVERE, e.getMessage(), e);
    }
  }
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.