move cbRgFcLcb from FIBFieldHandler to FIB
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1178045 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
23a44c7c6d
commit
847b8fe81d
@ -149,14 +149,12 @@ public final class FIBFieldHandler
|
|||||||
private int[] _fields;
|
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)
|
HashSet<Integer> offsetList, boolean areKnown)
|
||||||
{
|
{
|
||||||
int numFields = LittleEndian.getShort(mainStream, startOffset);
|
_fields = new int[cbRgFcLcb * 2];
|
||||||
int offset = startOffset + LittleEndian.SHORT_SIZE;
|
|
||||||
_fields = new int[numFields * 2];
|
|
||||||
|
|
||||||
for (int x = 0; x < numFields; x++)
|
for (int x = 0; x < cbRgFcLcb; x++)
|
||||||
{
|
{
|
||||||
int fieldOffset = (x * FIELD_SIZE) + offset;
|
int fieldOffset = (x * FIELD_SIZE) + offset;
|
||||||
int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
|
int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
|
||||||
@ -213,17 +211,17 @@ public final class FIBFieldHandler
|
|||||||
|
|
||||||
public int sizeInBytes()
|
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)
|
void writeTo(byte[] mainStream, int offset, HWPFOutputStream tableStream)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
int length = _fields.length/2;
|
for (int x = 0; x < _fields.length/2; x++)
|
||||||
LittleEndian.putShort(mainStream, offset, (short)length);
|
|
||||||
offset += LittleEndian.SHORT_SIZE;
|
|
||||||
|
|
||||||
for (int x = 0; x < length; x++)
|
|
||||||
{
|
{
|
||||||
UnhandledDataStructure ds = _unknownMap.get(Integer.valueOf(x));
|
UnhandledDataStructure ds = _unknownMap.get(Integer.valueOf(x));
|
||||||
if (ds != null)
|
if (ds != null)
|
||||||
|
@ -51,8 +51,8 @@ public final class FileInformationBlock implements Cloneable
|
|||||||
private FibRgW97 _fibRgW;
|
private FibRgW97 _fibRgW;
|
||||||
private int _cslw;
|
private int _cslw;
|
||||||
private FibRgLw97 _fibRgLw;
|
private FibRgLw97 _fibRgLw;
|
||||||
|
private int _cbRgFcLcb;
|
||||||
FIBFieldHandler _fieldHandler;
|
private FIBFieldHandler _fieldHandler;
|
||||||
|
|
||||||
/** Creates a new instance of FileInformationBlock */
|
/** Creates a new instance of FileInformationBlock */
|
||||||
public FileInformationBlock( byte[] mainDocument )
|
public FileInformationBlock( byte[] mainDocument )
|
||||||
@ -64,7 +64,7 @@ public final class FileInformationBlock implements Cloneable
|
|||||||
assert offset == 32;
|
assert offset == 32;
|
||||||
|
|
||||||
_csw = LittleEndian.getUShort( mainDocument, offset );
|
_csw = LittleEndian.getUShort( mainDocument, offset );
|
||||||
offset += 2;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
assert offset == 34;
|
assert offset == 34;
|
||||||
|
|
||||||
_fibRgW = new FibRgW97( mainDocument, offset );
|
_fibRgW = new FibRgW97( mainDocument, offset );
|
||||||
@ -72,12 +72,16 @@ public final class FileInformationBlock implements Cloneable
|
|||||||
assert offset == 62;
|
assert offset == 62;
|
||||||
|
|
||||||
_cslw = LittleEndian.getUShort( mainDocument, offset );
|
_cslw = LittleEndian.getUShort( mainDocument, offset );
|
||||||
offset += 2;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
assert offset == 64;
|
assert offset == 64;
|
||||||
|
|
||||||
_fibRgLw = new FibRgLw97( mainDocument, offset );
|
_fibRgLw = new FibRgLw97( mainDocument, offset );
|
||||||
offset += FibRgLw97.getSize();
|
offset += FibRgLw97.getSize();
|
||||||
assert offset == 152;
|
assert offset == 152;
|
||||||
|
|
||||||
|
_cbRgFcLcb = LittleEndian.getUShort( mainDocument, offset );
|
||||||
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
|
assert offset == 154;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillVariableFields( byte[] mainDocument, byte[] tableStream )
|
public void fillVariableFields( byte[] mainDocument, byte[] tableStream )
|
||||||
@ -120,8 +124,8 @@ public final class FileInformationBlock implements Cloneable
|
|||||||
knownFieldSet.add( Integer.valueOf( FIBFieldHandler.STTBSAVEDBY ) );
|
knownFieldSet.add( Integer.valueOf( FIBFieldHandler.STTBSAVEDBY ) );
|
||||||
knownFieldSet.add( Integer.valueOf( FIBFieldHandler.MODIFIED ) );
|
knownFieldSet.add( Integer.valueOf( FIBFieldHandler.MODIFIED ) );
|
||||||
|
|
||||||
_fieldHandler = new FIBFieldHandler( mainDocument, 152, tableStream,
|
_fieldHandler = new FIBFieldHandler( mainDocument, 154, _cbRgFcLcb,
|
||||||
knownFieldSet, true );
|
tableStream, knownFieldSet, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -866,31 +870,34 @@ public final class FileInformationBlock implements Cloneable
|
|||||||
public void writeTo( byte[] mainStream, HWPFOutputStream tableStream )
|
public void writeTo( byte[] mainStream, HWPFOutputStream tableStream )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// HWPFOutputStream mainDocument = sys.getStream("WordDocument");
|
_cbRgFcLcb = _fieldHandler.getFieldsCount();
|
||||||
// HWPFOutputStream tableStream = sys.getStream("1Table");
|
|
||||||
|
|
||||||
_fibBase.serialize( mainStream, 0 );
|
_fibBase.serialize( mainStream, 0 );
|
||||||
int offset = FibBase.getSize();
|
int offset = FibBase.getSize();
|
||||||
|
|
||||||
LittleEndian.putUShort( mainStream, offset, _csw );
|
LittleEndian.putUShort( mainStream, offset, _csw );
|
||||||
offset += 2;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
|
|
||||||
_fibRgW.serialize( mainStream, offset );
|
_fibRgW.serialize( mainStream, offset );
|
||||||
offset += FibRgW97.getSize();
|
offset += FibRgW97.getSize();
|
||||||
|
|
||||||
LittleEndian.putUShort( mainStream, offset, _cslw );
|
LittleEndian.putUShort( mainStream, offset, _cslw );
|
||||||
offset += 2;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
|
|
||||||
_fibRgLw.serialize( mainStream, offset );
|
_fibRgLw.serialize( mainStream, offset );
|
||||||
offset += FibRgLw97.getSize();
|
offset += FibRgLw97.getSize();
|
||||||
|
|
||||||
|
LittleEndian.putUShort( mainStream, offset, _cbRgFcLcb );
|
||||||
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
|
|
||||||
_fieldHandler.writeTo( mainStream, offset, tableStream );
|
_fieldHandler.writeTo( mainStream, offset, tableStream );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize()
|
public int getSize()
|
||||||
{
|
{
|
||||||
return FibBase.getSize() + 2 + FibRgW97.getSize() + 2
|
return FibBase.getSize() + LittleEndian.SHORT_SIZE + FibRgW97.getSize()
|
||||||
+ FibRgLw97.getSize() + _fieldHandler.sizeInBytes();
|
+ LittleEndian.SHORT_SIZE + FibRgLw97.getSize()
|
||||||
|
+ LittleEndian.SHORT_SIZE + _fieldHandler.sizeInBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FibBase getFibBase()
|
public FibBase getFibBase()
|
||||||
|
Loading…
Reference in New Issue
Block a user