public static CTBorder apply(CTBorder source, CTBorder destination) { if (!isEmpty(source)) { if (destination == null) destination = Context.getWmlObjectFactory().createCTBorder(); destination.setColor(apply(source.getColor(), destination.getColor())); destination.setSpace(apply(source.getSpace(), destination.getSpace())); destination.setSz(apply(source.getSz(), destination.getSz())); destination.setThemeColor(source.getThemeColor()); destination.setThemeShade(apply(source.getThemeShade(), destination.getThemeShade())); destination.setThemeTint(apply(source.getThemeTint(), destination.getThemeTint())); destination.setVal(apply(source.getVal(), destination.getVal())); } return destination; }
public static boolean areEqual(CTBorder border1, CTBorder border2) { return ((border1 == border2) || ((border1 != null) && (border2 != null) && areEqual(border1.getColor(), border2.getColor()) && areEqual(border1.getSpace(), border2.getSpace()) && areEqual(border1.getSz(), border2.getSz()) && areEqual(border1.getThemeColor(), border2.getThemeColor()) && areEqual(border1.getThemeShade(), border2.getThemeShade()) && areEqual(border1.getThemeTint(), border2.getThemeTint()) && ((border1.getVal() == border2.getVal()) || ((border1.getVal() != null) && (border1.getVal().equals(border2.getVal())))) ) ); }
if (border.getVal()!=null) { STBorder stBorder = border.getVal(); if (border.getSz()!=null) { float mm = eighthsToMM(border.getSz().intValue()); // eights of a point foElement.setAttribute(CSS_NAME__WIDTH, UnitsOfMeasurement.format2DP.format(mm) + "mm" ); if (border.getColor()!=null) { if (border.getColor().equals("auto")) { foElement.setAttribute(CSS_NAME__COLOR, "#000000" ); } else { foElement.setAttribute(CSS_NAME__COLOR, "#" + border.getColor() );
public CTBorder keepDiff(CTBorder orig, CTBorder from) { if (from != null && orig != null) { if (orig.getVal() != null && from.getVal() != null && from.getVal() != null && orig.getVal().compareTo(from.getVal()) == 0) orig.setVal(null); if (orig.getThemeColor() != null && from.getThemeColor() != null && orig.getThemeColor().compareTo(from.getThemeColor()) == 0) orig.setThemeColor(null); if (orig.getSpace() != null && from.getSpace() != null && orig.getSpace().compareTo(from.getSpace()) == 0) orig.setSpace(null); if (orig.getSz() != null && from.getSz() != null && orig.getSz().compareTo(from.getSz()) == 0) orig.setSz(null); if (orig.getColor() != null && from.getColor() != null && orig.getColor().compareTo(from.getColor()) == 0) orig.setColor(null); if (orig.getThemeShade() != null && from.getThemeShade() != null && orig.getThemeShade().compareTo(from.getThemeShade()) == 0) orig.setThemeShade(null); if (orig.getThemeTint() != null && from.getThemeTint() != null && orig.getThemeTint().compareTo(from.getThemeTint()) == 0) orig.setThemeTint(null); if (orig.isFrame() == from.isFrame()) orig.setFrame(null); if (orig.isShadow() == from.isShadow()) orig.setShadow(null); } return StyleUtil.isEmpty(orig) ? null : orig; }
border.setVal(org.docx4j.wml.STBorder.SINGLE); border.setSz(BigInteger.valueOf(2)); border.setColor("000001"); border.setSpace(BigInteger.valueOf(0)); border2.setVal(org.docx4j.wml.STBorder.SINGLE); border2.setSz(BigInteger.valueOf(2)); border2.setColor("000001"); border2.setSpace(BigInteger.valueOf(0)); border3.setVal(org.docx4j.wml.STBorder.SINGLE); border3.setSz(BigInteger.valueOf(2)); border3.setColor("000001"); border3.setSpace(BigInteger.valueOf(0)); border4.setVal(org.docx4j.wml.STBorder.SINGLE); border4.setSz(BigInteger.valueOf(2)); border4.setColor("000001"); border4.setSpace(BigInteger.valueOf(0)); border5.setVal(org.docx4j.wml.STBorder.SINGLE); border5.setSz(BigInteger.valueOf(2)); border5.setColor("000001"); border5.setSpace(BigInteger.valueOf(0)); border6.setVal(org.docx4j.wml.STBorder.SINGLE); border6.setSz(BigInteger.valueOf(2)); border6.setColor("000001"); border6.setSpace(BigInteger.valueOf(0));
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)); 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));
private static boolean borderChanged(CTBorder currentBorder, CTBorder lastBorder) { if (currentBorder != lastBorder) { if ((currentBorder != null) && (lastBorder != null)) { return !currentBorder.getVal().equals(lastBorder.getVal()); } //one was null return true; } //both null or both identical return false; }
protected void appendNoneBordersAndShading(List<Property> tableProperties) { CTBorder ctBrdr = null; CTShd shd = Context.getWmlObjectFactory().createCTShd(); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderLeft(ctBrdr)); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderRight(ctBrdr)); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderTop(ctBrdr)); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderBottom(ctBrdr)); shd.setColor("auto"); shd.setFill("auto"); shd.setVal(STShd.CLEAR); tableProperties.add(new Shading(shd)); }
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. }
@Override public void adjustPPrForFormatting(PPr pPr) { // here we need to adjust for inherited left margin final BigInteger newLeftInd = myDocx.getHelper().safeIndLeft(pPr); final PPr styledPPr = myDocx.getHelper().getExplicitPPr(pPr); if (styledPPr != null && styledPPr.getPBdr() != null && newLeftInd != null && newLeftInd.compareTo(myLeftInd) > 0) { // it grew, word has the border hanging and we want the we shift it by our left border spacing CTBorder leftBorder = styledPPr.getPBdr().getLeft(); if (leftBorder != null && leftBorder.getSpace() != null && leftBorder.getSpace().compareTo(BigInteger.ZERO) > 0) { //pPr.getInd().setLeft(newLeftInd.add(leftBorder.getSpace().multiply(BigInteger.valueOf(20)))); final T currentNode = myDocx.getContextFrame(); if (currentNode instanceof Paragraph) { int tmp = 0; } } } } }
public CTBorder getCopy(CTBorder copy, boolean whenNull) { if (copy != null) { CTBorder result = myFactory.createCTBorder(); result.setVal(copy.getVal()); result.setThemeColor(copy.getThemeColor()); result.setSpace(copy.getSpace()); result.setSz(copy.getSz()); result.setFrame(copy.isFrame()); result.setShadow(copy.isShadow()); result.setColor(copy.getColor()); result.setThemeShade(copy.getThemeShade()); result.setThemeTint(copy.getThemeTint()); return result; } if (whenNull) { return myFactory.createCTBorder(); } return null; }
public static boolean isEmpty(CTBorder border) { return ((border == null) || (isEmpty(border.getColor()) && isEmpty(border.getSpace()) && isEmpty(border.getSz()) && (border.getThemeColor() == null) && isEmpty(border.getThemeShade()) && isEmpty(border.getThemeTint()) && (border.getVal() == null) ) ); }
if (border.getVal()!=null) { STBorder stBorder = border.getVal(); if (border.getSz()!=null) { float pt = border.getSz().intValue() / 8f; // eights of a point foElement.setAttribute(CSS_NAME__WIDTH, UnitsOfMeasurement.format2DP.format(pt) + "pt" ); if (border.getColor()!=null) { if (border.getColor().equals("auto")) { foElement.setAttribute(CSS_NAME__COLOR, "#000000" ); } else { foElement.setAttribute(CSS_NAME__COLOR, "#" + border.getColor() );
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)); 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));
private static boolean borderChanged(CTBorder currentBorder, CTBorder lastBorder) { if (currentBorder != lastBorder) { if ((currentBorder != null) && (lastBorder != null)) { return !currentBorder.getVal().equals(lastBorder.getVal()); } //one was null return true; } //both null or both identical return false; }
protected void appendNoneBordersAndShading(List<Property> tableProperties) { CTBorder ctBrdr = null; CTShd shd = Context.getWmlObjectFactory().createCTShd(); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderLeft(ctBrdr)); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderRight(ctBrdr)); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderTop(ctBrdr)); ctBrdr = Context.getWmlObjectFactory().createCTBorder(); ctBrdr.setVal(STBorder.NONE); tableProperties.add(new BorderBottom(ctBrdr)); shd.setColor("auto"); shd.setFill("auto"); shd.setVal(STShd.CLEAR); tableProperties.add(new Shading(shd)); }
public static CTBorder apply(CTBorder source, CTBorder destination) { if (!isEmpty(source)) { if (destination == null) destination = Context.getWmlObjectFactory().createCTBorder(); destination.setColor(apply(source.getColor(), destination.getColor())); destination.setSpace(apply(source.getSpace(), destination.getSpace())); destination.setSz(apply(source.getSz(), destination.getSz())); destination.setThemeColor(source.getThemeColor()); destination.setThemeShade(apply(source.getThemeShade(), destination.getThemeShade())); destination.setThemeTint(apply(source.getThemeTint(), destination.getThemeTint())); destination.setVal(apply(source.getVal(), destination.getVal())); } return destination; }