private void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);

    TblBorders borders = new TblBorders();
    borders.setBottom(border);
    borders.setLeft(border);
    borders.setRight(border);
    borders.setTop(border);
    borders.setInsideH(border);
    borders.setInsideV(border);
    table.getTblPr().setTblBorders(borders);
  }
Пример #2
0
  protected void createCellProperties(List<Property> properties, CTTblPrBase tblPr) {
    TblBorders tblBorders = tblPr.getTblBorders();
    CTTblCellMar tblCellMargin = tblPr.getTblCellMar();
    if (tblBorders != null) {
      if (tblBorders.getInsideH() != null) {
        properties.add(new BorderTop(tblBorders.getTop()));
        properties.add(new BorderBottom(tblBorders.getBottom()));
      }
      if (tblBorders.getInsideV() != null) {
        properties.add(new BorderRight(tblBorders.getRight()));
        properties.add(new BorderLeft(tblBorders.getLeft()));
      }
    }

    if (tblCellMargin != null) {
      if (tblCellMargin.getTop() != null) properties.add(new CellMarginTop(tblCellMargin.getTop()));
      if (tblCellMargin.getBottom() != null)
        properties.add(new CellMarginBottom(tblCellMargin.getBottom()));
      if (tblCellMargin.getLeft() != null)
        properties.add(new CellMarginLeft(tblCellMargin.getLeft()));
      if (tblCellMargin.getRight() != null)
        properties.add(new CellMarginRight(tblCellMargin.getRight()));
    }
  }
Пример #3
0
  public static String getCssForTableCells(HTMLConversionContext context, Tbl tbl, int idx) {

    StringBuffer result = new StringBuffer();
    PropertyResolver pr = context.getPropertyResolver();
    Style s = pr.getEffectiveTableStyle(tbl.getTblPr());

    result.append("#" + TableWriter.getId(idx) + " td { ");
    List<Property> properties = new ArrayList<Property>();
    if (s.getTblPr() != null && s.getTblPr().getTblBorders() != null) {
      TblBorders tblBorders = s.getTblPr().getTblBorders();
      if (tblBorders.getInsideH() != null) {
        if (tblBorders.getInsideH().getVal() == STBorder.NONE
            || tblBorders.getInsideH().getVal() == STBorder.NIL
            || tblBorders.getInsideH().getSz() == BigInteger.ZERO) {
          properties.add(new AdHocProperty("border-top-style", "none", null, null));
          properties.add(new AdHocProperty("border-top-width", "0mm", null, null));
          properties.add(new AdHocProperty("border-bottom-style", "none", null, null));
          properties.add(new AdHocProperty("border-bottom-width", "0mm", null, null));
        } else {
          properties.add(new BorderTop(tblBorders.getTop()));
          properties.add(new BorderBottom(tblBorders.getBottom()));
        }
      }
      if (tblBorders.getInsideV() != null) {
        if (tblBorders.getInsideV().getVal() == STBorder.NONE
            || tblBorders.getInsideV().getVal() == STBorder.NIL
            || tblBorders.getInsideV().getSz() == BigInteger.ZERO) {
          properties.add(new AdHocProperty("border-left-style", "none", null, null));
          properties.add(new AdHocProperty("border-left-width", "0mm", null, null));
          properties.add(new AdHocProperty("border-right-style", "none", null, null));
          properties.add(new AdHocProperty("border-right-width", "0mm", null, null));
        } else {
          properties.add(new BorderRight(tblBorders.getRight()));
          properties.add(new BorderLeft(tblBorders.getLeft()));
        }
      }
    }
    if (s.getTcPr() != null) {
      PropertyFactory.createProperties(properties, s.getTcPr());
    }
    // Ensure empty cells have a sensible height
    // TODO - this is no good with IE8, which doesn't treat this
    // as a minimum; it won't resize if there is more :-(
    properties.add(new AdHocProperty("height", "5mm", null, null));

    for (Property p : properties) {
      if (p != null) {
        result.append(p.getCssProperty());
      }
    }
    result.append("}\n");
    return result.toString();
  }