protected void doSide(PPr pPr, Styleable styleable, Map<String, CSSValue> cssMap, String side) { CTBorder border = null; CSSValue borderStyle = cssMap.get("border-"+side+"-style"); if (borderStyle!=null && !"none".equals(borderStyle.getCssText())) { // paragraph has a border border = createBorderStyle( styleable, side); setBorder( pPr, side, border ); } // padding to space BigInteger spaceAttrVal = paddingToSpace(styleable, side); if (spaceAttrVal!=null) { border = getBorder( pPr, side); border.setSpace(spaceAttrVal); } // NB: Word 2010 doesn't seem to honour this when its in a table cell! // and there doesn't seem to be a compat setting which should affect this. }
ParagraphBorderHelper pbh = new ParagraphBorderHelper(this); pbh.addBorderProperties(pPr, styleable, cssMap);
private void setBorder(PPr pPr, String side, CTBorder border ) { pBdr = createPBdr(pPr); if (side.equals("left")) { pBdr.setLeft(border); } else if (side.equals("right")) { pBdr.setRight(border); } else if (side.equals("top")) { pBdr.setTop(border); } else if (side.equals("bottom")) { pBdr.setBottom(border); } }
/** * borders support * @param box table or cell to copy css border properties from * @param side "top"/"bottom"/"left"/"right" * @return border style */ private CTBorder createBorderStyle(Styleable styleable, String side) { FSDerivedValue borderStyle = styleable.getStyle().valueByName( CSSName.getByPropertyName("border-"+side+"-style") ); FSDerivedValue borderColor = styleable.getStyle().valueByName( CSSName.getByPropertyName("border-"+side+"-color") ); float width = styleable.getStyle().getFloatPropertyProportionalHeight( CSSName.getByPropertyName("border-"+side+"-width"), 0, importer.getRenderer().getLayoutContext() ); STBorder stBorder; try { stBorder = STBorder.fromValue( borderStyle.asString() ); } catch (IllegalArgumentException e) { stBorder = STBorder.SINGLE; } // w:ST_EighthPointMeasure - Measurement in Eighths of a Point width = UnitsOfMeasurement.twipToPoint( Math.round(width) ) * 8.0f; String color = borderColor.asString(); if (color.startsWith("#")) color=color.substring(1); return createBorderStyle( stBorder, color, BigInteger.valueOf( Math.round(width) ) ); }
private CTBorder getBorder(PPr pPr, String side) { pBdr = createPBdr(pPr); CTBorder border = null; if (side.equals("left")) { border = pBdr.getLeft(); } else if (side.equals("right")) { border = pBdr.getRight(); } else if (side.equals("top")) { border = pBdr.getTop(); } else if (side.equals("bottom")) { border = pBdr.getBottom(); } if (border==null) { border = Context.getWmlObjectFactory().createCTBorder(); if (side.equals("left")) { pBdr.setLeft(border); } else if (side.equals("right")) { pBdr.setRight(border); } else if (side.equals("top")) { pBdr.setTop(border); } else if (side.equals("bottom")) { pBdr.setBottom(border); } } return border; }