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.FieldsTables;
import org.apache.poi.hwpf.model.FileInformationBlock;
import org.apache.poi.hwpf.model.GenericPropertyNode;
import org.apache.poi.hwpf.model.PAPFormattedDiskPage;
+ "\t\t[--chpx] [--chpxProperties] [--chpxSprms]\n"
+ "\t\t[--papx] [--papxProperties]\n"
+ "\t\t[--paragraphs] [--paragraphsSprms] [--paragraphsText]\n"
- + "\t\t[--pictures]\n" + "\t\t[--writereadback]\n" );
+ + "\t\t[--fields]\n" + "\t\t[--pictures]\n"
+ + "\t\t[--writereadback]\n" );
System.exit( 1 );
}
boolean outputPapx = false;
boolean outputPapxProperties = false;
+ boolean outputFields = false;
boolean outputPictures = false;
boolean writereadback = false;
if ( "--papxProperties".equals( arg ) )
outputPapxProperties = true;
+ if ( "--fields".equals( arg ) )
+ outputFields = true;
if ( "--pictures".equals( arg ) )
outputPictures = true;
outputParagraphsText );
}
+ if ( outputFields )
+ {
+ System.out.println( "== FIELDS ==" );
+ lister.dumpFields();
+ }
+
if ( outputPictures )
{
System.out.println( "== PICTURES ==" );
System.out.println( fib );
}
+ private void dumpFields()
+ {
+ if ( !( _doc instanceof HWPFDocument ) )
+ {
+ System.out.println( "Word 95 not supported so far" );
+ return;
+ }
+
+ HWPFDocument document = (HWPFDocument) _doc;
+
+ for ( int i = FieldsTables.PLCFFLDATN; i <= FieldsTables.PLCFFLDTXBX; i++ )
+ {
+ System.out.println( "=== Document part: " + i + " ===" );
+ for ( org.apache.poi.hwpf.model.Field field : document
+ .getFieldsTables().getFields( i ) )
+ {
+ System.out.println( field );
+ }
+ }
+ }
+
public void dumpPapx( boolean withProperties ) throws Exception
{
if ( _doc instanceof HWPFDocument )
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
* This is port and adaptation of Arrays.binarySearch from Java 6 (Apache
* Harmony).
*/
- public static <T> int binarySearch( GenericPropertyNode[] array,
+ private static <T> int binarySearch( GenericPropertyNode[] array,
int startIndex, int endIndex, int requiredStartOffset )
{
checkIndexForBinarySearch( array.length, startIndex, endIndex );
return new PlexOfCps( tableStream, start, length, FLD_SIZE );
}
+ public Collection<Field> getFields( int documentPart )
+ {
+ Map<Integer, Field> map = _fieldsByOffset.get( Integer
+ .valueOf( documentPart ) );
+ if ( map == null || map.isEmpty() )
+ return Collections.emptySet();
+
+ return Collections.unmodifiableCollection( map.values() );
+ }
+
public ArrayList<PlexOfField> getFieldsPLCF( int type )
{
return toArrayList( _tables.get( Integer.valueOf( type ) ) );