From a69d691581fee80353f9499973ee145f96156ca6 Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Thu, 7 Jul 2011 14:14:37 +0000 Subject: [PATCH] dump text runs git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143837 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hwpf/dev/HWPFLister.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java b/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java index 0564dba20..f85e2f1c5 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java @@ -29,6 +29,7 @@ import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFDocumentCore; import org.apache.poi.hwpf.HWPFOldDocument; import org.apache.poi.hwpf.OldWordFileFormatException; +import org.apache.poi.hwpf.model.CHPX; import org.apache.poi.hwpf.model.FileInformationBlock; import org.apache.poi.hwpf.model.PAPX; import org.apache.poi.hwpf.model.TextPiece; @@ -84,6 +85,7 @@ public final class HWPFLister System.err .println( "\tHWPFLister \n" + "\t\t[--textPieces] [--textPiecesText]\n" + + "\t\t[--textRuns] [--textRunsSprms]\n" + "\t\t[--papx] [--papxProperties]\n" + "\t\t[--paragraphs] [--paragraphsSprms] [--paragraphsText]\n" + "\t\t[--writereadback]\n" ); @@ -93,6 +95,9 @@ public final class HWPFLister boolean outputTextPieces = false; boolean outputTextPiecesText = false; + boolean outputTextRuns = false; + boolean outputTextRunsSprms = false; + boolean outputParagraphs = false; boolean outputParagraphsSprms = false; boolean outputParagraphsText = false; @@ -109,6 +114,11 @@ public final class HWPFLister if ( "--textPiecesText".equals( arg ) ) outputTextPiecesText = true; + if ( "--textRuns".equals( arg ) ) + outputTextRuns = true; + if ( "--textRunsSprms".equals( arg ) ) + outputTextRunsSprms = true; + if ( "--paragraphs".equals( arg ) ) outputParagraphs = true; if ( "--paragraphsSprms".equals( arg ) ) @@ -138,6 +148,12 @@ public final class HWPFLister lister.dumpTextPieces( outputTextPiecesText ); } + if ( outputTextRuns ) + { + System.out.println( "== Text runs ==" ); + lister.dumpTextRuns( outputTextRunsSprms ); + } + if ( outputParagraphs ) { System.out.println( "== Paragraphs ==" ); @@ -220,6 +236,23 @@ public final class HWPFLister } } + public void dumpTextRuns( boolean withSprms ) + { + for ( CHPX chpx : _doc.getCharacterTable().getTextRuns() ) + { + System.out.println( chpx ); + + if ( withSprms ) + { + SprmIterator sprmIt = new SprmIterator( chpx.getGrpprl(), 2 ); + while ( sprmIt.hasNext() ) + { + SprmOperation sprm = sprmIt.next(); + System.out.println( "\t" + sprm.toString() ); + } + } + } + } public void dumpTextPieces( boolean withText ) { for ( TextPiece textPiece : _doc.getTextTable().getTextPieces() )