Package org.odftoolkit.odfdom.dom.element.number

Examples of org.odftoolkit.odfdom.dom.element.number.NumberCurrencySymbolElement


  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


   * Get OdfCurrencySymbol element from this currency style.
   * Once you have it, you can add language and country.
   * @return an OdfCurrencySymbol element
   */
  public NumberCurrencySymbolElement getCurrencySymbolElement() {
    NumberCurrencySymbolElement cSymbol = null;
    NodeList list = this.getElementsByTagNameNS(
        OdfDocumentNamespace.NUMBER.getUri(), "currency-symbol");
    if (list.getLength() > 0) {
      cSymbol = (NumberCurrencySymbolElement) list.item(0);
    }
View Full Code Here

   * Set language and currency for the currency symbol.
   * @param language the language for the country
   * @param country the country name
   */
  public void setCurrencyLocale(String language, String country) {
    NumberCurrencySymbolElement cSymbol = getCurrencySymbolElement();
    cSymbol.setNumberCountryAttribute(country);
    cSymbol.setNumberLanguageAttribute(language);
  }
View Full Code Here

   * Argument could be just a language like "el" or a
   * language and country like "en-US".
   * @param locale string in form language-country or language
   */
  public void setCurrencyLocale(String locale) {
    NumberCurrencySymbolElement cSymbol = getCurrencySymbolElement();
    int pos = locale.indexOf('-');
    if (pos >= 0) {
      cSymbol.setNumberLanguageAttribute(locale.substring(0, pos));
      cSymbol.setNumberCountryAttribute(locale.substring(pos + 1));
    } else {
      cSymbol.setNumberLanguageAttribute(locale);
    }
  }
View Full Code Here

  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

   * Get OdfCurrencySymbol element from this currency style.
   * Once you have it, you can add language and country.
   * @return an OdfCurrencySymbol element
   */
  public NumberCurrencySymbolElement getCurrencySymbolElement() {
    NumberCurrencySymbolElement cSymbol = null;
    NodeList list = this.getElementsByTagNameNS(
        OdfDocumentNamespace.NUMBER.getUri(), "currency-symbol");
    if (list.getLength() > 0) {
      cSymbol = (NumberCurrencySymbolElement) list.item(0);
    }
View Full Code Here

   * Set language and currency for the currency symbol.
   * @param language the language for the country
   * @param country the country name
   */
  public void setCurrencyLocale(String language, String country) {
    NumberCurrencySymbolElement cSymbol = getCurrencySymbolElement();
    cSymbol.setNumberCountryAttribute(country);
    cSymbol.setNumberLanguageAttribute(language);
  }
View Full Code Here

   * Argument could be just a language like "el" or a
   * language and country like "en-US".
   * @param locale string in form language-country or language
   */
  public void setCurrencyLocale(String locale) {
    NumberCurrencySymbolElement cSymbol = getCurrencySymbolElement();
    int pos = locale.indexOf('-');
    if (pos >= 0) {
      cSymbol.setNumberLanguageAttribute(locale.substring(0, pos));
      cSymbol.setNumberCountryAttribute(locale.substring(pos + 1));
    } else {
      cSymbol.setNumberLanguageAttribute(locale);
    }
  }
View Full Code Here

  @Test
  public void testGetCurrencySymbolElement() {
    LOG.info("getCurrencySymbolElement");
    OdfNumberCurrencyStyle instance = new OdfNumberCurrencyStyle(dom,
      "$", "$#,##0.00", "cstyle");
    NumberCurrencySymbolElement expResult = new NumberCurrencySymbolElement(dom);
    expResult.setTextContent("$");
    NumberCurrencySymbolElement result = instance.getCurrencySymbolElement();
    Assert.assertEquals(expResult.getTextContent(),
      result.getTextContent());
  }
View Full Code Here

    LOG.info("setCurrencyLocale");
    String language = "ko";
    String country = "KR";
    OdfNumberCurrencyStyle instance = new OdfNumberCurrencyStyle(dom,
      "\u20a9", "\u20a9#,##0.00", "kstyle"); // korean Won
    NumberCurrencySymbolElement cSymbol;
    instance.setCurrencyLocale(language,
      country);
    NodeList list = instance.getElementsByTagNameNS(
      OdfDocumentNamespace.NUMBER.getUri(), "currency-symbol");
    Assert.assertTrue("Has currency symbol", list.getLength() > 0);
    cSymbol = (NumberCurrencySymbolElement) list.item(0);
    Assert.assertEquals(language, cSymbol.getNumberLanguageAttribute());
    Assert.assertEquals(country, cSymbol.getNumberCountryAttribute());
  }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.number.NumberCurrencySymbolElement

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.