dump text runs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143837 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-07 14:14:37 +00:00
parent 78a951143f
commit a69d691581

View 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() )