/** * Get table cell margins from table style. * <br>Parameter tableStyle can be null - 0 will be returned. * @return left margin plus right margin (twips) */ private long getTblCellMargins(String tableStyle) { Style s = null; if(tableStyle != null && !tableStyle.isEmpty()) { s = importer.getStyleByIdOrName(tableStyle); } if(s != null && importer.getTableHelper().isTableStyle(s)) { CTTblCellMar cellMar = getTblCellMar(s); if(cellMar == null) { //try "based on" style CTTblCellMar bsCellMar = getBasedOnTblCellMar(s); if(bsCellMar != null) { return getLeftPlusRightMarginsValue(bsCellMar); } } else { return getLeftPlusRightMarginsValue(cellMar); } } return 0; }
/** * Get cell margins from "based on" style. * <br>Search recursively while possible. */ private CTTblCellMar getBasedOnTblCellMar(Style s) { BasedOn bo = s.getBasedOn(); if(bo != null) { String basedOn = bo.getVal(); if(basedOn != null && !basedOn.isEmpty()) { Style bs = importer.getStyleByIdOrName(basedOn); if(bs != null) { CTTblCellMar bsCellMar = getTblCellMar(bs); if(bsCellMar != null) { return bsCellMar; } else { return getBasedOnTblCellMar(bs); } } } } return null; }
oldMaxWidth = ((XHTMLImageHandlerDefault)xHTMLImageHandler).getMaxWidth(); if (!box.getStyle().isMaxWidthNone()) { .setMaxWidth( (int) dotsToTwip(maxWidth)); ((XHTMLImageHandlerDefault)xHTMLImageHandler).setMaxWidth(oldMaxWidth);
log.debug("image maxWidth:" + maxWidth + ", table style: " + tableStyle); System.out.println("image maxWidth:" + maxWidth); long excessWidth = getTblCellMargins(tableStyle); if(excessWidth > 0) { log.debug("table style margins subtracted (twips): " + excessWidth);