Example #1
0
  /** @param context */
  public void calculateRow(TableInfoContext context) {
    this._rowIndex = context.getCurrentRow();

    List children = getFigure().getChildren();
    for (int i = 0, size = children.size(); i < size; i++) {
      IFigure childfigure = (IFigure) children.get(i);
      if (childfigure instanceof ICSSFigure) {
        ICSSStyle childstyle = ((ICSSFigure) childfigure).getCSSStyle();
        if (childstyle != null) {
          String display = childstyle.getDisplay();
          if ("table-cell".equalsIgnoreCase(display)) { // $NON-NLS-1$
            TableCellInfo cellInfo = new TableCellInfo((ICSSFigure) childfigure);
            cellInfo.calculateCellInfo(context);
            _cells.add(cellInfo);
          } else {
            // skip
          }
        }
      } else {
        // skip
      }
    }
    // ok, we have finished a row
    context.finishRow();
  }
Example #2
0
  public ICSSFont createFont(ICSSStyle style) {
    String fontfamily = (String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_FAMILY);
    Object fontsizeobj = style.getStyleProperty(ICSSPropertyID.ATTR_FONT_SIZE);
    int fontsize;
    fontsize = getFontSize(style, fontsizeobj);
    int fontstyle = getFontStyle(style);
    int fontweight = ((Integer) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_WEIGHT)).intValue();

    return new CSSFont(fontfamily, fontsize, fontstyle, fontweight, resolveFontStyleString(style));
  }
Example #3
0
 /**
  * @param node
  * @return true if is list item
  */
 public static boolean isListItem(Node node) {
   if (node instanceof INodeNotifier) {
     Object adapter = ((INodeNotifier) node).getAdapterFor(ICSSStyle.class);
     if (adapter != null) {
       ICSSStyle style = (ICSSStyle) adapter;
       String display = style.getDisplay();
       return (display.equalsIgnoreCase(ICSSPropertyID.VAL_LIST_ITEM));
     }
   }
   return false;
 }
Example #4
0
 /**
  * @param node
  * @return true if is table cell
  */
 static boolean isTableCell(Node node) {
   if (node instanceof INodeNotifier) {
     Object adapter = ((INodeNotifier) node).getAdapterFor(ICSSStyle.class);
     if (adapter != null) {
       ICSSStyle style = (ICSSStyle) adapter;
       String display = style.getDisplay();
       return display.equalsIgnoreCase(ICSSPropertyID.VAL_TABLE_CELL);
     }
   }
   return false;
 }
Example #5
0
 private int getFontSize(ICSSStyle style, Object fontsizeobj) {
   int fontsize;
   if (fontsizeobj instanceof Length) {
     fontsize = ((Length) fontsizeobj).getValue();
   } else {
     fontsize = style.getParentStyle().getCSSFont().getFontSize();
   }
   return fontsize;
 }
Example #6
0
 private String resolveFontStyleString(ICSSStyle style) {
   StringBuffer sb = new StringBuffer();
   sb.append(ICSSPropertyID.ATTR_FONT_FAMILY).append(":"); // $NON-NLS-1$
   sb.append("'")
       .append( //$NON-NLS-1$
           (String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_FAMILY))
       .append("'"); // $NON-NLS-1$
   sb.append(";"); // $NON-NLS-1$
   sb.append(ICSSPropertyID.ATTR_FONT_STYLE).append(":"); // $NON-NLS-1$
   sb.append((String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_STYLE))
       .append(";"); // $NON-NLS-1$
   sb.append(ICSSPropertyID.ATTR_FONT_WEIGHT).append(":"); // $NON-NLS-1$
   sb.append(((Integer) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_WEIGHT)).toString())
       .append(";"); // $NON-NLS-1$
   sb.append(ICSSPropertyID.ATTR_FONT_SIZE).append(":"); // $NON-NLS-1$
   int fontSize = getFontSize(style, style.getStyleProperty(ICSSPropertyID.ATTR_FONT_SIZE));
   sb.append(Integer.toString(fontSize));
   return sb.toString();
 }
Example #7
0
 /** @param style */
 private int getFontStyle(ICSSStyle style) {
   int fontstyle;
   String fontstylestr = (String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_STYLE);
   if (ICSSPropertyID.VAL_ITALIC.equals(fontstylestr)
       || ICSSPropertyID.VAL_OBLIQUE.equals(fontstylestr)) {
     fontstyle = SWT.ITALIC;
   } else {
     fontstyle = SWT.NORMAL;
   }
   return fontstyle;
 }
Example #8
0
 /**
  * To see if a node's display type is inline.
  *
  * @param refNode
  * @return true if is inline
  */
 public static boolean isInline(Node refNode) {
   Node node = refNode;
   EditPart part = Target.resolvePart(node);
   if (part instanceof ElementEditPart) {
     node = ((ElementEditPart) part).getTagConvert().getResultElement();
   }
   if (isText(node)) {
     return true;
   } else if (node instanceof INodeNotifier) {
     Object adapter = ((INodeNotifier) node).getAdapterFor(ICSSStyle.class);
     if (adapter != null) {
       ICSSStyle style = (ICSSStyle) adapter;
       String display = style.getDisplay();
       return (display.equalsIgnoreCase(ICSSPropertyID.VAL_INLINE)
           || //
           display.equalsIgnoreCase(ICSSPropertyID.VAL_INLINE_TABLE)
           || //
           display.equalsIgnoreCase(ICSSPropertyID.VAL_COMPACT)
           || //
           display.equalsIgnoreCase(ICSSPropertyID.VAL_RUN_IN));
     }
   }
   return false;
 }
Example #9
0
  /**
   * @param info
   * @param tableHeight
   */
  public void calculateHeight(TableInfo info, int tableHeight) {
    ICSSStyle style = this.getFigure().getCSSStyle();
    if (style == null) {
      this._rowHeight = -1;
    } else {
      Object height = style.getStyleProperty(ICSSPropertyID.ATTR_HEIGHT);
      Length recommendedHeight = (height instanceof Length) ? (Length) height : null;

      int rh = 0;
      if (recommendedHeight == null || recommendedHeight.getValue() <= 0) {
        rh = 0;
      } else {
        if (recommendedHeight.isPercentage()) {
          // not supported.
        } else {
          rh = recommendedHeight.getValue();
        }
        if (rh > 0 && !style.isSizeIncludeBorderPadding()) {
          rh += style.getBorderInsets().getHeight() + style.getPaddingInsets().getHeight();
        }
      }
      this._rowHeight = rh;
    }
  }