private int[] _fields;
- public FIBFieldHandler(byte[] mainStream, int startOffset, byte[] tableStream,
+ FIBFieldHandler(byte[] mainStream, int offset, int cbRgFcLcb, byte[] tableStream,
HashSet<Integer> offsetList, boolean areKnown)
{
- int numFields = LittleEndian.getShort(mainStream, startOffset);
- int offset = startOffset + LittleEndian.SHORT_SIZE;
- _fields = new int[numFields * 2];
+ _fields = new int[cbRgFcLcb * 2];
- for (int x = 0; x < numFields; x++)
+ for (int x = 0; x < cbRgFcLcb; x++)
{
int fieldOffset = (x * FIELD_SIZE) + offset;
int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
public int sizeInBytes()
{
- return (_fields.length * LittleEndian.INT_SIZE) + LittleEndian.SHORT_SIZE;
+ return (_fields.length * LittleEndian.INT_SIZE);
}
+ public int getFieldsCount() {
+ return _fields.length / 2;
+ }
+
void writeTo(byte[] mainStream, int offset, HWPFOutputStream tableStream)
throws IOException
{
- int length = _fields.length/2;
- LittleEndian.putShort(mainStream, offset, (short)length);
- offset += LittleEndian.SHORT_SIZE;
-
- for (int x = 0; x < length; x++)
+ for (int x = 0; x < _fields.length/2; x++)
{
UnhandledDataStructure ds = _unknownMap.get(Integer.valueOf(x));
if (ds != null)
private FibRgW97 _fibRgW;
private int _cslw;
private FibRgLw97 _fibRgLw;
-
- FIBFieldHandler _fieldHandler;
+ private int _cbRgFcLcb;
+ private FIBFieldHandler _fieldHandler;
/** Creates a new instance of FileInformationBlock */
public FileInformationBlock( byte[] mainDocument )
assert offset == 32;
_csw = LittleEndian.getUShort( mainDocument, offset );
- offset += 2;
+ offset += LittleEndian.SHORT_SIZE;
assert offset == 34;
_fibRgW = new FibRgW97( mainDocument, offset );
assert offset == 62;
_cslw = LittleEndian.getUShort( mainDocument, offset );
- offset += 2;
+ offset += LittleEndian.SHORT_SIZE;
assert offset == 64;
_fibRgLw = new FibRgLw97( mainDocument, offset );
offset += FibRgLw97.getSize();
assert offset == 152;
+
+ _cbRgFcLcb = LittleEndian.getUShort( mainDocument, offset );
+ offset += LittleEndian.SHORT_SIZE;
+ assert offset == 154;
}
public void fillVariableFields( byte[] mainDocument, byte[] tableStream )
knownFieldSet.add( Integer.valueOf( FIBFieldHandler.STTBSAVEDBY ) );
knownFieldSet.add( Integer.valueOf( FIBFieldHandler.MODIFIED ) );
- _fieldHandler = new FIBFieldHandler( mainDocument, 152, tableStream,
- knownFieldSet, true );
+ _fieldHandler = new FIBFieldHandler( mainDocument, 154, _cbRgFcLcb,
+ tableStream, knownFieldSet, true );
}
@Override
public void writeTo( byte[] mainStream, HWPFOutputStream tableStream )
throws IOException
{
- // HWPFOutputStream mainDocument = sys.getStream("WordDocument");
- // HWPFOutputStream tableStream = sys.getStream("1Table");
+ _cbRgFcLcb = _fieldHandler.getFieldsCount();
_fibBase.serialize( mainStream, 0 );
int offset = FibBase.getSize();
LittleEndian.putUShort( mainStream, offset, _csw );
- offset += 2;
+ offset += LittleEndian.SHORT_SIZE;
_fibRgW.serialize( mainStream, offset );
offset += FibRgW97.getSize();
LittleEndian.putUShort( mainStream, offset, _cslw );
- offset += 2;
+ offset += LittleEndian.SHORT_SIZE;
_fibRgLw.serialize( mainStream, offset );
offset += FibRgLw97.getSize();
+ LittleEndian.putUShort( mainStream, offset, _cbRgFcLcb );
+ offset += LittleEndian.SHORT_SIZE;
+
_fieldHandler.writeTo( mainStream, offset, tableStream );
}
public int getSize()
{
- return FibBase.getSize() + 2 + FibRgW97.getSize() + 2
- + FibRgLw97.getSize() + _fieldHandler.sizeInBytes();
+ return FibBase.getSize() + LittleEndian.SHORT_SIZE + FibRgW97.getSize()
+ + LittleEndian.SHORT_SIZE + FibRgLw97.getSize()
+ + LittleEndian.SHORT_SIZE + _fieldHandler.sizeInBytes();
}
public FibBase getFibBase()