Example usage for org.apache.poi.xwpf.model XWPFParagraphDecorator getText

List of usage examples for org.apache.poi.xwpf.model XWPFParagraphDecorator getText

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.model XWPFParagraphDecorator getText.

Prototype

public String getText() 

Source Link

Usage

From source file:org.olat.search.service.document.file.WordOOXMLDocument.java

License:Apache License

private void extractContent(final StringBuilder buffy, final XWPFDocument document)
        throws IOException, XmlException {
    // first all paragraphs
    final Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while (i.hasNext()) {
        final XWPFParagraph paragraph = i.next();
        CTSectPr ctSectPr = null;/*from   w  w  w. j  a v a2 s  . co  m*/
        if (paragraph.getCTP().getPPr() != null) {
            ctSectPr = paragraph.getCTP().getPPr().getSectPr();
        }

        XWPFHeaderFooterPolicy headerFooterPolicy = null;
        if (ctSectPr != null) {
            headerFooterPolicy = new XWPFHeaderFooterPolicy(document, ctSectPr);
            extractHeaders(buffy, headerFooterPolicy);
        }

        final XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
                new XWPFHyperlinkDecorator(paragraph, null, true));

        final CTBookmark[] bookmarks = paragraph.getCTP().getBookmarkStartArray();
        for (final CTBookmark bookmark : bookmarks) {
            buffy.append(bookmark.getName()).append(' ');
        }

        buffy.append(decorator.getText()).append(' ');

        if (ctSectPr != null) {
            extractFooters(buffy, headerFooterPolicy);
        }
    }
}