Example usage for org.apache.poi.xwpf.usermodel XWPFParagraph getCTP

List of usage examples for org.apache.poi.xwpf.usermodel XWPFParagraph getCTP

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFParagraph getCTP.

Prototype

@Internal
    public CTP getCTP() 

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  ww w. ja v a  2s  .  com*/
        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);
        }
    }
}