/** * Returns the textual content of the header/footer, * by flattening out the text of its paragraph(s) */ public String getText() { StringBuilder t = new StringBuilder(64); //TODO: simplify this to get ibody elements in order for (int i = 0; i < paragraphs.size(); i++) { if (!paragraphs.get(i).isEmpty()) { String text = paragraphs.get(i).getText(); if (text != null && text.length() > 0) { t.append(text); t.append('\n'); } } } for (int i = 0; i < tables.size(); i++) { String text = tables.get(i).getText(); if (text != null && text.length() > 0) { t.append(text); t.append('\n'); } } for (IBodyElement bodyElement : getBodyElements()) { if (bodyElement instanceof XWPFSDT) { t.append(((XWPFSDT) bodyElement).getContent().getText() + '\n'); } } return t.toString(); }
private void extractHeaderText(XHTMLContentHandler xhtml, XWPFHeaderFooter header, XWPFListManager listManager) throws SAXException, XmlException, IOException { for (IBodyElement e : header.getBodyElements()) { if (e instanceof XWPFParagraph) { extractParagraph((XWPFParagraph) e, listManager, xhtml); } else if (e instanceof XWPFTable) { extractTable((XWPFTable) e, listManager, xhtml); } else if (e instanceof XWPFSDT) { extractSDT((XWPFSDT) e, xhtml); } } }
/** * Returns the textual content of the header/footer, * by flattening out the text of its paragraph(s) */ public String getText() { StringBuilder t = new StringBuilder(64); //TODO: simplify this to get ibody elements in order for (int i = 0; i < paragraphs.size(); i++) { if (!paragraphs.get(i).isEmpty()) { String text = paragraphs.get(i).getText(); if (text != null && text.length() > 0) { t.append(text); t.append('\n'); } } } for (int i = 0; i < tables.size(); i++) { String text = tables.get(i).getText(); if (text != null && text.length() > 0) { t.append(text); t.append('\n'); } } for (IBodyElement bodyElement : getBodyElements()) { if (bodyElement instanceof XWPFSDT) { t.append(((XWPFSDT) bodyElement).getContent().getText() + '\n'); } } return t.toString(); }
private void extractHeaderText(XHTMLContentHandler xhtml, XWPFHeaderFooter header, XWPFListManager listManager) throws SAXException, XmlException, IOException { for (IBodyElement e : header.getBodyElements()) { if (e instanceof XWPFParagraph) { extractParagraph((XWPFParagraph) e, listManager, xhtml); } else if (e instanceof XWPFTable) { extractTable((XWPFTable) e, listManager, xhtml); } else if (e instanceof XWPFSDT) { extractSDT((XWPFSDT) e, xhtml); } } }
private void extractHeaderText(XHTMLContentHandler xhtml, XWPFHeaderFooter header, XWPFListManager listManager) throws SAXException, XmlException, IOException { for (IBodyElement e : header.getBodyElements()) { if (e instanceof XWPFParagraph) { extractParagraph((XWPFParagraph) e, listManager, xhtml); } else if (e instanceof XWPFTable) { extractTable((XWPFTable) e, listManager, xhtml); } else if (e instanceof XWPFSDT) { extractSDT((XWPFSDT) e, xhtml); } } }