Search in sources :

Example 1 with PlexOfCps

use of org.apache.poi.hwpf.model.PlexOfCps in project poi by apache.

the class HWPFLister method dumpPapx.

public void dumpPapx(boolean withProperties, boolean withSprms) throws Exception {
    if (_doc instanceof HWPFDocument) {
        System.out.println("binary PAP pages ");
        HWPFDocument doc = (HWPFDocument) _doc;
        byte[] mainStream = _doc.getMainStream();
        PlexOfCps binTable = new PlexOfCps(doc.getTableStream(), doc.getFileInformationBlock().getFcPlcfbtePapx(), doc.getFileInformationBlock().getLcbPlcfbtePapx(), 4);
        List<PAPX> papxs = new ArrayList<PAPX>();
        int length = binTable.length();
        for (int x = 0; x < length; x++) {
            GenericPropertyNode node = binTable.getProperty(x);
            int pageNum = LittleEndian.getInt(node.getBytes());
            int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
            PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(mainStream, doc.getDataStream(), pageOffset, doc.getTextTable());
            System.out.println("* PFKP: " + pfkp);
            for (PAPX papx : pfkp.getPAPXs()) {
                System.out.println("** " + papx);
                papxs.add(papx);
                if (papx != null && withSprms) {
                    SprmIterator sprmIt = new SprmIterator(papx.getGrpprl(), 2);
                    dumpSprms(sprmIt, "*** ");
                }
            }
        }
        Collections.sort(papxs);
        System.out.println("* Sorted by END");
        for (PAPX papx : papxs) {
            System.out.println("** " + papx);
            if (papx != null && withSprms) {
                SprmIterator sprmIt = new SprmIterator(papx.getGrpprl(), 2);
                dumpSprms(sprmIt, "*** ");
            }
        }
    }
    for (PAPX papx : _doc.getParagraphTable().getParagraphs()) {
        System.out.println(papx);
        if (withProperties) {
            Paragraph paragraph = Paragraph.newParagraph(_doc.getOverallRange(), papx);
            System.out.println(paragraph.getProps());
        }
        SprmIterator sprmIt = new SprmIterator(papx.getGrpprl(), 2);
        dumpSprms(sprmIt, "\t");
    }
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) SprmIterator(org.apache.poi.hwpf.sprm.SprmIterator) PlexOfCps(org.apache.poi.hwpf.model.PlexOfCps) ArrayList(java.util.ArrayList) PAPFormattedDiskPage(org.apache.poi.hwpf.model.PAPFormattedDiskPage) PAPX(org.apache.poi.hwpf.model.PAPX) GenericPropertyNode(org.apache.poi.hwpf.model.GenericPropertyNode) Paragraph(org.apache.poi.hwpf.usermodel.Paragraph)

Aggregations

ArrayList (java.util.ArrayList)1 HWPFDocument (org.apache.poi.hwpf.HWPFDocument)1 GenericPropertyNode (org.apache.poi.hwpf.model.GenericPropertyNode)1 PAPFormattedDiskPage (org.apache.poi.hwpf.model.PAPFormattedDiskPage)1 PAPX (org.apache.poi.hwpf.model.PAPX)1 PlexOfCps (org.apache.poi.hwpf.model.PlexOfCps)1 SprmIterator (org.apache.poi.hwpf.sprm.SprmIterator)1 Paragraph (org.apache.poi.hwpf.usermodel.Paragraph)1