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

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


    return result;
  }

  public String getNumberFormat() {
    String result = "";
    NumberNumberElement number = OdfElement.findFirstChildNode(NumberNumberElement.class, this);
    boolean isGroup = number.getNumberGroupingAttribute();
    int decimalPos = (number.getNumberDecimalPlacesAttribute() == null) ? 0
        : number.getNumberDecimalPlacesAttribute().intValue();
    int minInt = (number.getNumberMinIntegerDigitsAttribute() == null) ? 1
        : number.getNumberMinIntegerDigitsAttribute().intValue();

    int i;
    for (i = 0; i < minInt; i++) {
      if (((i + 1) % 3) == 0 && isGroup) {
        result = ",0" + result;
View Full Code Here


    char ch;
    int nDigits;

    Pattern p = Pattern.compile("[#0,.]+");
    Matcher m;
    NumberNumberElement number;

    /*
     * If there is a numeric specifcation, then split the
     * string into the part before the specifier, the specifier
     * itself, and then part after the specifier. The parts
     * before and after are just text (which may contain the
     * currency symbol).
     */
    m = p.matcher(format);
    if (m.find()) {
      preMatch = format.substring(0, m.start());
      numberSpec = format.substring(m.start(), m.end());
      postMatch = format.substring(m.end());

      processText(preMatch, currencySymbol);

      number = new NumberNumberElement((OdfFileDom) this.getOwnerDocument());

      /* Process part before the decimal point (if any) */
      nDigits = 0;
      for (pos = 0; pos < numberSpec.length()
          && (ch = numberSpec.charAt(pos)) != '.'; pos++) {
        if (ch == ',') {
          number.setNumberGroupingAttribute(new Boolean(true));
        } else if (ch == '0') {
          nDigits++;
        }
      }
      number.setNumberMinIntegerDigitsAttribute(nDigits);

      /* Number of decimal places is the length after the decimal */
      if (pos < numberSpec.length()) {
        number.setNumberDecimalPlacesAttribute(numberSpec.length() - (pos + 1));
      }
      this.appendChild(number);

      processText(postMatch, currencySymbol);
    }
View Full Code Here

            checkNumberFormat(expectedValue, node);
            break;
        }
        node = node.getNextSibling();
        Assert.assertEquals(expectedFormat[i], instance.getFormat());
        NumberNumberElement number = OdfElement.findFirstChildNode(NumberNumberElement.class, instance);
        try {
          Assert.assertEquals(expectedNumberDecimalPlaces[i], number
              .getNumberDecimalPlacesAttribute().intValue());
        } catch (Exception e) {
          Assert.fail(e.getMessage());
        }
      }
View Full Code Here

  {
    int nDigits = Integer.parseInt(expected.substring(0,1));
    int nDecimals = Integer.parseInt(expected.substring(1,2));
    boolean grouped = (expected.charAt(2) == 'T');
    boolean nodeGrouped;
    NumberNumberElement number;

    Assert.assertTrue("node is OdfNumber", node instanceof NumberNumberElement);
    number = (NumberNumberElement) node;

    // check number of digits and decimals
    Assert.assertEquals(nDigits, (long) number.getNumberMinIntegerDigitsAttribute());

    if (nDecimals > 0)
    {
      Assert.assertEquals(nDecimals, (long)number.getNumberDecimalPlacesAttribute());
    }

    // check if grouping is set properly
    nodeGrouped = (number.getNumberGroupingAttribute() == null) ? false :
      number.getNumberGroupingAttribute().booleanValue();
    Assert.assertTrue("Grouping", grouped == nodeGrouped);
  }
View Full Code Here

  {
    int nDigits = Integer.parseInt(expected.substring(0,1));
    int nDecimals = Integer.parseInt(expected.substring(1,2));
    boolean grouped = (expected.charAt(2) == 'T');
    boolean nodeGrouped;
    NumberNumberElement number;

    Assert.assertTrue("node is NumberNmberElement", node instanceof NumberNumberElement);
    number = (NumberNumberElement) node;

    // check number of digits and decimals
    Assert.assertEquals(nDigits, (long) number.getNumberMinIntegerDigitsAttribute());

    if (nDecimals > 0)
    {
      Assert.assertEquals(nDecimals, (long)number.getNumberDecimalPlacesAttribute());
    }

    // check if grouping is set properly
    nodeGrouped = (number.getNumberGroupingAttribute() == null) ?
      false :
      number.getNumberGroupingAttribute().booleanValue();
    Assert.assertTrue("Grouping", grouped == nodeGrouped);
  }
View Full Code Here

TOP

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

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.