/** * Returns the level of text properties that this paragraph will follow. * * @return the text level of this paragraph (0-based). Default is 0. */ public int getLevel(){ CTTextParagraphProperties pr = _p.getPPr(); if(pr == null) return 0; return pr.getLvl(); }
private XDDFParagraphProperties getProperties() { if (_properties == null) { _properties = new XDDFParagraphProperties(_p.getPPr()); } return _properties; }
private <R> Optional<R> findDefinedParagraphProperty(Function<CTTextParagraphProperties, Boolean> isSet, Function<CTTextParagraphProperties, R> getter, int level) { final CTTextParagraphProperties props = _p.getPPr(); if (props != null && isSet.apply(props)) { return Optional.ofNullable(getter.apply(props)); } else { return _parent.findDefinedParagraphProperty(isSet, getter, level); } }
private <R> Optional<R> findDefinedRunProperty(Function<CTTextCharacterProperties, Boolean> isSet, Function<CTTextCharacterProperties, R> getter, int level) { final CTTextCharacterProperties props = _p.getPPr().isSetDefRPr() ? _p.getPPr().getDefRPr() : null; if (props != null && isSet.apply(props)) { return Optional.ofNullable(getter.apply(props)); } else { return _parent.findDefinedRunProperty(isSet, getter, level); } } }
@Override public int getIndentLevel() { CTTextParagraphProperties pr = _p.getPPr(); return (pr == null || !pr.isSetLvl()) ? 0 : pr.getLvl(); }
protected <R> Optional<R> findDefinedParagraphProperty(Function<CTTextParagraphProperties, Boolean> isSet, Function<CTTextParagraphProperties, R> getter) { if (_p.isSetPPr()) { int level = _p.getPPr().isSetLvl() ? 1 + _p.getPPr().getLvl() : 0; return findDefinedParagraphProperty(isSet, getter, level); } else { return _parent.findDefinedParagraphProperty(isSet, getter, 0); } }
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); } }
@Override public void setIndentLevel(int level){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); pr.setLvl(level); }
@SuppressWarnings("rawtypes") private boolean fetchParagraphProperty(ParagraphPropertyFetcher visitor){ boolean ok = false; if(_p.isSetPPr()) ok = visitor.fetch(_p.getPPr()); if(!ok) { ok = visitor.fetch(_shape); } return ok; }
/** * Set the color to be used on bullet characters within a given paragraph. * * @param color the bullet color */ public void setBulletFontColor(Color color){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr(); CTSRgbColor clr = c.isSetSrgbClr() ? c.getSrgbClr() : c.addNewSrgbClr(); clr.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()}); }
public void setBulletCharacter(String str){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTTextCharBullet c = pr.isSetBuChar() ? pr.getBuChar() : pr.addNewBuChar(); c.setChar(str); }
/** * Specifies the indent size that will be applied to the first line of text in the paragraph. * * @param value the indent in points, -1 to unset indent and use the default of 0. */ public void setIndent(double value){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if(value == -1) { if(pr.isSetIndent()) pr.unsetIndent(); } else { pr.setIndent(Units.toEMU(value)); } }
public void setBulletFont(String typeface){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTTextFont font = pr.isSetBuFont() ? pr.getBuFont() : pr.addNewBuFont(); font.setTypeface(typeface); }
@SuppressWarnings("WeakerAccess") public void setBulletCharacter(String str){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTTextCharBullet c = pr.isSetBuChar() ? pr.getBuChar() : pr.addNewBuChar(); c.setChar(str); }
@Override public void clearTabStops() { final XSLFSheet sheet = getParentShape().getSheet(); CTTextParagraphProperties tpp = (sheet instanceof XSLFSlideMaster) ? getDefaultMasterStyle() : getXmlObject().getPPr(); if (tpp != null && tpp.isSetTabLst()) { tpp.unsetTabLst(); } }
@Override public void setTextAlign(TextAlign align) { CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if(align == null) { if(pr.isSetAlgn()) pr.unsetAlgn(); } else { pr.setAlgn(STTextAlignType.Enum.forInt(align.ordinal() + 1)); } }
@Override public void setRightMargin(Double rightMargin){ if (rightMargin == null && !_p.isSetPPr()) return; CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if(rightMargin == null) { if(pr.isSetMarR()) pr.unsetMarR(); } else { pr.setMarR(Units.toEMU(rightMargin)); } }
@Override public void setIndent(Double indent){ if ((indent == null) && !_p.isSetPPr()) return; CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if(indent == null) { if(pr.isSetIndent()) pr.unsetIndent(); } else { pr.setIndent(Units.toEMU(indent)); } }
@Override public void setLeftMargin(Double leftMargin){ if (leftMargin == null && !_p.isSetPPr()) return; CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if (leftMargin == null) { if(pr.isSetMarL()) pr.unsetMarL(); } else { pr.setMarL(Units.toEMU(leftMargin)); } }
/** * Add a single tab stop to be used on a line of text when there are one or more tab characters * present within the text. * * @param value the position of the tab stop relative to the left margin */ public void addTabStop(double value){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTTextTabStopList tabStops = pr.isSetTabLst() ? pr.getTabLst() : pr.addNewTabLst(); tabStops.addNewTab().setPos(Units.toEMU(value)); }