mirror of https://github.com/apache/poi.git
add bookmarks dump feature to HWPFLister
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1150593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
909ce058fa
commit
3dc3d03c4b
|
@ -45,6 +45,8 @@ import org.apache.poi.hwpf.model.StyleSheet;
|
||||||
import org.apache.poi.hwpf.model.TextPiece;
|
import org.apache.poi.hwpf.model.TextPiece;
|
||||||
import org.apache.poi.hwpf.sprm.SprmIterator;
|
import org.apache.poi.hwpf.sprm.SprmIterator;
|
||||||
import org.apache.poi.hwpf.sprm.SprmOperation;
|
import org.apache.poi.hwpf.sprm.SprmOperation;
|
||||||
|
import org.apache.poi.hwpf.usermodel.Bookmark;
|
||||||
|
import org.apache.poi.hwpf.usermodel.Bookmarks;
|
||||||
import org.apache.poi.hwpf.usermodel.Field;
|
import org.apache.poi.hwpf.usermodel.Field;
|
||||||
import org.apache.poi.hwpf.usermodel.Paragraph;
|
import org.apache.poi.hwpf.usermodel.Paragraph;
|
||||||
import org.apache.poi.hwpf.usermodel.Picture;
|
import org.apache.poi.hwpf.usermodel.Picture;
|
||||||
|
@ -102,7 +104,7 @@ public final class HWPFLister
|
||||||
+ "\t\t[--chpx] [--chpxProperties] [--chpxSprms]\n"
|
+ "\t\t[--chpx] [--chpxProperties] [--chpxSprms]\n"
|
||||||
+ "\t\t[--papx] [--papxProperties]\n"
|
+ "\t\t[--papx] [--papxProperties]\n"
|
||||||
+ "\t\t[--paragraphs] [--paragraphsSprms] [--paragraphsText]\n"
|
+ "\t\t[--paragraphs] [--paragraphsSprms] [--paragraphsText]\n"
|
||||||
+ "\t\t[--fields]\n" + "\t\t[--pictures]\n"
|
+ "\t\t[--bookmarks]\n" +"\t\t[--fields]\n" + "\t\t[--pictures]\n"
|
||||||
+ "\t\t[--writereadback]\n" );
|
+ "\t\t[--writereadback]\n" );
|
||||||
System.exit( 1 );
|
System.exit( 1 );
|
||||||
}
|
}
|
||||||
|
@ -121,6 +123,7 @@ public final class HWPFLister
|
||||||
boolean outputPapx = false;
|
boolean outputPapx = false;
|
||||||
boolean outputPapxProperties = false;
|
boolean outputPapxProperties = false;
|
||||||
|
|
||||||
|
boolean outputBookmarks = false;
|
||||||
boolean outputFields = false;
|
boolean outputFields = false;
|
||||||
boolean outputPictures = false;
|
boolean outputPictures = false;
|
||||||
|
|
||||||
|
@ -152,6 +155,8 @@ public final class HWPFLister
|
||||||
if ( "--papxProperties".equals( arg ) )
|
if ( "--papxProperties".equals( arg ) )
|
||||||
outputPapxProperties = true;
|
outputPapxProperties = true;
|
||||||
|
|
||||||
|
if ( "--bookmarks".equals( arg ) )
|
||||||
|
outputBookmarks = true;
|
||||||
if ( "--fields".equals( arg ) )
|
if ( "--fields".equals( arg ) )
|
||||||
outputFields = true;
|
outputFields = true;
|
||||||
if ( "--pictures".equals( arg ) )
|
if ( "--pictures".equals( arg ) )
|
||||||
|
@ -196,6 +201,12 @@ public final class HWPFLister
|
||||||
outputParagraphsText );
|
outputParagraphsText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( outputBookmarks )
|
||||||
|
{
|
||||||
|
System.out.println( "== BOOKMARKS ==" );
|
||||||
|
lister.dumpBookmarks();
|
||||||
|
}
|
||||||
|
|
||||||
if ( outputFields )
|
if ( outputFields )
|
||||||
{
|
{
|
||||||
System.out.println( "== FIELDS ==" );
|
System.out.println( "== FIELDS ==" );
|
||||||
|
@ -275,6 +286,24 @@ public final class HWPFLister
|
||||||
this.text = builder.toString();
|
this.text = builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dumpBookmarks()
|
||||||
|
{
|
||||||
|
if ( !( _doc instanceof HWPFDocument ) )
|
||||||
|
{
|
||||||
|
System.out.println( "Word 95 not supported so far" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HWPFDocument document = (HWPFDocument) _doc;
|
||||||
|
Bookmarks bookmarks = document.getBookmarks();
|
||||||
|
for ( int b = 0; b < bookmarks.getBookmarksCount(); b++ )
|
||||||
|
{
|
||||||
|
Bookmark bookmark = bookmarks.getBookmark( b );
|
||||||
|
System.out.println( "[" + bookmark.getStart() + "; "
|
||||||
|
+ 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() )
|
||||||
|
|
Loading…
Reference in New Issue