/** * @return the font to be used on bullet characters within a given paragraph */ public String getBulletFont(){ ParagraphPropertyFetcher<String> fetcher = new ParagraphPropertyFetcher<String>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuFont()){ setValue(props.getBuFont().getTypeface()); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
/** * @return the character to be used in place of the standard bullet point */ public String getBulletCharacter(){ ParagraphPropertyFetcher<String> fetcher = new ParagraphPropertyFetcher<String>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuChar()){ setValue(props.getBuChar().getChar()); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
/** * * @return the color of bullet characters within a given paragraph. * A <code>null</code> value means to use the text font color. */ public Color getBulletFontColor(){ ParagraphPropertyFetcher<Color> fetcher = new ParagraphPropertyFetcher<Color>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuClr()){ if(props.getBuClr().isSetSrgbClr()){ CTSRgbColor clr = props.getBuClr().getSrgbClr(); byte[] rgb = clr.getVal(); setValue(new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2])); return true; } } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
/** * Returns the starting number if this paragraph has automatic numbered bullets, otherwise returns 0 */ public int getBulletAutoNumberStart() { ParagraphPropertyFetcher<Integer> fetcher = new ParagraphPropertyFetcher<Integer>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuAutoNum() && props.getBuAutoNum().isSetStartAt()) { setValue(props.getBuAutoNum().getStartAt()); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
/** * Returns the auto number scheme if this paragraph has automatic numbered bullets, otherwise returns ListAutoNumber.ARABIC_PLAIN */ public ListAutoNumber getBulletAutoNumberScheme() { ParagraphPropertyFetcher<ListAutoNumber> fetcher = new ParagraphPropertyFetcher<ListAutoNumber>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuAutoNum()) { setValue(ListAutoNumber.values()[props.getBuAutoNum().getType().intValue() - 1]); return true; } return false; } }; fetchParagraphProperty(fetcher); // Note: documentation does not define a default, return ListAutoNumber.ARABIC_PLAIN (1,2,3...) return fetcher.getValue() == null ? ListAutoNumber.ARABIC_PLAIN : fetcher.getValue(); }
/** * Returns whether this paragraph has automatic numbered bullets */ public boolean isBulletAutoNumber() { ParagraphPropertyFetcher<Boolean> fetcher = new ParagraphPropertyFetcher<Boolean>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuAutoNum()) { setValue(true); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
/** * * @return the default size for a tab character within this paragraph in points */ public double getDefaultTabSize(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetDefTabSz()){ double val = Units.toPoints(props.getDefTabSz()); setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
/** * * @return the right margin of the paragraph */ public double getRightMargin(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetMarR()){ double val = Units.toPoints(props.getMarR()); setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); // if the marL attribute is omitted, then a value of 347663 is implied return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
/** * * @return the left margin of the paragraph */ public double getLeftMargin(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetMarL()){ double val = Units.toPoints(props.getMarL()); setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); // if the marL attribute is omitted, then a value of 347663 is implied return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
public double getTabStop(final int idx){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetTabLst()){ CTTextTabStopList tabStops = props.getTabLst(); if(idx < tabStops.sizeOfTabArray() ) { CTTextTabStop ts = tabStops.getTabArray(idx); double val = Units.toPoints(ts.getPos()); setValue(val); return true; } } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0. : fetcher.getValue(); } /**
/** * * @return the indent applied to the first line of text in the paragraph. */ public double getIndent(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetIndent()){ setValue(Units.toPoints(props.getIndent())); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
/** * Returns the alignment that is applied to the paragraph. * * If this attribute is omitted, then a value of left is implied. * @return alignment that is applied to the paragraph */ public TextAlign getTextAlign(){ ParagraphPropertyFetcher<TextAlign> fetcher = new ParagraphPropertyFetcher<TextAlign>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetAlgn()){ TextAlign val = TextAlign.values()[props.getAlgn().intValue() - 1]; setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? TextAlign.LEFT : fetcher.getValue(); }
/** * Returns where vertically on a line of text the actual words are positioned. This deals * with vertical placement of the characters with respect to the baselines. * * If this attribute is omitted, then a value of baseline is implied. * @return alignment that is applied to the paragraph */ public TextFontAlign getTextFontAlign(){ ParagraphPropertyFetcher<TextFontAlign> fetcher = new ParagraphPropertyFetcher<TextFontAlign>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetFontAlgn()){ TextFontAlign val = TextFontAlign.values()[props.getFontAlgn().intValue() - 1]; setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? TextFontAlign.BASELINE : fetcher.getValue(); }
/** * The amount of vertical white space before the paragraph * This may be specified in two different ways, percentage spacing and font point spacing: * <p> * If spaceBefore >= 0, then space is a percentage of normal line height. * If spaceBefore < 0, the absolute value of linespacing is the spacing in points * </p> * * @return the vertical white space before the paragraph */ public double getSpaceBefore(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetSpcBef()){ CTTextSpacing spc = props.getSpcBef(); if(spc.isSetSpcPct()) setValue( spc.getSpcPct().getVal()*0.001 ); else if (spc.isSetSpcPts()) setValue( -spc.getSpcPts().getVal()*0.01 ); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
/** * Returns whether this paragraph has bullets */ public boolean isBullet() { ParagraphPropertyFetcher<Boolean> fetcher = new ParagraphPropertyFetcher<Boolean>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if (props.isSetBuNone()) { setValue(false); return true; } if (props.isSetBuFont()) { if (props.isSetBuChar() || props.isSetBuAutoNum()) { setValue(true); return true; } /*else { // Excel treats text with buFont but no char/autonum // as not bulleted // Possibly the font is just used if bullets turned on again? }*/ } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
/** * The amount of vertical white space after the paragraph * This may be specified in two different ways, percentage spacing and font point spacing: * <p> * If spaceBefore >= 0, then space is a percentage of normal line height. * If spaceBefore < 0, the absolute value of linespacing is the spacing in points * </p> * * @return the vertical white space after the paragraph */ public double getSpaceAfter(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetSpcAft()){ CTTextSpacing spc = props.getSpcAft(); if(spc.isSetSpcPct()) setValue( spc.getSpcPct().getVal()*0.001 ); else if (spc.isSetSpcPts()) setValue( -spc.getSpcPts().getVal()*0.01 ); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
/** * Returns the bullet size that is to be used within a paragraph. * This may be specified in two different ways, percentage spacing and font point spacing: * <p> * If bulletSize >= 0, then bulletSize is a percentage of the font size. * If bulletSize < 0, then it specifies the size in points * </p> * * @return the bullet size */ public double getBulletFontSize(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuSzPct()){ setValue(props.getBuSzPct().getVal() * 0.001); return true; } if(props.isSetBuSzPts()){ setValue( - props.getBuSzPts().getVal() * 0.01); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 100 : fetcher.getValue(); }
/** * Returns whether this paragraph has automatic numbered bullets */ public boolean isBulletAutoNumber() { ParagraphPropertyFetcher<Boolean> fetcher = new ParagraphPropertyFetcher<Boolean>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuAutoNum()) { setValue(true); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
/** * * @return the indent applied to the first line of text in the paragraph. */ public double getIndent(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetIndent()){ setValue(Units.toPoints(props.getIndent())); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }