Package org.odftoolkit.odfdom.dom.element.text

Examples of org.odftoolkit.odfdom.dom.element.text.TextListLevelStyleElementBase


   * Retrieves the List Level Style
   *
   * @return the <code>TextListLevelStyleElementBase</code>
   */
  public TextListLevelStyleElementBase getListLevelStyle() {
    TextListLevelStyleElementBase odfListLevelStyle = null;
    OdfTextListStyle style = getListStyle();
    int level = getListLevel();
    if (style != null) {
      odfListLevelStyle = style.getLevel(level);
    } else {
View Full Code Here


   * Retrieves the List Level Style
   *
   * @return the <code>TextListLevelStyleElementBase</code>
   */
  public TextListLevelStyleElementBase getListLevelStyle() {
    TextListLevelStyleElementBase odfListLevelStyle = null;
    OdfTextListStyle style = getListStyle();
    int level = getListLevel();
    if (style != null) {
      odfListLevelStyle = style.getLevel(level);
    } else {
View Full Code Here

     *        a list level style with the given level and class
     */
    @SuppressWarnings("unchecked")
    public TextListLevelStyleElementBase getOrCreateListLevel( int level, Class clazz )
    {
        TextListLevelStyleElementBase levelStyle = getLevel( level );
        if( (levelStyle != null) && clazz.isInstance(levelStyle) ) {
            return levelStyle;
        }
       
        if( levelStyle != null ) {
            removeChild(levelStyle);
        }
       
        levelStyle = (TextListLevelStyleElementBase)
                        ((OdfFileDom)this.ownerDocument).newOdfElement(clazz);
        levelStyle.setTextLevelAttribute(level);
        appendChild(levelStyle);
       
        return levelStyle;
    }
View Full Code Here

    String cssLengthUnits;
    int displayLevels;

    OdfTextListLevelStyleNumber number;
    OdfTextListLevelStyleBullet bullet;
    TextListLevelStyleElementBase styleItem;

    this.setStyleNameAttribute(name);

    // split up the spacing into length and units
    m = cssLengthPattern.matcher(spacing);
    if (m.find())
    {
      try
      {
        cssLengthNum = Double.parseDouble(m.group(1));
      }
      catch (NumberFormatException oops)
      {
        cssLengthNum = 0.0;
      }
      cssLengthUnits = (m.group(2) == null) ? "" : m.group(2);
    }
    else
    {
      cssLengthNum = 0;
      cssLengthUnits = "";
    }


    for (int i = 0; i < Math.min(specArray.length, MAX_LIST_LEVEL); i++)
    {
      specArray[i] = specArray[i].trim();
      m = numFormatPattern.matcher( specArray[i] );
      if (m.find())  // if it has 1, I, i, A, or a, it's a numbering style
      {
        numberFormat = m.group(1);
        numPrefix = specArray[i].substring( 0, m.start(1) );
        numSuffix = specArray[i].substring( m.end(1) );
        displayLevels = (showAllLevels) ? (i+1) : 1;
        number = new OdfTextListLevelStyleNumber(
          (OdfFileDom)this.ownerDocument);
        number.setStyleNumPrefixAttribute(numPrefix);
        number.setStyleNumFormatAttribute(numberFormat);
        number.setStyleNumSuffixAttribute(numSuffix);
        number.setTextDisplayLevelsAttribute( displayLevels );
        styleItem = number;
      }
      else  // it's a bullet style
      {
        bullet = new OdfTextListLevelStyleBullet(
          (OdfFileDom)this.ownerDocument);
        bullet.setStyleNumPrefixAttribute("");
        bullet.setStyleNumSuffixAttribute("");
        if (!specArray[i].equals(""))
        {
          bullet.setTextBulletCharAttribute(specArray[i].substring(0,1));
        }
        else
        {
          bullet.setTextBulletCharAttribute("");
        }
        styleItem = bullet;
      }

      styleItem.setTextLevelAttribute(i+1);
      styleItem.setProperty(OdfListLevelProperties.SpaceBefore,
        Double.toString(cssLengthNum * (i+1)) + cssLengthUnits);
      styleItem.setProperty(OdfListLevelProperties.MinLabelWidth,
        Double.toString(cssLengthNum) + cssLengthUnits);
      this.appendChild(styleItem);

    }
  }
View Full Code Here

        OdfTextListStyle listStyle = styles.getListStyle(textStyleName);
        if (listStyle == null) {
          listStyle = documentStyles.getListStyle(textStyleName);
        }
        if (listStyle != null) {
          TextListLevelStyleElementBase listLevelStyle = listStyle.getLevel(1);
          if (listLevelStyle instanceof TextListLevelStyleBulletElement) {
            return ListType.BULLET;
          } else if (listLevelStyle instanceof TextListLevelStyleNumberElement) {
            return ListType.NUMBER;
          } else if (listLevelStyle instanceof TextListLevelStyleImageElement) {
View Full Code Here

  private void checkNodes(Node node, int position)
  {
    OdfTextListStyle theStyle;
    OdfTextListLevelStyleBullet bullet;
    OdfTextListLevelStyleNumber number;
    TextListLevelStyleElementBase base;

    int i = 0;
    theStyle = (OdfTextListStyle) node;
    Assert.assertTrue("Style name " +
      theStyle.getStyleNameAttribute() + " incorrect",
      theStyle.getStyleNameAttribute().equals("list" + position));
    node = node.getFirstChild();

    while (node != null)
    {
      Assert.assertTrue("More nodes than specifiers",
        i < levelType[position].length);
      String[] surround;
      if (prefixSuffix[position][i].equals("/"))
      {
        surround = new String[2];
        surround[0] = "";
        surround[1] = "";
      }
      else
      {
        surround = prefixSuffix[position][i].split("/");
      }
      if (levelType[position][i].equals("B"))
      {
        Assert.assertTrue("Class is not bullet",
          node instanceof OdfTextListLevelStyleBullet);
        bullet = (OdfTextListLevelStyleBullet) node;
        base = bullet;
        Assert.assertEquals("Prefix incorrect",
          surround[0], bullet.getStyleNumPrefixAttribute());
        Assert.assertEquals("Suffix incorrect", surround[1],
          bullet.getStyleNumSuffixAttribute());
      }
      else
      {
        Assert.assertTrue("Class is not number",
          node instanceof OdfTextListLevelStyleNumber);
        number = (OdfTextListLevelStyleNumber) node;
        Assert.assertEquals(formatChar[position][i],
          number.getStyleNumFormatAttribute());
        base = number;
        Assert.assertEquals("Prefix incorrect",
          surround[0], number.getStyleNumPrefixAttribute());
        Assert.assertEquals("Suffix incorrect", surround[1],
          number.getStyleNumSuffixAttribute());
      }
      Assert.assertEquals("Level incorrect",
        i+1, base.getTextLevelAttribute().intValue());

      checkNumber(
        "SpaceBefore",
        base.getProperty(OdfListLevelProperties.SpaceBefore),
        i+1);

      checkNumber(
        "MinLabelWidth",
        base.getProperty(OdfListLevelProperties.MinLabelWidth),
        1.0);

      node = node.getNextSibling();
      i++;
    }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.text.TextListLevelStyleElementBase

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.