You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by sa...@apache.org on 2003/07/15 05:22:54 UTC
cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes CHPBinTable.java Ffn.java FileInformationBlock.java FontTable.java PAPBinTable.java PAPFormattedDiskPage.java StyleDescription.java StyleSheet.java
sackley 2003/07/14 20:22:54
Modified: src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes
CHPBinTable.java Ffn.java FileInformationBlock.java
FontTable.java PAPBinTable.java
PAPFormattedDiskPage.java StyleDescription.java
StyleSheet.java
Log:
Reached first milestone
Revision Changes Path
1.4 +1 -1 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/CHPBinTable.java
Index: CHPBinTable.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/CHPBinTable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CHPBinTable.java 1 Jul 2003 23:57:07 -0000 1.3
+++ CHPBinTable.java 15 Jul 2003 03:22:53 -0000 1.4
@@ -142,7 +142,7 @@
int end = endingFc;
if (overflow != null)
{
- end = ((PropertyNode)overflow.get(0)).getStart();
+ end = ((PropertyNode)overflow.get(0)).getStart() + fcMin;
}
byte[] intHolder = new byte[4];
1.2 +153 -34 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/Ffn.java
Index: Ffn.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/Ffn.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Ffn.java 1 Jul 2003 23:59:59 -0000 1.1
+++ Ffn.java 15 Jul 2003 03:22:53 -0000 1.2
@@ -56,93 +56,212 @@
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
+import java.util.Arrays;
-
+/**
+ * FFN - Font Family Name. FFN is a data structure that stores the names of the Main
+ * Font and that of Alternate font as an array of characters. It has also a header
+ * that stores info about the whole structure and the fonts
+ *
+ * @author Praveen Mathew
+ */
public class Ffn
{
- private int field1_cbFfnM1; //total length of FFN - 1.
- private byte field2;
+ private int field_1_cbFfnM1;//total length of FFN - 1.
+ private byte field_2;
private static BitField _prq = new BitField(0x0003);// pitch request
private static BitField _fTrueType = new BitField(0x0004);// when 1, font is a TrueType font
private static BitField _ff = new BitField(0x0070);
- private short field3_wWeight;// base weight of font
- private byte field4_chs;// character set identifier
- private byte field5_ixchSzAlt; // index into ffn.szFfn to the name of
+ private short field_3_wWeight;// base weight of font
+ private byte field_4_chs;// character set identifier
+ private byte field_5_ixchSzAlt; // index into ffn.szFfn to the name of
// the alternate font
- private byte [] panose = new byte[10]; //????
- private byte [] fontSig = new byte[24]; //????
+ private byte [] field_6_panose = new byte[10];//????
+ private byte [] field_7_fontSig = new byte[24];//????
// zero terminated string that records name of font, cuurently not
// supporting Extended chars
- private char [] xszFfn;
+ private char [] field_8_xszFfn;
+
+ // extra facilitator members
private int xszFfnLength;
public Ffn(byte[] buf, int offset)
{
- field1_cbFfnM1 = LittleEndian.getUnsignedByte(buf, offset);
+ int offsetTmp = offset;
+
+ field_1_cbFfnM1 = LittleEndian.getUnsignedByte(buf,offset);
offset += LittleEndian.BYTE_SIZE;
- field2 = buf[offset];
+ field_2 = buf[offset];
offset += LittleEndian.BYTE_SIZE;
- field3_wWeight = LittleEndian.getShort(buf, offset);
+ field_3_wWeight = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
- field4_chs = buf[offset];
+ field_4_chs = buf[offset];
offset += LittleEndian.BYTE_SIZE;
- field5_ixchSzAlt = buf[offset];
+ field_5_ixchSzAlt = buf[offset];
offset += LittleEndian.BYTE_SIZE;
// read panose and fs so we can write them back out.
- System.arraycopy(buf, offset, panose, 0, panose.length);
- offset += panose.length;
- System.arraycopy(buf, offset, fontSig, 0, fontSig.length);
- offset += fontSig.length;
-
- xszFfnLength = this.getSize() - offset;
- xszFfn = new char[xszFfnLength];
+ System.arraycopy(buf, offset, field_6_panose, 0, field_6_panose.length);
+ offset += field_6_panose.length;
+ System.arraycopy(buf, offset, field_7_fontSig, 0, field_7_fontSig.length);
+ offset += field_7_fontSig.length;
+
+ offsetTmp = offset - offsetTmp;
+ xszFfnLength = this.getSize() - offsetTmp;
+ field_8_xszFfn = new char[xszFfnLength];
for(int i = 0; i < xszFfnLength; i++)
{
- xszFfn[i] = (char)LittleEndian.getUnsignedByte(buf, offset);
+ field_8_xszFfn[i] = (char)LittleEndian.getUnsignedByte(buf, offset);
offset += LittleEndian.BYTE_SIZE;
}
}
- public int getField1_cbFfnM1()
+ public int getField_1_cbFfnM1()
+ {
+ return field_1_cbFfnM1;
+ }
+
+ public byte getField_2()
+ {
+ return field_2;
+ }
+
+ public short getField_3_wWeight()
{
- return field1_cbFfnM1;
+ return field_3_wWeight;
+ }
+
+ public byte getField_4_chs()
+ {
+ return field_4_chs;
+ }
+
+ public byte getField_5_ixchSzAlt()
+ {
+ return field_5_ixchSzAlt;
+ }
+
+ public byte [] getField_6_panose()
+ {
+ return field_6_panose;
+ }
+
+ public byte [] getField_7_fontSig()
+ {
+ return field_7_fontSig;
+ }
+
+ public char [] getField_8_xszFfn()
+ {
+ return field_8_xszFfn;
}
public int getSize()
{
- return (field1_cbFfnM1 + 1);
+ return (field_1_cbFfnM1 + 1);
}
public char [] getMainFontName()
{
- char [] temp = new char[field5_ixchSzAlt];
- System.arraycopy(xszFfn,0,temp,0,temp.length);
+ char [] temp = new char[field_5_ixchSzAlt];
+ System.arraycopy(field_8_xszFfn,0,temp,0,temp.length);
return temp;
}
public char [] getAltFontName()
{
- char [] temp = new char[xszFfnLength - field5_ixchSzAlt];
- System.arraycopy(xszFfn, field5_ixchSzAlt, temp, 0, temp.length);
+ char [] temp = new char[xszFfnLength - field_5_ixchSzAlt];
+ System.arraycopy(field_8_xszFfn, field_5_ixchSzAlt, temp, 0, temp.length);
return temp;
}
- public void setField1_cbFfnM1(short field1_cbFfnM1)
+ public void setField_1_cbFfnM1(int field_1_cbFfnM1)
{
- this.field1_cbFfnM1 = field1_cbFfnM1;
+ this.field_1_cbFfnM1 = field_1_cbFfnM1;
}
- protected byte[] toByteArray()
+ // changed protected to public
+ public byte[] toByteArray()
{
- //return buf;
- return null;
+ int offset = 0;
+ byte[] buf = new byte[this.getSize()];
+
+ buf[offset] = (byte)field_1_cbFfnM1;
+ offset += LittleEndian.BYTE_SIZE;
+ buf[offset] = field_2;
+ offset += LittleEndian.BYTE_SIZE;
+ LittleEndian.putShort(buf, offset, field_3_wWeight);
+ offset += LittleEndian.SHORT_SIZE;
+ buf[offset] = field_4_chs;
+ offset += LittleEndian.BYTE_SIZE;
+ buf[offset] = field_5_ixchSzAlt;
+ offset += LittleEndian.BYTE_SIZE;
+
+ System.arraycopy(field_6_panose,0,buf, offset,field_6_panose.length);
+ offset += field_6_panose.length;
+ System.arraycopy(field_7_fontSig,0,buf, offset, field_7_fontSig.length);
+ offset += field_7_fontSig.length;
+
+ for(int i = 0; i < field_8_xszFfn.length; i++)
+ {
+ buf[offset] = (byte)field_8_xszFfn[i];
+ offset += LittleEndian.BYTE_SIZE;
+ }
+
+ return buf;
+
+ }
+
+ public boolean equals(Object o)
+ {
+ boolean retVal = true;
+
+ if (((Ffn)o).getField_1_cbFfnM1() == field_1_cbFfnM1)
+ {
+ if(((Ffn)o).getField_2() == field_2)
+ {
+ if(((Ffn)o).getField_3_wWeight() == field_3_wWeight)
+ {
+ if(((Ffn)o).getField_4_chs() == field_4_chs)
+ {
+ if(((Ffn)o).getField_5_ixchSzAlt() == field_5_ixchSzAlt)
+ {
+ if(Arrays.equals(((Ffn)o).getField_6_panose(),field_6_panose))
+ {
+ if(Arrays.equals(((Ffn)o).getField_7_fontSig(),field_7_fontSig))
+ {
+ if(!(Arrays.equals(((Ffn)o).getField_8_xszFfn(),field_8_xszFfn)))
+ retVal = false;
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+
+ return retVal;
}
}
+
1.3 +47 -0 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/FileInformationBlock.java
Index: FileInformationBlock.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/FileInformationBlock.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileInformationBlock.java 11 Jul 2003 11:29:31 -0000 1.2
+++ FileInformationBlock.java 15 Jul 2003 03:22:53 -0000 1.3
@@ -55,6 +55,9 @@
package org.apache.poi.hwpf.model.hdftypes;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
@@ -66,6 +69,7 @@
* @author andy
*/
public class FileInformationBlock extends FIBAbstractType
+ implements Cloneable
{
/** Creates a new instance of FileInformationBlock */
@@ -74,5 +78,48 @@
fillFields(mainDocument, (short)0, (short)0);
}
+ public void clearOffsetsSizes()
+ {
+ try
+ {
+ Field[] fields = FileInformationBlock.class.getSuperclass().getDeclaredFields();
+ AccessibleObject.setAccessible(fields, true);
+
+ for (int x = 0; x < fields.length; x++)
+ {
+ String name = fields[x].getName();
+ int index = name.indexOf('_');
+ if (index != -1)
+ {
+ int nextIndex = name.indexOf('_', index + 1);
+ if (nextIndex != -1)
+ {
+ // clear any field greater than field_53
+ if (Integer.parseInt(name.substring(index + 1, nextIndex)) > 53)
+ {
+ fields[x].setInt(this, 0);
+ }
+ }
+ }
+ }
+ }
+ catch (IllegalAccessException iae)
+ {
+ iae.printStackTrace();
+ }
+ }
+
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
}
1.2 +84 -42 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/FontTable.java
Index: FontTable.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/FontTable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FontTable.java 1 Jul 2003 23:59:59 -0000 1.1
+++ FontTable.java 15 Jul 2003 03:22:53 -0000 1.2
@@ -54,67 +54,64 @@
package org.apache.poi.hwpf.model.hdftypes;
-import org.apache.poi.util.BitField;
+import java.io.IOException;
+import org.apache.poi.hwpf.model.io.HWPFFileSystem;
+import org.apache.poi.hwpf.model.io.HWPFOutputStream;
import org.apache.poi.util.LittleEndian;
-
+/**
+ * FontTable or in MS terminology sttbfffn is a common data structure written in all
+ * Word files. The sttbfffn is an sttbf where each string is an FFN structure instead
+ * of pascal-style strings. An sttbf is a string Table stored in file. Thus sttbffn
+ * is like an Sttbf with an array of FFN structures that stores the font name strings
+ *
+ * @author Praveen Mathew
+ */
public class FontTable
{
- private short exntdChar; // strings are extended character if = 0xFFFF
- private short stringCount; // how many strings are included in the string table
- private short extraDataSz; // size in bytes of the extra data
-
- private int lcbSttbfffn; // count of bytes in sttbfffn
- private boolean isExtndChar;
+ private short _stringCount;// how many strings are included in the string table
+ private short _extraDataSz;// size in bytes of the extra data
+ // added extra facilitator members
+ private int lcbSttbfffn;// count of bytes in sttbfffn
+ private int fcSttbfffn;// table stream offset for sttbfffn
// FFN structure containing strings of font names
- private Ffn [] fontNames = null;
+ private Ffn[] _fontNames = null;
+
public FontTable(byte[] buf, int offset, int lcbSttbfffn)
{
this.lcbSttbfffn = lcbSttbfffn;
+ this.fcSttbfffn = offset;
- exntdChar = LittleEndian.getShort(buf, offset);
+ _stringCount = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
- stringCount = LittleEndian.getShort(buf, offset);
+ _extraDataSz = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
- extraDataSz = LittleEndian.getShort(buf, offset);
- offset += LittleEndian.SHORT_SIZE;
-
- if ((exntdChar & 0xFFFF) == 0xFFFF)
- {
- isExtndChar = true;
- }
- else
- {
- isExtndChar = false;
- }
- fontNames = new Ffn[stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
+ _fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
- for(int i = 0;i<stringCount; i++)
+ for(int i = 0;i<_stringCount; i++)
{
- // some mistake in the fields we have chosen
- if(offset >= this.getSize())
- {
- System.out.println("Total size of Sttbfn mismatched with calculated size");
- break;
- }
-
- fontNames[i] = new Ffn(buf,offset);
- offset += fontNames[i].getSize();
+ _fontNames[i] = new Ffn(buf,offset);
+ offset += _fontNames[i].getSize();
}
}
- public boolean isExtndChar()
+ public short getStringCount()
{
- return isExtndChar;
+ return _stringCount;
}
- public short getStringCount()
+ public short getExtraDataSz()
{
- return stringCount;
+ return _extraDataSz;
+ }
+
+ public Ffn[] getFontNames()
+ {
+ return _fontNames;
}
public int getSize()
@@ -124,31 +121,76 @@
public char [] getMainFont(int chpFtc )
{
- if(chpFtc >= stringCount)
+ if(chpFtc >= _stringCount)
{
System.out.println("Mismatch in chpFtc with stringCount");
return null;
}
- return fontNames[chpFtc].getMainFontName();
+ return _fontNames[chpFtc].getMainFontName();
}
public char [] getAltFont(int chpFtc )
{
- if(chpFtc >= stringCount)
+ if(chpFtc >= _stringCount)
{
System.out.println("Mismatch in chpFtc with stringCount");
return null;
}
- return fontNames[chpFtc].getAltFontName();
+ return _fontNames[chpFtc].getAltFontName();
}
public void setStringCount(short stringCount)
{
- this.stringCount = stringCount;
+ this._stringCount = stringCount;
}
+ public void writeTo(HWPFFileSystem sys)
+ throws IOException
+ {
+ HWPFOutputStream tableStream = sys.getStream("1Table");
+
+ byte[] buf = new byte[LittleEndian.SHORT_SIZE];
+ LittleEndian.putShort(buf, _stringCount);
+ tableStream.write(buf);
+ LittleEndian.putShort(buf, _extraDataSz);
+ tableStream.write(buf);
+
+ for(int i = 0; i < _fontNames.length; i++)
+ {
+ tableStream.write(_fontNames[i].toByteArray());
+ }
+
+ }
+
+ public boolean equals(Object o)
+ {
+ boolean retVal = true;
+
+ if(((FontTable)o).getStringCount() == _stringCount)
+ {
+ if(((FontTable)o).getExtraDataSz() == _extraDataSz)
+ {
+ Ffn[] fontNamesNew = ((FontTable)o).getFontNames();
+ for(int i = 0;i<_stringCount; i++)
+ {
+ if(!(_fontNames[i].equals(fontNamesNew[i])))
+ retVal = false;
+ }
+ }
+ else
+ retVal = false;
+ }
+ else
+ retVal = false;
+
+
+ return retVal;
+ }
+
+
}
+
1.5 +1 -1 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/PAPBinTable.java
Index: PAPBinTable.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/PAPBinTable.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PAPBinTable.java 1 Jul 2003 23:57:07 -0000 1.4
+++ PAPBinTable.java 15 Jul 2003 03:22:53 -0000 1.5
@@ -141,7 +141,7 @@
int end = endingFc;
if (overflow != null)
{
- end = ((PropertyNode)overflow.get(0)).getStart();
+ end = ((PropertyNode)overflow.get(0)).getStart() + fcMin;
}
byte[] intHolder = new byte[4];
1.6 +39 -14 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/PAPFormattedDiskPage.java
Index: PAPFormattedDiskPage.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/PAPFormattedDiskPage.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PAPFormattedDiskPage.java 1 Jul 2003 23:57:07 -0000 1.5
+++ PAPFormattedDiskPage.java 15 Jul 2003 03:22:53 -0000 1.6
@@ -58,6 +58,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Arrays;
/**
* Represents a PAP FKP. The style properties for paragraph and character runs
@@ -152,6 +153,7 @@
int grpprlOffset = 0;
int bxOffset = 0;
int fcOffset = 0;
+ byte[] lastGrpprl = new byte[0];
// total size is currently the size of one FC
int totalSize = FC_SIZE;
@@ -159,16 +161,28 @@
int index = 0;
for (; index < size; index++)
{
- int grpprlLength = ((PAPX)_papxList.get(index)).getGrpprl().length;
+ byte[] grpprl = ((PAPX)_papxList.get(index)).getGrpprl();
+ int grpprlLength = grpprl.length;
// check to see if we have enough room for an FC, a BX, and the grpprl
// and the 1 byte size of the grpprl.
- totalSize += (FC_SIZE + BX_SIZE + grpprlLength + 1);
+ int addition = 0;
+ if (!Arrays.equals(grpprl, lastGrpprl))
+ {
+ addition = (FC_SIZE + BX_SIZE + grpprlLength + 1);
+ }
+ else
+ {
+ addition = (FC_SIZE + BX_SIZE);
+ }
+
+ totalSize += addition;
+
// if size is uneven we will have to add one so the first grpprl falls
// on a word boundary
if (totalSize > 511 + (index % 2))
{
- totalSize -= (FC_SIZE + BX_SIZE + grpprlLength);
+ totalSize -= addition;
break;
}
@@ -181,6 +195,7 @@
{
totalSize += 2;
}
+ lastGrpprl = grpprl;
}
// see if we couldn't fit some
@@ -197,14 +212,19 @@
grpprlOffset = 511;
PAPX papx = null;
+ lastGrpprl = new byte[0];
for (int x = 0; x < index; x++)
{
papx = (PAPX)_papxList.get(x);
byte[] phe = papx.getParagraphHeight().toByteArray();
byte[] grpprl = papx.getGrpprl();
- grpprlOffset -= (grpprl.length + (2 - grpprl.length % 2));
- grpprlOffset -= (grpprlOffset % 2);
+ boolean same = Arrays.equals(lastGrpprl, grpprl);
+ if (!same)
+ {
+ grpprlOffset -= (grpprl.length + (2 - grpprl.length % 2));
+ grpprlOffset -= (grpprlOffset % 2);
+ }
LittleEndian.putInt(buf, fcOffset, papx.getStart() + fcMin);
buf[bxOffset] = (byte)(grpprlOffset/2);
System.arraycopy(phe, 0, buf, bxOffset + 1, phe.length);
@@ -212,20 +232,25 @@
// refer to the section on PAPX in the spec. Places a size on the front
// of the PAPX. Has to do with how the grpprl stays on word
// boundaries.
- int copyOffset = grpprlOffset;
- if ((grpprl.length % 2) > 0)
- {
- buf[copyOffset++] = (byte)((grpprl.length + 1)/2);
- }
- else
+ if (!same)
{
- buf[++copyOffset] = (byte)((grpprl.length)/2);
- copyOffset++;
+ int copyOffset = grpprlOffset;
+ if ( (grpprl.length % 2) > 0)
+ {
+ buf[copyOffset++] = (byte) ( (grpprl.length + 1) / 2);
+ }
+ else
+ {
+ buf[++copyOffset] = (byte) ( (grpprl.length) / 2);
+ copyOffset++;
+ }
+ System.arraycopy(grpprl, 0, buf, copyOffset, grpprl.length);
+ lastGrpprl = grpprl;
}
- System.arraycopy(grpprl, 0, buf, copyOffset, grpprl.length);
bxOffset += BX_SIZE;
fcOffset += FC_SIZE;
+
}
// put the last papx's end in
LittleEndian.putInt(buf, fcOffset, papx.getEnd() + fcMin);
1.4 +14 -10 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/StyleDescription.java
Index: StyleDescription.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/StyleDescription.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StyleDescription.java 7 Jul 2003 00:45:06 -0000 1.3
+++ StyleDescription.java 15 Jul 2003 03:22:53 -0000 1.4
@@ -146,38 +146,42 @@
// the spec only refers to two possible upxs but it mentions
// that more may be added in the future
- int add = 0;
+ int varOffset = grupxStart;
int numUPX = _numUPX.getValue(_infoShort3);
for(int x = 0; x < numUPX; x++)
{
- int upxSize = LittleEndian.getShort(std, grupxStart + add);
+ int upxSize = LittleEndian.getShort(std, varOffset);
+ varOffset += LittleEndian.SHORT_SIZE;
if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
{
if(x == 0)
{
- _istd = LittleEndian.getShort(std, grupxStart + add + 2);
+ _istd = LittleEndian.getShort(std, varOffset);
+ varOffset += LittleEndian.SHORT_SIZE;
int grrprlSize = upxSize - 2;
- _papx = new byte[upxSize];
- System.arraycopy(std, grupxStart + add + 4, _papx, 0, grrprlSize);
+ _papx = new byte[grrprlSize];
+ System.arraycopy(std, varOffset, _papx, 0, grrprlSize);
+ varOffset += grrprlSize;
}
else if(x == 1)
{
_chpx = new byte[upxSize];
- System.arraycopy(std, grupxStart + add + 2, _chpx, 0, upxSize);
+ System.arraycopy(std, varOffset, _chpx, 0, upxSize);
+ varOffset += upxSize;
}
}
else if(_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE && x == 0)
{
_chpx = new byte[upxSize];
- System.arraycopy(std, grupxStart + add + 2, _chpx, 0, upxSize);
+ System.arraycopy(std, varOffset, _chpx, 0, upxSize);
}
// the upx will always start on a word boundary.
if(upxSize % 2 == 1)
{
- ++upxSize;
+ ++varOffset;
}
- add += 2 + upxSize;
+
}
@@ -259,7 +263,7 @@
//only worry about papx and chpx for upxs
if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
{
- LittleEndian.putShort(buf, offset, (short)_papx.length);
+ LittleEndian.putShort(buf, offset, (short)(_papx.length + 2));
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_istd);
offset += LittleEndian.SHORT_SIZE;
1.3 +1 -1 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/StyleSheet.java
Index: StyleSheet.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/StyleSheet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StyleSheet.java 7 Jul 2003 00:45:06 -0000 1.2
+++ StyleSheet.java 15 Jul 2003 03:22:53 -0000 1.3
@@ -161,7 +161,7 @@
throws IOException
{
int offset = 0;
- // add two bytes so we can prepend the styelsheet w/ its size
+ // add two bytes so we can prepend the stylesheet w/ its size
byte[] buf = new byte[_stshiLength + 2];
LittleEndian.putShort(buf, offset, (short)_stshiLength);
offset += LittleEndian.SHORT_SIZE;