Set NOSONAR and reformat code

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1844876 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2018-10-26 09:32:19 +00:00
parent e0ad9625f5
commit 8bf6a26751
2 changed files with 102 additions and 201 deletions

View File

@ -75,33 +75,25 @@ import org.apache.poi.util.LittleEndian;
* @author Sergey Vladimirov (vlsergey at gmail dot com) * @author Sergey Vladimirov (vlsergey at gmail dot com)
*/ */
@Beta @Beta
public final class HWPFLister public final class HWPFLister {
{ private static HWPFDocumentCore loadDoc( File docFile ) throws IOException {
private static HWPFDocumentCore loadDoc( File docFile ) throws IOException
{
try (final FileInputStream istream = new FileInputStream( docFile )) { try (final FileInputStream istream = new FileInputStream( docFile )) {
return loadDoc( istream ); return loadDoc( istream );
} }
} }
private static HWPFDocumentCore loadDoc( InputStream inputStream ) private static HWPFDocumentCore loadDoc( InputStream inputStream )
throws IOException throws IOException {
{ final POIFSFileSystem poifsFileSystem = HWPFDocumentCore.verifyAndBuildPOIFS( inputStream ); // NOSONAR
final POIFSFileSystem poifsFileSystem = HWPFDocumentCore.verifyAndBuildPOIFS( inputStream ); try {
try
{
return new HWPFDocument( poifsFileSystem ); return new HWPFDocument( poifsFileSystem );
} } catch ( OldWordFileFormatException exc ) {
catch ( OldWordFileFormatException exc )
{
return new HWPFOldDocument( poifsFileSystem ); return new HWPFOldDocument( poifsFileSystem );
} }
} }
public static void main( String[] args ) throws Exception public static void main( String[] args ) throws Exception {
{ if ( args.length == 0 ) {
if ( args.length == 0 )
{
System.err.println( "Use:" ); System.err.println( "Use:" );
System.err.println( "\tHWPFLister <filename>\n" + "\t\t[--dop]\n" System.err.println( "\tHWPFLister <filename>\n" + "\t\t[--dop]\n"
+ "\t\t[--textPieces] [--textPiecesText]\n" + "\t\t[--textPieces] [--textPiecesText]\n"
@ -140,8 +132,7 @@ public final class HWPFLister
boolean writereadback = false; boolean writereadback = false;
for ( String arg : Arrays.asList( args ).subList( 1, args.length ) ) for ( String arg : Arrays.asList( args ).subList( 1, args.length ) ) {
{
if ( "--dop".equals( arg ) ) if ( "--dop".equals( arg ) )
outputDop = true; outputDop = true;
@ -190,17 +181,14 @@ public final class HWPFLister
if ( writereadback ) if ( writereadback )
doc = writeOutAndReadBack( doc ); doc = writeOutAndReadBack( doc );
HWPFDocumentCore original; System.setProperty( "org.apache.poi.hwpf.preserveBinTables",
{ Boolean.TRUE.toString() );
System.setProperty( "org.apache.poi.hwpf.preserveBinTables", System.setProperty( "org.apache.poi.hwpf.preserveTextTable",
Boolean.TRUE.toString() ); Boolean.TRUE.toString() );
System.setProperty( "org.apache.poi.hwpf.preserveTextTable",
Boolean.TRUE.toString() );
original = loadDoc( new File( args[0] ) ); HWPFDocumentCore original = loadDoc( new File( args[0] ) );
if ( writereadback ) if ( writereadback )
original = writeOutAndReadBack( original ); original = writeOutAndReadBack( original );
}
HWPFLister listerOriginal = new HWPFLister( original ); HWPFLister listerOriginal = new HWPFLister( original );
HWPFLister listerRebuilded = new HWPFLister( doc ); HWPFLister listerRebuilded = new HWPFLister( doc );
@ -211,20 +199,17 @@ public final class HWPFLister
System.out.println( "== FIB (original) ==" ); System.out.println( "== FIB (original) ==" );
listerOriginal.dumpFIB(); listerOriginal.dumpFIB();
if ( outputDop ) if ( outputDop ) {
{
System.out.println( "== Document properties ==" ); System.out.println( "== Document properties ==" );
listerOriginal.dumpDop(); listerOriginal.dumpDop();
} }
if ( outputTextPieces ) if ( outputTextPieces ) {
{
System.out.println( "== Text pieces (original) ==" ); System.out.println( "== Text pieces (original) ==" );
listerOriginal.dumpTextPieces( outputTextPiecesText ); listerOriginal.dumpTextPieces( outputTextPiecesText );
} }
if ( outputChpx ) if ( outputChpx ) {
{
System.out.println( "== CHPX (original) ==" ); System.out.println( "== CHPX (original) ==" );
listerOriginal.dumpChpx( outputChpxProperties, outputChpxSprms ); listerOriginal.dumpChpx( outputChpxProperties, outputChpxSprms );
@ -232,8 +217,7 @@ public final class HWPFLister
listerRebuilded.dumpChpx( outputChpxProperties, outputChpxSprms ); listerRebuilded.dumpChpx( outputChpxProperties, outputChpxSprms );
} }
if ( outputPapx ) if ( outputPapx ) {
{
System.out.println( "== PAPX (original) ==" ); System.out.println( "== PAPX (original) ==" );
listerOriginal.dumpPapx( outputPapxProperties, outputPapxSprms ); listerOriginal.dumpPapx( outputPapxProperties, outputPapxSprms );
@ -241,8 +225,7 @@ public final class HWPFLister
listerRebuilded.dumpPapx( outputPapxProperties, outputPapxSprms ); listerRebuilded.dumpPapx( outputPapxProperties, outputPapxSprms );
} }
if ( outputParagraphs ) if ( outputParagraphs ) {
{
System.out.println( "== Text paragraphs (original) ==" ); System.out.println( "== Text paragraphs (original) ==" );
listerRebuilded.dumpParagraphs( true ); listerRebuilded.dumpParagraphs( true );
@ -250,56 +233,47 @@ public final class HWPFLister
listerRebuilded.dumpParagraphsDom( outputParagraphsText ); listerRebuilded.dumpParagraphsDom( outputParagraphsText );
} }
if ( outputBookmarks ) if ( outputBookmarks ) {
{
System.out.println( "== BOOKMARKS (rebuilded) ==" ); System.out.println( "== BOOKMARKS (rebuilded) ==" );
listerRebuilded.dumpBookmarks(); listerRebuilded.dumpBookmarks();
} }
if ( outputEscher ) if ( outputEscher ) {
{
System.out.println( "== ESCHER PROPERTIES (rebuilded) ==" ); System.out.println( "== ESCHER PROPERTIES (rebuilded) ==" );
listerRebuilded.dumpEscher(); listerRebuilded.dumpEscher();
} }
if ( outputFields ) if ( outputFields ) {
{
System.out.println( "== FIELDS (rebuilded) ==" ); System.out.println( "== FIELDS (rebuilded) ==" );
listerRebuilded.dumpFields(); listerRebuilded.dumpFields();
} }
if ( outputOfficeDrawings ) if ( outputOfficeDrawings ) {
{
System.out.println( "== OFFICE DRAWINGS (rebuilded) ==" ); System.out.println( "== OFFICE DRAWINGS (rebuilded) ==" );
listerRebuilded.dumpOfficeDrawings(); listerRebuilded.dumpOfficeDrawings();
} }
if ( outputPictures ) if ( outputPictures ) {
{
System.out.println( "== PICTURES (rebuilded) ==" ); System.out.println( "== PICTURES (rebuilded) ==" );
listerRebuilded.dumpPictures(); listerRebuilded.dumpPictures();
} }
if ( outputStyles ) if ( outputStyles ) {
{
System.out.println( "== STYLES (rebuilded) ==" ); System.out.println( "== STYLES (rebuilded) ==" );
listerRebuilded.dumpStyles(); listerRebuilded.dumpStyles();
} }
} }
private static HWPFDocumentCore writeOutAndReadBack( private static HWPFDocumentCore writeOutAndReadBack(
HWPFDocumentCore original ) HWPFDocumentCore original ) {
{ try {
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream( 4096 ); ByteArrayOutputStream baos = new ByteArrayOutputStream( 4096 );
original.write( baos ); original.write( baos );
ByteArrayInputStream bais = new ByteArrayInputStream( ByteArrayInputStream bais = new ByteArrayInputStream(
baos.toByteArray() ); baos.toByteArray() );
return loadDoc( bais ); return loadDoc( bais );
} }
catch ( IOException e ) catch ( IOException e ) {
{
throw new RuntimeException( e ); throw new RuntimeException( e );
} }
} }
@ -308,82 +282,67 @@ public final class HWPFLister
private LinkedHashMap<Integer, String> paragraphs; private LinkedHashMap<Integer, String> paragraphs;
public HWPFLister( HWPFDocumentCore doc ) public HWPFLister( HWPFDocumentCore doc ) {
{
_doc = doc; _doc = doc;
buildParagraphs(); buildParagraphs();
} }
private void buildParagraphs() private void buildParagraphs() {
{
paragraphs = new LinkedHashMap<>(); paragraphs = new LinkedHashMap<>();
StringBuilder part = new StringBuilder(); StringBuilder part = new StringBuilder();
String text = _doc.getDocumentText(); String text = _doc.getDocumentText();
for ( int charIndex = 0; charIndex < text.length(); charIndex++ ) for ( int charIndex = 0; charIndex < text.length(); charIndex++ ) {
{
char c = text.charAt( charIndex ); char c = text.charAt( charIndex );
part.append( c ); part.append( c );
if ( c == 13 || c == 7 || c == 12 ) if ( c == 13 || c == 7 || c == 12 ) {
{
paragraphs.put( Integer.valueOf( charIndex ), part.toString() ); paragraphs.put( Integer.valueOf( charIndex ), part.toString() );
part.setLength( 0 ); part.setLength( 0 );
} }
} }
} }
private void dumpBookmarks() private void dumpBookmarks() {
{ if ( !( _doc instanceof HWPFDocument ) ) {
if ( !( _doc instanceof HWPFDocument ) )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
HWPFDocument document = (HWPFDocument) _doc; HWPFDocument document = (HWPFDocument) _doc;
Bookmarks bookmarks = document.getBookmarks(); Bookmarks bookmarks = document.getBookmarks();
for ( int b = 0; b < bookmarks.getBookmarksCount(); b++ ) for ( int b = 0; b < bookmarks.getBookmarksCount(); b++ ) {
{
Bookmark bookmark = bookmarks.getBookmark( b ); Bookmark bookmark = bookmarks.getBookmark( b );
System.out.println( "[" + bookmark.getStart() + "; " System.out.println( "[" + bookmark.getStart() + "; "
+ bookmark.getEnd() + "): " + bookmark.getName() ); + bookmark.getEnd() + "): " + bookmark.getName() );
} }
} }
public void dumpChpx( boolean withProperties, boolean withSprms ) public void dumpChpx( boolean withProperties, boolean withSprms ) {
{ for ( CHPX chpx : _doc.getCharacterTable().getTextRuns() ) {
for ( CHPX chpx : _doc.getCharacterTable().getTextRuns() )
{
System.out.println( chpx ); System.out.println( chpx );
if ( withProperties ) if ( withProperties ) {
{
System.out.println( chpx.getCharacterProperties( System.out.println( chpx.getCharacterProperties(
_doc.getStyleSheet(), (short) StyleSheet.NIL_STYLE ) ); _doc.getStyleSheet(), (short) StyleSheet.NIL_STYLE ) );
} }
if ( withSprms ) if ( withSprms ) {
{
SprmIterator sprmIt = new SprmIterator( chpx.getGrpprl(), 0 ); SprmIterator sprmIt = new SprmIterator( chpx.getGrpprl(), 0 );
while ( sprmIt.hasNext() ) while ( sprmIt.hasNext() ) {
{
SprmOperation sprm = sprmIt.next(); SprmOperation sprm = sprmIt.next();
System.out.println( "\t" + sprm); System.out.println( "\t" + sprm);
} }
} }
String text = new Range( chpx.getStart(), chpx.getEnd(), String text = new Range( chpx.getStart(), chpx.getEnd(),
_doc.getOverallRange() ) _doc.getOverallRange() ) {
{ public String toString() {
public String toString()
{
return "CHPX range (" + super.toString() + ")"; return "CHPX range (" + super.toString() + ")";
} }
}.text(); }.text();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for ( char c : text.toCharArray() ) for ( char c : text.toCharArray() ) {
{
if ( c < 30 ) if ( c < 30 )
stringBuilder.append("\\0x").append(Integer.toHexString(c)); stringBuilder.append("\\0x").append(Integer.toHexString(c));
else else
@ -393,10 +352,8 @@ public final class HWPFLister
} }
} }
private void dumpDop() private void dumpDop() {
{ if ( !( _doc instanceof HWPFDocument ) ) {
if ( !( _doc instanceof HWPFDocument ) )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
@ -404,10 +361,8 @@ public final class HWPFLister
System.out.println( ( (HWPFDocument) _doc ).getDocProperties() ); System.out.println( ( (HWPFDocument) _doc ).getDocProperties() );
} }
private void dumpEscher() private void dumpEscher() {
{ if ( _doc instanceof HWPFOldDocument ) {
if ( _doc instanceof HWPFOldDocument )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
@ -415,46 +370,38 @@ public final class HWPFLister
System.out.println( ( (HWPFDocument) _doc ).getEscherRecordHolder() ); System.out.println( ( (HWPFDocument) _doc ).getEscherRecordHolder() );
} }
public void dumpFIB() public void dumpFIB() {
{
FileInformationBlock fib = _doc.getFileInformationBlock(); FileInformationBlock fib = _doc.getFileInformationBlock();
System.out.println( fib ); System.out.println( fib );
} }
private void dumpFields() private void dumpFields() {
{ if ( !( _doc instanceof HWPFDocument ) ) {
if ( !( _doc instanceof HWPFDocument ) )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
HWPFDocument document = (HWPFDocument) _doc; HWPFDocument document = (HWPFDocument) _doc;
for ( FieldsDocumentPart part : FieldsDocumentPart.values() ) for ( FieldsDocumentPart part : FieldsDocumentPart.values() ) {
{
System.out.println( "=== Document part: " + part + " ===" ); System.out.println( "=== Document part: " + part + " ===" );
for ( Field field : document.getFields().getFields( part ) ) for ( Field field : document.getFields().getFields( part ) ) {
{
System.out.println( field ); System.out.println( field );
} }
} }
} }
public void dumpFileSystem() throws Exception public void dumpFileSystem() throws Exception {
{
System.out.println( dumpFileSystem( _doc.getDirectory() ) ); System.out.println( dumpFileSystem( _doc.getDirectory() ) );
} }
private String dumpFileSystem( DirectoryEntry directory ) private String dumpFileSystem( DirectoryEntry directory ) {
{
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
result.append( "+ " ); result.append( "+ " );
result.append( directory.getName() ); result.append( directory.getName() );
for ( Iterator<Entry> iterator = directory.getEntries(); iterator for ( Iterator<Entry> iterator = directory.getEntries(); iterator
.hasNext(); ) .hasNext(); ) {
{
Entry entry = iterator.next(); Entry entry = iterator.next();
String entryToString = "\n" + dumpFileSystem( entry ); String entryToString = "\n" + dumpFileSystem( entry );
entryToString = entryToString.replaceAll( "\n", "\n+---" ); entryToString = entryToString.replaceAll( "\n", "\n+---" );
@ -464,50 +411,41 @@ public final class HWPFLister
return result.toString(); return result.toString();
} }
private String dumpFileSystem( Entry entry ) private String dumpFileSystem( Entry entry ) {
{
if ( entry instanceof DirectoryEntry ) if ( entry instanceof DirectoryEntry )
return dumpFileSystem( (DirectoryEntry) entry ); return dumpFileSystem( (DirectoryEntry) entry );
return entry.getName(); return entry.getName();
} }
private void dumpOfficeDrawings() private void dumpOfficeDrawings() {
{ if ( !( _doc instanceof HWPFDocument ) ) {
if ( !( _doc instanceof HWPFDocument ) )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
HWPFDocument document = (HWPFDocument) _doc; HWPFDocument document = (HWPFDocument) _doc;
if ( document.getOfficeDrawingsHeaders() != null ) if ( document.getOfficeDrawingsHeaders() != null ) {
{
System.out.println( "=== Document part: HEADER ===" ); System.out.println( "=== Document part: HEADER ===" );
for ( OfficeDrawing officeDrawing : document for ( OfficeDrawing officeDrawing : document
.getOfficeDrawingsHeaders().getOfficeDrawings() ) .getOfficeDrawingsHeaders().getOfficeDrawings() ) {
{
System.out.println( officeDrawing ); System.out.println( officeDrawing );
} }
} }
if ( document.getOfficeDrawingsHeaders() != null ) if ( document.getOfficeDrawingsHeaders() != null ) {
{
System.out.println( "=== Document part: MAIN ===" ); System.out.println( "=== Document part: MAIN ===" );
for ( OfficeDrawing officeDrawing : document for ( OfficeDrawing officeDrawing : document
.getOfficeDrawingsMain().getOfficeDrawings() ) .getOfficeDrawingsMain().getOfficeDrawings() ) {
{
System.out.println( officeDrawing ); System.out.println( officeDrawing );
} }
} }
} }
public void dumpPapx( boolean withProperties, boolean withSprms ) public void dumpPapx( boolean withProperties, boolean withSprms )
throws Exception throws Exception {
{ if ( _doc instanceof HWPFDocument ) {
if ( _doc instanceof HWPFDocument )
{
System.out.println( "binary PAP pages " ); System.out.println( "binary PAP pages " );
HWPFDocument doc = (HWPFDocument) _doc; HWPFDocument doc = (HWPFDocument) _doc;
@ -521,8 +459,7 @@ public final class HWPFLister
List<PAPX> papxs = new ArrayList<>(); List<PAPX> papxs = new ArrayList<>();
int length = binTable.length(); int length = binTable.length();
for ( int x = 0; x < length; x++ ) for ( int x = 0; x < length; x++ ) {
{
GenericPropertyNode node = binTable.getProperty( x ); GenericPropertyNode node = binTable.getProperty( x );
int pageNum = LittleEndian.getInt( node.getBytes() ); int pageNum = LittleEndian.getInt( node.getBytes() );
@ -535,12 +472,10 @@ public final class HWPFLister
System.out.println( "* PFKP: " + pfkp ); System.out.println( "* PFKP: " + pfkp );
for ( PAPX papx : pfkp.getPAPXs() ) for ( PAPX papx : pfkp.getPAPXs() ) {
{
System.out.println( "** " + papx ); System.out.println( "** " + papx );
papxs.add( papx ); papxs.add( papx );
if ( papx != null && withSprms ) if ( papx != null && withSprms ) {
{
SprmIterator sprmIt = new SprmIterator( SprmIterator sprmIt = new SprmIterator(
papx.getGrpprl(), 2 ); papx.getGrpprl(), 2 );
dumpSprms( sprmIt, "*** " ); dumpSprms( sprmIt, "*** " );
@ -551,11 +486,9 @@ public final class HWPFLister
Collections.sort( papxs ); Collections.sort( papxs );
System.out.println( "* Sorted by END" ); System.out.println( "* Sorted by END" );
for ( PAPX papx : papxs ) for ( PAPX papx : papxs ) {
{
System.out.println( "** " + papx ); System.out.println( "** " + papx );
if ( papx != null && withSprms ) if ( papx != null && withSprms ) {
{
SprmIterator sprmIt = new SprmIterator( papx.getGrpprl(), 2 ); SprmIterator sprmIt = new SprmIterator( papx.getGrpprl(), 2 );
dumpSprms( sprmIt, "*** " ); dumpSprms( sprmIt, "*** " );
} }
@ -563,12 +496,10 @@ public final class HWPFLister
} }
for ( PAPX papx : _doc.getParagraphTable().getParagraphs() ) for ( PAPX papx : _doc.getParagraphTable().getParagraphs() ) {
{
System.out.println( papx ); System.out.println( papx );
if ( withProperties ) if ( withProperties ) {
{
Paragraph paragraph = Paragraph.newParagraph( _doc.getOverallRange(), papx ); Paragraph paragraph = Paragraph.newParagraph( _doc.getOverallRange(), papx );
System.out.println( paragraph.getProps() ); System.out.println( paragraph.getProps() );
} }
@ -578,23 +509,18 @@ public final class HWPFLister
} }
} }
public void dumpParagraphs( boolean dumpAssotiatedPapx ) public void dumpParagraphs( boolean dumpAssotiatedPapx ) {
{ for ( Map.Entry<Integer, String> entry : paragraphs.entrySet() ) {
for ( Map.Entry<Integer, String> entry : paragraphs.entrySet() )
{
Integer endOfParagraphCharOffset = entry.getKey(); Integer endOfParagraphCharOffset = entry.getKey();
System.out.println( "[...; " + ( endOfParagraphCharOffset + 1 ) System.out.println( "[...; " + ( endOfParagraphCharOffset + 1 )
+ "): " + entry.getValue() ); + "): " + entry.getValue() );
if ( dumpAssotiatedPapx ) if ( dumpAssotiatedPapx ) {
{
boolean hasAssotiatedPapx = false; boolean hasAssotiatedPapx = false;
for ( PAPX papx : _doc.getParagraphTable().getParagraphs() ) for ( PAPX papx : _doc.getParagraphTable().getParagraphs() ) {
{
if ( papx.getStart() <= endOfParagraphCharOffset.intValue() if ( papx.getStart() <= endOfParagraphCharOffset.intValue()
&& endOfParagraphCharOffset.intValue() < papx && endOfParagraphCharOffset.intValue() < papx
.getEnd() ) .getEnd() ) {
{
hasAssotiatedPapx = true; hasAssotiatedPapx = true;
System.out.println( "* " + papx ); System.out.println( "* " + papx );
@ -603,8 +529,7 @@ public final class HWPFLister
dumpSprms( sprmIt, "** " ); dumpSprms( sprmIt, "** " );
} }
} }
if ( !hasAssotiatedPapx ) if ( !hasAssotiatedPapx ) {
{
System.out.println( "* " System.out.println( "* "
+ "NO PAPX ASSOTIATED WITH PARAGRAPH!" ); + "NO PAPX ASSOTIATED WITH PARAGRAPH!" );
} }
@ -612,20 +537,16 @@ public final class HWPFLister
} }
} }
protected void dumpSprms( SprmIterator sprmIt, String linePrefix ) protected void dumpSprms( SprmIterator sprmIt, String linePrefix ) {
{ while ( sprmIt.hasNext() ) {
while ( sprmIt.hasNext() )
{
SprmOperation sprm = sprmIt.next(); SprmOperation sprm = sprmIt.next();
System.out.println( linePrefix + sprm); System.out.println( linePrefix + sprm);
} }
} }
public void dumpParagraphsDom( boolean withText ) public void dumpParagraphsDom( boolean withText ) {
{
Range range = _doc.getOverallRange(); Range range = _doc.getOverallRange();
for ( int p = 0; p < range.numParagraphs(); p++ ) for ( int p = 0; p < range.numParagraphs(); p++ ) {
{
Paragraph paragraph = range.getParagraph( p ); Paragraph paragraph = range.getParagraph( p );
System.out.println( p + ":\t" + paragraph); System.out.println( p + ":\t" + paragraph);
@ -634,33 +555,27 @@ public final class HWPFLister
} }
} }
private void dumpPictures() private void dumpPictures() {
{ if ( _doc instanceof HWPFOldDocument ) {
if ( _doc instanceof HWPFOldDocument )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
List<Picture> allPictures = ( (HWPFDocument) _doc ).getPicturesTable() List<Picture> allPictures = ( (HWPFDocument) _doc ).getPicturesTable()
.getAllPictures(); .getAllPictures();
for ( Picture picture : allPictures ) for ( Picture picture : allPictures ) {
{
System.out.println(picture); System.out.println(picture);
} }
} }
private void dumpStyles() private void dumpStyles() {
{ if ( _doc instanceof HWPFOldDocument ) {
if ( _doc instanceof HWPFOldDocument )
{
System.out.println( "Word 95 not supported so far" ); System.out.println( "Word 95 not supported so far" );
return; return;
} }
HWPFDocument hwpfDocument = (HWPFDocument) _doc; HWPFDocument hwpfDocument = (HWPFDocument) _doc;
for ( int s = 0; s < hwpfDocument.getStyleSheet().numStyles(); s++ ) for ( int s = 0; s < hwpfDocument.getStyleSheet().numStyles(); s++ ) {
{
StyleDescription styleDescription = hwpfDocument.getStyleSheet() StyleDescription styleDescription = hwpfDocument.getStyleSheet()
.getStyleDescription( s ); .getStyleDescription( s );
if ( styleDescription == null ) if ( styleDescription == null )
@ -681,32 +596,27 @@ public final class HWPFLister
} }
protected void dumpParagraphLevels( ListTables listTables, protected void dumpParagraphLevels( ListTables listTables,
ParagraphProperties paragraph ) ParagraphProperties paragraph ) {
{ if ( paragraph.getIlfo() != 0 ) {
if ( paragraph.getIlfo() != 0 )
{
final LFO lfo = listTables.getLfo( paragraph.getIlfo() ); final LFO lfo = listTables.getLfo( paragraph.getIlfo() );
System.out.println( "PAP's LFO: " + lfo ); System.out.println( "PAP's LFO: " + lfo );
final LFOData lfoData = listTables.getLfoData( paragraph.getIlfo() ); final LFOData lfoData = listTables.getLfoData( paragraph.getIlfo() );
System.out.println( "PAP's LFOData: " + lfoData ); System.out.println( "PAP's LFOData: " + lfoData );
if ( lfo != null ) if ( lfo != null ) {
{
final ListLevel listLevel = listTables.getLevel( lfo.getLsid(), final ListLevel listLevel = listTables.getLevel( lfo.getLsid(),
paragraph.getIlvl() ); paragraph.getIlvl() );
System.out.println( "PAP's ListLevel: " + listLevel ); System.out.println( "PAP's ListLevel: " + listLevel );
if ( listLevel.getGrpprlPapx() != null ) if ( listLevel.getGrpprlPapx() != null ) {
{
System.out.println( "PAP's ListLevel PAPX:" ); System.out.println( "PAP's ListLevel PAPX:" );
dumpSprms( dumpSprms(
new SprmIterator( listLevel.getGrpprlPapx(), 0 ), new SprmIterator( listLevel.getGrpprlPapx(), 0 ),
"* " ); "* " );
} }
if ( listLevel.getGrpprlPapx() != null ) if ( listLevel.getGrpprlPapx() != null ) {
{
System.out.println( "PAP's ListLevel CHPX:" ); System.out.println( "PAP's ListLevel CHPX:" );
dumpSprms( dumpSprms(
new SprmIterator( listLevel.getGrpprlChpx(), 0 ), new SprmIterator( listLevel.getGrpprlChpx(), 0 ),
@ -716,14 +626,11 @@ public final class HWPFLister
} }
} }
public void dumpTextPieces( boolean withText ) public void dumpTextPieces( boolean withText ) {
{ for ( TextPiece textPiece : _doc.getTextTable().getTextPieces() ) {
for ( TextPiece textPiece : _doc.getTextTable().getTextPieces() )
{
System.out.println( textPiece ); System.out.println( textPiece );
if ( withText ) if ( withText ) {
{
System.out.println( "\t" + textPiece.getStringBuilder() ); System.out.println( "\t" + textPiece.getStringBuilder() );
} }
} }

View File

@ -31,22 +31,18 @@ import org.apache.poi.util.Internal;
* v20110608 Word (.doc) Binary File Format * v20110608 Word (.doc) Binary File Format
*/ */
@Internal @Internal
public class FibBase extends FibBaseAbstractType public class FibBase extends FibBaseAbstractType {
{
public FibBase() public FibBase() {
{
} }
public FibBase( byte[] std, int offset ) public FibBase( byte[] std, int offset ) {
{
fillFields( std, offset ); fillFields( std, offset );
} }
@Override @Override
@SuppressWarnings( "deprecation" ) @SuppressWarnings( "deprecation" )
public boolean equals( Object obj ) public boolean equals( Object obj ) {
{
if ( this == obj ) if ( this == obj )
return true; return true;
if ( obj == null ) if ( obj == null )
@ -87,8 +83,7 @@ public class FibBase extends FibBaseAbstractType
@Override @Override
@SuppressWarnings( "deprecation" ) @SuppressWarnings( "deprecation" )
public int hashCode() public int hashCode() {
{
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + field_10_flags2; result = prime * result + field_10_flags2;
@ -107,5 +102,4 @@ public class FibBase extends FibBaseAbstractType
result = prime * result + field_9_envr; result = prime * result + field_9_envr;
return result; return result;
} }
} }