// Now load the rest of the properties, which need to be adjusted
// for where text really begin
- _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbteChpx(), _fib.getLcbPlcfbteChpx(), cpMin, _tpt);
+ _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbteChpx(), _fib.getLcbPlcfbteChpx(), cpMin, _tpt, true);
_pbt = new PAPBinTable(_mainStream, _tableStream, _dataStream, _fib.getFcPlcfbtePapx(), _fib.getLcbPlcfbtePapx(), cpMin, _tpt, true);
// Read FSPA and Escher information
{
}
- /**
- * Constructor used to read a binTable in from a Word document.
- *
- * @param documentStream
- * @param tableStream
- * @param offset
- * @param size
- * @param fcMin
- */
+ /**
+ * Constructor used to read a binTable in from a Word document.
+ *
+ * @deprecated Use
+ * {@link #CHPBinTable(byte[],byte[],int,int,int,TextPieceTable,boolean)}
+ * instead
+ */
public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
int size, int fcMin, TextPieceTable tpt )
+ {
+ this( documentStream, tableStream, offset, size, fcMin, tpt, true );
+ }
+
+ /**
+ * Constructor used to read a binTable in from a Word document.
+ */
+ public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
+ int size, int fcMin, TextPieceTable tpt,
+ boolean ignoreChpxWithoutTextPieces )
{
/*
* Page 35:
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
- pageOffset, fcMin, tpt);
+ pageOffset, fcMin, tpt, ignoreChpxWithoutTextPieces);
int fkpSize = cfkp.size();
/**
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
* read from a Word file).
+ *
+ * @deprecated Use
+ * {@link #CHPFormattedDiskPage(byte[],int,int,TextPieceTable,boolean)}
+ * instead
*/
- public CHPFormattedDiskPage(byte[] documentStream, int offset, int fcMin, TextPieceTable tpt)
+ public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
+ TextPieceTable tpt )
+ {
+ this( documentStream, offset, fcMin, tpt, true );
+ }
+
+ /**
+ * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
+ * read from a Word file).
+ *
+ * @param ignoreChpxWithoutTextPieces
+ * TODO
+ */
+ public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
+ TextPieceTable tpt, boolean ignoreChpxWithoutTextPieces )
{
super(documentStream, offset);
int startAt = getStart(x);
int endAt = getEnd(x);
- if ( !tpt.isIndexInTable( startAt, endAt ) ) {
+ if (ignoreChpxWithoutTextPieces && !tpt.isIndexInTable( startAt, endAt ) ) {
_chpxList.add(null);
} else {
_chpxList.add(new CHPX(startAt, endAt, tpt, getGrpprl(x)));
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
- pageOffset, fcMin, tpt);
+ pageOffset, fcMin, tpt, true);
int fkpSize = cfkp.size();
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
-import junit.framework.*;
+import junit.framework.TestCase;
-import org.apache.poi.hwpf.*;
-import org.apache.poi.hwpf.model.io.*;
+import org.apache.poi.hwpf.HWPFDocFixture;
+import org.apache.poi.hwpf.model.io.HWPFFileSystem;
public final class TestCHPBinTable
extends TestCase
byte[] tableStream = _hWPFDocFixture._tableStream;
int fcMin = fib.getFcMin();
- _cHPBinTable = new CHPBinTable(mainStream, tableStream, fib.getFcPlcfbteChpx(), fib.getLcbPlcfbteChpx(), fcMin, fakeTPT);
+ _cHPBinTable = new CHPBinTable(mainStream, tableStream, fib.getFcPlcfbteChpx(), fib.getLcbPlcfbteChpx(), fcMin, fakeTPT, false);
HWPFFileSystem fileSys = new HWPFFileSystem();
byte[] newTableStream = tableOut.toByteArray();
byte[] newMainStream = mainOut.toByteArray();
- CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.length, 0, fakeTPT);
+ CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.length, 0, fakeTPT, false);
ArrayList oldTextRuns = _cHPBinTable._textRuns;
ArrayList newTextRuns = newBinTable._textRuns;