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!");
}
}
}
}
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);
}
}
Aggregations