int currentCharPage = LittleEndian.getInt(_tableBuffer, charOffset + charPlcf.getStructOffset(0));
int charPlcfLen = charPlcf.length();
int currentPageIndex = 0;
byte[] fkp = new byte[512];
System.arraycopy(_mainDocument, (currentCharPage * 512), fkp, 0, 512);
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(fkp);
int currentChpxIndex = 0;
int currentArraySize = cfkp.size();
int arraySize = parPlcf.length();
//first we must go through the bin table and find the fkps
for(int x = 0; x < arraySize; x++)
{
int PN = LittleEndian.getInt(_tableBuffer, parOffset + parPlcf.getStructOffset(x));
fkp = new byte[512];
System.arraycopy(_mainDocument, (PN * 512), fkp, 0, 512);
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(fkp);
//take each fkp and get the paps
int crun = pfkp.size();
for(int y = 0; y < crun; y++)
{
//get the beginning fc of each paragraph text run
int fcStart = pfkp.getStart(y);
int fcEnd = pfkp.getEnd(y);
//get the papx for this paragraph
byte[] papx = pfkp.getGrpprl(y);
_listener.paragraph(new PapxNode(fcStart, fcEnd, papx));
//get the character runs for this paragraph
int charStart = 0;
int charEnd = 0;
//add the character runs
do
{
if (currentChpxIndex < currentArraySize)
{
charStart = cfkp.getStart(currentChpxIndex);
charEnd = cfkp.getEnd(currentChpxIndex);
byte[] chpx = cfkp.getGrpprl(currentChpxIndex);
_listener.characterRun(new ChpxNode(charStart, charEnd, chpx));
if (charEnd < fcEnd)
{
currentChpxIndex++;
}
else
{
break;
}
}
else
{
currentCharPage = LittleEndian.getInt(_tableBuffer, charOffset + charPlcf.getStructOffset(++currentPageIndex));
fkp = new byte[512];
System.arraycopy(_mainDocument, (currentCharPage * 512), fkp, 0, 512);
cfkp = new CHPFormattedDiskPage(fkp);
currentChpxIndex = 0;
currentArraySize = cfkp.size();
}
}
while(currentCharPage <= charPlcfLen + 1);
}