Esempio n. 1
0
  /**
   * Resolve original style for Sheet.
   *
   * @param fods
   * @param table
   * @return Style display name.
   */
  public static String getTopParentStyleName(Workbook fods, Sheet table) {
    String result = table.getStyleName();

    if (result == null) {
      return null;
    }

    // Look for automatic style
    for (AutomaticStyle s : fods.getAutomaticStyles()) {
      if (s.getName().equals(result)) {
        result = s.getMasterPageName();
        break;
      }
    }

    // Next style should be a master style
    for (Style s : fods.getMasterStyles()) {
      if (s.getName().equals(result)) {
        result = s.getDisplayName();
        break;
      }
    }

    return result;
  }
Esempio n. 2
0
  /**
   * Resolve original style for Cell.
   *
   * @param fods
   * @param cell
   * @return Style display name.
   */
  public static String getTopParentStyleName(Workbook fods, Cell cell) {
    String result = cell.getStyle();

    if (result == null) {
      return null;
    }

    // Look for automatic style
    for (AutomaticStyle s : fods.getAutomaticStyles()) {
      if (s.getName().equals(result)) {
        result = s.getParentName();
        break;
      }
    }

    // Next style should be a standard style
    for (Style s : fods.getStyles()) {
      if (s.getName().equals(result)) {
        result = s.getDisplayName();
        break;
      }
    }

    return result;
  }
Esempio n. 3
0
  protected void copy(EditorConfiguration src, EditorConfiguration dst) {
    dst.title = src.title;
    dst.mimeType = src.mimeType;
    Enumeration styleNames = src.styleContext.getStyleNames();
    if (src.styleContext == dst.styleContext) dst.styleContext = new StyleContext();
    while (styleNames.hasMoreElements()) {
      String sname = (String) styleNames.nextElement();
      Style style = src.styleContext.getStyle(sname);

      Style newStyle = dst.styleContext.addStyle(sname, null);
      newStyle.addAttributes(style.copyAttributes());
    }

    styleNames = dst.styleContext.getStyleNames();
    while (styleNames.hasMoreElements()) {
      String sname = (String) styleNames.nextElement();
      Style style = src.styleContext.getStyle(sname);
      AttributeSet resolveParent = style.getResolveParent();
      Style parent = (Style) resolveParent;

      if (parent != null) {
        dst.styleContext
            .getStyle(sname)
            .setResolveParent(dst.styleContext.getStyle(parent.getName()));
      }
    }
  }
Esempio n. 4
0
 /**
  * sets a list of style that can be used form rendering the layer.
  *
  * @param styles
  */
 public void setStyles(Style[] styles) {
   if (styles == null) {
     this.styles.clear();
   } else {
     for (Style style : styles) {
       this.styles.put(style.getName(), style);
     }
   }
 }
Esempio n. 5
0
  /** @return a list of style that can be used form rendering the layer. */
  public Style[] getStyles() {
    HashMap<String, Style> list = new HashMap<String, Style>();

    if (parent != null) {
      Style[] pStyle = parent.getStyles();

      for (int i = 0; i < pStyle.length; i++) {
        list.put(pStyle[i].getName(), pStyle[i]);
      }
    }

    for (Style style : styles.values()) {
      if (list.get(style.getName()) == null) {
        list.put(style.getName(), style);
      }
    }

    return list.values().toArray(new Style[list.size()]);
  }
Esempio n. 6
0
 /**
  * adds a list of style that can be used form rendering the layer.
  *
  * @param style
  */
 public void addStyles(Style style) {
   this.styles.put(style.getName(), style);
 }