use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentBlock in project poi by apache.
the class TOC method addRow.
public void addRow(int level, String title, int page, String bookmarkRef) {
CTSdtContentBlock contentBlock = this.block.getSdtContent();
CTP p = contentBlock.addNewP();
p.setRsidR("00EF7E24".getBytes(LocaleUtil.CHARSET_1252));
p.setRsidRDefault("00EF7E24".getBytes(LocaleUtil.CHARSET_1252));
CTPPr pPr = p.addNewPPr();
pPr.addNewPStyle().setVal("TOC" + level);
CTTabs tabs = pPr.addNewTabs();
CTTabStop tab = tabs.addNewTab();
tab.setVal(STTabJc.RIGHT);
tab.setLeader(STTabTlc.DOT);
tab.setPos(new BigInteger("8290"));
pPr.addNewRPr().addNewNoProof();
CTR run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewT().setStringValue(title);
run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewTab();
run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewFldChar().setFldCharType(STFldCharType.BEGIN);
// pageref run
run = p.addNewR();
run.addNewRPr().addNewNoProof();
CTText text = run.addNewInstrText();
text.setSpace(Space.PRESERVE);
// bookmark reference
text.setStringValue(" PAGEREF _Toc" + bookmarkRef + " \\h ");
p.addNewR().addNewRPr().addNewNoProof();
run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
// page number run
run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewT().setStringValue(Integer.toString(page));
run = p.addNewR();
run.addNewRPr().addNewNoProof();
run.addNewFldChar().setFldCharType(STFldCharType.END);
}
Aggregations