Patch from Trejkaz - fix bug #48038 - handle reading HWPF stylesheets from non zero offsets
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@832625 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0880802d5d
commit
a9d6f34732
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.6-beta1" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">48038 - handle reading HWPF stylesheets from non zero offsets</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">When running the "compile-ooxml-xsds" ant task, also generate the source jar for the OOXML Schemas</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">45672 - improve handling by MissingRecordAwareHSSFListener of records that cover multiple cells (MulBlankRecord and MulRKRecord)</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">48096 - relaxed validation check in RecalcIdRecord</action>
|
||||
|
@ -65,6 +65,7 @@ public final class StyleSheet implements HDFType {
|
||||
*/
|
||||
public StyleSheet(byte[] tableStream, int offset)
|
||||
{
|
||||
int startOffset = offset;
|
||||
_stshiLength = LittleEndian.getShort(tableStream, offset);
|
||||
offset += LittleEndian.SHORT_SIZE;
|
||||
int stdCount = LittleEndian.getShort(tableStream, offset);
|
||||
@ -88,7 +89,7 @@ public final class StyleSheet implements HDFType {
|
||||
_rgftc[2] = LittleEndian.getShort(tableStream, offset);
|
||||
offset += LittleEndian.SHORT_SIZE;
|
||||
|
||||
offset = (LittleEndian.SHORT_SIZE + _stshiLength);
|
||||
offset = startOffset + LittleEndian.SHORT_SIZE + _stshiLength;
|
||||
_styleDescriptions = new StyleDescription[stdCount];
|
||||
for(int x = 0; x < stdCount; x++)
|
||||
{
|
||||
|
@ -46,6 +46,21 @@ public final class TestStyleSheet
|
||||
|
||||
}
|
||||
|
||||
public void testReadWriteFromNonZeroOffset()
|
||||
throws Exception
|
||||
{
|
||||
HWPFFileSystem fileSys = new HWPFFileSystem();
|
||||
HWPFOutputStream tableOut = fileSys.getStream("1Table");
|
||||
|
||||
tableOut.write(new byte[20]); // 20 bytes of whatever at the front.
|
||||
_styleSheet.writeTo(tableOut);
|
||||
|
||||
byte[] newTableStream = tableOut.toByteArray();
|
||||
|
||||
StyleSheet newStyleSheet = new StyleSheet(newTableStream, 20);
|
||||
assertEquals(newStyleSheet, _styleSheet);
|
||||
}
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user