@Override public void setIndentLevel(int level){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); pr.setLvl(level); }
private XDDFParagraphProperties getOrCreateProperties() { if (!_p.isSetPPr()) { _properties = new XDDFParagraphProperties(_p.addNewPPr()); } return getProperties(); }
/** * 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); }
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 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); }
/** * Specifies that automatic numbered bullet points should be applied to this paragraph * * @param scheme type of auto-numbering * @param startAt the number that will start number for a given sequence of automatically numbered bullets (1-based). */ @SuppressWarnings("WeakerAccess") public void setBulletAutoNumber(AutoNumberingScheme scheme, int startAt) { if(startAt < 1) throw new IllegalArgumentException("Start Number must be greater or equal that 1") ; CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTTextAutonumberBullet lst = pr.isSetBuAutoNum() ? pr.getBuAutoNum() : pr.addNewBuAutoNum(); lst.setType(STTextAutonumberScheme.Enum.forInt(scheme.ooxmlId)); lst.setStartAt(startAt); }
/** * 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)); } }
@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)); } }
/** * Specifies the left margin of the paragraph. This is specified in addition to the text body * inset and applies only to this text paragraph. That is the text body inset and the LeftMargin * attributes are additive with respect to the text position. * * @param value the left margin of the paragraph, -1 to clear the margin and use the default of 0. */ public void setLeftMargin(double value){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if(value == -1) { if(pr.isSetMarL()) pr.unsetMarL(); } else { pr.setMarL(Units.toEMU(value)); } }
/** * Specifies the right margin of the paragraph. This is specified in addition to the text body * inset and applies only to this text paragraph. That is the text body inset and the marR * attributes are additive with respect to the text position. * * @param value the right margin of the paragraph, -1 to clear the margin and use the default of 0. */ public void setRightMargin(double value){ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); if(value == -1) { if(pr.isSetMarR()) pr.unsetMarR(); } else { pr.setMarR(Units.toEMU(value)); } }
@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)); }
/** * Specifies the alignment that is to be applied to the paragraph. * Possible values for this include left, right, centered, justified and distributed, * see {@link org.apache.poi.xssf.usermodel.TextAlign}. * * @param align text align */ 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)); } }
@SuppressWarnings("WeakerAccess") 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)); }
@Override public void addTabStops(double positionInPoints, TabStopType tabStopType) { final XSLFSheet sheet = getParentShape().getSheet(); final CTTextParagraphProperties tpp; if (sheet instanceof XSLFSlideMaster) { tpp = getDefaultMasterStyle(); } else { final CTTextParagraph xo = getXmlObject(); tpp = (xo.isSetPPr()) ? xo.getPPr() : xo.addNewPPr(); } if (tpp == null) { return; } final CTTextTabStopList stl = (tpp.isSetTabLst()) ? tpp.getTabLst() : tpp.addNewTabLst(); XSLFTabStop tab = new XSLFTabStop(stl.addNewTab()); tab.setPositionInPoints(positionInPoints); tab.setType(tabStopType); }
/** * Set this paragraph as an automatic numbered bullet point * * @param scheme type of auto-numbering */ public void setBullet(ListAutoNumber scheme) { CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr(); CTTextAutonumberBullet lst = pr.isSetBuAutoNum() ? pr.getBuAutoNum() : pr.addNewBuAutoNum(); lst.setType(STTextAutonumberScheme.Enum.forInt(scheme.ordinal() + 1)); if(!pr.isSetBuFont()) pr.addNewBuFont().setTypeface("Arial"); if(pr.isSetBuNone()) pr.unsetBuNone(); // remove these elements if present as it results in invalid content when opening in Excel. if(pr.isSetBuBlip()) pr.unsetBuBlip(); if(pr.isSetBuChar()) pr.unsetBuChar(); }