/** * Set the table style. If the style is not defined in the document, MS Word * will set the table style to "Normal". * * @param styleName - the style name to apply to this table */ public void setStyleID(String styleName) { CTTblPr tblPr = getTblPr(); CTString styleStr = tblPr.getTblStyle(); if (styleStr == null) { styleStr = tblPr.addNewTblStyle(); } styleStr.setVal(styleName); }
/** * Set the style ID for the paragraph * * @param styleId ID (not name) of the style to set for the paragraph, e.g. "Heading1" (not "Heading 1"). */ public void setStyle(String styleId) { CTPPr pr = getCTPPr(); CTString style = pr.getPStyle() != null ? pr.getPStyle() : pr.addNewPStyle(); style.setVal(styleId); }
ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewFootnoteRef();
/** * Set the style ID for the run. * * @param styleId ID (not name) of the style to set for the run, e.g. "BoldItalic" (not "Bold Italic"). */ public void setStyle(String styleId) { CTRPr pr = getCTR().getRPr(); if (null == pr) { pr = getCTR().addNewRPr(); } CTString style = pr.getRStyle() != null ? pr.getRStyle() : pr.addNewRStyle(); style.setVal(styleId); }
ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewEndnoteRef();
public TOC(CTSdtBlock block) { this.block = block; CTSdtPr sdtPr = block.addNewSdtPr(); CTDecimalNumber id = sdtPr.addNewId(); id.setVal(new BigInteger("4844945")); sdtPr.addNewDocPartObj().addNewDocPartGallery().setVal("Table of contents"); CTSdtEndPr sdtEndPr = block.addNewSdtEndPr(); CTRPr rPr = sdtEndPr.addNewRPr(); CTFonts fonts = rPr.addNewRFonts(); fonts.setAsciiTheme(STTheme.MINOR_H_ANSI); fonts.setEastAsiaTheme(STTheme.MINOR_H_ANSI); fonts.setHAnsiTheme(STTheme.MINOR_H_ANSI); fonts.setCstheme(STTheme.MINOR_BIDI); rPr.addNewB().setVal(STOnOff.OFF); rPr.addNewBCs().setVal(STOnOff.OFF); rPr.addNewColor().setVal("auto"); rPr.addNewSz().setVal(new BigInteger("24")); rPr.addNewSzCs().setVal(new BigInteger("24")); CTSdtContentBlock content = block.addNewSdtContent(); CTP p = content.addNewP(); p.setRsidR("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); p.setRsidRDefault("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); p.addNewPPr().addNewPStyle().setVal("TOCHeading"); p.addNewR().addNewT().setStringValue("Table of Contents"); }
/** * Add a new run with a reference to the specified footnote. * The footnote reference run will have the style name "FootnoteReference". * * @param footnote Footnote to which to add a reference. * @since 4.0.0 */ public void addFootnoteReference(XWPFAbstractFootnoteEndnote footnote) { XWPFRun run = createRun(); CTR ctRun = run.getCTR(); ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference"); if (footnote instanceof XWPFEndnote) { ctRun.addNewEndnoteReference().setId(footnote.getId()); } else { ctRun.addNewFootnoteReference().setId(footnote.getId()); } } }
p.setRsidRDefault("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); CTPPr pPr = p.addNewPPr(); pPr.addNewPStyle().setVal("TOC" + level); CTTabs tabs = pPr.addNewTabs(); CTTabStop tab = tabs.addNewTab();
p.setRsidRDefault(rsidrdefault); CTPPr pPr = p.addNewPPr(); pPr.addNewPStyle().setVal("Header");
/** * 重复样式 * * @param destRun 新建的run * @param srcRun 原始run */ public static void styleRun(XWPFRun destRun, XWPFRun srcRun) { if (null == destRun || null == srcRun) return; CTR ctr = srcRun.getCTR(); if (ctr.isSetRPr() && ctr.getRPr().isSetRStyle()){ String val = ctr.getRPr().getRStyle().getVal(); if (StringUtils.isNotBlank(val)) { CTRPr pr = destRun.getCTR().isSetRPr() ? destRun.getCTR().getRPr() : destRun.getCTR().addNewRPr(); CTString rStyle = pr.isSetRStyle() ? pr.getRStyle() : pr.addNewRStyle(); rStyle.setVal(val); } } if (Boolean.TRUE.equals(srcRun.isBold())) destRun.setBold(srcRun.isBold()); destRun.setColor(srcRun.getColor()); // destRun.setCharacterSpacing(srcRun.getCharacterSpacing()); if (StringUtils.isNotBlank(srcRun.getFontFamily())) destRun.setFontFamily(srcRun.getFontFamily()); int fontSize = srcRun.getFontSize(); if (-1 != fontSize) destRun.setFontSize(fontSize); if (Boolean.TRUE.equals(srcRun.isItalic())) destRun.setItalic(srcRun.isItalic()); if (Boolean.TRUE.equals(srcRun.isStrikeThrough())) destRun.setStrikeThrough(srcRun.isStrikeThrough()); destRun.setUnderline(srcRun.getUnderline()); }
/** * Set the table style. If the style is not defined in the document, MS Word * will set the table style to "Normal". * @param styleName - the style name to apply to this table */ public void setStyleID(String styleName) { CTTblPr tblPr = getTrPr(); CTString styleStr = tblPr.getTblStyle(); if (styleStr == null) { styleStr = tblPr.addNewTblStyle(); } styleStr.setVal(styleName); }
/** * Set the table style. If the style is not defined in the document, MS Word * will set the table style to "Normal". * * @param styleName - the style name to apply to this table */ public void setStyleID(String styleName) { CTTblPr tblPr = getTblPr(); CTString styleStr = tblPr.getTblStyle(); if (styleStr == null) { styleStr = tblPr.addNewTblStyle(); } styleStr.setVal(styleName); }
/** * Set the style ID for the paragraph * * @param styleId ID (not name) of the style to set for the paragraph, e.g. "Heading1" (not "Heading 1"). */ public void setStyle(String styleId) { CTPPr pr = getCTPPr(); CTString style = pr.getPStyle() != null ? pr.getPStyle() : pr.addNewPStyle(); style.setVal(styleId); }
/** * This method provides a style to the paragraph * This is useful when, e.g. an Heading style has to be assigned * @param newStyle */ public void setStyle(String newStyle) { CTPPr pr = getCTPPr(); CTString style = pr.getPStyle() != null ? pr.getPStyle() : pr.addNewPStyle(); style.setVal(newStyle); }
/** * Set the style ID for the run. * * @param styleId ID (not name) of the style to set for the run, e.g. "BoldItalic" (not "Bold Italic"). */ public void setStyle(String styleId) { CTRPr pr = getCTR().getRPr(); if (null == pr) { pr = getCTR().addNewRPr(); } CTString style = pr.getRStyle() != null ? pr.getRStyle() : pr.addNewRStyle(); style.setVal(styleId); }
styleName.setVal(strStyleId); ctStyle.setName(styleName);
public TOC(CTSdtBlock block) { this.block = block; CTSdtPr sdtPr = block.addNewSdtPr(); CTDecimalNumber id = sdtPr.addNewId(); id.setVal(new BigInteger("4844945")); sdtPr.addNewDocPartObj().addNewDocPartGallery().setVal("Table of contents"); CTSdtEndPr sdtEndPr = block.addNewSdtEndPr(); CTRPr rPr = sdtEndPr.addNewRPr(); CTFonts fonts = rPr.addNewRFonts(); fonts.setAsciiTheme(STTheme.MINOR_H_ANSI); fonts.setEastAsiaTheme(STTheme.MINOR_H_ANSI); fonts.setHAnsiTheme(STTheme.MINOR_H_ANSI); fonts.setCstheme(STTheme.MINOR_BIDI); rPr.addNewB().setVal(STOnOff.OFF); rPr.addNewBCs().setVal(STOnOff.OFF); rPr.addNewColor().setVal("auto"); rPr.addNewSz().setVal(new BigInteger("24")); rPr.addNewSzCs().setVal(new BigInteger("24")); CTSdtContentBlock content = block.addNewSdtContent(); CTP p = content.addNewP(); p.setRsidR("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); p.setRsidRDefault("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); p.addNewPPr().addNewPStyle().setVal("TOCHeading"); p.addNewR().addNewT().setStringValue("Table of Contents"); }
/** * Add a new run with a reference to the specified footnote. * The footnote reference run will have the style name "FootnoteReference". * * @param footnote Footnote to which to add a reference. * @since 4.0.0 */ public void addFootnoteReference(XWPFAbstractFootnoteEndnote footnote) { XWPFRun run = createRun(); CTR ctRun = run.getCTR(); ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference"); if (footnote instanceof XWPFEndnote) { ctRun.addNewEndnoteReference().setId(footnote.getId()); } else { ctRun.addNewFootnoteReference().setId(footnote.getId()); } } }
private CTHdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs) { CTHdrFtr ftr = CTHdrFtr.Factory.newInstance(); if (paragraphs != null) { for (int i = 0 ; i < paragraphs.length ; i++) { CTP p = ftr.addNewP(); //ftr.setPArray(0, paragraphs[i].getCTP()); // MB 23 May 2010 ftr.setPArray(i, paragraphs[i].getCTP()); // MB 23 May 2010 } } else { CTP p = ftr.addNewP(); byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR(); byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault(); p.setRsidP(rsidr); p.setRsidRDefault(rsidrdefault); CTPPr pPr = p.addNewPPr(); pPr.addNewPStyle().setVal(pStyle); } return ftr; }
p.setRsidRDefault(rsidrdefault); CTPPr pPr = p.addNewPPr(); pPr.addNewPStyle().setVal(pStyle);