]> source.dussan.org Git - poi.git/commitdiff
dump text runs
authorSergey Vladimirov <sergey@apache.org>
Thu, 7 Jul 2011 14:14:37 +0000 (14:14 +0000)
committerSergey Vladimirov <sergey@apache.org>
Thu, 7 Jul 2011 14:14:37 +0000 (14:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143837 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java

index 0564dba207de1199572981afda17c22bcf92bf9a..f85e2f1c54747152b61803ec0a44234ab20c6250 100644 (file)
@@ -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 <filename>\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() )