@Override public Double getIndent() { ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetIndent()){ setValue(Units.toPoints(props.getIndent())); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
@Override public TextAlign getTextAlign(){ ParagraphPropertyFetcher<TextAlign> fetcher = new ParagraphPropertyFetcher<TextAlign>(getIndentLevel()){ 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(); }
@Override public FontAlign getFontAlign(){ ParagraphPropertyFetcher<FontAlign> fetcher = new ParagraphPropertyFetcher<FontAlign>(getIndentLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetFontAlgn()){ FontAlign val = FontAlign.values()[props.getFontAlgn().intValue() - 1]; setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
@Override public Double getDefaultTabSize(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){ 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(); }
/** * @return the font to be used on bullet characters within a given paragraph */ @SuppressWarnings("WeakerAccess") public String getBulletFont(){ ParagraphPropertyFetcher<String> fetcher = new ParagraphPropertyFetcher<String>(getIndentLevel()){ 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 */ @SuppressWarnings("WeakerAccess") public String getBulletCharacter(){ ParagraphPropertyFetcher<String> fetcher = new ParagraphPropertyFetcher<String>(getIndentLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetBuChar()){ setValue(props.getBuChar().getChar()); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
/** * @return the left margin (in points) of the paragraph, null if unset */ @Override public Double getLeftMargin(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){ 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(); }
/** * @return the auto numbering starting number, or null if not defined */ @SuppressWarnings("WeakerAccess") public Integer getAutoNumberingStartAt() { ParagraphPropertyFetcher<Integer> fetcher = new ParagraphPropertyFetcher<Integer>(getIndentLevel()) { public boolean fetch(CTTextParagraphProperties props) { if (props.isSetBuAutoNum()) { if (props.getBuAutoNum().isSetStartAt()) { setValue(props.getBuAutoNum().getStartAt()); return true; } } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
/** * * @return the right margin of the paragraph, null if unset */ @Override public Double getRightMargin(){ ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){ public boolean fetch(CTTextParagraphProperties props){ if(props.isSetMarR()){ double val = Units.toPoints(props.getMarR()); setValue(val); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
@Override public List<XSLFTabStop> getTabStops() { ParagraphPropertyFetcher<List<XSLFTabStop>> fetcher = new ParagraphPropertyFetcher<List<XSLFTabStop>>(getIndentLevel()){ public boolean fetch(CTTextParagraphProperties props) { if (props.isSetTabLst()) { final List<XSLFTabStop> list = new ArrayList<>(); //noinspection deprecation for (final CTTextTabStop ta : props.getTabLst().getTabArray()) { list.add(new XSLFTabStop(ta)); } setValue(list); return true; } return false; } }; fetchParagraphProperty(fetcher); return fetcher.getValue(); }
@Override public boolean isItalic(){ CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if (props != null && props.isSetI()) { setValue(props.getI()); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
private CTTextFont getXmlObject(boolean create) { if (create) { return getCTTextFont(getRPr(true), true); } CharacterPropertyFetcher<CTTextFont> visitor = new CharacterPropertyFetcher<CTTextFont>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ CTTextFont font = getCTTextFont(props, false); if (font == null) { return false; } setValue(font); return true; } }; fetchCharacterProperty(visitor); return visitor.getValue(); }
@Override public boolean isStrikethrough() { CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if(props != null && props.isSetStrike()) { setValue(props.getStrike() != STTextStrikeType.NO_STRIKE); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
@Override public boolean isSubscript() { CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if (props != null && props.isSetBaseline()) { setValue(props.getBaseline() < 0); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
@Override public boolean isBold(){ CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if (props != null && props.isSetB()) { setValue(props.getB()); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
@Override public boolean isUnderlined(){ CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if (props != null && props.isSetU()) { setValue(props.getU() != STTextUnderlineType.NONE); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
@Override public boolean isSuperscript() { CharacterPropertyFetcher<Boolean> fetcher = new CharacterPropertyFetcher<Boolean>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if (props != null && props.isSetBaseline()) { setValue(props.getBaseline() > 0); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
@SuppressWarnings("WeakerAccess") public double getTabStop(final int idx) { ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){ 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 spacing between characters within a text run, * If this attribute is omitted than a value of 0 or no adjustment is assumed. */ @SuppressWarnings("WeakerAccess") public double getCharacterSpacing(){ CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){ @Override public boolean fetch(CTTextCharacterProperties props){ if (props != null && props.isSetSpc()) { setValue(props.getSpc()*0.01); return true; } return false; } }; fetchCharacterProperty(fetcher); return fetcher.getValue() == null ? 0 : fetcher.getValue(); }
boolean fetchThemeProperty(final ParagraphPropertyFetcher<?> visitor) { final XSLFTextShape shape = getParentShape(); if (shape.isPlaceholder()) { return false; } // if it is a plain text box then take defaults from presentation.xml @SuppressWarnings("resource") final XMLSlideShow ppt = shape.getSheet().getSlideShow(); final CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(getIndentLevel()); return themeProps != null && visitor.fetch(themeProps); }