shortcut for test case to allow loading bad structure of CHP
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144691 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bb9b395b69
commit
6b96874866
@ -222,7 +222,7 @@ public final class HWPFDocument extends HWPFDocumentCore
|
|||||||
|
|
||||||
// Now load the rest of the properties, which need to be adjusted
|
// Now load the rest of the properties, which need to be adjusted
|
||||||
// for where text really begin
|
// 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);
|
_pbt = new PAPBinTable(_mainStream, _tableStream, _dataStream, _fib.getFcPlcfbtePapx(), _fib.getLcbPlcfbtePapx(), cpMin, _tpt, true);
|
||||||
|
|
||||||
// Read FSPA and Escher information
|
// Read FSPA and Escher information
|
||||||
|
@ -50,14 +50,22 @@ public class CHPBinTable
|
|||||||
/**
|
/**
|
||||||
* Constructor used to read a binTable in from a Word document.
|
* Constructor used to read a binTable in from a Word document.
|
||||||
*
|
*
|
||||||
* @param documentStream
|
* @deprecated Use
|
||||||
* @param tableStream
|
* {@link #CHPBinTable(byte[],byte[],int,int,int,TextPieceTable,boolean)}
|
||||||
* @param offset
|
* instead
|
||||||
* @param size
|
|
||||||
* @param fcMin
|
|
||||||
*/
|
*/
|
||||||
public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
|
public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
|
||||||
int size, int fcMin, TextPieceTable tpt )
|
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:
|
* Page 35:
|
||||||
@ -79,7 +87,7 @@ public class CHPBinTable
|
|||||||
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
|
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
|
||||||
|
|
||||||
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
|
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
|
||||||
pageOffset, fcMin, tpt);
|
pageOffset, fcMin, tpt, ignoreChpxWithoutTextPieces);
|
||||||
|
|
||||||
int fkpSize = cfkp.size();
|
int fkpSize = cfkp.size();
|
||||||
|
|
||||||
|
@ -53,8 +53,26 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
|
|||||||
/**
|
/**
|
||||||
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
|
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
|
||||||
* read from a Word file).
|
* 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);
|
super(documentStream, offset);
|
||||||
|
|
||||||
@ -63,7 +81,7 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
|
|||||||
int startAt = getStart(x);
|
int startAt = getStart(x);
|
||||||
int endAt = getEnd(x);
|
int endAt = getEnd(x);
|
||||||
|
|
||||||
if ( !tpt.isIndexInTable( startAt, endAt ) ) {
|
if (ignoreChpxWithoutTextPieces && !tpt.isIndexInTable( startAt, endAt ) ) {
|
||||||
_chpxList.add(null);
|
_chpxList.add(null);
|
||||||
} else {
|
} else {
|
||||||
_chpxList.add(new CHPX(startAt, endAt, tpt, getGrpprl(x)));
|
_chpxList.add(new CHPX(startAt, endAt, tpt, getGrpprl(x)));
|
||||||
|
@ -55,7 +55,7 @@ public final class OldCHPBinTable extends CHPBinTable
|
|||||||
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
|
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
|
||||||
|
|
||||||
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
|
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
|
||||||
pageOffset, fcMin, tpt);
|
pageOffset, fcMin, tpt, true);
|
||||||
|
|
||||||
int fkpSize = cfkp.size();
|
int fkpSize = cfkp.size();
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ package org.apache.poi.hwpf.model;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.hwpf.*;
|
import org.apache.poi.hwpf.HWPFDocFixture;
|
||||||
import org.apache.poi.hwpf.model.io.*;
|
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
|
||||||
|
|
||||||
public final class TestCHPBinTable
|
public final class TestCHPBinTable
|
||||||
extends TestCase
|
extends TestCase
|
||||||
@ -46,7 +46,7 @@ public final class TestCHPBinTable
|
|||||||
byte[] tableStream = _hWPFDocFixture._tableStream;
|
byte[] tableStream = _hWPFDocFixture._tableStream;
|
||||||
int fcMin = fib.getFcMin();
|
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();
|
HWPFFileSystem fileSys = new HWPFFileSystem();
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public final class TestCHPBinTable
|
|||||||
byte[] newTableStream = tableOut.toByteArray();
|
byte[] newTableStream = tableOut.toByteArray();
|
||||||
byte[] newMainStream = mainOut.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 oldTextRuns = _cHPBinTable._textRuns;
|
||||||
ArrayList newTextRuns = newBinTable._textRuns;
|
ArrayList newTextRuns = newBinTable._textRuns;
|
||||||
|
Loading…
Reference in New Issue
Block a user