Search in sources :

Example 6 with SprmIterator

use of org.apache.poi.hwpf.sprm.SprmIterator in project poi by apache.

the class HWPFLister method dumpParagraphs.

public void dumpParagraphs(boolean dumpAssotiatedPapx) {
    for (Map.Entry<Integer, String> entry : paragraphs.entrySet()) {
        Integer endOfParagraphCharOffset = entry.getKey();
        System.out.println("[...; " + (endOfParagraphCharOffset + 1) + "): " + entry.getValue());
        if (dumpAssotiatedPapx) {
            boolean hasAssotiatedPapx = false;
            for (PAPX papx : _doc.getParagraphTable().getParagraphs()) {
                if (papx.getStart() <= endOfParagraphCharOffset.intValue() && endOfParagraphCharOffset.intValue() < papx.getEnd()) {
                    hasAssotiatedPapx = true;
                    System.out.println("* " + papx);
                    SprmIterator sprmIt = new SprmIterator(papx.getGrpprl(), 2);
                    dumpSprms(sprmIt, "** ");
                }
            }
            if (!hasAssotiatedPapx) {
                System.out.println("* " + "NO PAPX ASSOTIATED WITH PARAGRAPH!");
            }
        }
    }
}
Also used : SprmIterator(org.apache.poi.hwpf.sprm.SprmIterator) PAPX(org.apache.poi.hwpf.model.PAPX) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 7 with SprmIterator

use of org.apache.poi.hwpf.sprm.SprmIterator in project poi by apache.

the class HWPFLister method dumpChpx.

public void dumpChpx(boolean withProperties, boolean withSprms) {
    for (CHPX chpx : _doc.getCharacterTable().getTextRuns()) {
        System.out.println(chpx);
        if (withProperties) {
            System.out.println(chpx.getCharacterProperties(_doc.getStyleSheet(), (short) StyleSheet.NIL_STYLE));
        }
        if (withSprms) {
            SprmIterator sprmIt = new SprmIterator(chpx.getGrpprl(), 0);
            while (sprmIt.hasNext()) {
                SprmOperation sprm = sprmIt.next();
                System.out.println("\t" + sprm);
            }
        }
        String text = new Range(chpx.getStart(), chpx.getEnd(), _doc.getOverallRange()) {

            public String toString() {
                return "CHPX range (" + super.toString() + ")";
            }
        }.text();
        StringBuilder stringBuilder = new StringBuilder();
        for (char c : text.toCharArray()) {
            if (c < 30)
                stringBuilder.append("\\0x").append(Integer.toHexString(c));
            else
                stringBuilder.append(c);
        }
        System.out.println(stringBuilder);
    }
}
Also used : CHPX(org.apache.poi.hwpf.model.CHPX) SprmIterator(org.apache.poi.hwpf.sprm.SprmIterator) SprmOperation(org.apache.poi.hwpf.sprm.SprmOperation) Range(org.apache.poi.hwpf.usermodel.Range)

Aggregations

SprmIterator (org.apache.poi.hwpf.sprm.SprmIterator)7 ArrayList (java.util.ArrayList)3 SprmOperation (org.apache.poi.hwpf.sprm.SprmOperation)3 Comparator (java.util.Comparator)2 IdentityHashMap (java.util.IdentityHashMap)2 LinkedList (java.util.LinkedList)2 HWPFDocument (org.apache.poi.hwpf.HWPFDocument)2 PAPX (org.apache.poi.hwpf.model.PAPX)2 SprmBuffer (org.apache.poi.hwpf.sprm.SprmBuffer)2 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 HWPFOldDocument (org.apache.poi.hwpf.HWPFOldDocument)1 CHPX (org.apache.poi.hwpf.model.CHPX)1 GenericPropertyNode (org.apache.poi.hwpf.model.GenericPropertyNode)1 LFO (org.apache.poi.hwpf.model.LFO)1 LFOData (org.apache.poi.hwpf.model.LFOData)1 ListLevel (org.apache.poi.hwpf.model.ListLevel)1 PAPFormattedDiskPage (org.apache.poi.hwpf.model.PAPFormattedDiskPage)1