org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd Java Examples
The following examples show how to use
org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StyleUtils.java From poi-tl with Apache License 2.0 | 6 votes |
public static void styleTable(XWPFTable table, TableStyle style) { if (null == table || null == style) return; CTTblPr tblPr = table.getCTTbl().getTblPr(); if (null == tblPr) { tblPr = table.getCTTbl().addNewTblPr(); } if (null != style.getAlign()) { CTJc jc = tblPr.isSetJc() ? tblPr.getJc() : tblPr.addNewJc(); jc.setVal(style.getAlign()); } if (StringUtils.isNotBlank(style.getBackgroundColor())) { CTShd ctshd = tblPr.isSetShd() ? tblPr.getShd() : tblPr.addNewShd(); ctshd.setColor("auto"); ctshd.setVal(STShd.CLEAR); ctshd.setFill(style.getBackgroundColor()); } }
Example #2
Source File: M2DocEvaluator.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
/** * Apply the given style to the given run. Background color is not taken into account here since it does not apply to runs. * * @param run * The run to style * @param style * The style to apply, can be <code>null</code> */ private void applyMStyle(XWPFRun run, MStyle style) { if (style.getFontSize() != -1) { run.setFontSize(style.getFontSize()); } if (style.getFontName() != null) { run.setFontFamily(style.getFontName()); } if (style.getFontModifiers() != -1) { run.setBold((style.getFontModifiers() & MStyle.FONT_BOLD) != 0); run.setItalic((style.getFontModifiers() & MStyle.FONT_ITALIC) != 0); if ((style.getFontModifiers() & MStyle.FONT_UNDERLINE) != 0) { run.setUnderline(UnderlinePatterns.SINGLE); } run.setStrikeThrough((style.getFontModifiers() & MStyle.FONT_STRIKE_THROUGH) != 0); } if (style.getForegroundColor() != null) { run.setColor(hexColor(style.getForegroundColor())); } if (style.getBackgroundColor() != null) { final CTRPr ctrpr; if (run.getCTR().getRPr() != null) { ctrpr = run.getCTR().getRPr(); } else { ctrpr = run.getCTR().addNewRPr(); } final CTShd ctshd; if (ctrpr.getShd() != null) { ctshd = ctrpr.getShd(); } else { ctshd = ctrpr.addNewShd(); } ctshd.setVal(STShd.CLEAR); ctshd.setColor("auto"); ctshd.setFill(hexColor(style.getBackgroundColor())); } }