public XDDFTextParagraph addNewParagraph() { return new XDDFTextParagraph(_body.addNewP(), this); }
public XDDFTextParagraph initialize() { _body.addNewLstStyle(); _body.addNewBodyPr(); XDDFBodyProperties bp = getBodyProperties(); bp.setAnchoring(AnchorType.TOP); bp.setRightToLeft(false); XDDFTextParagraph p = addNewParagraph(); p.setTextAlignment(TextAlignment.LEFT); XDDFRunProperties end = p.addAfterLastRunProperties(); end.setLanguage(Locale.US); end.setFontSize(11.0); return p; }
@Internal protected XDDFTextParagraph(CTTextParagraph paragraph, XDDFTextBody parent) { this._p = paragraph; this._parent = parent; final int count = paragraph.sizeOfBrArray() + paragraph.sizeOfFldArray() + paragraph.sizeOfRArray(); this._runs = new ArrayList<>(count); for (XmlObject xo : _p.selectChildren(QNameSet.ALL)) { if (xo instanceof CTTextLineBreak) { _runs.add(new XDDFTextRun((CTTextLineBreak) xo, this)); } else if (xo instanceof CTTextField) { _runs.add(new XDDFTextRun((CTTextField) xo, this)); } else if (xo instanceof CTRegularTextRun) { _runs.add(new XDDFTextRun((CTRegularTextRun) xo, this)); } } addDefaultRunProperties(); addAfterLastRunProperties(); }
/** * The amount of vertical white space before the paragraph. This may be * specified in two different ways, percentage spacing or font points * spacing: * <p> * If spacing is a percentage of normal line height, result is instance of * XDDFSpacingPercent. If spacing is expressed in points, result is instance * of XDDFSpacingPoints. * </p> * * @return the vertical white space before the paragraph. */ public XDDFSpacing getSpaceBefore() { return findDefinedParagraphProperty(props -> props.isSetSpcBef(), props -> props.getSpcBef()) .map(spacing -> extractSpacing(spacing)).orElse(null); }
/** * @since 4.0.1 */ public XDDFRunProperties addDefaultRunProperties() { return getOrCreateProperties().addDefaultRunProperties(); }
public boolean hasHangingPunctuation() { return findDefinedParagraphProperty(props -> props.isSetHangingPunct(), props -> props.getHangingPunct()) .orElse(false); }
/** * Specifies the color to be used on bullet characters has to follow text * color within a given paragraph. */ public void setBulletColorFollowText() { getOrCreateBulletProperties().setBulletColorFollowText(); }
private <R> Optional<R> findDefinedProperty(Function<CTTextCharacterProperties, Boolean> isSet, Function<CTTextCharacterProperties, R> getter) { CTTextCharacterProperties props = getProperties(); if (props != null && isSet.apply(props)) { return Optional.ofNullable(getter.apply(props)); } else { return _parent.findDefinedRunProperty(isSet, getter); } }
public XDDFRunProperties addAfterLastRunProperties() { if (!_p.isSetEndParaRPr()) { _p.addNewEndParaRPr(); } return getAfterLastRunProperties(); }
protected static void initTextBody(XDDFTextBody body) { XDDFTextParagraph p = body.getParagraph(0); p.appendRegularRun(""); }
public XDDFParagraphBulletProperties getOrCreateBulletProperties() { return getOrCreateProperties().getBulletProperties(); }
public boolean isRightToLeft() { return findDefinedParagraphProperty(props -> props.isSetRtl(), props -> props.getRtl()).orElse(false); }
/** * Returns the vertical line spacing that is to be used within a paragraph. * This may be specified in two different ways, percentage spacing or font * points spacing: * <p> * If line spacing is a percentage of normal line height, result is instance * of XDDFSpacingPercent. If line spacing is expressed in points, result is * instance of XDDFSpacingPoints. * </p> * * @return the vertical line spacing. */ public XDDFSpacing getLineSpacing() { return findDefinedParagraphProperty(props -> props.isSetLnSpc(), props -> props.getLnSpc()) .map(spacing -> extractSpacing(spacing)).orElse(null); }
/** * Specifies the font to be used on bullet characters has to follow text * font within a given paragraph. */ public void setBulletFontFollowText() { getOrCreateBulletProperties().setBulletFontFollowText(); }
protected <R> Optional<R> findDefinedRunProperty(Function<CTTextCharacterProperties, Boolean> isSet, Function<CTTextCharacterProperties, R> getter) { if (_p.isSetPPr()) { int level = _p.getPPr().isSetLvl() ? 1 + _p.getPPr().getLvl() : 0; return findDefinedRunProperty(isSet, getter, level); } else { return _parent.findDefinedRunProperty(isSet, getter, 0); } }
XDDFRunProperties rp = p.getAfterLastRunProperties(); XDDFColor black = new XDDFColorRgbBinary(new byte[] { 0, 0, 0 }); XDDFFillProperties fp = new XDDFSolidFillProperties(black);
public void setText(String text) { // remove all runs for (int i = _p.sizeOfBrArray() - 1; i >= 0; i--) { _p.removeBr(i); } for (int i = _p.sizeOfFldArray() - 1; i >= 0; i--) { _p.removeFld(i); } for (int i = _p.sizeOfRArray() - 1; i >= 0; i--) { _p.removeR(i); } _runs.clear(); appendRegularRun(text); }
public XDDFTabStop addTabStop() { return getOrCreateProperties().addTabStop(); }
public boolean hasLatinLineBreak() { return findDefinedParagraphProperty(props -> props.isSetLatinLnBrk(), props -> props.getLatinLnBrk()) .orElse(false); }
/** * The amount of vertical white space after the paragraph. This may be * specified in two different ways, percentage spacing or font points * spacing: * <p> * If spacing is a percentage of normal line height, result is instance of * XDDFSpacingPercent. If spacing is expressed in points, result is instance * of XDDFSpacingPoints. * </p> * * @return the vertical white space after the paragraph. */ public XDDFSpacing getSpaceAfter() { return findDefinedParagraphProperty(props -> props.isSetSpcAft(), props -> props.getSpcAft()) .map(spacing -> extractSpacing(spacing)).orElse(null); }