/** * Turn separate even-and-odd headings on or off * * @param enable <code>true</code> to turn on separate even and odd headings, * <code>false</code> to turn off even and odd headings. */ public void setEvenAndOddHeadings(boolean enable) { CTOnOff onOff = CTOnOff.Factory.newInstance(); onOff.setVal(enable ? STOnOff.TRUE : STOnOff.FALSE); ctSettings.setEvenAndOddHeaders(onOff); }
/** * Turn mirrored margins on or off * * @param enable <code>true</code> to turn on mirrored margins, * <code>false</code> to turn off mirrored marginss. */ public void setMirrorMargins(boolean enable) { CTOnOff onOff = CTOnOff.Factory.newInstance(); onOff.setVal(enable ? STOnOff.TRUE : STOnOff.FALSE); ctSettings.setMirrorMargins(onOff); }
/** * Enforces fields update on document open (in Word). * In the settings.xml file <br> * sets the updateSettings value to true (w:updateSettings w:val="true") * <p> * NOTICES: * <ul> * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?" * (if "Update automatic links at open" is enabled)</li> * <li>Flag is removed after saving with changes in Word </li> * </ul> */ public void setUpdateFields() { CTOnOff onOff = CTOnOff.Factory.newInstance(); onOff.setVal(STOnOff.TRUE); ctSettings.setUpdateFields(onOff); }
/** * Specifies that when rendering this document in a paginated * view, the contents of this paragraph are rendered on the start of a new * page in the document. * <p> * If this element is omitted on a given paragraph, * its value is determined by the setting previously set at any level of the * style hierarchy (i.e. that previous setting remains unchanged). If this * setting is never specified in the style hierarchy, then this property * shall not be applied. Since the paragraph is specified to start on a new * page, it begins page two even though it could have fit on page one. * </p> * * @param pageBreak - * boolean value */ public void setPageBreak(boolean pageBreak) { CTPPr ppr = getCTPPr(); CTOnOff ctPageBreak = ppr.isSetPageBreakBefore() ? ppr .getPageBreakBefore() : ppr.addNewPageBreakBefore(); if (pageBreak) { ctPageBreak.setVal(STOnOff.TRUE); } else { ctPageBreak.setVal(STOnOff.FALSE); } }
@Override public void setCapitalized(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff caps = pr.isSetCaps() ? pr.getCaps() : pr.addNewCaps(); caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
@Override public void setImprinted(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff imprinted = pr.isSetImprint() ? pr.getImprint() : pr.addNewImprint(); imprinted.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
/** * Specifies that the contents of this run shall be displayed with a * double horizontal line through the center of the line. * * @see #setStrikeThrough(boolean) for the rules about this */ @Override public void setDoubleStrikethrough(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike(); dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
@Override public void setEmbossed(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff emboss = pr.isSetEmboss() ? pr.getEmboss() : pr.addNewEmboss(); emboss.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
@Override public void setShadow(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff shadow = pr.isSetShadow() ? pr.getShadow() : pr.addNewShadow(); shadow.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
/** * The vanish (hidden text) property for the run. * * @param value Set to true to make the run hidden text. * @since 4.0.0 */ public void setVanish(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff vanish = pr.isSetVanish() ? pr.getVanish() : pr.addNewVanish(); vanish.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
@Override public void setSmallCaps(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps(); caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
/** * Controls whether to allow this table row to split across pages. * The logic for this attribute is a little unusual: a true value means * DON'T allow rows to split, false means allow rows to split. * * @param split - if true, don't allow row to be split. If false, allow * row to be split. */ public void setCantSplitRow(boolean split) { CTTrPr trpr = getTrPr(); CTOnOff onoff = (trpr.sizeOfCantSplitArray() > 0 ? trpr.getCantSplitArray(0) : trpr.addNewCantSplit()); onoff.setVal(WMLHelper.convertBooleanToSTOnOff(split)); }
/** * This attribute controls whether to repeat a table's header row at the top * of a table split across pages. NOTE - for a row to be repeated, all preceding * rows in the table must also be repeated. * * @param repeat - if TRUE, repeat header row at the top of each page of table; * if FALSE, don't repeat header row. */ public void setRepeatHeader(boolean repeat) { CTTrPr trpr = getTrPr(); CTOnOff onoff = (trpr.sizeOfTblHeaderArray() > 0 ? trpr.getTblHeaderArray(0) : trpr.addNewTblHeader()); onoff.setVal(WMLHelper.convertBooleanToSTOnOff(repeat)); } }
/** * Specifies that the contents of this run shall be displayed with a single * horizontal line through the center of the line. * <p> * This formatting property is a toggle property, which specifies that its * behaviour differs between its use within a style definition and its use as * direct formatting. When used as part of a style definition, setting this * property shall toggle the current state of that property as specified up * to this point in the hierarchy (i.e. applied to not applied, and vice * versa). Setting it to false (or an equivalent) shall result in the * current setting remaining unchanged. However, when used as direct * formatting, setting this property to true or false shall set the absolute * state of the resulting property. * </p> * <p> * If this element is not present, the default value is to leave the * formatting applied at previous level in the style hierarchy. If this * element is never applied in the style hierarchy, then strikethrough shall * not be applied to the contents of this run. * </p> * * @param value <code>true</code> if the strike property is applied to * this run */ @Override public void setStrikeThrough(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike(); strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
CTRPr pr = getRunProperties(true); CTOnOff italic = pr.isSetI() ? pr.getI() : pr.addNewI(); italic.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
/** * Whether the bold property shall be applied to all non-complex script * characters in the contents of this run when displayed in a document. * <p> * This formatting property is a toggle property, which specifies that its * behavior differs between its use within a style definition and its use as * direct formatting. When used as part of a style definition, setting this * property shall toggle the current state of that property as specified up * to this point in the hierarchy (i.e. applied to not applied, and vice * versa). Setting it to <code>false</code> (or an equivalent) shall * result in the current setting remaining unchanged. However, when used as * direct formatting, setting this property to true or false shall set the * absolute state of the resulting property. * </p> * <p> * If this element is not present, the default value is to leave the * formatting applied at previous level in the style hierarchy. If this * element is never applied in the style hierarchy, then bold shall not be * applied to non-complex script characters. * </p> * * @param value <code>true</code> if the bold property is applied to * this run */ @Override public void setBold(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff bold = pr.isSetB() ? pr.getB() : pr.addNewB(); bold.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
/** * This element specifies whether a consumer shall break Latin text which * exceeds the text extents of a line by breaking the word across two lines * (breaking on the character level) or by moving the word to the following * line (breaking on the word level). * * @param wrap - boolean */ @Override public void setWordWrapped(boolean wrap) { CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr() .getWordWrap() : getCTPPr().addNewWordWrap(); if (wrap) { wordWrap.setVal(STOnOff.TRUE); } else { wordWrap.unsetVal(); } }
/** * Create a header of the given type * * @param type {@link HeaderFooterType} enum * @return object of type {@link XWPFHeader} */ public XWPFHeader createHeader(HeaderFooterType type) { XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy(); // TODO this needs to be migrated out into section code if (type == HeaderFooterType.FIRST) { CTSectPr ctSectPr = getSection(); if (!ctSectPr.isSetTitlePg()) { CTOnOff titlePg = ctSectPr.addNewTitlePg(); titlePg.setVal(STOnOff.ON); } // } else if (type == HeaderFooterType.EVEN) { // TODO Add support for Even/Odd headings and footers } return hfPolicy.createHeader(STHdrFtr.Enum.forInt(type.toInt())); }
/** * Create a footer of the given type * * @param type {@link HeaderFooterType} enum * @return object of type {@link XWPFFooter} */ public XWPFFooter createFooter(HeaderFooterType type) { XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy(); // TODO this needs to be migrated out into section code if (type == HeaderFooterType.FIRST) { CTSectPr ctSectPr = getSection(); if (!ctSectPr.isSetTitlePg()) { CTOnOff titlePg = ctSectPr.addNewTitlePg(); titlePg.setVal(STOnOff.ON); } // } else if (type == HeaderFooterType.EVEN) { // TODO Add support for Even/Odd headings and footers } return hfPolicy.createFooter(STHdrFtr.Enum.forInt(type.toInt())); }
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"); }