Search in sources :

Example 1 with QCBit

use of org.apache.poi.hpbf.model.qcbits.QCBit in project poi by apache.

the class PublisherTextExtractor method getText.

public String getText() {
    StringBuffer text = new StringBuffer();
    // Get the text from the Quill Contents
    QCBit[] bits = doc.getQuillContents().getBits();
    for (int i = 0; i < bits.length; i++) {
        if (bits[i] != null && bits[i] instanceof QCTextBit) {
            QCTextBit t = (QCTextBit) bits[i];
            text.append(t.getText().replace('\r', '\n'));
        }
    }
    //  how to tie that together.
    if (hyperlinksByDefault) {
        for (int i = 0; i < bits.length; i++) {
            if (bits[i] != null && bits[i] instanceof Type12) {
                Type12 hyperlinks = (Type12) bits[i];
                for (int j = 0; j < hyperlinks.getNumberOfHyperlinks(); j++) {
                    text.append("<");
                    text.append(hyperlinks.getHyperlink(j));
                    text.append(">\n");
                }
            }
        }
    }
    return text.toString();
}
Also used : QCTextBit(org.apache.poi.hpbf.model.qcbits.QCTextBit) QCBit(org.apache.poi.hpbf.model.qcbits.QCBit) Type12(org.apache.poi.hpbf.model.qcbits.QCPLCBit.Type12)

Aggregations

QCBit (org.apache.poi.hpbf.model.qcbits.QCBit)1 Type12 (org.apache.poi.hpbf.model.qcbits.QCPLCBit.Type12)1 QCTextBit (org.apache.poi.hpbf.model.qcbits.QCTextBit)1