sackley 2003/11/11 03:41:51
Modified: src/scratchpad/src/org/apache/poi/hwpf/sprm
CharacterSprmCompresser.java
CharacterSprmUncompressor.java
ParagraphSprmCompressor.java
ParagraphSprmUncompressor.java
SectionSprmCompressor.java
SectionSprmUncompressor.java
Log:
latest changes
Revision Changes Path
1.3 +4 -7
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmCompresser.java
Index: CharacterSprmCompresser.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmCompresser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CharacterSprmCompresser.java 10 Nov 2003 11:52:11 -0000 1.2
+++ CharacterSprmCompresser.java 11 Nov 2003 11:41:50 -0000 1.3
@@ -58,7 +58,7 @@
import java.util.List;
import java.util.Arrays;
-import org.apache.poi.hwpf.usermodel.CharacterProperties;
+import org.apache.poi.hwpf.usermodel.CharacterRun;
import org.apache.poi.util.LittleEndian;
public class CharacterSprmCompresser
@@ -66,7 +66,7 @@
public CharacterSprmCompresser()
{
}
- public static byte[] compressCharacterProperty(CharacterProperties newCHP,
CharacterProperties oldCHP)
+ public static byte[] compressCharacterProperty(CharacterRun newCHP, CharacterRun
oldCHP)
{
ArrayList sprmList = new ArrayList();
int size = 0;
@@ -108,13 +108,10 @@
{
size += SprmUtils.addSprm((short)0x4804, newCHP.getIbstRMark(), null,
sprmList);
}
- if (!Arrays.equals(newCHP.getDttmRMark(), oldCHP.getDttmRMark()))
+ if (!newCHP.getDttmRMark().equals(oldCHP.getDttmRMark()))
{
- // Create an int for the sprm
- short[] dttmMark = newCHP.getDttmRMark();
byte[] buf = new byte[4];
- LittleEndian.putShort(buf, dttmMark[0]);
- LittleEndian.putShort(buf, 2, dttmMark[1]);
+ newCHP.getDttmRMark().serialize(buf, 0);
size += SprmUtils.addSprm((short)0x6805, LittleEndian.getInt(buf), null,
sprmList);
}
1.2 +7 -7
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
Index: CharacterSprmUncompressor.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CharacterSprmUncompressor.java 10 Nov 2003 11:52:31 -0000 1.1
+++ CharacterSprmUncompressor.java 11 Nov 2003 11:41:50 -0000 1.2
@@ -54,7 +54,7 @@
package org.apache.poi.hwpf.sprm;
-import org.apache.poi.hwpf.usermodel.CharacterProperties;
+import org.apache.poi.hwpf.usermodel.CharacterRun;
import org.apache.poi.hwpf.usermodel.DateAndTime;
import org.apache.poi.hwpf.usermodel.BorderCode;
import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
@@ -67,14 +67,14 @@
{
}
- public static CharacterProperties uncompressCHP(CharacterProperties parent,
+ public static CharacterRun uncompressCHP(CharacterRun parent,
byte[] grpprl,
int offset)
{
- CharacterProperties newProperties = null;
+ CharacterRun newProperties = null;
try
{
- newProperties = (CharacterProperties) parent.clone();
+ newProperties = (CharacterRun) parent.clone();
}
catch (CloneNotSupportedException cnse)
{
@@ -105,8 +105,8 @@
* @param offset The offset in the grpprl of the next sprm
* @param styleSheet The StyleSheet for this document.
*/
- static void unCompressCHPOperation (CharacterProperties oldCHP,
- CharacterProperties newCHP,
+ static void unCompressCHPOperation (CharacterRun oldCHP,
+ CharacterRun newCHP,
SprmOperation sprm)
{
@@ -264,7 +264,7 @@
{
// preserve the fSpec setting from the original CHP
boolean fSpec = newCHP.isFSpec ();
- newCHP = (CharacterProperties) oldCHP.clone ();
+ newCHP = (CharacterRun) oldCHP.clone ();
newCHP.setFSpec (fSpec);
}
1.3 +34 -35
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmCompressor.java
Index: ParagraphSprmCompressor.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmCompressor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ParagraphSprmCompressor.java 10 Nov 2003 11:52:15 -0000 1.2
+++ ParagraphSprmCompressor.java 11 Nov 2003 11:41:50 -0000 1.3
@@ -60,7 +60,7 @@
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hwpf.usermodel.ParagraphProperties;
+import org.apache.poi.hwpf.usermodel.Paragraph;
public class ParagraphSprmCompressor
{
@@ -68,8 +68,8 @@
{
}
- public static byte[] compressParagraphProperty(ParagraphProperties newPAP,
- ParagraphProperties oldPAP)
+ public static byte[] compressParagraphProperty(Paragraph newPAP,
+ Paragraph oldPAP)
{
ArrayList sprmList = new ArrayList();
int size = 0;
@@ -126,22 +126,23 @@
!Arrays.equals(newPAP.getRgdxaTab(), oldPAP.getRgdxaTab()) ||
!Arrays.equals(newPAP.getRgtbd(), oldPAP.getRgtbd()))
{
- byte[] oldTabArray = oldPAP.getRgdxaTab();
- byte[] newTabArray = newPAP.getRgdxaTab();
- byte[] newTabDescriptors = newPAP.getRgtbd();
- byte[] varParam = new byte[2 + oldTabArray.length + newTabArray.length +
- newTabDescriptors.length];
- varParam[0] = (byte)(oldTabArray.length/2);
- int offset = 1;
- System.arraycopy(oldTabArray, 0, varParam, offset, oldTabArray.length);
- offset += oldTabArray.length;
- varParam[offset] = (byte)(newTabArray.length/2);
- offset += 1;
- System.arraycopy(newTabArray, 0, varParam, offset, newTabArray.length);
- offset += newTabArray.length;
- System.arraycopy(newTabDescriptors, 0, varParam, offset,
newTabDescriptors.length);
-
- size += SprmUtils.addSprm((short)0xC60D, 0, varParam, sprmList);
+ /** @todo revisit this */
+// byte[] oldTabArray = oldPAP.getRgdxaTab();
+// byte[] newTabArray = newPAP.getRgdxaTab();
+// byte[] newTabDescriptors = newPAP.getRgtbd();
+// byte[] varParam = new byte[2 + oldTabArray.length + newTabArray.length +
+// newTabDescriptors.length];
+// varParam[0] = (byte)(oldTabArray.length/2);
+// int offset = 1;
+// System.arraycopy(oldTabArray, 0, varParam, offset, oldTabArray.length);
+// offset += oldTabArray.length;
+// varParam[offset] = (byte)(newTabArray.length/2);
+// offset += 1;
+// System.arraycopy(newTabArray, 0, varParam, offset, newTabArray.length);
+// offset += newTabArray.length;
+// System.arraycopy(newTabDescriptors, 0, varParam, offset,
newTabDescriptors.length);
+//
+// size += SprmUtils.addSprm((short)0xC60D, 0, varParam, sprmList);
}
if (newPAP.getDxaRight() != oldPAP.getDxaRight())
{
@@ -155,12 +156,10 @@
{
size += SprmUtils.addSprm((short)0x8411, newPAP.getDxaLeft1(), null,
sprmList);
}
- if (!Arrays.equals(newPAP.getLspd(), oldPAP.getLspd()))
+ if (!newPAP.getLspd().equals(oldPAP.getLspd()))
{
- short[] lspd = newPAP.getLspd();
byte[] buf = new byte[4];
- LittleEndian.putShort(buf, 0, lspd[0]);
- LittleEndian.putShort(buf, 2, lspd[1]);
+ newPAP.getLspd().serialize(buf, 0);
size += SprmUtils.addSprm((short)0x6412, LittleEndian.getInt(buf), null,
sprmList);
}
@@ -255,29 +254,29 @@
{
size += SprmUtils.addSprm((short)0x841A, newPAP.getDxaWidth(), null,
sprmList);
}
- if (!Arrays.equals(newPAP.getBrcTop(), oldPAP.getBrcTop()))
+ if (!newPAP.getBrcTop().equals(oldPAP.getBrcTop()))
{
- int brc = SprmUtils.convertBrcToInt(newPAP.getBrcTop());
+ int brc = newPAP.getBrcTop().toInt();
size += SprmUtils.addSprm((short)0x6424, brc, null, sprmList);
}
- if (!Arrays.equals(newPAP.getBrcLeft(), oldPAP.getBrcLeft()))
+ if (!newPAP.getBrcLeft().equals(oldPAP.getBrcLeft()))
{
- int brc = SprmUtils.convertBrcToInt(newPAP.getBrcLeft());
+ int brc = newPAP.getBrcLeft().toInt();
size += SprmUtils.addSprm((short)0x6425, brc, null, sprmList);
}
- if (!Arrays.equals(newPAP.getBrcBottom(), oldPAP.getBrcBottom()))
+ if (!newPAP.getBrcBottom().equals(oldPAP.getBrcBottom()))
{
- int brc = SprmUtils.convertBrcToInt(newPAP.getBrcBottom());
+ int brc = newPAP.getBrcBottom().toInt();
size += SprmUtils.addSprm((short)0x6426, brc, null, sprmList);
}
- if (!Arrays.equals(newPAP.getBrcRight(), oldPAP.getBrcRight()))
+ if (!newPAP.getBrcRight().equals(oldPAP.getBrcRight()))
{
- int brc = SprmUtils.convertBrcToInt(newPAP.getBrcRight());
+ int brc = newPAP.getBrcRight().toInt();
size += SprmUtils.addSprm((short)0x6427, brc, null, sprmList);
}
- if (!Arrays.equals(newPAP.getBrcBar(), oldPAP.getBrcBar()))
+ if (newPAP.getBrcBar().equals(oldPAP.getBrcBar()))
{
- int brc = SprmUtils.convertBrcToInt(newPAP.getBrcBar());
+ int brc = newPAP.getBrcBar().toInt();
size += SprmUtils.addSprm((short)0x6428, brc, null, sprmList);
}
if (newPAP.getDxaFromText() != oldPAP.getDxaFromText())
@@ -316,12 +315,12 @@
}
if (newPAP.getFPropRMark() != oldPAP.getFPropRMark() ||
newPAP.getIbstPropRMark() != oldPAP.getIbstPropRMark() ||
- !Arrays.equals(newPAP.getDttmPropRMark(), oldPAP.getDttmPropRMark()))
+ !newPAP.getDttmPropRMark().equals(oldPAP.getDttmPropRMark()))
{
byte[] buf = new byte[7];
buf[0] = (byte)newPAP.getFPropRMark();
LittleEndian.putShort(buf, 1, (short)newPAP.getIbstPropRMark());
- System.arraycopy(newPAP.getDttmPropRMark(), 0, buf, 3, 4);
+ newPAP.getDttmPropRMark().serialize(buf, 3);
size += SprmUtils.addSprm((short)0xC63F, 0, buf, sprmList);
}
if (!Arrays.equals(newPAP.getNumrm(), oldPAP.getNumrm()))
1.2 +6 -6
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java
Index: ParagraphSprmUncompressor.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParagraphSprmUncompressor.java 10 Nov 2003 11:52:43 -0000 1.1
+++ ParagraphSprmUncompressor.java 11 Nov 2003 11:41:50 -0000 1.2
@@ -54,7 +54,7 @@
package org.apache.poi.hwpf.sprm;
-import org.apache.poi.hwpf.usermodel.ParagraphProperties;
+import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.usermodel.BorderCode;
import org.apache.poi.hwpf.usermodel.DateAndTime;
import org.apache.poi.hwpf.usermodel.LineSpacingDescriptor;
@@ -73,14 +73,14 @@
{
}
- public static ParagraphProperties uncompressPAP(ParagraphProperties parent,
+ public static Paragraph uncompressPAP(Paragraph parent,
byte[] grpprl,
int offset)
{
- ParagraphProperties newProperties = null;
+ Paragraph newProperties = null;
try
{
- newProperties = (ParagraphProperties) parent.clone();
+ newProperties = (Paragraph) parent.clone();
}
catch (CloneNotSupportedException cnse)
{
@@ -109,7 +109,7 @@
* @param offset The current offset in the papx.
* @param spra A part of the sprm that defined this operation.
*/
- static void unCompressPAPOperation (ParagraphProperties newPAP, SprmOperation
sprm)
+ static void unCompressPAPOperation (Paragraph newPAP, SprmOperation sprm)
{
switch (sprm.getOperation())
{
@@ -410,7 +410,7 @@
}
}
- private static void handleTabs(ParagraphProperties pap, SprmOperation sprm)
+ private static void handleTabs(Paragraph pap, SprmOperation sprm)
{
byte[] grpprl = sprm.getGrpprl();
int offset = sprm.getGrpprlOffset();
1.2 +14 -14
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmCompressor.java
Index: SectionSprmCompressor.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmCompressor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SectionSprmCompressor.java 10 Nov 2003 11:52:49 -0000 1.1
+++ SectionSprmCompressor.java 11 Nov 2003 11:41:50 -0000 1.2
@@ -58,18 +58,18 @@
import java.util.Arrays;
import org.apache.poi.hwpf.model.hdftypes.definitions.SEPAbstractType;
-import org.apache.poi.hwpf.usermodel.SectionProperties;
+import org.apache.poi.hwpf.usermodel.Section;
import org.apache.poi.util.LittleEndian;
public class SectionSprmCompressor
{
- private final static SectionProperties DEFAULT_SEP = new SectionProperties();
+ private final static Section DEFAULT_SEP = new Section();
public SectionSprmCompressor()
{
}
- public static byte[] compressSectionProperty(SectionProperties newSEP,
- SectionProperties oldSEP)
+ public static byte[] compressSectionProperty(Section newSEP,
+ Section oldSEP)
{
int size = 0;
ArrayList sprmList = new ArrayList();
@@ -220,31 +220,31 @@
}
if (newSEP.getFPropMark() != DEFAULT_SEP.getFPropMark() ||
newSEP.getIbstPropRMark() != DEFAULT_SEP.getIbstPropRMark() ||
- newSEP.getDttmPropRMark() != DEFAULT_SEP.getDttmPropRMark())
+ !newSEP.getDttmPropRMark().equals(DEFAULT_SEP.getDttmPropRMark()))
{
byte[] buf = new byte[7];
buf[0] = (byte)(newSEP.getFPropMark() ? 1 : 0);
int offset = LittleEndian.BYTE_SIZE;
LittleEndian.putShort(buf, (short)newSEP.getIbstPropRMark());
offset += LittleEndian.SHORT_SIZE;
- LittleEndian.putInt(buf, newSEP.getDttmPropRMark());
+ newSEP.getDttmPropRMark().serialize(buf, offset);
size += SprmUtils.addSprm((short)0xD227, -1, buf, sprmList);
}
- if (!Arrays.equals(newSEP.getBrcTop(), DEFAULT_SEP.getBrcTop()))
+ if (!newSEP.getBrcTop().equals( DEFAULT_SEP.getBrcTop()))
{
- size += SprmUtils.addSprm((short)0x702B,
SprmUtils.convertBrcToInt(newSEP.getBrcTop()), null, sprmList);
+ size += SprmUtils.addSprm((short)0x702B, newSEP.getBrcTop().toInt(), null,
sprmList);
}
- if (!Arrays.equals(newSEP.getBrcLeft(), DEFAULT_SEP.getBrcLeft()))
+ if (!newSEP.getBrcLeft().equals(DEFAULT_SEP.getBrcLeft()))
{
- size += SprmUtils.addSprm((short)0x702C,
SprmUtils.convertBrcToInt(newSEP.getBrcLeft()), null, sprmList);
+ size += SprmUtils.addSprm((short)0x702C, newSEP.getBrcLeft().toInt(), null,
sprmList);
}
- if (!Arrays.equals(newSEP.getBrcBottom(), DEFAULT_SEP.getBrcBottom()))
+ if (!newSEP.getBrcBottom().equals(DEFAULT_SEP.getBrcBottom()))
{
- size += SprmUtils.addSprm((short)0x702D,
SprmUtils.convertBrcToInt(newSEP.getBrcBottom()), null, sprmList);
+ size += SprmUtils.addSprm((short)0x702D, newSEP.getBrcBottom().toInt(), null,
sprmList);
}
- if (!Arrays.equals(newSEP.getBrcRight(), DEFAULT_SEP.getBrcRight()))
+ if (!newSEP.getBrcRight().equals(DEFAULT_SEP.getBrcRight()))
{
- size += SprmUtils.addSprm((short)0x702E,
SprmUtils.convertBrcToInt(newSEP.getBrcRight()), null, sprmList);
+ size += SprmUtils.addSprm((short)0x702E, newSEP.getBrcRight().toInt(), null,
sprmList);
}
if (newSEP.getPgbProp() != DEFAULT_SEP.getPgbProp())
{
1.2 +5 -5
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java
Index: SectionSprmUncompressor.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmUncompressor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SectionSprmUncompressor.java 10 Nov 2003 11:52:56 -0000 1.1
+++ SectionSprmUncompressor.java 11 Nov 2003 11:41:50 -0000 1.2
@@ -54,7 +54,7 @@
package org.apache.poi.hwpf.sprm;
-import org.apache.poi.hwpf.usermodel.SectionProperties;
+import org.apache.poi.hwpf.usermodel.Section;
import org.apache.poi.hwpf.usermodel.BorderCode;
public class SectionSprmUncompressor extends SprmUncompressor
@@ -62,14 +62,14 @@
public SectionSprmUncompressor()
{
}
- public static SectionProperties uncompressSEP(SectionProperties parent,
+ public static Section uncompressSEP(Section parent,
byte[] grpprl,
int offset)
{
- SectionProperties newProperties = null;
+ Section newProperties = null;
try
{
- newProperties = (SectionProperties) parent.clone();
+ newProperties = (Section) parent.clone();
}
catch (CloneNotSupportedException cnse)
{
@@ -95,7 +95,7 @@
* @param param The operation's parameter.
* @param varParam The operation variable length parameter.
*/
- static void unCompressSEPOperation (SectionProperties newSEP, SprmOperation sprm)
+ static void unCompressSEPOperation (Section newSEP, SprmOperation sprm)
{
switch (sprm.getOperation())
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]