public static String getText(List<HSLFTextParagraph> paragraphs) { assert (!paragraphs.isEmpty()); String rawText = getRawText(paragraphs); return toExternalString(rawText, paragraphs.get(0).getRunType()); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (HSLFTextRun r : getTextRuns()) { sb.append(r.getRawText()); } return toExternalString(sb.toString(), getRunType()); }
/** * Returns the type of the text, from the TextHeaderAtom. * Possible values can be seen from TextHeaderAtom * @see org.apache.poi.hslf.record.TextHeaderAtom */ public int getRunType() { getEscherTextboxWrapper(); if (_txtbox == null) { return -1; } List<HSLFTextParagraph> paras = HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet()); return (paras.isEmpty()) ? -1 : paras.get(0).getRunType(); }
/** * <p> * The title is a run of text of type <code>TextHeaderAtom.CENTER_TITLE_TYPE</code> or * <code>TextHeaderAtom.TITLE_TYPE</code> * </p> * * @see TextHeaderAtom */ @Override public String getTitle(){ for (List<HSLFTextParagraph> tp : getTextParagraphs()) { if (tp.isEmpty()) { continue; } int type = tp.get(0).getRunType(); switch (type) { case TextHeaderAtom.CENTER_TITLE_TYPE: case TextHeaderAtom.TITLE_TYPE: String str = HSLFTextParagraph.getRawText(tp); return HSLFTextParagraph.toExternalString(str, type); } } return null; }
private void setPropValInner(final TextPropCollection props, final String name, Consumer<? extends TextProp> handler) { final boolean isChar = props.getTextPropType() == TextPropType.character; final TextPropCollection pc; if (_sheet instanceof HSLFMasterSheet) { pc = ((HSLFMasterSheet)_sheet).getPropCollection(getRunType(), getIndentLevel(), "*", isChar); if (pc == null) { throw new HSLFException("Master text property collection can't be determined."); } } else { pc = props; } if (handler == null) { pc.removeByName(name); } else { // Fetch / Add the TextProp handler.accept(pc.addWithName(name)); } setDirty(); }
private <T extends TextProp> T getMasterProp(final String name) { final int txtype = parentParagraph.getRunType(); final HSLFSheet sheet = parentParagraph.getSheet(); if (sheet == null) { logger.log(POILogger.ERROR, "Sheet is not available"); return null; } final HSLFMasterSheet master = sheet.getMasterSheet(); if (master == null) { logger.log(POILogger.WARN, "MasterSheet is not available"); return null; } final TextPropCollection col = master.getPropCollection(txtype, parentParagraph.getIndentLevel(), name, true); return (col == null) ? null : col.findByName(name); }
for (HSLFTextParagraph textPara : textLevel1) { final ParserField parserField; switch (textPara.getRunType()) { case TextHeaderAtom.TITLE_TYPE: case TextHeaderAtom.CENTER_TITLE_TYPE:
final int txtype = getRunType(); final HSLFMasterSheet master; if (sheet instanceof HSLFMasterSheet) {
int txType = htp.getRunType(); if (txType >= _txmaster.length || _txmaster[txType] == null) { throw new HSLFException("Master styles not initialized");