diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CHPFormattedDiskPage.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CHPFormattedDiskPage.java
index 7022b87e7..e34067655 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CHPFormattedDiskPage.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CHPFormattedDiskPage.java
@@ -51,7 +51,10 @@
* information on the Apache Software Foundation, please see
* .
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
+
+import java.util.List;
+import java.util.ArrayList;
import org.apache.poi.util.LittleEndian;
@@ -73,7 +76,15 @@ import org.apache.poi.util.LittleEndian;
*/
public class CHPFormattedDiskPage extends FormattedDiskPage
{
+ private static final int FC_SIZE = 4;
+ private ArrayList _chpxList = new ArrayList();
+ private ArrayList _overFlow;
+
+
+ public CHPFormattedDiskPage()
+ {
+ }
/**
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
@@ -81,9 +92,29 @@ public class CHPFormattedDiskPage extends FormattedDiskPage
*
* @param fkp The 512 byte array to read data from
*/
- public CHPFormattedDiskPage(byte[] fkp)
+ public CHPFormattedDiskPage(byte[] documentStream, int offset, int fcMin)
{
- super(fkp);
+ super(documentStream, offset);
+
+ for (int x = 0; x < _crun; x++)
+ {
+ _chpxList.add(new CHPX(getStart(x) - fcMin, getEnd(x) - fcMin, getGrpprl(x)));
+ }
+ }
+
+ public CHPX getCHPX(int index)
+ {
+ return (CHPX)_chpxList.get(index);
+ }
+
+ public void fill(List filler)
+ {
+ _chpxList.addAll(filler);
+ }
+
+ public ArrayList getOverflow()
+ {
+ return _overFlow;
}
/**
@@ -92,22 +123,87 @@ public class CHPFormattedDiskPage extends FormattedDiskPage
* @param index The index of the chpx to get.
* @return a chpx grpprl.
*/
- public byte[] getGrpprl(int index)
+ protected byte[] getGrpprl(int index)
{
- int chpxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, ((_crun + 1) * 4) + index);
+ int chpxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * 4) + index));
//optimization if offset == 0 use "Normal" style
if(chpxOffset == 0)
{
return new byte[0];
-
}
- int size = LittleEndian.getUnsignedByte(_fkp, chpxOffset);
+ int size = LittleEndian.getUnsignedByte(_fkp, _offset + chpxOffset);
byte[] chpx = new byte[size];
- System.arraycopy(_fkp, ++chpxOffset, chpx, 0, size);
+ System.arraycopy(_fkp, _offset + ++chpxOffset, chpx, 0, size);
return chpx;
}
-}
\ No newline at end of file
+
+ protected byte[] toByteArray(int fcMin)
+ {
+ byte[] buf = new byte[512];
+ int size = _chpxList.size();
+ int grpprlOffset = 0;
+ int offsetOffset = 0;
+ int fcOffset = 0;
+
+ // total size is currently the size of one FC
+ int totalSize = FC_SIZE;
+
+ int index = 0;
+ for (; index < size; index++)
+ {
+ int grpprlLength = ((CHPX)_chpxList.get(index)).getGrpprl().length;
+
+ // check to see if we have enough room for an FC, a byte, and the grpprl.
+ totalSize += (FC_SIZE + 1 + grpprlLength);
+ // 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 + 1 + grpprlLength);
+ break;
+ }
+
+ // grpprls must fall on word boundaries
+ if (grpprlLength % 2 > 0)
+ {
+ totalSize += 1;
+ }
+ }
+
+ // see if we couldn't fit some
+ if (index != size)
+ {
+ _overFlow = new ArrayList();
+ _overFlow.addAll(index, _chpxList);
+ }
+
+ // index should equal number of CHPXs that will be in this fkp now.
+ buf[511] = (byte)index;
+
+ offsetOffset = (FC_SIZE * index) + FC_SIZE;
+ grpprlOffset = offsetOffset + index + (grpprlOffset % 2);
+
+ CHPX chpx = null;
+ for (int x = 0; x < index; x++)
+ {
+ chpx = (CHPX)_chpxList.get(x);
+ byte[] grpprl = chpx.getGrpprl();
+
+ LittleEndian.putInt(buf, fcOffset, chpx.getStart() + fcMin);
+ buf[offsetOffset] = (byte)(grpprlOffset/2);
+ System.arraycopy(grpprl, 0, buf, grpprlOffset, grpprl.length);
+
+ grpprlOffset += grpprl.length + (grpprl.length % 2);
+ offsetOffset += 1;
+ fcOffset += FC_SIZE;
+ }
+ // put the last chpx's end in
+ LittleEndian.putInt(buf, fcOffset, chpx.getEnd() + fcMin);
+ return buf;
+ }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/DocumentProperties.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/DocumentProperties.java
index 08fda3084..dc196417b 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/DocumentProperties.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/DocumentProperties.java
@@ -55,38 +55,23 @@
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hwpf.model.hdftypes.definitions.DOPAbstractType;
+
/**
* Comment me
*
* @author Ryan Ackley
*/
-public class DocumentProperties implements HDFType
+public class DocumentProperties extends DOPAbstractType
{
- public boolean _fFacingPages;
- public int _fpc;
- public int _epc;
- public int _rncFtn;
- public int _nFtn;
- public int _rncEdn;
- public int _nEdn;
- public DocumentProperties(byte[] dopArray)
+ public DocumentProperties(byte[] tableStream, int offset)
{
- _fFacingPages = (dopArray[0] & 0x1) > 0;
- _fpc = (dopArray[0] & 0x60) >> 5;
-
- short num = LittleEndian.getShort(dopArray, 2);
- _rncFtn = (num & 0x3);
- _nFtn = (short)(num & 0xfffc) >> 2;
- num = LittleEndian.getShort(dopArray, 52);
- _rncEdn = num & 0x3;
- _nEdn = (short)(num & 0xfffc) >> 2;
- num = LittleEndian.getShort(dopArray, 54);
- _epc = num & 0x3;
+ super.fillFields(tableStream, (short)0, offset);
}
-}
\ No newline at end of file
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java
index 5e5c782d2..3b939603f 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java
@@ -1,10 +1,65 @@
-package org.apache.poi.hdf.model.hdftypes;
+/*
+ * ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hdf.model.hdftypes.definitions.FIBAbstractType;
+import org.apache.poi.hwpf.model.hdftypes.definitions.FIBAbstractType;
/**
*
@@ -102,7 +157,7 @@ public class FileInformationBlock extends FIBAbstractType
private int field_51_unknown;
private int field_52_unknown; */
- //not sure about this array.
+ //not sure about this array.
/*
private short field_53_fc_lcb_array_size;
private int field_54_original_stylesheet_offset;
@@ -183,7 +238,7 @@ public class FileInformationBlock extends FIBAbstractType
^/
- /** Creates a new instance of FileInformationBlock */
+ /** Creates a new instance of FileInformationBlock */
public FileInformationBlock(byte[] mainDocument)
{
fillFields(mainDocument, (short)0, (short)0);
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FormattedDiskPage.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FormattedDiskPage.java
index c18105d61..e2e892323 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FormattedDiskPage.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FormattedDiskPage.java
@@ -52,7 +52,7 @@
* .
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
@@ -80,32 +80,40 @@ public abstract class FormattedDiskPage
{
protected byte[] _fkp;
protected int _crun;
+ protected int _offset;
+
+
+ public FormattedDiskPage()
+ {
+
+ }
/**
* Uses a 512-byte array to create a FKP
*/
- public FormattedDiskPage(byte[] fkp)
+ public FormattedDiskPage(byte[] documentStream, int offset)
{
- _crun = LittleEndian.getUnsignedByte(fkp, 511);
- _fkp = fkp;
+ _crun = LittleEndian.getUnsignedByte(documentStream, offset + 511);
+ _fkp = documentStream;
+ _offset = offset;
}
/**
* Used to get a text offset corresponding to a grpprl in this fkp.
* @param index The index of the property in this FKP
* @return an int representing an offset in the "WordDocument" stream
*/
- public int getStart(int index)
+ protected int getStart(int index)
{
- return LittleEndian.getInt(_fkp, (index * 4));
+ return LittleEndian.getInt(_fkp, _offset + (index * 4));
}
/**
* Used to get the end of the text corresponding to a grpprl in this fkp.
* @param index The index of the property in this fkp.
* @return an int representing an offset in the "WordDocument" stream
*/
- public int getEnd(int index)
+ protected int getEnd(int index)
{
- return LittleEndian.getInt(_fkp, ((index + 1) * 4));
+ return LittleEndian.getInt(_fkp, _offset + ((index + 1) * 4));
}
/**
* Used to get the total number of grrprl's stored int this FKP
@@ -116,5 +124,5 @@ public abstract class FormattedDiskPage
return _crun;
}
- public abstract byte[] getGrpprl(int index);
-}
\ No newline at end of file
+ protected abstract byte[] getGrpprl(int index);
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HDFType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HDFType.java
index f0e318fbc..c3f12e6b3 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HDFType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HDFType.java
@@ -4,7 +4,7 @@
* Created on February 24, 2002, 2:37 PM
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
/**
*
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PAPFormattedDiskPage.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PAPFormattedDiskPage.java
index defe9343e..f23234a43 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PAPFormattedDiskPage.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PAPFormattedDiskPage.java
@@ -51,10 +51,14 @@
* information on the Apache Software Foundation, please see
* .
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
+import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Represents a PAP FKP. The style properties for paragraph and character runs
* are stored in fkps. There are PAP fkps for paragraph properties and CHP fkps
@@ -74,29 +78,62 @@ import org.apache.poi.util.LittleEndian;
public class PAPFormattedDiskPage extends FormattedDiskPage
{
+ private static final int BX_SIZE = 13;
+ private static final int FC_SIZE = 4;
+
+ private ArrayList _papxList = new ArrayList();
+ private ArrayList _overFlow;
+
+
+ public PAPFormattedDiskPage()
+ {
+
+ }
+
/**
* Creates a PAPFormattedDiskPage from a 512 byte array
*
* @param fkp a 512 byte array.
*/
- public PAPFormattedDiskPage(byte[] fkp)
+ public PAPFormattedDiskPage(byte[] documentStream, int offset, int fcMin)
{
- super(fkp);
+ super(documentStream, offset);
+
+ for (int x = 0; x < _crun; x++)
+ {
+ _papxList.add(new PAPX(getStart(x) - fcMin, getEnd(x) - fcMin, getGrpprl(x), getParagraphHeight(x)));
+ }
+ _fkp = null;
+ }
+
+ public void fill(List filler)
+ {
+ _papxList.addAll(filler);
+ }
+
+ public ArrayList getOverflow()
+ {
+ return _overFlow;
+ }
+
+ public PAPX getPAPX(int index)
+ {
+ return (PAPX)_papxList.get(index);
}
/**
- * Gets the papx for the pagraph at index in this fkp.
+ * Gets the papx for the paragraph at index in this fkp.
*
* @param index The index of the papx to get.
* @return a papx grpprl.
*/
- public byte[] getGrpprl(int index)
+ protected byte[] getGrpprl(int index)
{
- int papxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, ((_crun + 1) * 4) + (index * 13));
- int size = 2 * LittleEndian.getUnsignedByte(_fkp, papxOffset);
+ int papxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * FC_SIZE) + (index * BX_SIZE)));
+ int size = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + papxOffset);
if(size == 0)
{
- size = 2 * LittleEndian.getUnsignedByte(_fkp, ++papxOffset);
+ size = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + ++papxOffset);
}
else
{
@@ -104,7 +141,100 @@ public class PAPFormattedDiskPage extends FormattedDiskPage
}
byte[] papx = new byte[size];
- System.arraycopy(_fkp, ++papxOffset, papx, 0, size);
+ System.arraycopy(_fkp, _offset + ++papxOffset, papx, 0, size);
return papx;
}
-}
\ No newline at end of file
+
+ protected byte[] toByteArray(int fcMin)
+ {
+ byte[] buf = new byte[512];
+ int size = _papxList.size();
+ int grpprlOffset = 0;
+ int bxOffset = 0;
+ int fcOffset = 0;
+
+ // total size is currently the size of one FC
+ int totalSize = FC_SIZE;
+
+ int index = 0;
+ for (; index < size; index++)
+ {
+ int grpprlLength = ((PAPX)_papxList.get(index)).getGrpprl().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);
+ // 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);
+ break;
+ }
+
+ // grpprls must fall on word boundaries
+ if (grpprlLength % 2 > 0)
+ {
+ totalSize += 1;
+ }
+ else
+ {
+ totalSize += 2;
+ }
+ }
+
+ // see if we couldn't fit some
+ if (index != size)
+ {
+ _overFlow = new ArrayList();
+ _overFlow.addAll(index, _papxList);
+ }
+
+ // index should equal number of papxs that will be in this fkp now.
+ buf[511] = (byte)index;
+
+ bxOffset = (FC_SIZE * index) + FC_SIZE;
+ grpprlOffset = bxOffset + (BX_SIZE * index) + (grpprlOffset % 2);
+
+ PAPX papx = null;
+ for (int x = 0; x < index; x++)
+ {
+ papx = (PAPX)_papxList.get(x);
+ byte[] phe = papx.getParagraphHeight().toByteArray();
+ byte[] grpprl = papx.getGrpprl();
+
+ LittleEndian.putInt(buf, fcOffset, papx.getStart() + fcMin);
+ buf[bxOffset] = (byte)(grpprlOffset/2);
+ System.arraycopy(phe, 0, buf, bxOffset + 1, phe.length);
+
+ // 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.
+ if ((grpprl.length % 2) > 0)
+ {
+ buf[grpprlOffset++] = (byte)((grpprl.length + 1)/2);
+ }
+ else
+ {
+ buf[++grpprlOffset] = (byte)((grpprl.length)/2);
+ grpprlOffset++;
+ }
+ System.arraycopy(grpprl, 0, buf, grpprlOffset, grpprl.length);
+
+ bxOffset += BX_SIZE;
+ fcOffset += FC_SIZE;
+ }
+ // put the last papx's end in
+ LittleEndian.putInt(buf, fcOffset, papx.getEnd() + fcMin);
+ return buf;
+ }
+
+ private ParagraphHeight getParagraphHeight(int index)
+ {
+ int pheOffset = 1 + (2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * 4) + (index * 13))));
+
+ ParagraphHeight phe = new ParagraphHeight(_fkp, pheOffset);
+
+ return phe;
+ }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PlexOfCps.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PlexOfCps.java
index c902f4002..8a75cd321 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PlexOfCps.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PlexOfCps.java
@@ -51,62 +51,129 @@
* information on the Apache Software Foundation, please see
* .
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
+
+import java.util.ArrayList;
+
+import org.apache.poi.util.LittleEndian;
+
/**
* common data structure in a Word file. Contains an array of 4 byte ints in
* the front that relate to an array of abitrary data structures in the back.
*
- * This class acts more like a pointer. In the sense that it doesn't store any
- * data. It only provides convenience methods for accessing a particular
- * PlexOfCps
*
* @author Ryan Ackley
*/
public class PlexOfCps
{
- private int _count;
- private int _offset;
- private int _sizeOfStruct;
+ private int _count;
+ private int _offset;
+ private int _sizeOfStruct;
+ private ArrayList _props;
- /**
- * Constructor
- *
- * @param size The size in bytes of this PlexOfCps
- * @param sizeOfStruct The size of the data structure type stored in
- * this PlexOfCps.
- */
- public PlexOfCps(int size, int sizeOfStruct)
+ public PlexOfCps(int sizeOfStruct)
+ {
+ _props = new ArrayList();
+ _sizeOfStruct = sizeOfStruct;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param size The size in bytes of this PlexOfCps
+ * @param sizeOfStruct The size of the data structure type stored in
+ * this PlexOfCps.
+ */
+ public PlexOfCps(byte[] buf, int start, int size, int sizeOfStruct)
+ {
+ _count = (size - 4)/(4 + sizeOfStruct);
+ _sizeOfStruct = sizeOfStruct;
+ _props = new ArrayList(_count);
+
+ for (int x = 0; x < _count; x++)
{
- _count = (size - 4)/(4 + sizeOfStruct);
- _sizeOfStruct = sizeOfStruct;
+ _props.add(getProperty(x, buf, start));
}
- public int getIntOffset(int index)
+ }
+
+ public PropertyNode getProperty(int index)
+ {
+ return (PropertyNode)_props.get(index);
+ }
+
+ public void addProperty(PropertyNode node)
+ {
+ _props.add(node);
+ }
+
+ public byte[] toByteArray()
+ {
+ int size = _props.size();
+ int cpBufSize = ((size + 1) * LittleEndian.INT_SIZE);
+ int structBufSize = + (_sizeOfStruct * size);
+ int bufSize = cpBufSize + structBufSize;
+
+ byte[] buf = new byte[bufSize];
+
+ PropertyNode node = null;
+ for (int x = 0; x < size; x++)
{
- return index * 4;
+ node = (PropertyNode)_props.get(x);
+
+ // put the starting offset of the property into the plcf.
+ LittleEndian.putInt(buf, (LittleEndian.INT_SIZE * x), node.getStart());
+
+ // put the struct into the plcf
+ System.arraycopy(node.getBuf(), 0, buf, cpBufSize + (x * _sizeOfStruct),
+ _sizeOfStruct);
}
- /**
- * returns the number of data structures in this PlexOfCps.
- *
- * @return The number of data structures in this PlexOfCps
- */
- public int length()
- {
- return _count;
- }
- /**
- * Returns the offset, in bytes, from the beginning if this PlexOfCps to
- * the data structure at index.
- *
- * @param index The index of the data structure.
- *
- * @return The offset, in bytes, from the beginning if this PlexOfCps to
- * the data structure at index.
- */
- public int getStructOffset(int index)
- {
- return (4 * (_count + 1)) + (_sizeOfStruct * index);
- }
-}
\ No newline at end of file
+ // put the ending offset of the last property into the plcf.
+ LittleEndian.putInt(buf, LittleEndian.INT_SIZE * size, node.getEnd());
+
+ return buf;
+
+ }
+
+ private PropertyNode getProperty(int index, byte[] buf, int offset)
+ {
+ int start = LittleEndian.getInt(buf, offset + getIntOffset(index));
+ int end = LittleEndian.getInt(buf, offset + getIntOffset(index+1));
+
+ byte[] struct = new byte[_sizeOfStruct];
+ System.arraycopy(buf, offset + getStructOffset(index), struct, 0, _sizeOfStruct);
+
+ return new PropertyNode(start, end, struct);
+ }
+
+ private int getIntOffset(int index)
+ {
+ return index * 4;
+ }
+
+ /**
+ * returns the number of data structures in this PlexOfCps.
+ *
+ * @return The number of data structures in this PlexOfCps
+ */
+ public int length()
+ {
+ return _count;
+ }
+
+ /**
+ * Returns the offset, in bytes, from the beginning if this PlexOfCps to
+ * the data structure at index.
+ *
+ * @param index The index of the data structure.
+ *
+ * @return The offset, in bytes, from the beginning if this PlexOfCps to
+ * the data structure at index.
+ */
+ private int getStructOffset(int index)
+ {
+ return (4 * (_count + 1)) + (_sizeOfStruct * index);
+ }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PropertyNode.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PropertyNode.java
index d04185729..c7255e6b6 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PropertyNode.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PropertyNode.java
@@ -51,64 +51,65 @@
* information on the Apache Software Foundation, please see
* .
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
+
/**
- * Represents a lightweight node in the Trees used to store formatting
+ * Represents a lightweight node in the Trees used to store content
* properties.
*
* @author Ryan Ackley
*/
public class PropertyNode implements Comparable
{
- private byte[] _grpprl;
- private int _fcStart;
- private int _fcEnd;
+ private byte[] _buf;
+ private int _cpStart;
+ private int _cpEnd;
/**
* @param fcStart The start of the text for this property.
* @param fcEnd The end of the text for this property.
* @param grpprl The property description in compressed form.
*/
- public PropertyNode(int fcStart, int fcEnd, byte[] grpprl)
+ public PropertyNode(int fcStart, int fcEnd, byte[] buf)
{
- _fcStart = fcStart;
- _fcEnd = fcEnd;
- _grpprl = grpprl;
+ _cpStart = fcStart;
+ _cpEnd = fcEnd;
+ _buf = buf;
}
/**
* @return The offset of this property's text.
*/
public int getStart()
{
- return _fcStart;
+ return _cpStart;
}
/**
* @retrun The offset of the end of this property's text.
*/
public int getEnd()
{
- return _fcEnd;
+ return _cpEnd;
}
/**
* @return This property's property in copmpressed form.
*/
- protected byte[] getGrpprl()
+ public byte[] getBuf()
{
- return _grpprl;
+ return _buf;
}
/**
* Used for sorting in collections.
*/
public int compareTo(Object o)
{
- int fcEnd = ((PropertyNode)o).getEnd();
- if(_fcEnd == fcEnd)
+ int cpEnd = ((PropertyNode)o).getEnd();
+ if(_cpEnd == cpEnd)
{
return 0;
}
- else if(_fcEnd < fcEnd)
+ else if(_cpEnd < cpEnd)
{
return -1;
}
@@ -117,4 +118,4 @@ public class PropertyNode implements Comparable
return 1;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleDescription.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleDescription.java
index c133b993c..263e80441 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleDescription.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleDescription.java
@@ -54,9 +54,12 @@
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
+
+import java.io.UnsupportedEncodingException;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.BitField;
/**
* Comment me
*
@@ -69,27 +72,44 @@ public class StyleDescription implements HDFType
private static int PARAGRAPH_STYLE = 1;
private static int CHARACTER_STYLE = 2;
- int _baseStyleIndex;
- int _styleTypeCode;
- int _numUPX;
+ private short _infoShort;
+ private static BitField _sti = new BitField(0xfff);
+ private static BitField _fScratch = new BitField(0x1000);
+ private static BitField _fInvalHeight = new BitField(0x2000);
+ private static BitField _fHasUpe = new BitField(0x4000);
+ private static BitField _fMassCopy = new BitField(0x8000);
+ private short _infoShort2;
+ private static BitField _styleTypeCode = new BitField(0xf);
+ private static BitField _baseStyle = new BitField(0xfff0);
+ private static BitField _numUPX = new BitField(0xf);
+ private static BitField _nextStyle = new BitField(0xfff0);
+ private short _bchUpe;
+ private short _infoShort3;
+ private static BitField _fAutoRedef = new BitField(0x1);
+ private static BitField _fHidden = new BitField(0x2);
+
byte[] _papx;
byte[] _chpx;
- ParagraphProperties _pap;
- CharacterProperties _chp;
+ String _name;
+// ParagraphProperties _pap;
+// CharacterProperties _chp;
public StyleDescription()
{
- _pap = new ParagraphProperties();
- _chp = new CharacterProperties();
+// _pap = new ParagraphProperties();
+// _chp = new CharacterProperties();
}
- public StyleDescription(byte[] std, int baseLength, boolean word9)
+ public StyleDescription(byte[] std, int baseLength, int offset, boolean word9)
{
- int infoShort = LittleEndian.getShort(std, 2);
- _styleTypeCode = (infoShort & 0xf);
- _baseStyleIndex = (infoShort & 0xfff0) >> 4;
-
- infoShort = LittleEndian.getShort(std, 4);
- _numUPX = infoShort & 0xf;
+ int nameStart = offset + baseLength;
+ _infoShort = LittleEndian.getShort(std, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _infoShort2 = LittleEndian.getShort(std, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _bchUpe = LittleEndian.getShort(std, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _infoShort3 = LittleEndian.getShort(std, offset);
+ offset += LittleEndian.SHORT_SIZE;
//first byte(s) of variable length section of std is the length of the
//style name and aliases string
@@ -97,52 +117,66 @@ public class StyleDescription implements HDFType
int multiplier = 1;
if(word9)
{
- nameLength = LittleEndian.getShort(std, baseLength);
+ nameLength = LittleEndian.getShort(std, nameStart);
multiplier = 2;
+ nameStart += LittleEndian.SHORT_SIZE;
}
else
{
- nameLength = std[baseLength];
+ nameLength = std[nameStart];
}
- //2 bytes for length, length then null terminator.
- int grupxStart = multiplier + ((nameLength + 1) * multiplier) + baseLength;
- int offset = 0;
- for(int x = 0; x < _numUPX; x++)
+ try
{
- int upxSize = LittleEndian.getShort(std, grupxStart + offset);
- if(_styleTypeCode == PARAGRAPH_STYLE)
+ _name = new String(std, nameStart, nameLength * multiplier, "UTF-16LE");
+ }
+ catch (UnsupportedEncodingException ignore)
+ {
+ // ignore
+ }
+
+ //2 bytes for length, length then null terminator.
+ int grupxStart = multiplier + ((nameLength + 1) * multiplier) + nameStart;
+
+ // the spec only refers to two possible upxs but it mentions
+ // that more may be added in the future
+ int add = 0;
+ int numUPX = _numUPX.getValue(_infoShort2);
+ for(int x = 0; x < numUPX; x++)
+ {
+ int upxSize = LittleEndian.getShort(std, grupxStart + add);
+ if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
{
if(x == 0)
{
_papx = new byte[upxSize];
- System.arraycopy(std, grupxStart + offset + 2, _papx, 0, upxSize);
+ System.arraycopy(std, grupxStart + add + 2, _papx, 0, upxSize);
}
else if(x == 1)
{
_chpx = new byte[upxSize];
- System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
+ System.arraycopy(std, grupxStart + add + 2, _chpx, 0, upxSize);
}
}
- else if(_styleTypeCode == CHARACTER_STYLE && x == 0)
+ else if(_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE && x == 0)
{
_chpx = new byte[upxSize];
- System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
+ System.arraycopy(std, grupxStart + add + 2, _chpx, 0, upxSize);
}
+ // the upx will always start on a word boundary.
if(upxSize % 2 == 1)
{
++upxSize;
}
- offset += 2 + upxSize;
+ add += 2 + upxSize;
}
-
}
public int getBaseStyle()
{
- return _baseStyleIndex;
+ return _baseStyle.getValue(_infoShort2);
}
public byte[] getCHPX()
{
@@ -152,20 +186,83 @@ public class StyleDescription implements HDFType
{
return _papx;
}
- public ParagraphProperties getPAP()
+// public ParagraphProperties getPAP()
+// {
+// return _pap;
+// }
+// public CharacterProperties getCHP()
+// {
+// return _chp;
+// }
+// public void setPAP(ParagraphProperties pap)
+// {
+// _pap = pap;
+// }
+// public void setCHP(CharacterProperties chp)
+// {
+// _chp = chp;
+// }
+ public byte[] toByteArray()
{
- return _pap;
+ // size equals 8 bytes for known variables plus 2 bytes for name length plus
+ // name length * 2 plus 2 bytes for null plus upx's preceded by length
+ int size = 8 + 2 + ((_name.length() + 1) * 2);
+
+ //only worry about papx and chpx for upxs
+ if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
+ {
+ size += _papx.length + 2 + (_papx.length % 2);
+ size += _chpx.length + 2;
+ }
+ else if (_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE)
+ {
+ size += _chpx.length + 2;
+ }
+
+ byte[] buf = new byte[size];
+
+ int offset = 0;
+ LittleEndian.putShort(buf, offset, _infoShort);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, _infoShort2);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, _bchUpe);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, _infoShort3);
+ offset += LittleEndian.SHORT_SIZE;
+
+ char[] letters = _name.toCharArray();
+ LittleEndian.putShort(buf, offset, (short)letters.length);
+ offset += LittleEndian.SHORT_SIZE;
+ for (int x = 0; x < letters.length; x++)
+ {
+ LittleEndian.putShort(buf, offset, (short)letters[x]);
+ offset += LittleEndian.SHORT_SIZE;
+ }
+ // get past the null delimiter for the name.
+ offset += LittleEndian.SHORT_SIZE;
+
+ //only worry about papx and chpx for upxs
+ if(_styleTypeCode.getValue(_infoShort2) == PARAGRAPH_STYLE)
+ {
+ LittleEndian.putShort(buf, offset, (short)_papx.length);
+ offset += LittleEndian.SHORT_SIZE;
+ System.arraycopy(_papx, 0, buf, offset, _papx.length);
+ offset += _papx.length + (_papx.length % 2);
+
+ LittleEndian.putShort(buf, offset, (short)_chpx.length);
+ offset += LittleEndian.SHORT_SIZE;
+ System.arraycopy(_chpx, 0, buf, offset, _chpx.length);
+ offset += _chpx.length;
+ }
+ else if (_styleTypeCode.getValue(_infoShort2) == CHARACTER_STYLE)
+ {
+ LittleEndian.putShort(buf, offset, (short)_chpx.length);
+ offset += LittleEndian.SHORT_SIZE;
+ System.arraycopy(_chpx, 0, buf, offset, _chpx.length);
+ offset += _chpx.length;
+ }
+
+ return buf;
}
- public CharacterProperties getCHP()
- {
- return _chp;
- }
- public void setPAP(ParagraphProperties pap)
- {
- _pap = pap;
- }
- public void setCHP(CharacterProperties chp)
- {
- _chp = chp;
- }
-}
\ No newline at end of file
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
index 9c153e906..87a3f4441 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
@@ -55,11 +55,14 @@
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
import java.util.*;
+import java.io.IOException;
+
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hdf.model.hdftypes.definitions.TCAbstractType;
+import org.apache.poi.hwpf.model.io.HWPFOutputStream;
+//import org.apache.poi.hdf.model.hdftypes.definitions.TCAbstractType;
/**
* Represents a document's stylesheet. A word documents formatting is stored as
@@ -78,7 +81,16 @@ public class StyleSheet implements HDFType
private static final int CHP_TYPE = 2;
private static final int SEP_TYPE = 4;
private static final int TAP_TYPE = 5;
- //Vector _styleDescriptions;
+
+
+ private int _stshiLength;
+ private int _baseLength;
+ private int _flags;
+ private int _maxIndex;
+ private int _maxFixedIndex;
+ private int _stylenameVersion;
+ private int[] _rgftc;
+
StyleDescription _nilStyle = new StyleDescription();
StyleDescription[] _styleDescriptions;
@@ -89,48 +101,110 @@ public class StyleSheet implements HDFType
* info. Found by using FileInformationBlock.getFcStshf() and
* FileInformationBLock.getLcbStshf()
*/
- public StyleSheet(byte[] styleSheet)
+ public StyleSheet(byte[] styleSheet, int offset)
{
- int stshiLength = LittleEndian.getShort(styleSheet, 0);
- int stdCount = LittleEndian.getShort(styleSheet, 2);
- int baseLength = LittleEndian.getShort(styleSheet, 4);
- int[] rgftc = new int[3];
+ _stshiLength = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ int stdCount = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _baseLength = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _flags = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _maxIndex = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _maxFixedIndex = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _stylenameVersion = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
- rgftc[0] = LittleEndian.getInt(styleSheet, 14);
- rgftc[1] = LittleEndian.getInt(styleSheet, 18);
- rgftc[2] = LittleEndian.getInt(styleSheet, 22);
+ _rgftc = new int[3];
+ _rgftc[0] = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _rgftc[1] = LittleEndian.getShort(styleSheet, offset);
+ offset += LittleEndian.SHORT_SIZE;
+ _rgftc[2] = LittleEndian.getShort(styleSheet, offset);
- int offset = 0;
+ offset = (2 + _stshiLength);
_styleDescriptions = new StyleDescription[stdCount];
for(int x = 0; x < stdCount; x++)
{
- int stdOffset = (2 + stshiLength) + offset;
- int stdSize = LittleEndian.getShort(styleSheet, stdOffset);
+
+ int stdSize = LittleEndian.getShort(styleSheet, offset);
if(stdSize > 0)
{
byte[] std = new byte[stdSize];
//get past the size
- stdOffset += 2;
- System.arraycopy(styleSheet, stdOffset, std, 0, stdSize);
- StyleDescription aStyle = new StyleDescription(std, baseLength, true);
+ offset += 2;
+
+ StyleDescription aStyle = new StyleDescription(styleSheet,
+ _baseLength, offset, true);
_styleDescriptions[x] = aStyle;
}
-
- offset += stdSize + 2;
+ offset += stdSize;
}
for(int x = 0; x < _styleDescriptions.length; x++)
{
if(_styleDescriptions[x] != null)
{
- createPap(x);
- createChp(x);
+// createPap(x);
+// createChp(x);
}
}
}
+
+ public void write(HWPFOutputStream out)
+ throws IOException
+ {
+ int offset = 0;
+ byte[] buf = new byte[_stshiLength];
+ LittleEndian.putShort(buf, offset, (short)_stshiLength);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_styleDescriptions.length);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_baseLength);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_flags);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_maxIndex);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_maxFixedIndex);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_stylenameVersion);
+ offset += LittleEndian.SHORT_SIZE;
+
+ LittleEndian.putShort(buf, offset, (short)_rgftc[0]);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_rgftc[1]);
+ offset += LittleEndian.SHORT_SIZE;
+ LittleEndian.putShort(buf, offset, (short)_rgftc[2]);
+
+ out.write(buf);
+
+ byte[] sizeHolder = new byte[2];
+ for (int x = 0; x < _styleDescriptions.length; x++)
+ {
+ if(_styleDescriptions[x] != null)
+ {
+ byte[] std = _styleDescriptions[x].toByteArray();
+
+ LittleEndian.putShort(sizeHolder, (short)std.length);
+ out.write(sizeHolder);
+ out.write(std);
+ }
+ else
+ {
+ sizeHolder[0] = 0;
+ sizeHolder[1] = 0;
+ out.write(sizeHolder);
+ }
+ }
+
+ }
/**
* Creates a PartagraphProperties object from a papx stored in the
* StyleDescription at the index istd in the StyleDescription array. The PAP
@@ -141,66 +215,66 @@ public class StyleSheet implements HDFType
* @param istd The index of the StyleDescription to create the
* ParagraphProperties from (and also place the finished PAP in)
*/
- private void createPap(int istd)
- {
- StyleDescription sd = _styleDescriptions[istd];
- ParagraphProperties pap = sd.getPAP();
- byte[] papx = sd.getPAPX();
- int baseIndex = sd.getBaseStyle();
- if(pap == null && papx != null)
- {
- ParagraphProperties parentPAP = _nilStyle.getPAP();
- if(baseIndex != NIL_STYLE)
- {
-
- parentPAP = _styleDescriptions[baseIndex].getPAP();
- if(parentPAP == null)
- {
- createPap(baseIndex);
- parentPAP = _styleDescriptions[baseIndex].getPAP();
- }
-
- }
-
- pap = (ParagraphProperties)uncompressProperty(papx, parentPAP, this);
- sd.setPAP(pap);
- }
- }
- /**
- * Creates a CharacterProperties object from a chpx stored in the
- * StyleDescription at the index istd in the StyleDescription array. The
- * CharacterProperties object is placed in the StyleDescription at istd after
- * its been created. Not every StyleDescription will contain a chpx. In these
- * cases this function does nothing.
- *
- * @param istd The index of the StyleDescription to create the
- * CharacterProperties object from.
- */
- private void createChp(int istd)
- {
- StyleDescription sd = _styleDescriptions[istd];
- CharacterProperties chp = sd.getCHP();
- byte[] chpx = sd.getCHPX();
- int baseIndex = sd.getBaseStyle();
- if(chp == null && chpx != null)
- {
- CharacterProperties parentCHP = _nilStyle.getCHP();
- if(baseIndex != NIL_STYLE)
- {
-
- parentCHP = _styleDescriptions[baseIndex].getCHP();
- if(parentCHP == null)
- {
- createChp(baseIndex);
- parentCHP = _styleDescriptions[baseIndex].getCHP();
- }
-
- }
-
- chp = (CharacterProperties)uncompressProperty(chpx, parentCHP, this);
- sd.setCHP(chp);
- }
- }
+// private void createPap(int istd)
+// {
+// StyleDescription sd = _styleDescriptions[istd];
+// ParagraphProperties pap = sd.getPAP();
+// byte[] papx = sd.getPAPX();
+// int baseIndex = sd.getBaseStyle();
+// if(pap == null && papx != null)
+// {
+// ParagraphProperties parentPAP = _nilStyle.getPAP();
+// if(baseIndex != NIL_STYLE)
+// {
+//
+// parentPAP = _styleDescriptions[baseIndex].getPAP();
+// if(parentPAP == null)
+// {
+// createPap(baseIndex);
+// parentPAP = _styleDescriptions[baseIndex].getPAP();
+// }
+//
+// }
+//
+// pap = (ParagraphProperties)uncompressProperty(papx, parentPAP, this);
+// sd.setPAP(pap);
+// }
+// }
+// /**
+// * Creates a CharacterProperties object from a chpx stored in the
+// * StyleDescription at the index istd in the StyleDescription array. The
+// * CharacterProperties object is placed in the StyleDescription at istd after
+// * its been created. Not every StyleDescription will contain a chpx. In these
+// * cases this function does nothing.
+// *
+// * @param istd The index of the StyleDescription to create the
+// * CharacterProperties object from.
+// */
+// private void createChp(int istd)
+// {
+// StyleDescription sd = _styleDescriptions[istd];
+// CharacterProperties chp = sd.getCHP();
+// byte[] chpx = sd.getCHPX();
+// int baseIndex = sd.getBaseStyle();
+// if(chp == null && chpx != null)
+// {
+// CharacterProperties parentCHP = _nilStyle.getCHP();
+// if(baseIndex != NIL_STYLE)
+// {
+//
+// parentCHP = _styleDescriptions[baseIndex].getCHP();
+// if(parentCHP == null)
+// {
+// createChp(baseIndex);
+// parentCHP = _styleDescriptions[baseIndex].getCHP();
+// }
+//
+// }
+//
+// chp = (CharacterProperties)uncompressProperty(chpx, parentCHP, this);
+// sd.setCHP(chp);
+// }
+// }
/**
* Gets the StyleDescription at index x.
@@ -212,460 +286,460 @@ public class StyleSheet implements HDFType
return _styleDescriptions[x];
}
- /**
- * Used in decompression of a chpx. This performs an operation defined by
- * a single sprm.
- *
- * @param oldCHP The base CharacterProperties.
- * @param newCHP The current CharacterProperties.
- * @param operand The operand defined by the sprm (See Word file format spec)
- * @param param The parameter defined by the sprm (See Word file format spec)
- * @param varParam The variable length parameter defined by the sprm. (See
- * Word file format spec)
- * @param grpprl The entire chpx that this operation is a part of.
- * @param offset The offset in the grpprl of the next sprm
- * @param styleSheet The StyleSheet for this document.
- */
- static void doCHPOperation(CharacterProperties oldCHP, CharacterProperties newCHP,
- int operand, int param,
- byte[] varParam, byte[] grpprl, int offset,
- StyleSheet styleSheet)
- {
- switch(operand)
- {
- case 0:
- newCHP.setFRMarkDel(getFlag(param));
- break;
- case 0x1:
- newCHP.setFRMark(getFlag(param));
- break;
- case 0x2:
- break;
- case 0x3:
- newCHP.setFcPic(param);
- newCHP.setFSpec(true);
- break;
- case 0x4:
- newCHP.setIbstRMark((short)param);
- break;
- case 0x5:
- short[] dttmRMark = new short[2];
- dttmRMark[0] = LittleEndian.getShort(grpprl, (offset - 4));
- dttmRMark[1] = LittleEndian.getShort(grpprl, (offset - 2));
- newCHP.setDttmRMark(dttmRMark);
- break;
- case 0x6:
- newCHP.setFData(getFlag(param));
- break;
- case 0x7:
- //don't care about this
- break;
- case 0x8:
- short chsDiff = (short)((param & 0xff0000) >>> 8);
- newCHP.setFChsDiff(getFlag(chsDiff));
- newCHP.setChse((short)(param & 0xffff));
- break;
- case 0x9:
- newCHP.setFSpec(true);
- newCHP.setFtcSym((short)LittleEndian.getShort(varParam, 0));
- newCHP.setXchSym((short)LittleEndian.getShort(varParam, 2));
- break;
- case 0xa:
- newCHP.setFOle2(getFlag(param));
- break;
- case 0xb:
- //?
- break;
- case 0xc:
- newCHP.setIcoHighlight((byte)param);
- newCHP.setFHighlight(getFlag(param));
- break;
- case 0xd:
- break;
- case 0xe:
- newCHP.setFcObj(param);
- break;
- case 0xf:
- break;
- case 0x10:
- //?
- break;
- case 0x11:
- break;
- case 0x12:
- break;
- case 0x13:
- break;
- case 0x14:
- break;
- case 0x15:
- break;
- case 0x16:
- break;
- case 0x17:
- break;
- case 0x18:
- break;
- case 0x19:
- break;
- case 0x1a:
- break;
- case 0x1b:
- break;
- case 0x1c:
- break;
- case 0x1d:
- break;
- case 0x1e:
- break;
- case 0x1f:
- break;
- case 0x20:
- break;
- case 0x21:
- break;
- case 0x22:
- break;
- case 0x23:
- break;
- case 0x24:
- break;
- case 0x25:
- break;
- case 0x26:
- break;
- case 0x27:
- break;
- case 0x28:
- break;
- case 0x29:
- break;
- case 0x2a:
- break;
- case 0x2b:
- break;
- case 0x2c:
- break;
- case 0x2d:
- break;
- case 0x2e:
- break;
- case 0x2f:
- break;
- case 0x30:
- newCHP.setIstd(param);
- break;
- case 0x31:
- //permutation vector for fast saves, who cares!
- break;
- case 0x32:
- newCHP.setFBold(false);
- newCHP.setFItalic(false);
- newCHP.setFOutline(false);
- newCHP.setFStrike(false);
- newCHP.setFShadow(false);
- newCHP.setFSmallCaps(false);
- newCHP.setFCaps(false);
- newCHP.setFVanish(false);
- newCHP.setKul((byte)0);
- newCHP.setIco((byte)0);
- break;
- case 0x33:
- try
- {
- newCHP = (CharacterProperties)oldCHP.clone();
- }
- catch(CloneNotSupportedException e)
- {
- //do nothing
- }
- return;
- case 0x34:
- break;
- case 0x35:
- newCHP.setFBold(getCHPFlag((byte)param, oldCHP.isFBold()));
- break;
- case 0x36:
- newCHP.setFItalic(getCHPFlag((byte)param, oldCHP.isFItalic()));
- break;
- case 0x37:
- newCHP.setFStrike(getCHPFlag((byte)param, oldCHP.isFStrike()));
- break;
- case 0x38:
- newCHP.setFOutline(getCHPFlag((byte)param, oldCHP.isFOutline()));
- break;
- case 0x39:
- newCHP.setFShadow(getCHPFlag((byte)param, oldCHP.isFShadow()));
- break;
- case 0x3a:
- newCHP.setFSmallCaps(getCHPFlag((byte)param, oldCHP.isFSmallCaps()));
- break;
- case 0x3b:
- newCHP.setFCaps(getCHPFlag((byte)param, oldCHP.isFCaps()));
- break;
- case 0x3c:
- newCHP.setFVanish(getCHPFlag((byte)param, oldCHP.isFVanish()));
- break;
- case 0x3d:
- newCHP.setFtcAscii((short)param);
- break;
- case 0x3e:
- newCHP.setKul((byte)param);
- break;
- case 0x3f:
- int hps = param & 0xff;
- if(hps != 0)
- {
- newCHP.setHps(hps);
- }
- byte cInc = (byte)(((byte)(param & 0xfe00) >>> 4) >> 1);
- if(cInc != 0)
- {
- newCHP.setHps(Math.max(newCHP.getHps() + (cInc * 2), 2));
- }
- byte hpsPos = (byte)((param & 0xff0000) >>> 8);
- if(hpsPos != 0x80)
- {
- newCHP.setHpsPos(hpsPos);
- }
- boolean fAdjust = (param & 0x0100) > 0;
- if(fAdjust && hpsPos != 128 && hpsPos != 0 && oldCHP.getHpsPos() == 0)
- {
- newCHP.setHps(Math.max(newCHP.getHps() + (-2), 2));
- }
- if(fAdjust && hpsPos == 0 && oldCHP.getHpsPos() != 0)
- {
- newCHP.setHps(Math.max(newCHP.getHps() + 2, 2));
- }
- break;
- case 0x40:
- newCHP.setDxaSpace(param);
- break;
- case 0x41:
- newCHP.setLidDefault((short)param);
- break;
- case 0x42:
- newCHP.setIco((byte)param);
- break;
- case 0x43:
- newCHP.setHps(param);
- break;
- case 0x44:
- byte hpsLvl = (byte)param;
- newCHP.setHps(Math.max(newCHP.getHps() + (hpsLvl * 2), 2));
- break;
- case 0x45:
- newCHP.setHpsPos((short)param);
- break;
- case 0x46:
- if(param != 0)
- {
- if(oldCHP.getHpsPos() == 0)
- {
- newCHP.setHps(Math.max(newCHP.getHps() + (-2), 2));
- }
- }
- else
- {
- if(oldCHP.getHpsPos() != 0)
- {
- newCHP.setHps(Math.max(newCHP.getHps() + 2, 2));
- }
- }
- break;
- case 0x47:
- CharacterProperties genCHP = new CharacterProperties();
- genCHP.setFtcAscii(4);
- genCHP = (CharacterProperties)uncompressProperty(varParam, genCHP, styleSheet);
- CharacterProperties styleCHP = styleSheet.getStyleDescription(oldCHP.getBaseIstd()).getCHP();
- if(genCHP.isFBold() == newCHP.isFBold())
- {
- newCHP.setFBold(styleCHP.isFBold());
- }
- if(genCHP.isFItalic() == newCHP.isFItalic())
- {
- newCHP.setFItalic(styleCHP.isFItalic());
- }
- if(genCHP.isFSmallCaps() == newCHP.isFSmallCaps())
- {
- newCHP.setFSmallCaps(styleCHP.isFSmallCaps());
- }
- if(genCHP.isFVanish() == newCHP.isFVanish())
- {
- newCHP.setFVanish(styleCHP.isFVanish());
- }
- if(genCHP.isFStrike() == newCHP.isFStrike())
- {
- newCHP.setFStrike(styleCHP.isFStrike());
- }
- if(genCHP.isFCaps() == newCHP.isFCaps())
- {
- newCHP.setFCaps(styleCHP.isFCaps());
- }
- if(genCHP.getFtcAscii() == newCHP.getFtcAscii())
- {
- newCHP.setFtcAscii(styleCHP.getFtcAscii());
- }
- if(genCHP.getFtcFE() == newCHP.getFtcFE())
- {
- newCHP.setFtcFE(styleCHP.getFtcFE());
- }
- if(genCHP.getFtcOther() == newCHP.getFtcOther())
- {
- newCHP.setFtcOther(styleCHP.getFtcOther());
- }
- if(genCHP.getHps() == newCHP.getHps())
- {
- newCHP.setHps(styleCHP.getHps());
- }
- if(genCHP.getHpsPos() == newCHP.getHpsPos())
- {
- newCHP.setHpsPos(styleCHP.getHpsPos());
- }
- if(genCHP.getKul() == newCHP.getKul())
- {
- newCHP.setKul(styleCHP.getKul());
- }
- if(genCHP.getDxaSpace() == newCHP.getDxaSpace())
- {
- newCHP.setDxaSpace(styleCHP.getDxaSpace());
- }
- if(genCHP.getIco() == newCHP.getIco())
- {
- newCHP.setIco(styleCHP.getIco());
- }
- if(genCHP.getLidDefault() == newCHP.getLidDefault())
- {
- newCHP.setLidDefault(styleCHP.getLidDefault());
- }
- if(genCHP.getLidFE() == newCHP.getLidFE())
- {
- newCHP.setLidFE(styleCHP.getLidFE());
- }
- break;
- case 0x48:
- newCHP.setIss((byte)param);
- break;
- case 0x49:
- newCHP.setHps(LittleEndian.getShort(varParam, 0));
- break;
- case 0x4a:
- int increment = LittleEndian.getShort(varParam, 0);
- newCHP.setHps(Math.max(newCHP.getHps() + increment, 8));
- break;
- case 0x4b:
- newCHP.setHpsKern(param);
- break;
- case 0x4c:
- doCHPOperation(oldCHP, newCHP, 0x47, param, varParam, grpprl, offset, styleSheet);
- break;
- case 0x4d:
- float percentage = (float)param/100.0f;
- int add = (int)((float)percentage * (float)newCHP.getHps());
- newCHP.setHps(newCHP.getHps() + add);
- break;
- case 0x4e:
- newCHP.setYsr((byte)param);
- break;
- case 0x4f:
- newCHP.setFtcAscii((short)param);
- break;
- case 0x50:
- newCHP.setFtcFE((short)param);
- break;
- case 0x51:
- newCHP.setFtcOther((short)param);
- break;
- case 0x52:
- break;
- case 0x53:
- newCHP.setFDStrike(getFlag(param));
- break;
- case 0x54:
- newCHP.setFImprint(getFlag(param));
- break;
- case 0x55:
- newCHP.setFSpec(getFlag(param));
- break;
- case 0x56:
- newCHP.setFObj(getFlag(param));
- break;
- case 0x57:
- newCHP.setFPropMark(varParam[0]);
- newCHP.setIbstPropRMark((short)LittleEndian.getShort(varParam, 1));
- newCHP.setDttmPropRMark(LittleEndian.getInt(varParam, 3));
- break;
- case 0x58:
- newCHP.setFEmboss(getFlag(param));
- break;
- case 0x59:
- newCHP.setSfxtText((byte)param);
- break;
- case 0x5a:
- break;
- case 0x5b:
- break;
- case 0x5c:
- break;
- case 0x5d:
- break;
- case 0x5e:
- break;
- case 0x5f:
- break;
- case 0x60:
- break;
- case 0x61:
- break;
- case 0x62:
- byte[] xstDispFldRMark = new byte[32];
- newCHP.setFDispFldRMark(varParam[0]);
- newCHP.setIbstDispFldRMark((short)LittleEndian.getShort(varParam, 1));
- newCHP.setDttmDispFldRMark(LittleEndian.getInt(varParam, 3));
- System.arraycopy(varParam, 7, xstDispFldRMark, 0, 32);
- newCHP.setXstDispFldRMark(xstDispFldRMark);
- break;
- case 0x63:
- newCHP.setIbstRMarkDel((short)param);
- break;
- case 0x64:
- short[] dttmRMarkDel = new short[2];
- dttmRMarkDel[0] = LittleEndian.getShort(grpprl, offset - 4);
- dttmRMarkDel[1] = LittleEndian.getShort(grpprl, offset - 2);
- newCHP.setDttmRMarkDel(dttmRMarkDel);
- break;
- case 0x65:
- short[] brc = new short[2];
- brc[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brc[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- newCHP.setBrc(brc);
- break;
- case 0x66:
- newCHP.setShd((short)param);
- break;
- case 0x67:
- break;
- case 0x68:
- break;
- case 0x69:
- break;
- case 0x6a:
- break;
- case 0x6b:
- break;
- case 0x6c:
- break;
- case 0x6d:
- newCHP.setLidDefault((short)param);
- break;
- case 0x6e:
- newCHP.setLidFE((short)param);
- break;
- case 0x6f:
- newCHP.setIdctHint((byte)param);
- break;
- }
- }
+// /**
+// * Used in decompression of a chpx. This performs an operation defined by
+// * a single sprm.
+// *
+// * @param oldCHP The base CharacterProperties.
+// * @param newCHP The current CharacterProperties.
+// * @param operand The operand defined by the sprm (See Word file format spec)
+// * @param param The parameter defined by the sprm (See Word file format spec)
+// * @param varParam The variable length parameter defined by the sprm. (See
+// * Word file format spec)
+// * @param grpprl The entire chpx that this operation is a part of.
+// * @param offset The offset in the grpprl of the next sprm
+// * @param styleSheet The StyleSheet for this document.
+// */
+// static void doCHPOperation(CharacterProperties oldCHP, CharacterProperties newCHP,
+// int operand, int param,
+// byte[] varParam, byte[] grpprl, int offset,
+// StyleSheet styleSheet)
+// {
+// switch(operand)
+// {
+// case 0:
+// newCHP.setFRMarkDel(getFlag(param));
+// break;
+// case 0x1:
+// newCHP.setFRMark(getFlag(param));
+// break;
+// case 0x2:
+// break;
+// case 0x3:
+// newCHP.setFcPic(param);
+// newCHP.setFSpec(true);
+// break;
+// case 0x4:
+// newCHP.setIbstRMark((short)param);
+// break;
+// case 0x5:
+// short[] dttmRMark = new short[2];
+// dttmRMark[0] = LittleEndian.getShort(grpprl, (offset - 4));
+// dttmRMark[1] = LittleEndian.getShort(grpprl, (offset - 2));
+// newCHP.setDttmRMark(dttmRMark);
+// break;
+// case 0x6:
+// newCHP.setFData(getFlag(param));
+// break;
+// case 0x7:
+// //don't care about this
+// break;
+// case 0x8:
+// short chsDiff = (short)((param & 0xff0000) >>> 8);
+// newCHP.setFChsDiff(getFlag(chsDiff));
+// newCHP.setChse((short)(param & 0xffff));
+// break;
+// case 0x9:
+// newCHP.setFSpec(true);
+// newCHP.setFtcSym((short)LittleEndian.getShort(varParam, 0));
+// newCHP.setXchSym((short)LittleEndian.getShort(varParam, 2));
+// break;
+// case 0xa:
+// newCHP.setFOle2(getFlag(param));
+// break;
+// case 0xb:
+// //?
+// break;
+// case 0xc:
+// newCHP.setIcoHighlight((byte)param);
+// newCHP.setFHighlight(getFlag(param));
+// break;
+// case 0xd:
+// break;
+// case 0xe:
+// newCHP.setFcObj(param);
+// break;
+// case 0xf:
+// break;
+// case 0x10:
+// //?
+// break;
+// case 0x11:
+// break;
+// case 0x12:
+// break;
+// case 0x13:
+// break;
+// case 0x14:
+// break;
+// case 0x15:
+// break;
+// case 0x16:
+// break;
+// case 0x17:
+// break;
+// case 0x18:
+// break;
+// case 0x19:
+// break;
+// case 0x1a:
+// break;
+// case 0x1b:
+// break;
+// case 0x1c:
+// break;
+// case 0x1d:
+// break;
+// case 0x1e:
+// break;
+// case 0x1f:
+// break;
+// case 0x20:
+// break;
+// case 0x21:
+// break;
+// case 0x22:
+// break;
+// case 0x23:
+// break;
+// case 0x24:
+// break;
+// case 0x25:
+// break;
+// case 0x26:
+// break;
+// case 0x27:
+// break;
+// case 0x28:
+// break;
+// case 0x29:
+// break;
+// case 0x2a:
+// break;
+// case 0x2b:
+// break;
+// case 0x2c:
+// break;
+// case 0x2d:
+// break;
+// case 0x2e:
+// break;
+// case 0x2f:
+// break;
+// case 0x30:
+// newCHP.setIstd(param);
+// break;
+// case 0x31:
+// //permutation vector for fast saves, who cares!
+// break;
+// case 0x32:
+// newCHP.setFBold(false);
+// newCHP.setFItalic(false);
+// newCHP.setFOutline(false);
+// newCHP.setFStrike(false);
+// newCHP.setFShadow(false);
+// newCHP.setFSmallCaps(false);
+// newCHP.setFCaps(false);
+// newCHP.setFVanish(false);
+// newCHP.setKul((byte)0);
+// newCHP.setIco((byte)0);
+// break;
+// case 0x33:
+// try
+// {
+// newCHP = (CharacterProperties)oldCHP.clone();
+// }
+// catch(CloneNotSupportedException e)
+// {
+// //do nothing
+// }
+// return;
+// case 0x34:
+// break;
+// case 0x35:
+// newCHP.setFBold(getCHPFlag((byte)param, oldCHP.isFBold()));
+// break;
+// case 0x36:
+// newCHP.setFItalic(getCHPFlag((byte)param, oldCHP.isFItalic()));
+// break;
+// case 0x37:
+// newCHP.setFStrike(getCHPFlag((byte)param, oldCHP.isFStrike()));
+// break;
+// case 0x38:
+// newCHP.setFOutline(getCHPFlag((byte)param, oldCHP.isFOutline()));
+// break;
+// case 0x39:
+// newCHP.setFShadow(getCHPFlag((byte)param, oldCHP.isFShadow()));
+// break;
+// case 0x3a:
+// newCHP.setFSmallCaps(getCHPFlag((byte)param, oldCHP.isFSmallCaps()));
+// break;
+// case 0x3b:
+// newCHP.setFCaps(getCHPFlag((byte)param, oldCHP.isFCaps()));
+// break;
+// case 0x3c:
+// newCHP.setFVanish(getCHPFlag((byte)param, oldCHP.isFVanish()));
+// break;
+// case 0x3d:
+// newCHP.setFtcAscii((short)param);
+// break;
+// case 0x3e:
+// newCHP.setKul((byte)param);
+// break;
+// case 0x3f:
+// int hps = param & 0xff;
+// if(hps != 0)
+// {
+// newCHP.setHps(hps);
+// }
+// byte cInc = (byte)(((byte)(param & 0xfe00) >>> 4) >> 1);
+// if(cInc != 0)
+// {
+// newCHP.setHps(Math.max(newCHP.getHps() + (cInc * 2), 2));
+// }
+// byte hpsPos = (byte)((param & 0xff0000) >>> 8);
+// if(hpsPos != 0x80)
+// {
+// newCHP.setHpsPos(hpsPos);
+// }
+// boolean fAdjust = (param & 0x0100) > 0;
+// if(fAdjust && hpsPos != 128 && hpsPos != 0 && oldCHP.getHpsPos() == 0)
+// {
+// newCHP.setHps(Math.max(newCHP.getHps() + (-2), 2));
+// }
+// if(fAdjust && hpsPos == 0 && oldCHP.getHpsPos() != 0)
+// {
+// newCHP.setHps(Math.max(newCHP.getHps() + 2, 2));
+// }
+// break;
+// case 0x40:
+// newCHP.setDxaSpace(param);
+// break;
+// case 0x41:
+// newCHP.setLidDefault((short)param);
+// break;
+// case 0x42:
+// newCHP.setIco((byte)param);
+// break;
+// case 0x43:
+// newCHP.setHps(param);
+// break;
+// case 0x44:
+// byte hpsLvl = (byte)param;
+// newCHP.setHps(Math.max(newCHP.getHps() + (hpsLvl * 2), 2));
+// break;
+// case 0x45:
+// newCHP.setHpsPos((short)param);
+// break;
+// case 0x46:
+// if(param != 0)
+// {
+// if(oldCHP.getHpsPos() == 0)
+// {
+// newCHP.setHps(Math.max(newCHP.getHps() + (-2), 2));
+// }
+// }
+// else
+// {
+// if(oldCHP.getHpsPos() != 0)
+// {
+// newCHP.setHps(Math.max(newCHP.getHps() + 2, 2));
+// }
+// }
+// break;
+// case 0x47:
+// CharacterProperties genCHP = new CharacterProperties();
+// genCHP.setFtcAscii(4);
+// genCHP = (CharacterProperties)uncompressProperty(varParam, genCHP, styleSheet);
+// CharacterProperties styleCHP = styleSheet.getStyleDescription(oldCHP.getBaseIstd()).getCHP();
+// if(genCHP.isFBold() == newCHP.isFBold())
+// {
+// newCHP.setFBold(styleCHP.isFBold());
+// }
+// if(genCHP.isFItalic() == newCHP.isFItalic())
+// {
+// newCHP.setFItalic(styleCHP.isFItalic());
+// }
+// if(genCHP.isFSmallCaps() == newCHP.isFSmallCaps())
+// {
+// newCHP.setFSmallCaps(styleCHP.isFSmallCaps());
+// }
+// if(genCHP.isFVanish() == newCHP.isFVanish())
+// {
+// newCHP.setFVanish(styleCHP.isFVanish());
+// }
+// if(genCHP.isFStrike() == newCHP.isFStrike())
+// {
+// newCHP.setFStrike(styleCHP.isFStrike());
+// }
+// if(genCHP.isFCaps() == newCHP.isFCaps())
+// {
+// newCHP.setFCaps(styleCHP.isFCaps());
+// }
+// if(genCHP.getFtcAscii() == newCHP.getFtcAscii())
+// {
+// newCHP.setFtcAscii(styleCHP.getFtcAscii());
+// }
+// if(genCHP.getFtcFE() == newCHP.getFtcFE())
+// {
+// newCHP.setFtcFE(styleCHP.getFtcFE());
+// }
+// if(genCHP.getFtcOther() == newCHP.getFtcOther())
+// {
+// newCHP.setFtcOther(styleCHP.getFtcOther());
+// }
+// if(genCHP.getHps() == newCHP.getHps())
+// {
+// newCHP.setHps(styleCHP.getHps());
+// }
+// if(genCHP.getHpsPos() == newCHP.getHpsPos())
+// {
+// newCHP.setHpsPos(styleCHP.getHpsPos());
+// }
+// if(genCHP.getKul() == newCHP.getKul())
+// {
+// newCHP.setKul(styleCHP.getKul());
+// }
+// if(genCHP.getDxaSpace() == newCHP.getDxaSpace())
+// {
+// newCHP.setDxaSpace(styleCHP.getDxaSpace());
+// }
+// if(genCHP.getIco() == newCHP.getIco())
+// {
+// newCHP.setIco(styleCHP.getIco());
+// }
+// if(genCHP.getLidDefault() == newCHP.getLidDefault())
+// {
+// newCHP.setLidDefault(styleCHP.getLidDefault());
+// }
+// if(genCHP.getLidFE() == newCHP.getLidFE())
+// {
+// newCHP.setLidFE(styleCHP.getLidFE());
+// }
+// break;
+// case 0x48:
+// newCHP.setIss((byte)param);
+// break;
+// case 0x49:
+// newCHP.setHps(LittleEndian.getShort(varParam, 0));
+// break;
+// case 0x4a:
+// int increment = LittleEndian.getShort(varParam, 0);
+// newCHP.setHps(Math.max(newCHP.getHps() + increment, 8));
+// break;
+// case 0x4b:
+// newCHP.setHpsKern(param);
+// break;
+// case 0x4c:
+// doCHPOperation(oldCHP, newCHP, 0x47, param, varParam, grpprl, offset, styleSheet);
+// break;
+// case 0x4d:
+// float percentage = (float)param/100.0f;
+// int add = (int)((float)percentage * (float)newCHP.getHps());
+// newCHP.setHps(newCHP.getHps() + add);
+// break;
+// case 0x4e:
+// newCHP.setYsr((byte)param);
+// break;
+// case 0x4f:
+// newCHP.setFtcAscii((short)param);
+// break;
+// case 0x50:
+// newCHP.setFtcFE((short)param);
+// break;
+// case 0x51:
+// newCHP.setFtcOther((short)param);
+// break;
+// case 0x52:
+// break;
+// case 0x53:
+// newCHP.setFDStrike(getFlag(param));
+// break;
+// case 0x54:
+// newCHP.setFImprint(getFlag(param));
+// break;
+// case 0x55:
+// newCHP.setFSpec(getFlag(param));
+// break;
+// case 0x56:
+// newCHP.setFObj(getFlag(param));
+// break;
+// case 0x57:
+// newCHP.setFPropMark(varParam[0]);
+// newCHP.setIbstPropRMark((short)LittleEndian.getShort(varParam, 1));
+// newCHP.setDttmPropRMark(LittleEndian.getInt(varParam, 3));
+// break;
+// case 0x58:
+// newCHP.setFEmboss(getFlag(param));
+// break;
+// case 0x59:
+// newCHP.setSfxtText((byte)param);
+// break;
+// case 0x5a:
+// break;
+// case 0x5b:
+// break;
+// case 0x5c:
+// break;
+// case 0x5d:
+// break;
+// case 0x5e:
+// break;
+// case 0x5f:
+// break;
+// case 0x60:
+// break;
+// case 0x61:
+// break;
+// case 0x62:
+// byte[] xstDispFldRMark = new byte[32];
+// newCHP.setFDispFldRMark(varParam[0]);
+// newCHP.setIbstDispFldRMark((short)LittleEndian.getShort(varParam, 1));
+// newCHP.setDttmDispFldRMark(LittleEndian.getInt(varParam, 3));
+// System.arraycopy(varParam, 7, xstDispFldRMark, 0, 32);
+// newCHP.setXstDispFldRMark(xstDispFldRMark);
+// break;
+// case 0x63:
+// newCHP.setIbstRMarkDel((short)param);
+// break;
+// case 0x64:
+// short[] dttmRMarkDel = new short[2];
+// dttmRMarkDel[0] = LittleEndian.getShort(grpprl, offset - 4);
+// dttmRMarkDel[1] = LittleEndian.getShort(grpprl, offset - 2);
+// newCHP.setDttmRMarkDel(dttmRMarkDel);
+// break;
+// case 0x65:
+// short[] brc = new short[2];
+// brc[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brc[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// newCHP.setBrc(brc);
+// break;
+// case 0x66:
+// newCHP.setShd((short)param);
+// break;
+// case 0x67:
+// break;
+// case 0x68:
+// break;
+// case 0x69:
+// break;
+// case 0x6a:
+// break;
+// case 0x6b:
+// break;
+// case 0x6c:
+// break;
+// case 0x6d:
+// newCHP.setLidDefault((short)param);
+// break;
+// case 0x6e:
+// newCHP.setLidFE((short)param);
+// break;
+// case 0x6f:
+// newCHP.setIdctHint((byte)param);
+// break;
+// }
+// }
/**
* Used to uncompress a property stored in a grpprl. These include
@@ -678,800 +752,800 @@ public class StyleSheet implements HDFType
*
* @return An object that should be casted to the appropriate property.
*/
- public static Object uncompressProperty(byte[] grpprl, Object parent, StyleSheet styleSheet)
- {
- return uncompressProperty(grpprl, parent, styleSheet, true);
- }
+// public static Object uncompressProperty(byte[] grpprl, Object parent, StyleSheet styleSheet)
+// {
+// return uncompressProperty(grpprl, parent, styleSheet, true);
+// }
- /**
- * Used to uncompress a property stored in a grpprl. These include
- * CharacterProperties, ParagraphProperties, TableProperties, and
- * SectionProperties.
- *
- * @param grpprl The compressed form of the property.
- * @param parent The base property of the property.
- * @param styleSheet The document's stylesheet.
- *
- * @return An object that should be casted to the appropriate property.
- */
- public static Object uncompressProperty(byte[] grpprl, Object parent, StyleSheet styleSheet, boolean doIstd)
- {
- Object newProperty = null;
- int offset = 0;
- int propertyType = PAP_TYPE;
-
-
- if(parent instanceof ParagraphProperties)
- {
- try
- {
- newProperty = ((ParagraphProperties)parent).clone();
- }
- catch(Exception e){}
- if(doIstd)
- {
- ((ParagraphProperties)newProperty).setIstd(LittleEndian.getShort(grpprl, 0));
-
- offset = 2;
- }
- }
- else if(parent instanceof CharacterProperties)
- {
- try
- {
- newProperty = ((CharacterProperties)parent).clone();
- ((CharacterProperties)newProperty).setBaseIstd(((CharacterProperties)parent).getIstd());
- }
- catch(Exception e){}
- propertyType = CHP_TYPE;
- }
- else if(parent instanceof SectionProperties)
- {
- newProperty = parent;
- propertyType = SEP_TYPE;
- }
- else if(parent instanceof TableProperties)
- {
- newProperty = parent;
- propertyType = TAP_TYPE;
- offset = 2;//because this is really just a papx
- }
- else
- {
- return null;
- }
-
- while(offset < grpprl.length)
- {
- short sprm = LittleEndian.getShort(grpprl, offset);
- offset += 2;
-
- byte spra = (byte)((sprm & 0xe000) >> 13);
- int opSize = 0;
- int param = 0;
- byte[] varParam = null;
-
- switch(spra)
- {
- case 0:
- case 1:
- opSize = 1;
- param = grpprl[offset];
- break;
- case 2:
- opSize = 2;
- param = LittleEndian.getShort(grpprl, offset);
- break;
- case 3:
- opSize = 4;
- param = LittleEndian.getInt(grpprl, offset);
- break;
- case 4:
- case 5:
- opSize = 2;
- param = LittleEndian.getShort(grpprl, offset);
- break;
- case 6://variable size
-
- //there is one sprm that is a very special case
- if(sprm != (short)0xd608)
- {
- opSize = LittleEndian.getUnsignedByte(grpprl, offset);
- offset++;
- }
- else
- {
- opSize = LittleEndian.getShort(grpprl, offset) - 1;
- offset += 2;
- }
- varParam = new byte[opSize];
- System.arraycopy(grpprl, offset, varParam, 0, opSize);
-
- break;
- case 7:
- opSize = 3;
- byte threeByteInt[] = new byte[4];
- threeByteInt[0] = grpprl[offset];
- threeByteInt[1] = grpprl[offset + 1];
- threeByteInt[2] = grpprl[offset + 2];
- threeByteInt[3] = (byte)0;
- param = LittleEndian.getInt(threeByteInt, 0);
- break;
- default:
- throw new RuntimeException("unrecognized pap opcode");
- }
-
- offset += opSize;
- short operand = (short)(sprm & 0x1ff);
- byte type = (byte)((sprm & 0x1c00) >> 10);
- switch(propertyType)
- {
- case PAP_TYPE:
- if(type == 1)//papx stores TAP sprms along with PAP sprms
- {
- doPAPOperation((ParagraphProperties)newProperty, operand,
- param, varParam, grpprl,
- offset, spra);
- }
- break;
- case CHP_TYPE:
-
- doCHPOperation((CharacterProperties)parent,
- (CharacterProperties)newProperty,
- operand, param, varParam,
- grpprl, offset, styleSheet);
- break;
- case SEP_TYPE:
-
- doSEPOperation((SectionProperties)newProperty, operand, param, varParam);
- break;
- case TAP_TYPE:
- if(type == 5)
- {
- doTAPOperation((TableProperties)newProperty, operand, param, varParam);
- }
- break;
- }
-
-
- }
- return newProperty;
-
- }
- /**
- * Performs an operation on a ParagraphProperties object. Used to uncompress
- * from a papx.
- *
- * @param newPAP The ParagraphProperties object to perform the operation on.
- * @param operand The operand that defines the operation.
- * @param param The operation's parameter.
- * @param varParam The operation's variable length parameter.
- * @param grpprl The original papx.
- * @param offset The current offset in the papx.
- * @param spra A part of the sprm that defined this operation.
- */
- static void doPAPOperation(ParagraphProperties newPAP, int operand, int param,
- byte[] varParam, byte[] grpprl, int offset,
- int spra)
- {
- switch(operand)
- {
- case 0:
- newPAP.setIstd(param);
- break;
- case 0x1:
- //permuteIstd(newPAP, varParam);
- break;
- case 0x2:
- if(newPAP.getIstd() <=9 || newPAP.getIstd() >=1)
- {
- newPAP.setIstd(newPAP.getIstd() + param);
- if(param > 0)
- {
- newPAP.setIstd(Math.max(newPAP.getIstd(), 9));
- }
- else
- {
- newPAP.setIstd(Math.min(newPAP.getIstd(), 1));
- }
- }
- break;
- case 0x3:
- newPAP.setJc((byte)param);
- break;
- case 0x4:
- newPAP.setFSideBySide((byte)param);
- break;
- case 0x5:
- newPAP.setFKeep((byte)param);
- break;
- case 0x6:
- newPAP.setFKeepFollow((byte)param);
- break;
- case 0x7:
- newPAP.setFPageBreakBefore((byte)param);
- break;
- case 0x8:
- newPAP.setBrcl((byte)param);
- break;
- case 0x9:
- newPAP.setBrcp((byte)param);
- break;
- case 0xa:
- newPAP.setIlvl((byte)param);
- break;
- case 0xb:
- newPAP.setIlfo(param);
- break;
- case 0xc:
- newPAP.setFNoLnn((byte)param);
- break;
- case 0xd:
- /**@todo handle tabs*/
- break;
- case 0xe:
- newPAP.setDxaRight(param);
- break;
- case 0xf:
- newPAP.setDxaLeft(param);
- break;
- case 0x10:
- newPAP.setDxaLeft(newPAP.getDxaLeft() + param);
- newPAP.setDxaLeft(Math.max(0, newPAP.getDxaLeft()));
- break;
- case 0x11:
- newPAP.setDxaLeft1(param);
- break;
- case 0x12:
- short[] lspd = newPAP.getLspd();
- lspd[0] = LittleEndian.getShort(grpprl, offset - 4);
- lspd[1] = LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x13:
- newPAP.setDyaBefore(param);
- break;
- case 0x14:
- newPAP.setDyaAfter(param);
- break;
- case 0x15:
- /**@todo handle tabs*/
- break;
- case 0x16:
- newPAP.setFInTable((byte)param);
- break;
- case 0x17:
- newPAP.setFTtp((byte)param);
- break;
- case 0x18:
- newPAP.setDxaAbs(param);
- break;
- case 0x19:
- newPAP.setDyaAbs(param);
- break;
- case 0x1a:
- newPAP.setDxaWidth(param);
- break;
- case 0x1b:
- /** @todo handle paragraph postioning*/
- /*byte pcVert = (param & 0x0c) >> 2;
- byte pcHorz = param & 0x03;
- if(pcVert != 3)
- {
- newPAP._pcVert = pcVert;
- }
- if(pcHorz != 3)
- {
- newPAP._pcHorz = pcHorz;
- }*/
- break;
- case 0x1c:
- //newPAP.setBrcTop1((short)param);
- break;
- case 0x1d:
- //newPAP.setBrcLeft1((short)param);
- break;
- case 0x1e:
- //newPAP.setBrcBottom1((short)param);
- break;
- case 0x1f:
- //newPAP.setBrcRight1((short)param);
- break;
- case 0x20:
- //newPAP.setBrcBetween1((short)param);
- break;
- case 0x21:
- //newPAP.setBrcBar1((byte)param);
- break;
- case 0x22:
- newPAP.setDxaFromText(param);
- break;
- case 0x23:
- newPAP.setWr((byte)param);
- break;
- case 0x24:
- short[] brcTop = newPAP.getBrcTop();
- brcTop[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brcTop[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x25:
- short[] brcLeft = newPAP.getBrcLeft();
- brcLeft[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brcLeft[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x26:
- short[] brcBottom = newPAP.getBrcBottom();
- brcBottom[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brcBottom[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x27:
- short[] brcRight = newPAP.getBrcRight();
- brcRight[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brcRight[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x28:
- short[] brcBetween = newPAP.getBrcBetween();
- brcBetween[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brcBetween[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x29:
- short[] brcBar = newPAP.getBrcBar();
- brcBar[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
- brcBar[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
- break;
- case 0x2a:
- newPAP.setFNoAutoHyph((byte)param);
- break;
- case 0x2b:
- newPAP.setDyaHeight(param);
- break;
- case 0x2c:
- newPAP.setDcs((short)param);
- break;
- case 0x2d:
- newPAP.setShd((short)param);
- break;
- case 0x2e:
- newPAP.setDyaFromText(param);
- break;
- case 0x2f:
- newPAP.setDxaFromText(param);
- break;
- case 0x30:
- newPAP.setFLocked((byte)param);
- break;
- case 0x31:
- newPAP.setFWidowControl((byte)param);
- break;
- case 0x32:
- //undocumented
- break;
- case 0x33:
- newPAP.setFKinsoku((byte)param);
- break;
- case 0x34:
- newPAP.setFWordWrap((byte)param);
- break;
- case 0x35:
- newPAP.setFOverflowPunct((byte)param);
- break;
- case 0x36:
- newPAP.setFTopLinePunct((byte)param);
- break;
- case 0x37:
- newPAP.setFAutoSpaceDE((byte)param);
- break;
- case 0x38:
- newPAP.setFAutoSpaceDN((byte)param);
- break;
- case 0x39:
- newPAP.setWAlignFont(param);
- break;
- case 0x3a:
- newPAP.setFontAlign((short)param);
- break;
- case 0x3b:
- //obsolete
- break;
- case 0x3e:
- newPAP.setAnld(varParam);
- break;
- case 0x3f:
- //don't really need this. spec is confusing regarding this
- //sprm
- break;
- case 0x40:
- //newPAP._lvl = param;
- break;
- case 0x41:
- //?
- break;
- case 0x43:
- //?
- break;
- case 0x44:
- //?
- break;
- case 0x45:
- if(spra == 6)
- {
- newPAP.setNumrm(varParam);
- }
- else
- {
- /**@todo handle large PAPX from data stream*/
- }
- break;
-
- case 0x47:
- newPAP.setFUsePgsuSettings((byte)param);
- break;
- case 0x48:
- newPAP.setFAdjustRight((byte)param);
- break;
- default:
- break;
- }
- }
- /**
- * Used to uncompress a table property. Performs an operation defined
- * by a sprm stored in a tapx.
- *
- * @param newTAP The TableProperties object to perform the operation on.
- * @param operand The operand that defines this operation.
- * @param param The parameter for this operation.
- * @param varParam Variable length parameter for this operation.
- */
- static void doTAPOperation(TableProperties newTAP, int operand, int param, byte[] varParam)
- {
- switch(operand)
- {
- case 0:
- newTAP.setJc((short)param);
- break;
- case 0x01:
- {
- short[] rgdxaCenter = newTAP.getRgdxaCenter();
- short itcMac = newTAP.getItcMac();
- int adjust = param - (rgdxaCenter[0] + newTAP.getDxaGapHalf());
- for(int x = 0; x < itcMac; x++)
- {
- rgdxaCenter[x] += adjust;
- }
- break;
- }
- case 0x02:
- {
- short[] rgdxaCenter = newTAP.getRgdxaCenter();
- if(rgdxaCenter != null)
- {
- int adjust = newTAP.getDxaGapHalf() - param;
- rgdxaCenter[0] += adjust;
- }
- newTAP.setDxaGapHalf(param);
- break;
- }
- case 0x03:
- newTAP.setFCantSplit(getFlag(param));
- break;
- case 0x04:
- newTAP.setFTableHeader(getFlag(param));
- break;
- case 0x05:
- {
- short[] brcTop = newTAP.getBrcTop();
- short[] brcLeft = newTAP.getBrcLeft();
- short[] brcBottom = newTAP.getBrcBottom();
- short[] brcRight = newTAP.getBrcRight();
- short[] brcVertical = newTAP.getBrcVertical();
- short[] brcHorizontal = newTAP.getBrcHorizontal();
-
- brcTop[0] = LittleEndian.getShort(varParam, 0);
- brcTop[1] = LittleEndian.getShort(varParam, 2);
-
- brcLeft[0] = LittleEndian.getShort(varParam, 4);
- brcLeft[1] = LittleEndian.getShort(varParam, 6);
-
- brcBottom[0] = LittleEndian.getShort(varParam, 8);
- brcBottom[1] = LittleEndian.getShort(varParam, 10);
-
- brcRight[0] = LittleEndian.getShort(varParam, 12);
- brcRight[1] = LittleEndian.getShort(varParam, 14);
-
- brcHorizontal[0] = LittleEndian.getShort(varParam, 16);
- brcHorizontal[1] = LittleEndian.getShort(varParam, 18);
-
- brcVertical[0] = LittleEndian.getShort(varParam, 20);
- brcVertical[1] = LittleEndian.getShort(varParam, 22);
- break;
- }
- case 0x06:
- //obsolete, used in word 1.x
- break;
- case 0x07:
- newTAP.setDyaRowHeight(param);
- break;
- case 0x08:
- {
- short[] rgdxaCenter = new short[varParam[0] + 1];
- TableCellDescriptor[] rgtc = new TableCellDescriptor[varParam[0]];
- short itcMac = varParam[0];
- //I use varParam[0] and newTAP._itcMac interchangably
- newTAP.setItcMac(itcMac);
- newTAP.setRgdxaCenter(rgdxaCenter) ;
- newTAP.setRgtc(rgtc);
-
- for(int x = 0; x < itcMac; x++)
- {
- rgdxaCenter[x] = LittleEndian.getShort(varParam , 1 + (x * 2));
- rgtc[x] = TableCellDescriptor.convertBytesToTC(varParam, 1 + ((itcMac + 1) * 2) + (x * 20));
- }
- rgdxaCenter[itcMac] = LittleEndian.getShort(varParam , 1 + (itcMac * 2));
- break;
- }
- case 0x09:
- /** @todo handle cell shading*/
- break;
- case 0x0a:
- /** @todo handle word defined table styles*/
- break;
- case 0x20:
- {
- TCAbstractType[] rgtc = newTAP.getRgtc();
-
- for(int x = varParam[0]; x < varParam[1]; x++)
- {
-
- if((varParam[2] & 0x08) > 0)
- {
- short[] brcRight = rgtc[x].getBrcRight();
- brcRight[0] = LittleEndian.getShort(varParam, 6);
- brcRight[1] = LittleEndian.getShort(varParam, 8);
- }
- else if((varParam[2] & 0x04) > 0)
- {
- short[] brcBottom = rgtc[x].getBrcBottom();
- brcBottom[0] = LittleEndian.getShort(varParam, 6);
- brcBottom[1] = LittleEndian.getShort(varParam, 8);
- }
- else if((varParam[2] & 0x02) > 0)
- {
- short[] brcLeft = rgtc[x].getBrcLeft();
- brcLeft[0] = LittleEndian.getShort(varParam, 6);
- brcLeft[1] = LittleEndian.getShort(varParam, 8);
- }
- else if((varParam[2] & 0x01) > 0)
- {
- short[] brcTop = rgtc[x].getBrcTop();
- brcTop[0] = LittleEndian.getShort(varParam, 6);
- brcTop[1] = LittleEndian.getShort(varParam, 8);
- }
- }
- break;
- }
- case 0x21:
- int index = (param & 0xff000000) >> 24;
- int count = (param & 0x00ff0000) >> 16;
- int width = (param & 0x0000ffff);
- int itcMac = newTAP.getItcMac();
-
- short[] rgdxaCenter = new short[itcMac + count + 1];
- TableCellDescriptor[] rgtc = new TableCellDescriptor[itcMac + count];
- if(index >= itcMac)
- {
- index = itcMac;
- System.arraycopy(newTAP.getRgdxaCenter(), 0, rgdxaCenter, 0, itcMac + 1);
- System.arraycopy(newTAP.getRgtc(), 0, rgtc, 0, itcMac);
- }
- else
- {
- //copy rgdxaCenter
- System.arraycopy(newTAP.getRgdxaCenter(), 0, rgdxaCenter, 0, index + 1);
- System.arraycopy(newTAP.getRgdxaCenter(), index + 1, rgdxaCenter, index + count, itcMac - (index));
- //copy rgtc
- System.arraycopy(newTAP.getRgtc(), 0, rgtc, 0, index);
- System.arraycopy(newTAP.getRgtc(), index, rgtc, index + count, itcMac - index);
- }
-
- for(int x = index; x < index + count; x++)
- {
- rgtc[x] = new TableCellDescriptor();
- rgdxaCenter[x] = (short)(rgdxaCenter[x-1] + width);
- }
- rgdxaCenter[index + count] = (short)(rgdxaCenter[(index + count)-1] + width);
- break;
- /**@todo handle table sprms from complex files*/
- case 0x22:
- case 0x23:
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- case 0x28:
- case 0x29:
- case 0x2a:
- case 0x2b:
- case 0x2c:
- break;
- default:
- break;
- }
- }
- /**
- * Used in decompression of a sepx. This performs an operation defined by
- * a single sprm.
- *
- * @param newSEP The SectionProperty to perfrom the operation on.
- * @param operand The operation to perform.
- * @param param The operation's parameter.
- * @param varParam The operation variable length parameter.
- */
- static void doSEPOperation(SectionProperties newSEP, int operand, int param, byte[] varParam)
- {
- switch(operand)
- {
- case 0:
- newSEP.setCnsPgn((byte)param);
- break;
- case 0x1:
- newSEP.setIHeadingPgn((byte)param);
- break;
- case 0x2:
- newSEP.setOlstAnm(varParam);
- break;
- case 0x3:
- //not quite sure
- break;
- case 0x4:
- //not quite sure
- break;
- case 0x5:
- newSEP.setFEvenlySpaced(getFlag(param));
- break;
- case 0x6:
- newSEP.setFUnlocked(getFlag(param));
- break;
- case 0x7:
- newSEP.setDmBinFirst((short)param);
- break;
- case 0x8:
- newSEP.setDmBinOther((short)param);
- break;
- case 0x9:
- newSEP.setBkc((byte)param);
- break;
- case 0xa:
- newSEP.setFTitlePage(getFlag(param));
- break;
- case 0xb:
- newSEP.setCcolM1((short)param);
- break;
- case 0xc:
- newSEP.setDxaColumns(param);
- break;
- case 0xd:
- newSEP.setFAutoPgn(getFlag(param));
- break;
- case 0xe:
- newSEP.setNfcPgn((byte)param);
- break;
- case 0xf:
- newSEP.setDyaPgn((short)param);
- break;
- case 0x10:
- newSEP.setDxaPgn((short)param);
- break;
- case 0x11:
- newSEP.setFPgnRestart(getFlag(param));
- break;
- case 0x12:
- newSEP.setFEndNote(getFlag(param));
- break;
- case 0x13:
- newSEP.setLnc((byte)param);
- break;
- case 0x14:
- newSEP.setGrpfIhdt((byte)param);
- break;
- case 0x15:
- newSEP.setNLnnMod((short)param);
- break;
- case 0x16:
- newSEP.setDxaLnn(param);
- break;
- case 0x17:
- newSEP.setDyaHdrTop(param);
- break;
- case 0x18:
- newSEP.setDyaHdrBottom(param);
- break;
- case 0x19:
- newSEP.setFLBetween(getFlag(param));
- break;
- case 0x1a:
- newSEP.setVjc((byte)param);
- break;
- case 0x1b:
- newSEP.setLnnMin((short)param);
- break;
- case 0x1c:
- newSEP.setPgnStart((short)param);
- break;
- case 0x1d:
- newSEP.setDmOrientPage((byte)param);
- break;
- case 0x1e:
- //nothing
- break;
- case 0x1f:
- newSEP.setXaPage(param);
- break;
- case 0x20:
- newSEP.setYaPage(param);
- break;
- case 0x21:
- newSEP.setDxaLeft(param);
- break;
- case 0x22:
- newSEP.setDxaRight(param);
- break;
- case 0x23:
- newSEP.setDyaTop(param);
- break;
- case 0x24:
- newSEP.setDyaBottom(param);
- break;
- case 0x25:
- newSEP.setDzaGutter(param);
- break;
- case 0x26:
- newSEP.setDmPaperReq((short)param);
- break;
- case 0x27:
- newSEP.setFPropMark(getFlag(varParam[0]));
- break;
- case 0x28:
- break;
- case 0x29:
- break;
- case 0x2a:
- break;
- case 0x2b:
- short[] brcTop = newSEP.getBrcTop();
- brcTop[0] = (short)(param & 0xffff);
- brcTop[1] = (short)((param & 0xffff0000) >> 16);
- break;
- case 0x2c:
- short[] brcLeft = newSEP.getBrcLeft();
- brcLeft[0] = (short)(param & 0xffff);
- brcLeft[1] = (short)((param & 0xffff0000) >> 16);
- break;
- case 0x2d:
- short[] brcBottom = newSEP.getBrcBottom();
- brcBottom[0] = (short)(param & 0xffff);
- brcBottom[1] = (short)((param & 0xffff0000) >> 16);
- break;
- case 0x2e:
- short[] brcRight = newSEP.getBrcRight();
- brcRight[0] = (short)(param & 0xffff);
- brcRight[1] = (short)((param & 0xffff0000) >> 16);
- break;
- case 0x2f:
- newSEP.setPgbProp(param);
- break;
- case 0x30:
- newSEP.setDxtCharSpace(param);
- break;
- case 0x31:
- newSEP.setDyaLinePitch(param);
- break;
- case 0x33:
- newSEP.setWTextFlow((short)param);
- break;
- default:
- break;
- }
-
- }
+// /**
+// * Used to uncompress a property stored in a grpprl. These include
+// * CharacterProperties, ParagraphProperties, TableProperties, and
+// * SectionProperties.
+// *
+// * @param grpprl The compressed form of the property.
+// * @param parent The base property of the property.
+// * @param styleSheet The document's stylesheet.
+// *
+// * @return An object that should be casted to the appropriate property.
+// */
+// public static Object uncompressProperty(byte[] grpprl, Object parent, StyleSheet styleSheet, boolean doIstd)
+// {
+// Object newProperty = null;
+// int offset = 0;
+// int propertyType = PAP_TYPE;
+//
+//
+// if(parent instanceof ParagraphProperties)
+// {
+// try
+// {
+// newProperty = ((ParagraphProperties)parent).clone();
+// }
+// catch(Exception e){}
+// if(doIstd)
+// {
+// ((ParagraphProperties)newProperty).setIstd(LittleEndian.getShort(grpprl, 0));
+//
+// offset = 2;
+// }
+// }
+// else if(parent instanceof CharacterProperties)
+// {
+// try
+// {
+// newProperty = ((CharacterProperties)parent).clone();
+// ((CharacterProperties)newProperty).setBaseIstd(((CharacterProperties)parent).getIstd());
+// }
+// catch(Exception e){}
+// propertyType = CHP_TYPE;
+// }
+// else if(parent instanceof SectionProperties)
+// {
+// newProperty = parent;
+// propertyType = SEP_TYPE;
+// }
+// else if(parent instanceof TableProperties)
+// {
+// newProperty = parent;
+// propertyType = TAP_TYPE;
+// offset = 2;//because this is really just a papx
+// }
+// else
+// {
+// return null;
+// }
+//
+// while(offset < grpprl.length)
+// {
+// short sprm = LittleEndian.getShort(grpprl, offset);
+// offset += 2;
+//
+// byte spra = (byte)((sprm & 0xe000) >> 13);
+// int opSize = 0;
+// int param = 0;
+// byte[] varParam = null;
+//
+// switch(spra)
+// {
+// case 0:
+// case 1:
+// opSize = 1;
+// param = grpprl[offset];
+// break;
+// case 2:
+// opSize = 2;
+// param = LittleEndian.getShort(grpprl, offset);
+// break;
+// case 3:
+// opSize = 4;
+// param = LittleEndian.getInt(grpprl, offset);
+// break;
+// case 4:
+// case 5:
+// opSize = 2;
+// param = LittleEndian.getShort(grpprl, offset);
+// break;
+// case 6://variable size
+//
+// //there is one sprm that is a very special case
+// if(sprm != (short)0xd608)
+// {
+// opSize = LittleEndian.getUnsignedByte(grpprl, offset);
+// offset++;
+// }
+// else
+// {
+// opSize = LittleEndian.getShort(grpprl, offset) - 1;
+// offset += 2;
+// }
+// varParam = new byte[opSize];
+// System.arraycopy(grpprl, offset, varParam, 0, opSize);
+//
+// break;
+// case 7:
+// opSize = 3;
+// byte threeByteInt[] = new byte[4];
+// threeByteInt[0] = grpprl[offset];
+// threeByteInt[1] = grpprl[offset + 1];
+// threeByteInt[2] = grpprl[offset + 2];
+// threeByteInt[3] = (byte)0;
+// param = LittleEndian.getInt(threeByteInt, 0);
+// break;
+// default:
+// throw new RuntimeException("unrecognized pap opcode");
+// }
+//
+// offset += opSize;
+// short operand = (short)(sprm & 0x1ff);
+// byte type = (byte)((sprm & 0x1c00) >> 10);
+// switch(propertyType)
+// {
+// case PAP_TYPE:
+// if(type == 1)//papx stores TAP sprms along with PAP sprms
+// {
+// doPAPOperation((ParagraphProperties)newProperty, operand,
+// param, varParam, grpprl,
+// offset, spra);
+// }
+// break;
+// case CHP_TYPE:
+//
+// doCHPOperation((CharacterProperties)parent,
+// (CharacterProperties)newProperty,
+// operand, param, varParam,
+// grpprl, offset, styleSheet);
+// break;
+// case SEP_TYPE:
+//
+// doSEPOperation((SectionProperties)newProperty, operand, param, varParam);
+// break;
+// case TAP_TYPE:
+// if(type == 5)
+// {
+// doTAPOperation((TableProperties)newProperty, operand, param, varParam);
+// }
+// break;
+// }
+//
+//
+// }
+// return newProperty;
+//
+// }
+// /**
+// * Performs an operation on a ParagraphProperties object. Used to uncompress
+// * from a papx.
+// *
+// * @param newPAP The ParagraphProperties object to perform the operation on.
+// * @param operand The operand that defines the operation.
+// * @param param The operation's parameter.
+// * @param varParam The operation's variable length parameter.
+// * @param grpprl The original papx.
+// * @param offset The current offset in the papx.
+// * @param spra A part of the sprm that defined this operation.
+// */
+// static void doPAPOperation(ParagraphProperties newPAP, int operand, int param,
+// byte[] varParam, byte[] grpprl, int offset,
+// int spra)
+// {
+// switch(operand)
+// {
+// case 0:
+// newPAP.setIstd(param);
+// break;
+// case 0x1:
+// //permuteIstd(newPAP, varParam);
+// break;
+// case 0x2:
+// if(newPAP.getIstd() <=9 || newPAP.getIstd() >=1)
+// {
+// newPAP.setIstd(newPAP.getIstd() + param);
+// if(param > 0)
+// {
+// newPAP.setIstd(Math.max(newPAP.getIstd(), 9));
+// }
+// else
+// {
+// newPAP.setIstd(Math.min(newPAP.getIstd(), 1));
+// }
+// }
+// break;
+// case 0x3:
+// newPAP.setJc((byte)param);
+// break;
+// case 0x4:
+// newPAP.setFSideBySide((byte)param);
+// break;
+// case 0x5:
+// newPAP.setFKeep((byte)param);
+// break;
+// case 0x6:
+// newPAP.setFKeepFollow((byte)param);
+// break;
+// case 0x7:
+// newPAP.setFPageBreakBefore((byte)param);
+// break;
+// case 0x8:
+// newPAP.setBrcl((byte)param);
+// break;
+// case 0x9:
+// newPAP.setBrcp((byte)param);
+// break;
+// case 0xa:
+// newPAP.setIlvl((byte)param);
+// break;
+// case 0xb:
+// newPAP.setIlfo(param);
+// break;
+// case 0xc:
+// newPAP.setFNoLnn((byte)param);
+// break;
+// case 0xd:
+// /**@todo handle tabs*/
+// break;
+// case 0xe:
+// newPAP.setDxaRight(param);
+// break;
+// case 0xf:
+// newPAP.setDxaLeft(param);
+// break;
+// case 0x10:
+// newPAP.setDxaLeft(newPAP.getDxaLeft() + param);
+// newPAP.setDxaLeft(Math.max(0, newPAP.getDxaLeft()));
+// break;
+// case 0x11:
+// newPAP.setDxaLeft1(param);
+// break;
+// case 0x12:
+// short[] lspd = newPAP.getLspd();
+// lspd[0] = LittleEndian.getShort(grpprl, offset - 4);
+// lspd[1] = LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x13:
+// newPAP.setDyaBefore(param);
+// break;
+// case 0x14:
+// newPAP.setDyaAfter(param);
+// break;
+// case 0x15:
+// /**@todo handle tabs*/
+// break;
+// case 0x16:
+// newPAP.setFInTable((byte)param);
+// break;
+// case 0x17:
+// newPAP.setFTtp((byte)param);
+// break;
+// case 0x18:
+// newPAP.setDxaAbs(param);
+// break;
+// case 0x19:
+// newPAP.setDyaAbs(param);
+// break;
+// case 0x1a:
+// newPAP.setDxaWidth(param);
+// break;
+// case 0x1b:
+// /** @todo handle paragraph postioning*/
+// /*byte pcVert = (param & 0x0c) >> 2;
+// byte pcHorz = param & 0x03;
+// if(pcVert != 3)
+// {
+// newPAP._pcVert = pcVert;
+// }
+// if(pcHorz != 3)
+// {
+// newPAP._pcHorz = pcHorz;
+// }*/
+// break;
+// case 0x1c:
+// //newPAP.setBrcTop1((short)param);
+// break;
+// case 0x1d:
+// //newPAP.setBrcLeft1((short)param);
+// break;
+// case 0x1e:
+// //newPAP.setBrcBottom1((short)param);
+// break;
+// case 0x1f:
+// //newPAP.setBrcRight1((short)param);
+// break;
+// case 0x20:
+// //newPAP.setBrcBetween1((short)param);
+// break;
+// case 0x21:
+// //newPAP.setBrcBar1((byte)param);
+// break;
+// case 0x22:
+// newPAP.setDxaFromText(param);
+// break;
+// case 0x23:
+// newPAP.setWr((byte)param);
+// break;
+// case 0x24:
+// short[] brcTop = newPAP.getBrcTop();
+// brcTop[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brcTop[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x25:
+// short[] brcLeft = newPAP.getBrcLeft();
+// brcLeft[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brcLeft[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x26:
+// short[] brcBottom = newPAP.getBrcBottom();
+// brcBottom[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brcBottom[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x27:
+// short[] brcRight = newPAP.getBrcRight();
+// brcRight[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brcRight[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x28:
+// short[] brcBetween = newPAP.getBrcBetween();
+// brcBetween[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brcBetween[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x29:
+// short[] brcBar = newPAP.getBrcBar();
+// brcBar[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+// brcBar[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+// break;
+// case 0x2a:
+// newPAP.setFNoAutoHyph((byte)param);
+// break;
+// case 0x2b:
+// newPAP.setDyaHeight(param);
+// break;
+// case 0x2c:
+// newPAP.setDcs((short)param);
+// break;
+// case 0x2d:
+// newPAP.setShd((short)param);
+// break;
+// case 0x2e:
+// newPAP.setDyaFromText(param);
+// break;
+// case 0x2f:
+// newPAP.setDxaFromText(param);
+// break;
+// case 0x30:
+// newPAP.setFLocked((byte)param);
+// break;
+// case 0x31:
+// newPAP.setFWidowControl((byte)param);
+// break;
+// case 0x32:
+// //undocumented
+// break;
+// case 0x33:
+// newPAP.setFKinsoku((byte)param);
+// break;
+// case 0x34:
+// newPAP.setFWordWrap((byte)param);
+// break;
+// case 0x35:
+// newPAP.setFOverflowPunct((byte)param);
+// break;
+// case 0x36:
+// newPAP.setFTopLinePunct((byte)param);
+// break;
+// case 0x37:
+// newPAP.setFAutoSpaceDE((byte)param);
+// break;
+// case 0x38:
+// newPAP.setFAutoSpaceDN((byte)param);
+// break;
+// case 0x39:
+// newPAP.setWAlignFont(param);
+// break;
+// case 0x3a:
+// newPAP.setFontAlign((short)param);
+// break;
+// case 0x3b:
+// //obsolete
+// break;
+// case 0x3e:
+// newPAP.setAnld(varParam);
+// break;
+// case 0x3f:
+// //don't really need this. spec is confusing regarding this
+// //sprm
+// break;
+// case 0x40:
+// //newPAP._lvl = param;
+// break;
+// case 0x41:
+// //?
+// break;
+// case 0x43:
+// //?
+// break;
+// case 0x44:
+// //?
+// break;
+// case 0x45:
+// if(spra == 6)
+// {
+// newPAP.setNumrm(varParam);
+// }
+// else
+// {
+// /**@todo handle large PAPX from data stream*/
+// }
+// break;
+//
+// case 0x47:
+// newPAP.setFUsePgsuSettings((byte)param);
+// break;
+// case 0x48:
+// newPAP.setFAdjustRight((byte)param);
+// break;
+// default:
+// break;
+// }
+// }
+// /**
+// * Used to uncompress a table property. Performs an operation defined
+// * by a sprm stored in a tapx.
+// *
+// * @param newTAP The TableProperties object to perform the operation on.
+// * @param operand The operand that defines this operation.
+// * @param param The parameter for this operation.
+// * @param varParam Variable length parameter for this operation.
+// */
+// static void doTAPOperation(TableProperties newTAP, int operand, int param, byte[] varParam)
+// {
+// switch(operand)
+// {
+// case 0:
+// newTAP.setJc((short)param);
+// break;
+// case 0x01:
+// {
+// short[] rgdxaCenter = newTAP.getRgdxaCenter();
+// short itcMac = newTAP.getItcMac();
+// int adjust = param - (rgdxaCenter[0] + newTAP.getDxaGapHalf());
+// for(int x = 0; x < itcMac; x++)
+// {
+// rgdxaCenter[x] += adjust;
+// }
+// break;
+// }
+// case 0x02:
+// {
+// short[] rgdxaCenter = newTAP.getRgdxaCenter();
+// if(rgdxaCenter != null)
+// {
+// int adjust = newTAP.getDxaGapHalf() - param;
+// rgdxaCenter[0] += adjust;
+// }
+// newTAP.setDxaGapHalf(param);
+// break;
+// }
+// case 0x03:
+// newTAP.setFCantSplit(getFlag(param));
+// break;
+// case 0x04:
+// newTAP.setFTableHeader(getFlag(param));
+// break;
+// case 0x05:
+// {
+// short[] brcTop = newTAP.getBrcTop();
+// short[] brcLeft = newTAP.getBrcLeft();
+// short[] brcBottom = newTAP.getBrcBottom();
+// short[] brcRight = newTAP.getBrcRight();
+// short[] brcVertical = newTAP.getBrcVertical();
+// short[] brcHorizontal = newTAP.getBrcHorizontal();
+//
+// brcTop[0] = LittleEndian.getShort(varParam, 0);
+// brcTop[1] = LittleEndian.getShort(varParam, 2);
+//
+// brcLeft[0] = LittleEndian.getShort(varParam, 4);
+// brcLeft[1] = LittleEndian.getShort(varParam, 6);
+//
+// brcBottom[0] = LittleEndian.getShort(varParam, 8);
+// brcBottom[1] = LittleEndian.getShort(varParam, 10);
+//
+// brcRight[0] = LittleEndian.getShort(varParam, 12);
+// brcRight[1] = LittleEndian.getShort(varParam, 14);
+//
+// brcHorizontal[0] = LittleEndian.getShort(varParam, 16);
+// brcHorizontal[1] = LittleEndian.getShort(varParam, 18);
+//
+// brcVertical[0] = LittleEndian.getShort(varParam, 20);
+// brcVertical[1] = LittleEndian.getShort(varParam, 22);
+// break;
+// }
+// case 0x06:
+// //obsolete, used in word 1.x
+// break;
+// case 0x07:
+// newTAP.setDyaRowHeight(param);
+// break;
+// case 0x08:
+// {
+// short[] rgdxaCenter = new short[varParam[0] + 1];
+// TableCellDescriptor[] rgtc = new TableCellDescriptor[varParam[0]];
+// short itcMac = varParam[0];
+// //I use varParam[0] and newTAP._itcMac interchangably
+// newTAP.setItcMac(itcMac);
+// newTAP.setRgdxaCenter(rgdxaCenter) ;
+// newTAP.setRgtc(rgtc);
+//
+// for(int x = 0; x < itcMac; x++)
+// {
+// rgdxaCenter[x] = LittleEndian.getShort(varParam , 1 + (x * 2));
+// rgtc[x] = TableCellDescriptor.convertBytesToTC(varParam, 1 + ((itcMac + 1) * 2) + (x * 20));
+// }
+// rgdxaCenter[itcMac] = LittleEndian.getShort(varParam , 1 + (itcMac * 2));
+// break;
+// }
+// case 0x09:
+// /** @todo handle cell shading*/
+// break;
+// case 0x0a:
+// /** @todo handle word defined table styles*/
+// break;
+// case 0x20:
+// {
+// TCAbstractType[] rgtc = newTAP.getRgtc();
+//
+// for(int x = varParam[0]; x < varParam[1]; x++)
+// {
+//
+// if((varParam[2] & 0x08) > 0)
+// {
+// short[] brcRight = rgtc[x].getBrcRight();
+// brcRight[0] = LittleEndian.getShort(varParam, 6);
+// brcRight[1] = LittleEndian.getShort(varParam, 8);
+// }
+// else if((varParam[2] & 0x04) > 0)
+// {
+// short[] brcBottom = rgtc[x].getBrcBottom();
+// brcBottom[0] = LittleEndian.getShort(varParam, 6);
+// brcBottom[1] = LittleEndian.getShort(varParam, 8);
+// }
+// else if((varParam[2] & 0x02) > 0)
+// {
+// short[] brcLeft = rgtc[x].getBrcLeft();
+// brcLeft[0] = LittleEndian.getShort(varParam, 6);
+// brcLeft[1] = LittleEndian.getShort(varParam, 8);
+// }
+// else if((varParam[2] & 0x01) > 0)
+// {
+// short[] brcTop = rgtc[x].getBrcTop();
+// brcTop[0] = LittleEndian.getShort(varParam, 6);
+// brcTop[1] = LittleEndian.getShort(varParam, 8);
+// }
+// }
+// break;
+// }
+// case 0x21:
+// int index = (param & 0xff000000) >> 24;
+// int count = (param & 0x00ff0000) >> 16;
+// int width = (param & 0x0000ffff);
+// int itcMac = newTAP.getItcMac();
+//
+// short[] rgdxaCenter = new short[itcMac + count + 1];
+// TableCellDescriptor[] rgtc = new TableCellDescriptor[itcMac + count];
+// if(index >= itcMac)
+// {
+// index = itcMac;
+// System.arraycopy(newTAP.getRgdxaCenter(), 0, rgdxaCenter, 0, itcMac + 1);
+// System.arraycopy(newTAP.getRgtc(), 0, rgtc, 0, itcMac);
+// }
+// else
+// {
+// //copy rgdxaCenter
+// System.arraycopy(newTAP.getRgdxaCenter(), 0, rgdxaCenter, 0, index + 1);
+// System.arraycopy(newTAP.getRgdxaCenter(), index + 1, rgdxaCenter, index + count, itcMac - (index));
+// //copy rgtc
+// System.arraycopy(newTAP.getRgtc(), 0, rgtc, 0, index);
+// System.arraycopy(newTAP.getRgtc(), index, rgtc, index + count, itcMac - index);
+// }
+//
+// for(int x = index; x < index + count; x++)
+// {
+// rgtc[x] = new TableCellDescriptor();
+// rgdxaCenter[x] = (short)(rgdxaCenter[x-1] + width);
+// }
+// rgdxaCenter[index + count] = (short)(rgdxaCenter[(index + count)-1] + width);
+// break;
+// /**@todo handle table sprms from complex files*/
+// case 0x22:
+// case 0x23:
+// case 0x24:
+// case 0x25:
+// case 0x26:
+// case 0x27:
+// case 0x28:
+// case 0x29:
+// case 0x2a:
+// case 0x2b:
+// case 0x2c:
+// break;
+// default:
+// break;
+// }
+// }
+// /**
+// * Used in decompression of a sepx. This performs an operation defined by
+// * a single sprm.
+// *
+// * @param newSEP The SectionProperty to perfrom the operation on.
+// * @param operand The operation to perform.
+// * @param param The operation's parameter.
+// * @param varParam The operation variable length parameter.
+// */
+// static void doSEPOperation(SectionProperties newSEP, int operand, int param, byte[] varParam)
+// {
+// switch(operand)
+// {
+// case 0:
+// newSEP.setCnsPgn((byte)param);
+// break;
+// case 0x1:
+// newSEP.setIHeadingPgn((byte)param);
+// break;
+// case 0x2:
+// newSEP.setOlstAnm(varParam);
+// break;
+// case 0x3:
+// //not quite sure
+// break;
+// case 0x4:
+// //not quite sure
+// break;
+// case 0x5:
+// newSEP.setFEvenlySpaced(getFlag(param));
+// break;
+// case 0x6:
+// newSEP.setFUnlocked(getFlag(param));
+// break;
+// case 0x7:
+// newSEP.setDmBinFirst((short)param);
+// break;
+// case 0x8:
+// newSEP.setDmBinOther((short)param);
+// break;
+// case 0x9:
+// newSEP.setBkc((byte)param);
+// break;
+// case 0xa:
+// newSEP.setFTitlePage(getFlag(param));
+// break;
+// case 0xb:
+// newSEP.setCcolM1((short)param);
+// break;
+// case 0xc:
+// newSEP.setDxaColumns(param);
+// break;
+// case 0xd:
+// newSEP.setFAutoPgn(getFlag(param));
+// break;
+// case 0xe:
+// newSEP.setNfcPgn((byte)param);
+// break;
+// case 0xf:
+// newSEP.setDyaPgn((short)param);
+// break;
+// case 0x10:
+// newSEP.setDxaPgn((short)param);
+// break;
+// case 0x11:
+// newSEP.setFPgnRestart(getFlag(param));
+// break;
+// case 0x12:
+// newSEP.setFEndNote(getFlag(param));
+// break;
+// case 0x13:
+// newSEP.setLnc((byte)param);
+// break;
+// case 0x14:
+// newSEP.setGrpfIhdt((byte)param);
+// break;
+// case 0x15:
+// newSEP.setNLnnMod((short)param);
+// break;
+// case 0x16:
+// newSEP.setDxaLnn(param);
+// break;
+// case 0x17:
+// newSEP.setDyaHdrTop(param);
+// break;
+// case 0x18:
+// newSEP.setDyaHdrBottom(param);
+// break;
+// case 0x19:
+// newSEP.setFLBetween(getFlag(param));
+// break;
+// case 0x1a:
+// newSEP.setVjc((byte)param);
+// break;
+// case 0x1b:
+// newSEP.setLnnMin((short)param);
+// break;
+// case 0x1c:
+// newSEP.setPgnStart((short)param);
+// break;
+// case 0x1d:
+// newSEP.setDmOrientPage((byte)param);
+// break;
+// case 0x1e:
+// //nothing
+// break;
+// case 0x1f:
+// newSEP.setXaPage(param);
+// break;
+// case 0x20:
+// newSEP.setYaPage(param);
+// break;
+// case 0x21:
+// newSEP.setDxaLeft(param);
+// break;
+// case 0x22:
+// newSEP.setDxaRight(param);
+// break;
+// case 0x23:
+// newSEP.setDyaTop(param);
+// break;
+// case 0x24:
+// newSEP.setDyaBottom(param);
+// break;
+// case 0x25:
+// newSEP.setDzaGutter(param);
+// break;
+// case 0x26:
+// newSEP.setDmPaperReq((short)param);
+// break;
+// case 0x27:
+// newSEP.setFPropMark(getFlag(varParam[0]));
+// break;
+// case 0x28:
+// break;
+// case 0x29:
+// break;
+// case 0x2a:
+// break;
+// case 0x2b:
+// short[] brcTop = newSEP.getBrcTop();
+// brcTop[0] = (short)(param & 0xffff);
+// brcTop[1] = (short)((param & 0xffff0000) >> 16);
+// break;
+// case 0x2c:
+// short[] brcLeft = newSEP.getBrcLeft();
+// brcLeft[0] = (short)(param & 0xffff);
+// brcLeft[1] = (short)((param & 0xffff0000) >> 16);
+// break;
+// case 0x2d:
+// short[] brcBottom = newSEP.getBrcBottom();
+// brcBottom[0] = (short)(param & 0xffff);
+// brcBottom[1] = (short)((param & 0xffff0000) >> 16);
+// break;
+// case 0x2e:
+// short[] brcRight = newSEP.getBrcRight();
+// brcRight[0] = (short)(param & 0xffff);
+// brcRight[1] = (short)((param & 0xffff0000) >> 16);
+// break;
+// case 0x2f:
+// newSEP.setPgbProp(param);
+// break;
+// case 0x30:
+// newSEP.setDxtCharSpace(param);
+// break;
+// case 0x31:
+// newSEP.setDyaLinePitch(param);
+// break;
+// case 0x33:
+// newSEP.setWTextFlow((short)param);
+// break;
+// default:
+// break;
+// }
+//
+// }
/**
* Converts an byte value into a boolean. The byte parameter can be 1,0, 128,
* or 129. if it is 128, this function returns the same value as oldVal. If
@@ -1518,4 +1592,4 @@ public class StyleSheet implements HDFType
return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TextPiece.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TextPiece.java
index 15ae0aaac..91308c2b1 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TextPiece.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TextPiece.java
@@ -52,7 +52,7 @@
* .
*/
-package org.apache.poi.hdf.model.hdftypes;
+package org.apache.poi.hwpf.model.hdftypes;
@@ -66,6 +66,7 @@ public class TextPiece extends PropertyNode implements Comparable
{
private boolean _usesUnicode;
private int _length;
+ private PieceDescriptor _pd;
/**
* @param start Offset in main document stream.
@@ -73,12 +74,11 @@ public class TextPiece extends PropertyNode implements Comparable
* does not necessarily refer to 1 byte.
* @param unicode true if this text is unicode.
*/
- public TextPiece(int start, int length, boolean unicode)
+ public TextPiece(int start, int end, byte[] text, PieceDescriptor pd)
{
- super(start, start + length, null);
- _usesUnicode = unicode;
- _length = length;
-
+ super(start, end, text);
+ _usesUnicode = pd.isUnicode();
+ _length = end - start;
}
/**
* @return If this text piece uses unicode
@@ -87,4 +87,9 @@ public class TextPiece extends PropertyNode implements Comparable
{
return _usesUnicode;
}
+
+ public PieceDescriptor getPieceDescriptor()
+ {
+ return _pd;
+ }
}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/CHPAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/CHPAbstractType.java
index 7a7fcf9fd..ae019e9bf 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/CHPAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/CHPAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -77,27 +77,27 @@ public abstract class CHPAbstractType
private short field_1_chse;
private int field_2_format_flags;
- private BitField fBold = new BitField(0x0001);
- private BitField fItalic = new BitField(0x0002);
- private BitField fRMarkDel = new BitField(0x0004);
- private BitField fOutline = new BitField(0x0008);
- private BitField fFldVanish = new BitField(0x0010);
- private BitField fSmallCaps = new BitField(0x0020);
- private BitField fCaps = new BitField(0x0040);
- private BitField fVanish = new BitField(0x0080);
- private BitField fRMark = new BitField(0x0100);
- private BitField fSpec = new BitField(0x0200);
- private BitField fStrike = new BitField(0x0400);
- private BitField fObj = new BitField(0x0800);
- private BitField fShadow = new BitField(0x1000);
- private BitField fLowerCase = new BitField(0x2000);
- private BitField fData = new BitField(0x4000);
- private BitField fOle2 = new BitField(0x8000);
+ private static BitField fBold = new BitField(0x0001);
+ private static BitField fItalic = new BitField(0x0002);
+ private static BitField fRMarkDel = new BitField(0x0004);
+ private static BitField fOutline = new BitField(0x0008);
+ private static BitField fFldVanish = new BitField(0x0010);
+ private static BitField fSmallCaps = new BitField(0x0020);
+ private static BitField fCaps = new BitField(0x0040);
+ private static BitField fVanish = new BitField(0x0080);
+ private static BitField fRMark = new BitField(0x0100);
+ private static BitField fSpec = new BitField(0x0200);
+ private static BitField fStrike = new BitField(0x0400);
+ private static BitField fObj = new BitField(0x0800);
+ private static BitField fShadow = new BitField(0x1000);
+ private static BitField fLowerCase = new BitField(0x2000);
+ private static BitField fData = new BitField(0x4000);
+ private static BitField fOle2 = new BitField(0x8000);
private int field_3_format_flags1;
- private BitField fEmboss = new BitField(0x0001);
- private BitField fImprint = new BitField(0x0002);
- private BitField fDStrike = new BitField(0x0004);
- private BitField fUsePgsuSettings = new BitField(0x0008);
+ private static BitField fEmboss = new BitField(0x0001);
+ private static BitField fImprint = new BitField(0x0002);
+ private static BitField fDStrike = new BitField(0x0004);
+ private static BitField fUsePgsuSettings = new BitField(0x0008);
private int field_4_ftcAscii;
private int field_5_ftcFE;
private int field_6_ftcOther;
@@ -128,13 +128,13 @@ public abstract class CHPAbstractType
private byte field_31_chYsr;
private int field_32_hpsKern;
private short field_33_Highlight;
- private BitField icoHighlight = new BitField(0x001f);
- private BitField fHighlight = new BitField(0x0020);
- private BitField kcd = new BitField(0x01c0);
- private BitField fNavHighlight = new BitField(0x0200);
- private BitField fChsDiff = new BitField(0x0400);
- private BitField fMacChs = new BitField(0x0800);
- private BitField fFtcAsciSym = new BitField(0x1000);
+ private static BitField icoHighlight = new BitField(0x001f);
+ private static BitField fHighlight = new BitField(0x0020);
+ private static BitField kcd = new BitField(0x01c0);
+ private static BitField fNavHighlight = new BitField(0x0200);
+ private static BitField fChsDiff = new BitField(0x0400);
+ private static BitField fMacChs = new BitField(0x0800);
+ private static BitField fFtcAsciSym = new BitField(0x1000);
private short field_34_fPropMark;
private int field_35_ibstPropRMark;
private int field_36_dttmPropRMark;
@@ -157,7 +157,7 @@ public abstract class CHPAbstractType
*/
public int getSize()
{
- return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 1 + 1 + 1 + 2 + 2 + 2 + 1 + 2 + 4 + 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 4 + 1 + 1 + 2 + 4 + 32 + 2 + 4;
+ return 4 + + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 1 + 1 + 1 + 2 + 2 + 2 + 1 + 2 + 4 + 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 4 + 1 + 1 + 2 + 4 + 32 + 2 + 4;
}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/DOPAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/DOPAbstractType.java
index dee666a0e..a0f79f103 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/DOPAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/DOPAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -76,58 +76,58 @@ public abstract class DOPAbstractType
{
private byte field_1_formatFlags;
- private BitField fFacingPages = new BitField(0x01);
- private BitField fWidowControl = new BitField(0x02);
- private BitField fPMHMainDoc = new BitField(0x04);
- private BitField grfSupression = new BitField(0x18);
- private BitField fpc = new BitField(0x60);
- private BitField unused1 = new BitField(0x80);
- private short field_2_unused2;
+ private static BitField fFacingPages = new BitField(0x01);
+ private static BitField fWidowControl = new BitField(0x02);
+ private static BitField fPMHMainDoc = new BitField(0x04);
+ private static BitField grfSupression = new BitField(0x18);
+ private static BitField fpc = new BitField(0x60);
+ private static BitField unused1 = new BitField(0x80);
+ private byte field_2_unused2;
private short field_3_footnoteInfo;
- private BitField rncFtn = new BitField(0x0003);
- private BitField nFtn = new BitField(0xfffc);
+ private static BitField rncFtn = new BitField(0x0003);
+ private static BitField nFtn = new BitField(0xfffc);
private byte field_4_fOutlineDirtySave;
private byte field_5_docinfo;
- private BitField fOnlyMacPics = new BitField(0x01);
- private BitField fOnlyWinPics = new BitField(0x02);
- private BitField fLabelDoc = new BitField(0x04);
- private BitField fHyphCapitals = new BitField(0x08);
- private BitField fAutoHyphen = new BitField(0x10);
- private BitField fFormNoFields = new BitField(0x20);
- private BitField fLinkStyles = new BitField(0x40);
- private BitField fRevMarking = new BitField(0x80);
+ private static BitField fOnlyMacPics = new BitField(0x01);
+ private static BitField fOnlyWinPics = new BitField(0x02);
+ private static BitField fLabelDoc = new BitField(0x04);
+ private static BitField fHyphCapitals = new BitField(0x08);
+ private static BitField fAutoHyphen = new BitField(0x10);
+ private static BitField fFormNoFields = new BitField(0x20);
+ private static BitField fLinkStyles = new BitField(0x40);
+ private static BitField fRevMarking = new BitField(0x80);
private byte field_6_docinfo1;
- private BitField fBackup = new BitField(0x01);
- private BitField fExactCWords = new BitField(0x02);
- private BitField fPagHidden = new BitField(0x04);
- private BitField fPagResults = new BitField(0x08);
- private BitField fLockAtn = new BitField(0x10);
- private BitField fMirrorMargins = new BitField(0x20);
- private BitField unused3 = new BitField(0x40);
- private BitField fDfltTrueType = new BitField(0x80);
+ private static BitField fBackup = new BitField(0x01);
+ private static BitField fExactCWords = new BitField(0x02);
+ private static BitField fPagHidden = new BitField(0x04);
+ private static BitField fPagResults = new BitField(0x08);
+ private static BitField fLockAtn = new BitField(0x10);
+ private static BitField fMirrorMargins = new BitField(0x20);
+ private static BitField unused3 = new BitField(0x40);
+ private static BitField fDfltTrueType = new BitField(0x80);
private byte field_7_docinfo2;
- private BitField fPagSupressTopSpacing = new BitField(0x01);
- private BitField fProtEnabled = new BitField(0x02);
- private BitField fDispFormFldSel = new BitField(0x04);
- private BitField fRMView = new BitField(0x08);
- private BitField fRMPrint = new BitField(0x10);
- private BitField unused4 = new BitField(0x20);
- private BitField fLockRev = new BitField(0x40);
- private BitField fEmbedFonts = new BitField(0x80);
+ private static BitField fPagSupressTopSpacing = new BitField(0x01);
+ private static BitField fProtEnabled = new BitField(0x02);
+ private static BitField fDispFormFldSel = new BitField(0x04);
+ private static BitField fRMView = new BitField(0x08);
+ private static BitField fRMPrint = new BitField(0x10);
+ private static BitField unused4 = new BitField(0x20);
+ private static BitField fLockRev = new BitField(0x40);
+ private static BitField fEmbedFonts = new BitField(0x80);
private short field_8_docinfo3;
- private BitField oldfNoTabForInd = new BitField(0x0001);
- private BitField oldfNoSpaceRaiseLower = new BitField(0x0002);
- private BitField oldfSuppressSpbfAfterPageBreak = new BitField(0x0004);
- private BitField oldfWrapTrailSpaces = new BitField(0x0008);
- private BitField oldfMapPrintTextColor = new BitField(0x0010);
- private BitField oldfNoColumnBalance = new BitField(0x0020);
- private BitField oldfConvMailMergeEsc = new BitField(0x0040);
- private BitField oldfSupressTopSpacing = new BitField(0x0080);
- private BitField oldfOrigWordTableRules = new BitField(0x0100);
- private BitField oldfTransparentMetafiles = new BitField(0x0200);
- private BitField oldfShowBreaksInFrames = new BitField(0x0400);
- private BitField oldfSwapBordersFacingPgs = new BitField(0x0800);
- private BitField unused5 = new BitField(0xf000);
+ private static BitField oldfNoTabForInd = new BitField(0x0001);
+ private static BitField oldfNoSpaceRaiseLower = new BitField(0x0002);
+ private static BitField oldfSuppressSpbfAfterPageBreak = new BitField(0x0004);
+ private static BitField oldfWrapTrailSpaces = new BitField(0x0008);
+ private static BitField oldfMapPrintTextColor = new BitField(0x0010);
+ private static BitField oldfNoColumnBalance = new BitField(0x0020);
+ private static BitField oldfConvMailMergeEsc = new BitField(0x0040);
+ private static BitField oldfSupressTopSpacing = new BitField(0x0080);
+ private static BitField oldfOrigWordTableRules = new BitField(0x0100);
+ private static BitField oldfTransparentMetafiles = new BitField(0x0200);
+ private static BitField oldfShowBreaksInFrames = new BitField(0x0400);
+ private static BitField oldfSwapBordersFacingPgs = new BitField(0x0800);
+ private static BitField unused5 = new BitField(0xf000);
private int field_9_dxaTab;
private int field_10_wSpare;
private int field_11_dxaHotz;
@@ -143,16 +143,16 @@ public abstract class DOPAbstractType
private int field_21_cPg;
private int field_22_cParas;
private short field_23_Edn;
- private BitField rncEdn = new BitField(0x0003);
- private BitField nEdn = new BitField(0xfffc);
+ private static BitField rncEdn = new BitField(0x0003);
+ private static BitField nEdn = new BitField(0xfffc);
private short field_24_Edn1;
- private BitField epc = new BitField(0x0003);
- private BitField nfcFtnRef1 = new BitField(0x003c);
- private BitField nfcEdnRef1 = new BitField(0x03c0);
- private BitField fPrintFormData = new BitField(0x0400);
- private BitField fSaveFormData = new BitField(0x0800);
- private BitField fShadeFormData = new BitField(0x1000);
- private BitField fWCFtnEdn = new BitField(0x8000);
+ private static BitField epc = new BitField(0x0003);
+ private static BitField nfcFtnRef1 = new BitField(0x003c);
+ private static BitField nfcEdnRef1 = new BitField(0x03c0);
+ private static BitField fPrintFormData = new BitField(0x0400);
+ private static BitField fSaveFormData = new BitField(0x0800);
+ private static BitField fShadeFormData = new BitField(0x1000);
+ private static BitField fWCFtnEdn = new BitField(0x8000);
private int field_25_cLines;
private int field_26_cWordsFtnEnd;
private int field_27_cChFtnEdn;
@@ -161,55 +161,55 @@ public abstract class DOPAbstractType
private int field_30_cLinesFtnEdn;
private int field_31_lKeyProtDoc;
private short field_32_view;
- private BitField wvkSaved = new BitField(0x0007);
- private BitField wScaleSaved = new BitField(0x0ff8);
- private BitField zkSaved = new BitField(0x3000);
- private BitField fRotateFontW6 = new BitField(0x4000);
- private BitField iGutterPos = new BitField(0x8000);
+ private static BitField wvkSaved = new BitField(0x0007);
+ private static BitField wScaleSaved = new BitField(0x0ff8);
+ private static BitField zkSaved = new BitField(0x3000);
+ private static BitField fRotateFontW6 = new BitField(0x4000);
+ private static BitField iGutterPos = new BitField(0x8000);
private int field_33_docinfo4;
- private BitField fNoTabForInd = new BitField(0x00000001);
- private BitField fNoSpaceRaiseLower = new BitField(0x00000002);
- private BitField fSupressSpdfAfterPageBreak = new BitField(0x00000004);
- private BitField fWrapTrailSpaces = new BitField(0x00000008);
- private BitField fMapPrintTextColor = new BitField(0x00000010);
- private BitField fNoColumnBalance = new BitField(0x00000020);
- private BitField fConvMailMergeEsc = new BitField(0x00000040);
- private BitField fSupressTopSpacing = new BitField(0x00000080);
- private BitField fOrigWordTableRules = new BitField(0x00000100);
- private BitField fTransparentMetafiles = new BitField(0x00000200);
- private BitField fShowBreaksInFrames = new BitField(0x00000400);
- private BitField fSwapBordersFacingPgs = new BitField(0x00000800);
- private BitField fSuppressTopSPacingMac5 = new BitField(0x00010000);
- private BitField fTruncDxaExpand = new BitField(0x00020000);
- private BitField fPrintBodyBeforeHdr = new BitField(0x00040000);
- private BitField fNoLeading = new BitField(0x00080000);
- private BitField fMWSmallCaps = new BitField(0x00200000);
+ private static BitField fNoTabForInd = new BitField(0x00000001);
+ private static BitField fNoSpaceRaiseLower = new BitField(0x00000002);
+ private static BitField fSupressSpdfAfterPageBreak = new BitField(0x00000004);
+ private static BitField fWrapTrailSpaces = new BitField(0x00000008);
+ private static BitField fMapPrintTextColor = new BitField(0x00000010);
+ private static BitField fNoColumnBalance = new BitField(0x00000020);
+ private static BitField fConvMailMergeEsc = new BitField(0x00000040);
+ private static BitField fSupressTopSpacing = new BitField(0x00000080);
+ private static BitField fOrigWordTableRules = new BitField(0x00000100);
+ private static BitField fTransparentMetafiles = new BitField(0x00000200);
+ private static BitField fShowBreaksInFrames = new BitField(0x00000400);
+ private static BitField fSwapBordersFacingPgs = new BitField(0x00000800);
+ private static BitField fSuppressTopSPacingMac5 = new BitField(0x00010000);
+ private static BitField fTruncDxaExpand = new BitField(0x00020000);
+ private static BitField fPrintBodyBeforeHdr = new BitField(0x00040000);
+ private static BitField fNoLeading = new BitField(0x00080000);
+ private static BitField fMWSmallCaps = new BitField(0x00200000);
private short field_34_adt;
private byte[] field_35_doptypography;
private byte[] field_36_dogrid;
private short field_37_docinfo5;
- private BitField lvl = new BitField(0x001e);
- private BitField fGramAllDone = new BitField(0x0020);
- private BitField fGramAllClean = new BitField(0x0040);
- private BitField fSubsetFonts = new BitField(0x0080);
- private BitField fHideLastVersion = new BitField(0x0100);
- private BitField fHtmlDoc = new BitField(0x0200);
- private BitField fSnapBorder = new BitField(0x0800);
- private BitField fIncludeHeader = new BitField(0x1000);
- private BitField fIncludeFooter = new BitField(0x2000);
- private BitField fForcePageSizePag = new BitField(0x4000);
- private BitField fMinFontSizePag = new BitField(0x8000);
+ private static BitField lvl = new BitField(0x001e);
+ private static BitField fGramAllDone = new BitField(0x0020);
+ private static BitField fGramAllClean = new BitField(0x0040);
+ private static BitField fSubsetFonts = new BitField(0x0080);
+ private static BitField fHideLastVersion = new BitField(0x0100);
+ private static BitField fHtmlDoc = new BitField(0x0200);
+ private static BitField fSnapBorder = new BitField(0x0800);
+ private static BitField fIncludeHeader = new BitField(0x1000);
+ private static BitField fIncludeFooter = new BitField(0x2000);
+ private static BitField fForcePageSizePag = new BitField(0x4000);
+ private static BitField fMinFontSizePag = new BitField(0x8000);
private short field_38_docinfo6;
- private BitField fHaveVersions = new BitField(0x0001);
- private BitField fAutoVersions = new BitField(0x0002);
+ private static BitField fHaveVersions = new BitField(0x0001);
+ private static BitField fAutoVersions = new BitField(0x0002);
private byte[] field_39_asumyi;
private int field_40_cChWS;
private int field_41_cChWSFtnEdn;
private int field_42_grfDocEvents;
private int field_43_virusinfo;
- private BitField fVirusPrompted = new BitField(0x0001);
- private BitField fVirusLoadSafe = new BitField(0x0002);
- private BitField KeyVirusSession30 = new BitField(0xfffffffc);
+ private static BitField fVirusPrompted = new BitField(0x0001);
+ private static BitField fVirusLoadSafe = new BitField(0x0002);
+ private static BitField KeyVirusSession30 = new BitField(0xfffffffc);
private byte[] field_44_Spare;
private int field_45_reserved1;
private int field_46_reserved2;
@@ -230,58 +230,116 @@ public abstract class DOPAbstractType
protected void fillFields(byte [] data, short size, int offset)
{
field_1_formatFlags = data[ 0x0 + offset ];
- field_2_unused2 = LittleEndian.getShort(data, 0x1 + offset);
- field_3_footnoteInfo = LittleEndian.getShort(data, 0x3 + offset);
- field_4_fOutlineDirtySave = data[ 0x5 + offset ];
- field_5_docinfo = data[ 0x6 + offset ];
- field_6_docinfo1 = data[ 0x7 + offset ];
- field_7_docinfo2 = data[ 0x8 + offset ];
- field_8_docinfo3 = LittleEndian.getShort(data, 0x9 + offset);
- field_9_dxaTab = LittleEndian.getShort(data, 0xb + offset);
- field_10_wSpare = LittleEndian.getShort(data, 0xd + offset);
- field_11_dxaHotz = LittleEndian.getShort(data, 0xf + offset);
- field_12_cConsexHypLim = LittleEndian.getShort(data, 0x11 + offset);
- field_13_wSpare2 = LittleEndian.getShort(data, 0x13 + offset);
- field_14_dttmCreated = LittleEndian.getInt(data, 0x15 + offset);
- field_15_dttmRevised = LittleEndian.getInt(data, 0x19 + offset);
- field_16_dttmLastPrint = LittleEndian.getInt(data, 0x1d + offset);
- field_17_nRevision = LittleEndian.getShort(data, 0x21 + offset);
- field_18_tmEdited = LittleEndian.getInt(data, 0x23 + offset);
- field_19_cWords = LittleEndian.getInt(data, 0x27 + offset);
- field_20_cCh = LittleEndian.getInt(data, 0x2b + offset);
- field_21_cPg = LittleEndian.getShort(data, 0x2f + offset);
- field_22_cParas = LittleEndian.getInt(data, 0x31 + offset);
- field_23_Edn = LittleEndian.getShort(data, 0x35 + offset);
- field_24_Edn1 = LittleEndian.getShort(data, 0x37 + offset);
- field_25_cLines = LittleEndian.getInt(data, 0x39 + offset);
- field_26_cWordsFtnEnd = LittleEndian.getInt(data, 0x3d + offset);
- field_27_cChFtnEdn = LittleEndian.getInt(data, 0x41 + offset);
- field_28_cPgFtnEdn = LittleEndian.getShort(data, 0x45 + offset);
- field_29_cParasFtnEdn = LittleEndian.getInt(data, 0x47 + offset);
- field_30_cLinesFtnEdn = LittleEndian.getInt(data, 0x4b + offset);
- field_31_lKeyProtDoc = LittleEndian.getInt(data, 0x4f + offset);
- field_32_view = LittleEndian.getShort(data, 0x53 + offset);
- field_33_docinfo4 = LittleEndian.getInt(data, 0x55 + offset);
- field_34_adt = LittleEndian.getShort(data, 0x59 + offset);
- field_35_doptypography = LittleEndian.getByteArray(data, 0x5b + offset, size);
- field_36_dogrid = LittleEndian.getByteArray(data, 0x191 + offset, size);
- field_37_docinfo5 = LittleEndian.getShort(data, 0x19b + offset);
- field_38_docinfo6 = LittleEndian.getShort(data, 0x19d + offset);
- field_39_asumyi = LittleEndian.getByteArray(data, 0x19f + offset, size);
- field_40_cChWS = LittleEndian.getInt(data, 0x1ab + offset);
- field_41_cChWSFtnEdn = LittleEndian.getInt(data, 0x1af + offset);
- field_42_grfDocEvents = LittleEndian.getInt(data, 0x1b3 + offset);
- field_43_virusinfo = LittleEndian.getInt(data, 0x1b7 + offset);
- field_44_Spare = LittleEndian.getByteArray(data, 0x1bb + offset, size);
- field_45_reserved1 = LittleEndian.getInt(data, 0x1d9 + offset);
- field_46_reserved2 = LittleEndian.getInt(data, 0x1dd + offset);
- field_47_cDBC = LittleEndian.getInt(data, 0x1e1 + offset);
- field_48_cDBCFtnEdn = LittleEndian.getInt(data, 0x1e5 + offset);
- field_49_reserved = LittleEndian.getInt(data, 0x1e9 + offset);
- field_50_nfcFtnRef = LittleEndian.getShort(data, 0x1ed + offset);
- field_51_nfcEdnRef = LittleEndian.getShort(data, 0x1ef + offset);
- field_52_hpsZoonFontPag = LittleEndian.getShort(data, 0x1f1 + offset);
- field_53_dywDispPag = LittleEndian.getShort(data, 0x1f3 + offset);
+ field_2_unused2 = data[ 0x1 + offset ];
+ field_3_footnoteInfo = LittleEndian.getShort(data, 0x2 + offset);
+ field_4_fOutlineDirtySave = data[ 0x4 + offset ];
+ field_5_docinfo = data[ 0x5 + offset ];
+ field_6_docinfo1 = data[ 0x6 + offset ];
+ field_7_docinfo2 = data[ 0x7 + offset ];
+ field_8_docinfo3 = LittleEndian.getShort(data, 0x8 + offset);
+ field_9_dxaTab = LittleEndian.getShort(data, 0xa + offset);
+ field_10_wSpare = LittleEndian.getShort(data, 0xc + offset);
+ field_11_dxaHotz = LittleEndian.getShort(data, 0xe + offset);
+ field_12_cConsexHypLim = LittleEndian.getShort(data, 0x10 + offset);
+ field_13_wSpare2 = LittleEndian.getShort(data, 0x12 + offset);
+ field_14_dttmCreated = LittleEndian.getInt(data, 0x14 + offset);
+ field_15_dttmRevised = LittleEndian.getInt(data, 0x18 + offset);
+ field_16_dttmLastPrint = LittleEndian.getInt(data, 0x1c + offset);
+ field_17_nRevision = LittleEndian.getShort(data, 0x20 + offset);
+ field_18_tmEdited = LittleEndian.getInt(data, 0x22 + offset);
+ field_19_cWords = LittleEndian.getInt(data, 0x26 + offset);
+ field_20_cCh = LittleEndian.getInt(data, 0x2a + offset);
+ field_21_cPg = LittleEndian.getShort(data, 0x2e + offset);
+ field_22_cParas = LittleEndian.getInt(data, 0x30 + offset);
+ field_23_Edn = LittleEndian.getShort(data, 0x34 + offset);
+ field_24_Edn1 = LittleEndian.getShort(data, 0x36 + offset);
+ field_25_cLines = LittleEndian.getInt(data, 0x38 + offset);
+ field_26_cWordsFtnEnd = LittleEndian.getInt(data, 0x3c + offset);
+ field_27_cChFtnEdn = LittleEndian.getInt(data, 0x40 + offset);
+ field_28_cPgFtnEdn = LittleEndian.getShort(data, 0x44 + offset);
+ field_29_cParasFtnEdn = LittleEndian.getInt(data, 0x46 + offset);
+ field_30_cLinesFtnEdn = LittleEndian.getInt(data, 0x4a + offset);
+ field_31_lKeyProtDoc = LittleEndian.getInt(data, 0x4e + offset);
+ field_32_view = LittleEndian.getShort(data, 0x52 + offset);
+ field_33_docinfo4 = LittleEndian.getInt(data, 0x54 + offset);
+ field_34_adt = LittleEndian.getShort(data, 0x58 + offset);
+ field_35_doptypography = LittleEndian.getByteArray(data, 0x5a + offset,310);
+ field_36_dogrid = LittleEndian.getByteArray(data, 0x190 + offset,10);
+ field_37_docinfo5 = LittleEndian.getShort(data, 0x19a + offset);
+ field_38_docinfo6 = LittleEndian.getShort(data, 0x19c + offset);
+ field_39_asumyi = LittleEndian.getByteArray(data, 0x19e + offset,12);
+ field_40_cChWS = LittleEndian.getInt(data, 0x1aa + offset);
+ field_41_cChWSFtnEdn = LittleEndian.getInt(data, 0x1ae + offset);
+ field_42_grfDocEvents = LittleEndian.getInt(data, 0x1b2 + offset);
+ field_43_virusinfo = LittleEndian.getInt(data, 0x1b6 + offset);
+ field_44_Spare = LittleEndian.getByteArray(data, 0x1ba + offset,30);
+ field_45_reserved1 = LittleEndian.getInt(data, 0x1d8 + offset);
+ field_46_reserved2 = LittleEndian.getInt(data, 0x1dc + offset);
+ field_47_cDBC = LittleEndian.getInt(data, 0x1e0 + offset);
+ field_48_cDBCFtnEdn = LittleEndian.getInt(data, 0x1e4 + offset);
+ field_49_reserved = LittleEndian.getInt(data, 0x1e8 + offset);
+ field_50_nfcFtnRef = LittleEndian.getShort(data, 0x1ec + offset);
+ field_51_nfcEdnRef = LittleEndian.getShort(data, 0x1ee + offset);
+ field_52_hpsZoonFontPag = LittleEndian.getShort(data, 0x1f0 + offset);
+ field_53_dywDispPag = LittleEndian.getShort(data, 0x1f2 + offset);
+
+ }
+
+ public void serialize(byte[] data, int offset)
+ {
+ data[ 0x0 + offset] = field_1_formatFlags;;
+ data[ 0x1 + offset] = field_2_unused2;;
+ LittleEndian.putShort(data, 0x2 + offset, (short)field_3_footnoteInfo);;
+ data[ 0x4 + offset] = field_4_fOutlineDirtySave;;
+ data[ 0x5 + offset] = field_5_docinfo;;
+ data[ 0x6 + offset] = field_6_docinfo1;;
+ data[ 0x7 + offset] = field_7_docinfo2;;
+ LittleEndian.putShort(data, 0x8 + offset, (short)field_8_docinfo3);;
+ LittleEndian.putShort(data, 0xa + offset, (short)field_9_dxaTab);;
+ LittleEndian.putShort(data, 0xc + offset, (short)field_10_wSpare);;
+ LittleEndian.putShort(data, 0xe + offset, (short)field_11_dxaHotz);;
+ LittleEndian.putShort(data, 0x10 + offset, (short)field_12_cConsexHypLim);;
+ LittleEndian.putShort(data, 0x12 + offset, (short)field_13_wSpare2);;
+ LittleEndian.putInt(data, 0x14 + offset, field_14_dttmCreated);;
+ LittleEndian.putInt(data, 0x18 + offset, field_15_dttmRevised);;
+ LittleEndian.putInt(data, 0x1c + offset, field_16_dttmLastPrint);;
+ LittleEndian.putShort(data, 0x20 + offset, (short)field_17_nRevision);;
+ LittleEndian.putInt(data, 0x22 + offset, field_18_tmEdited);;
+ LittleEndian.putInt(data, 0x26 + offset, field_19_cWords);;
+ LittleEndian.putInt(data, 0x2a + offset, field_20_cCh);;
+ LittleEndian.putShort(data, 0x2e + offset, (short)field_21_cPg);;
+ LittleEndian.putInt(data, 0x30 + offset, field_22_cParas);;
+ LittleEndian.putShort(data, 0x34 + offset, (short)field_23_Edn);;
+ LittleEndian.putShort(data, 0x36 + offset, (short)field_24_Edn1);;
+ LittleEndian.putInt(data, 0x38 + offset, field_25_cLines);;
+ LittleEndian.putInt(data, 0x3c + offset, field_26_cWordsFtnEnd);;
+ LittleEndian.putInt(data, 0x40 + offset, field_27_cChFtnEdn);;
+ LittleEndian.putShort(data, 0x44 + offset, (short)field_28_cPgFtnEdn);;
+ LittleEndian.putInt(data, 0x46 + offset, field_29_cParasFtnEdn);;
+ LittleEndian.putInt(data, 0x4a + offset, field_30_cLinesFtnEdn);;
+ LittleEndian.putInt(data, 0x4e + offset, field_31_lKeyProtDoc);;
+ LittleEndian.putShort(data, 0x52 + offset, (short)field_32_view);;
+ LittleEndian.putInt(data, 0x54 + offset, field_33_docinfo4);;
+ LittleEndian.putShort(data, 0x58 + offset, (short)field_34_adt);;
+ ;
+ ;
+ LittleEndian.putShort(data, 0x19a + offset, (short)field_37_docinfo5);;
+ LittleEndian.putShort(data, 0x19c + offset, (short)field_38_docinfo6);;
+ ;
+ LittleEndian.putInt(data, 0x1aa + offset, field_40_cChWS);;
+ LittleEndian.putInt(data, 0x1ae + offset, field_41_cChWSFtnEdn);;
+ LittleEndian.putInt(data, 0x1b2 + offset, field_42_grfDocEvents);;
+ LittleEndian.putInt(data, 0x1b6 + offset, field_43_virusinfo);;
+ ;
+ LittleEndian.putInt(data, 0x1d8 + offset, field_45_reserved1);;
+ LittleEndian.putInt(data, 0x1dc + offset, field_46_reserved2);;
+ LittleEndian.putInt(data, 0x1e0 + offset, field_47_cDBC);;
+ LittleEndian.putInt(data, 0x1e4 + offset, field_48_cDBCFtnEdn);;
+ LittleEndian.putInt(data, 0x1e8 + offset, field_49_reserved);;
+ LittleEndian.putShort(data, 0x1ec + offset, (short)field_50_nfcFtnRef);;
+ LittleEndian.putShort(data, 0x1ee + offset, (short)field_51_nfcEdnRef);;
+ LittleEndian.putShort(data, 0x1f0 + offset, (short)field_52_hpsZoonFontPag);;
+ LittleEndian.putShort(data, 0x1f2 + offset, (short)field_53_dywDispPag);;
}
@@ -304,7 +362,7 @@ public abstract class DOPAbstractType
buffer.append(" .unused2 = ");
buffer.append("0x");
- buffer.append(HexDump.toHex((short)getUnused2()));
+ buffer.append(HexDump.toHex((byte)getUnused2()));
buffer.append(" (").append(getUnused2()).append(" )\n");
buffer.append(" .footnoteInfo = ");
@@ -657,7 +715,7 @@ public abstract class DOPAbstractType
*/
public int getSize()
{
- return 4 + 1 + 2 + 2 + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 4 + 4 + 4 + 2 + 4 + 2 + 2 + 4 + 4 + 4 + 2 + 4 + 4 + 4 + 2 + 4 + 2 + 310 + 10 + 2 + 2 + 12 + 4 + 4 + 4 + 4 + 30 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
+ return 4 + + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 4 + 4 + 4 + 2 + 4 + 2 + 2 + 4 + 4 + 4 + 2 + 4 + 4 + 4 + 2 + 4 + 2 + 310 + 10 + 2 + 2 + 12 + 4 + 4 + 4 + 4 + 30 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
}
@@ -681,7 +739,7 @@ public abstract class DOPAbstractType
/**
* Get the unused2 field for the DOP record.
*/
- public short getUnused2()
+ public byte getUnused2()
{
return field_2_unused2;
}
@@ -689,7 +747,7 @@ public abstract class DOPAbstractType
/**
* Set the unused2 field for the DOP record.
*/
- public void setUnused2(short field_2_unused2)
+ public void setUnused2(byte field_2_unused2)
{
this.field_2_unused2 = field_2_unused2;
}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/FIBAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/FIBAbstractType.java
index f71d8f658..5aa02fa5a 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/FIBAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/FIBAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -81,29 +81,29 @@ public abstract class FIBAbstractType
private int field_4_lid;
private int field_5_pnNext;
private short field_6_options;
- private BitField fDot = new BitField(0x0001);
- private BitField fGlsy = new BitField(0x0002);
- private BitField fComplex = new BitField(0x0004);
- private BitField fHasPic = new BitField(0x0008);
- private BitField cQuickSaves = new BitField(0x00F0);
- private BitField fEncrypted = new BitField(0x0100);
- private BitField fWhichTblStm = new BitField(0x0200);
- private BitField fReadOnlyRecommended = new BitField(0x0400);
- private BitField fWriteReservation = new BitField(0x0800);
- private BitField fExtChar = new BitField(0x1000);
- private BitField fLoadOverride = new BitField(0x2000);
- private BitField fFarEast = new BitField(0x4000);
- private BitField fCrypto = new BitField(0x8000);
+ private static BitField fDot = new BitField(0x0001);
+ private static BitField fGlsy = new BitField(0x0002);
+ private static BitField fComplex = new BitField(0x0004);
+ private static BitField fHasPic = new BitField(0x0008);
+ private static BitField cQuickSaves = new BitField(0x00F0);
+ private static BitField fEncrypted = new BitField(0x0100);
+ private static BitField fWhichTblStm = new BitField(0x0200);
+ private static BitField fReadOnlyRecommended = new BitField(0x0400);
+ private static BitField fWriteReservation = new BitField(0x0800);
+ private static BitField fExtChar = new BitField(0x1000);
+ private static BitField fLoadOverride = new BitField(0x2000);
+ private static BitField fFarEast = new BitField(0x4000);
+ private static BitField fCrypto = new BitField(0x8000);
private int field_7_nFibBack;
private int field_8_lKey;
private int field_9_envr;
private short field_10_history;
- private BitField fMac = new BitField(0x0001);
- private BitField fEmptySpecial = new BitField(0x0002);
- private BitField fLoadOverridePage = new BitField(0x0004);
- private BitField fFutureSavedUndo = new BitField(0x0008);
- private BitField fWord97Saved = new BitField(0x0010);
- private BitField fSpare0 = new BitField(0x00FE);
+ private static BitField fMac = new BitField(0x0001);
+ private static BitField fEmptySpecial = new BitField(0x0002);
+ private static BitField fLoadOverridePage = new BitField(0x0004);
+ private static BitField fFutureSavedUndo = new BitField(0x0008);
+ private static BitField fWord97Saved = new BitField(0x0010);
+ private static BitField fSpare0 = new BitField(0x00FE);
private int field_11_chs;
private int field_12_chsTables;
private int field_13_fcMin;
@@ -584,6 +584,250 @@ public abstract class FIBAbstractType
}
+ public void serialize(byte[] data, int offset)
+ {
+ LittleEndian.putShort(data, 0x0 + offset, (short)field_1_wIdent);;
+ LittleEndian.putShort(data, 0x2 + offset, (short)field_2_nFib);;
+ LittleEndian.putShort(data, 0x4 + offset, (short)field_3_nProduct);;
+ LittleEndian.putShort(data, 0x6 + offset, (short)field_4_lid);;
+ LittleEndian.putShort(data, 0x8 + offset, (short)field_5_pnNext);;
+ LittleEndian.putShort(data, 0xa + offset, (short)field_6_options);;
+ LittleEndian.putShort(data, 0xc + offset, (short)field_7_nFibBack);;
+ LittleEndian.putShort(data, 0xe + offset, (short)field_8_lKey);;
+ LittleEndian.putShort(data, 0x10 + offset, (short)field_9_envr);;
+ LittleEndian.putShort(data, 0x12 + offset, (short)field_10_history);;
+ LittleEndian.putShort(data, 0x14 + offset, (short)field_11_chs);;
+ LittleEndian.putShort(data, 0x16 + offset, (short)field_12_chsTables);;
+ LittleEndian.putInt(data, 0x18 + offset, field_13_fcMin);;
+ LittleEndian.putInt(data, 0x1c + offset, field_14_fcMac);;
+ LittleEndian.putShort(data, 0x20 + offset, (short)field_15_csw);;
+ LittleEndian.putShort(data, 0x22 + offset, (short)field_16_wMagicCreated);;
+ LittleEndian.putShort(data, 0x24 + offset, (short)field_17_wMagicRevised);;
+ LittleEndian.putShort(data, 0x26 + offset, (short)field_18_wMagicCreatedPrivate);;
+ LittleEndian.putShort(data, 0x28 + offset, (short)field_19_wMagicRevisedPrivate);;
+ LittleEndian.putShort(data, 0x2a + offset, (short)field_20_pnFbpChpFirst_W6);;
+ LittleEndian.putShort(data, 0x2c + offset, (short)field_21_pnChpFirst_W6);;
+ LittleEndian.putShort(data, 0x2e + offset, (short)field_22_cpnBteChp_W6);;
+ LittleEndian.putShort(data, 0x30 + offset, (short)field_23_pnFbpPapFirst_W6);;
+ LittleEndian.putShort(data, 0x32 + offset, (short)field_24_pnPapFirst_W6);;
+ LittleEndian.putShort(data, 0x34 + offset, (short)field_25_cpnBtePap_W6);;
+ LittleEndian.putShort(data, 0x36 + offset, (short)field_26_pnFbpLvcFirst_W6);;
+ LittleEndian.putShort(data, 0x38 + offset, (short)field_27_pnLvcFirst_W6);;
+ LittleEndian.putShort(data, 0x3a + offset, (short)field_28_cpnBteLvc_W6);;
+ LittleEndian.putShort(data, 0x3c + offset, (short)field_29_lidFE);;
+ LittleEndian.putShort(data, 0x3e + offset, (short)field_30_clw);;
+ LittleEndian.putInt(data, 0x40 + offset, field_31_cbMac);;
+ LittleEndian.putInt(data, 0x44 + offset, field_32_lProductCreated);;
+ LittleEndian.putInt(data, 0x48 + offset, field_33_lProductRevised);;
+ LittleEndian.putInt(data, 0x4c + offset, field_34_ccpText);;
+ LittleEndian.putInt(data, 0x50 + offset, field_35_ccpFtn);;
+ LittleEndian.putInt(data, 0x54 + offset, field_36_ccpHdd);;
+ LittleEndian.putInt(data, 0x58 + offset, field_37_ccpMcr);;
+ LittleEndian.putInt(data, 0x5c + offset, field_38_ccpAtn);;
+ LittleEndian.putInt(data, 0x60 + offset, field_39_ccpEdn);;
+ LittleEndian.putInt(data, 0x64 + offset, field_40_ccpTxbx);;
+ LittleEndian.putInt(data, 0x68 + offset, field_41_ccpHdrTxbx);;
+ LittleEndian.putInt(data, 0x6c + offset, field_42_pnFbpChpFirst);;
+ LittleEndian.putInt(data, 0x70 + offset, field_43_pnChpFirst);;
+ LittleEndian.putInt(data, 0x74 + offset, field_44_cpnBteChp);;
+ LittleEndian.putInt(data, 0x78 + offset, field_45_pnFbpPapFirst);;
+ LittleEndian.putInt(data, 0x7c + offset, field_46_pnPapFirst);;
+ LittleEndian.putInt(data, 0x80 + offset, field_47_cpnBtePap);;
+ LittleEndian.putInt(data, 0x84 + offset, field_48_pnFbpLvcFirst);;
+ LittleEndian.putInt(data, 0x88 + offset, field_49_pnLvcFirst);;
+ LittleEndian.putInt(data, 0x8c + offset, field_50_cpnBteLvc);;
+ LittleEndian.putInt(data, 0x90 + offset, field_51_fcIslandFirst);;
+ LittleEndian.putInt(data, 0x94 + offset, field_52_fcIslandLim);;
+ LittleEndian.putShort(data, 0x98 + offset, (short)field_53_cfclcb);;
+ LittleEndian.putInt(data, 0x9a + offset, field_54_fcStshfOrig);;
+ LittleEndian.putInt(data, 0x9e + offset, field_55_lcbStshfOrig);;
+ LittleEndian.putInt(data, 0xa2 + offset, field_56_fcStshf);;
+ LittleEndian.putInt(data, 0xa6 + offset, field_57_lcbStshf);;
+ LittleEndian.putInt(data, 0xaa + offset, field_58_fcPlcffndRef);;
+ LittleEndian.putInt(data, 0xae + offset, field_59_lcbPlcffndRef);;
+ LittleEndian.putInt(data, 0xb2 + offset, field_60_fcPlcffndTxt);;
+ LittleEndian.putInt(data, 0xb6 + offset, field_61_lcbPlcffndTxt);;
+ LittleEndian.putInt(data, 0xba + offset, field_62_fcPlcfandRef);;
+ LittleEndian.putInt(data, 0xbe + offset, field_63_lcbPlcfandRef);;
+ LittleEndian.putInt(data, 0xc2 + offset, field_64_fcPlcfandTxt);;
+ LittleEndian.putInt(data, 0xc6 + offset, field_65_lcbPlcfandTxt);;
+ LittleEndian.putInt(data, 0xca + offset, field_66_fcPlcfsed);;
+ LittleEndian.putInt(data, 0xce + offset, field_67_lcbPlcfsed);;
+ LittleEndian.putInt(data, 0xd2 + offset, field_68_fcPlcpad);;
+ LittleEndian.putInt(data, 0xd6 + offset, field_69_lcbPlcpad);;
+ LittleEndian.putInt(data, 0xda + offset, field_70_fcPlcfphe);;
+ LittleEndian.putInt(data, 0xde + offset, field_71_lcbPlcfphe);;
+ LittleEndian.putInt(data, 0xe2 + offset, field_72_fcSttbfglsy);;
+ LittleEndian.putInt(data, 0xe6 + offset, field_73_lcbSttbfglsy);;
+ LittleEndian.putInt(data, 0xea + offset, field_74_fcPlcfglsy);;
+ LittleEndian.putInt(data, 0xee + offset, field_75_lcbPlcfglsy);;
+ LittleEndian.putInt(data, 0xf2 + offset, field_76_fcPlcfhdd);;
+ LittleEndian.putInt(data, 0xf6 + offset, field_77_lcbPlcfhdd);;
+ LittleEndian.putInt(data, 0xfa + offset, field_78_fcPlcfbteChpx);;
+ LittleEndian.putInt(data, 0xfe + offset, field_79_lcbPlcfbteChpx);;
+ LittleEndian.putInt(data, 0x102 + offset, field_80_fcPlcfbtePapx);;
+ LittleEndian.putInt(data, 0x106 + offset, field_81_lcbPlcfbtePapx);;
+ LittleEndian.putInt(data, 0x10a + offset, field_82_fcPlcfsea);;
+ LittleEndian.putInt(data, 0x10e + offset, field_83_lcbPlcfsea);;
+ LittleEndian.putInt(data, 0x112 + offset, field_84_fcSttbfffn);;
+ LittleEndian.putInt(data, 0x116 + offset, field_85_lcbSttbfffn);;
+ LittleEndian.putInt(data, 0x11a + offset, field_86_fcPlcffldMom);;
+ LittleEndian.putInt(data, 0x11e + offset, field_87_lcbPlcffldMom);;
+ LittleEndian.putInt(data, 0x122 + offset, field_88_fcPlcffldHdr);;
+ LittleEndian.putInt(data, 0x126 + offset, field_89_lcbPlcffldHdr);;
+ LittleEndian.putInt(data, 0x12a + offset, field_90_fcPlcffldFtn);;
+ LittleEndian.putInt(data, 0x12e + offset, field_91_lcbPlcffldFtn);;
+ LittleEndian.putInt(data, 0x132 + offset, field_92_fcPlcffldAtn);;
+ LittleEndian.putInt(data, 0x136 + offset, field_93_lcbPlcffldAtn);;
+ LittleEndian.putInt(data, 0x13a + offset, field_94_fcPlcffldMcr);;
+ LittleEndian.putInt(data, 0x13e + offset, field_95_lcbPlcffldMcr);;
+ LittleEndian.putInt(data, 0x142 + offset, field_96_fcSttbfbkmk);;
+ LittleEndian.putInt(data, 0x146 + offset, field_97_lcbSttbfbkmk);;
+ LittleEndian.putInt(data, 0x14a + offset, field_98_fcPlcfbkf);;
+ LittleEndian.putInt(data, 0x14e + offset, field_99_lcbPlcfbkf);;
+ LittleEndian.putInt(data, 0x152 + offset, field_100_fcPlcfbkl);;
+ LittleEndian.putInt(data, 0x156 + offset, field_101_lcbPlcfbkl);;
+ LittleEndian.putInt(data, 0x15a + offset, field_102_fcCmds);;
+ LittleEndian.putInt(data, 0x15e + offset, field_103_lcbCmds);;
+ LittleEndian.putInt(data, 0x162 + offset, field_104_fcPlcmcr);;
+ LittleEndian.putInt(data, 0x166 + offset, field_105_lcbPlcmcr);;
+ LittleEndian.putInt(data, 0x16a + offset, field_106_fcSttbfmcr);;
+ LittleEndian.putInt(data, 0x16e + offset, field_107_lcbSttbfmcr);;
+ LittleEndian.putInt(data, 0x172 + offset, field_108_fcPrDrvr);;
+ LittleEndian.putInt(data, 0x176 + offset, field_109_lcbPrDrvr);;
+ LittleEndian.putInt(data, 0x17a + offset, field_110_fcPrEnvPort);;
+ LittleEndian.putInt(data, 0x17e + offset, field_111_lcbPrEnvPort);;
+ LittleEndian.putInt(data, 0x182 + offset, field_112_fcPrEnvLand);;
+ LittleEndian.putInt(data, 0x186 + offset, field_113_lcbPrEnvLand);;
+ LittleEndian.putInt(data, 0x18a + offset, field_114_fcWss);;
+ LittleEndian.putInt(data, 0x18e + offset, field_115_lcbWss);;
+ LittleEndian.putInt(data, 0x192 + offset, field_116_fcDop);;
+ LittleEndian.putInt(data, 0x196 + offset, field_117_lcbDop);;
+ LittleEndian.putInt(data, 0x19a + offset, field_118_fcSttbfAssoc);;
+ LittleEndian.putInt(data, 0x19e + offset, field_119_lcbSttbfAssoc);;
+ LittleEndian.putInt(data, 0x1a2 + offset, field_120_fcClx);;
+ LittleEndian.putInt(data, 0x1a6 + offset, field_121_lcbClx);;
+ LittleEndian.putInt(data, 0x1aa + offset, field_122_fcPlcfpgdFtn);;
+ LittleEndian.putInt(data, 0x1ae + offset, field_123_lcbPlcfpgdFtn);;
+ LittleEndian.putInt(data, 0x1b2 + offset, field_124_fcAutosaveSource);;
+ LittleEndian.putInt(data, 0x1b6 + offset, field_125_lcbAutosaveSource);;
+ LittleEndian.putInt(data, 0x1ba + offset, field_126_fcGrpXstAtnOwners);;
+ LittleEndian.putInt(data, 0x1be + offset, field_127_lcbGrpXstAtnOwners);;
+ LittleEndian.putInt(data, 0x1c2 + offset, field_128_fcSttbfAtnbkmk);;
+ LittleEndian.putInt(data, 0x1c6 + offset, field_129_lcbSttbfAtnbkmk);;
+ LittleEndian.putInt(data, 0x1ca + offset, field_130_fcPlcdoaMom);;
+ LittleEndian.putInt(data, 0x1ce + offset, field_131_lcbPlcdoaMom);;
+ LittleEndian.putInt(data, 0x1d2 + offset, field_132_fcPlcdoaHdr);;
+ LittleEndian.putInt(data, 0x1d6 + offset, field_133_lcbPlcdoaHdr);;
+ LittleEndian.putInt(data, 0x1da + offset, field_134_fcPlcspaMom);;
+ LittleEndian.putInt(data, 0x1de + offset, field_135_lcbPlcspaMom);;
+ LittleEndian.putInt(data, 0x1e2 + offset, field_136_fcPlcspaHdr);;
+ LittleEndian.putInt(data, 0x1e6 + offset, field_137_lcbPlcspaHdr);;
+ LittleEndian.putInt(data, 0x1ea + offset, field_138_fcPlcfAtnbkf);;
+ LittleEndian.putInt(data, 0x1ee + offset, field_139_lcbPlcfAtnbkf);;
+ LittleEndian.putInt(data, 0x1f2 + offset, field_140_fcPlcfAtnbkl);;
+ LittleEndian.putInt(data, 0x1f6 + offset, field_141_lcbPlcfAtnbkl);;
+ LittleEndian.putInt(data, 0x1fa + offset, field_142_fcPms);;
+ LittleEndian.putInt(data, 0x1fe + offset, field_143_lcbPms);;
+ LittleEndian.putInt(data, 0x202 + offset, field_144_fcFormFldSttbs);;
+ LittleEndian.putInt(data, 0x206 + offset, field_145_lcbFormFldSttbs);;
+ LittleEndian.putInt(data, 0x20a + offset, field_146_fcPlcfendRef);;
+ LittleEndian.putInt(data, 0x20e + offset, field_147_lcbPlcfendRef);;
+ LittleEndian.putInt(data, 0x212 + offset, field_148_fcPlcfendTxt);;
+ LittleEndian.putInt(data, 0x216 + offset, field_149_lcbPlcfendTxt);;
+ LittleEndian.putInt(data, 0x21a + offset, field_150_fcPlcffldEdn);;
+ LittleEndian.putInt(data, 0x21e + offset, field_151_lcbPlcffldEdn);;
+ LittleEndian.putInt(data, 0x222 + offset, field_152_fcPlcfpgdEdn);;
+ LittleEndian.putInt(data, 0x226 + offset, field_153_lcbPlcfpgdEdn);;
+ LittleEndian.putInt(data, 0x22a + offset, field_154_fcDggInfo);;
+ LittleEndian.putInt(data, 0x22e + offset, field_155_lcbDggInfo);;
+ LittleEndian.putInt(data, 0x232 + offset, field_156_fcSttbfRMark);;
+ LittleEndian.putInt(data, 0x236 + offset, field_157_lcbSttbfRMark);;
+ LittleEndian.putInt(data, 0x23a + offset, field_158_fcSttbCaption);;
+ LittleEndian.putInt(data, 0x23e + offset, field_159_lcbSttbCaption);;
+ LittleEndian.putInt(data, 0x242 + offset, field_160_fcSttbAutoCaption);;
+ LittleEndian.putInt(data, 0x246 + offset, field_161_lcbSttbAutoCaption);;
+ LittleEndian.putInt(data, 0x24a + offset, field_162_fcPlcfwkb);;
+ LittleEndian.putInt(data, 0x24e + offset, field_163_lcbPlcfwkb);;
+ LittleEndian.putInt(data, 0x252 + offset, field_164_fcPlcfspl);;
+ LittleEndian.putInt(data, 0x256 + offset, field_165_lcbPlcfspl);;
+ LittleEndian.putInt(data, 0x25a + offset, field_166_fcPlcftxbxTxt);;
+ LittleEndian.putInt(data, 0x25e + offset, field_167_lcbPlcftxbxTxt);;
+ LittleEndian.putInt(data, 0x262 + offset, field_168_fcPlcffldTxbx);;
+ LittleEndian.putInt(data, 0x266 + offset, field_169_lcbPlcffldTxbx);;
+ LittleEndian.putInt(data, 0x26a + offset, field_170_fcPlcfhdrtxbxTxt);;
+ LittleEndian.putInt(data, 0x26e + offset, field_171_lcbPlcfhdrtxbxTxt);;
+ LittleEndian.putInt(data, 0x272 + offset, field_172_fcPlcffldHdrTxbx);;
+ LittleEndian.putInt(data, 0x276 + offset, field_173_lcbPlcffldHdrTxbx);;
+ LittleEndian.putInt(data, 0x27a + offset, field_174_fcStwUser);;
+ LittleEndian.putInt(data, 0x27e + offset, field_175_lcbStwUser);;
+ LittleEndian.putInt(data, 0x282 + offset, field_176_fcSttbttmbd);;
+ LittleEndian.putInt(data, 0x286 + offset, field_177_cbSttbttmbd);;
+ LittleEndian.putInt(data, 0x28a + offset, field_178_fcUnused);;
+ LittleEndian.putInt(data, 0x28e + offset, field_179_lcbUnused);;
+ LittleEndian.putInt(data, 0x292 + offset, field_180_fcPgdMother);;
+ LittleEndian.putInt(data, 0x296 + offset, field_181_lcbPgdMother);;
+ LittleEndian.putInt(data, 0x29a + offset, field_182_fcBkdMother);;
+ LittleEndian.putInt(data, 0x29e + offset, field_183_lcbBkdMother);;
+ LittleEndian.putInt(data, 0x2a2 + offset, field_184_fcPgdFtn);;
+ LittleEndian.putInt(data, 0x2a6 + offset, field_185_lcbPgdFtn);;
+ LittleEndian.putInt(data, 0x2aa + offset, field_186_fcBkdFtn);;
+ LittleEndian.putInt(data, 0x2ae + offset, field_187_lcbBkdFtn);;
+ LittleEndian.putInt(data, 0x2b2 + offset, field_188_fcPgdEdn);;
+ LittleEndian.putInt(data, 0x2b6 + offset, field_189_lcbPgdEdn);;
+ LittleEndian.putInt(data, 0x2ba + offset, field_190_fcBkdEdn);;
+ LittleEndian.putInt(data, 0x2be + offset, field_191_lcbBkdEdn);;
+ LittleEndian.putInt(data, 0x2c2 + offset, field_192_fcSttbfIntlFld);;
+ LittleEndian.putInt(data, 0x2c6 + offset, field_193_lcbSttbfIntlFld);;
+ LittleEndian.putInt(data, 0x2ca + offset, field_194_fcRouteSlip);;
+ LittleEndian.putInt(data, 0x2ce + offset, field_195_lcbRouteSlip);;
+ LittleEndian.putInt(data, 0x2d2 + offset, field_196_fcSttbSavedBy);;
+ LittleEndian.putInt(data, 0x2d6 + offset, field_197_lcbSttbSavedBy);;
+ LittleEndian.putInt(data, 0x2da + offset, field_198_fcSttbFnm);;
+ LittleEndian.putInt(data, 0x2de + offset, field_199_lcbSttbFnm);;
+ LittleEndian.putInt(data, 0x2e2 + offset, field_200_fcPlcfLst);;
+ LittleEndian.putInt(data, 0x2e6 + offset, field_201_lcbPlcfLst);;
+ LittleEndian.putInt(data, 0x2ea + offset, field_202_fcPlfLfo);;
+ LittleEndian.putInt(data, 0x2ee + offset, field_203_lcbPlfLfo);;
+ LittleEndian.putInt(data, 0x2f2 + offset, field_204_fcPlcftxbxBkd);;
+ LittleEndian.putInt(data, 0x2f6 + offset, field_205_lcbPlcftxbxBkd);;
+ LittleEndian.putInt(data, 0x2fa + offset, field_206_fcPlcftxbxHdrBkd);;
+ LittleEndian.putInt(data, 0x2fe + offset, field_207_lcbPlcftxbxHdrBkd);;
+ LittleEndian.putInt(data, 0x302 + offset, field_208_fcDocUndo);;
+ LittleEndian.putInt(data, 0x306 + offset, field_209_lcbDocUndo);;
+ LittleEndian.putInt(data, 0x30a + offset, field_210_fcRgbuse);;
+ LittleEndian.putInt(data, 0x30e + offset, field_211_lcbRgbuse);;
+ LittleEndian.putInt(data, 0x312 + offset, field_212_fcUsp);;
+ LittleEndian.putInt(data, 0x316 + offset, field_213_lcbUsp);;
+ LittleEndian.putInt(data, 0x31a + offset, field_214_fcUskf);;
+ LittleEndian.putInt(data, 0x31e + offset, field_215_lcbUskf);;
+ LittleEndian.putInt(data, 0x322 + offset, field_216_fcPlcupcRgbuse);;
+ LittleEndian.putInt(data, 0x326 + offset, field_217_lcbPlcupcRgbuse);;
+ LittleEndian.putInt(data, 0x32a + offset, field_218_fcPlcupcUsp);;
+ LittleEndian.putInt(data, 0x32e + offset, field_219_lcbPlcupcUsp);;
+ LittleEndian.putInt(data, 0x332 + offset, field_220_fcSttbGlsyStyle);;
+ LittleEndian.putInt(data, 0x336 + offset, field_221_lcbSttbGlsyStyle);;
+ LittleEndian.putInt(data, 0x33a + offset, field_222_fcPlgosl);;
+ LittleEndian.putInt(data, 0x33e + offset, field_223_lcbPlgosl);;
+ LittleEndian.putInt(data, 0x342 + offset, field_224_fcPlcocx);;
+ LittleEndian.putInt(data, 0x346 + offset, field_225_lcbPlcocx);;
+ LittleEndian.putInt(data, 0x34a + offset, field_226_fcPlcfbteLvc);;
+ LittleEndian.putInt(data, 0x34e + offset, field_227_lcbPlcfbteLvc);;
+ LittleEndian.putInt(data, 0x352 + offset, field_228_dwLowDateTime);;
+ LittleEndian.putInt(data, 0x356 + offset, field_229_dwHighDateTime);;
+ LittleEndian.putInt(data, 0x35a + offset, field_230_fcPlcflvc);;
+ LittleEndian.putInt(data, 0x35e + offset, field_231_lcbPlcflvc);;
+ LittleEndian.putInt(data, 0x362 + offset, field_232_fcPlcasumy);;
+ LittleEndian.putInt(data, 0x366 + offset, field_233_lcbPlcasumy);;
+ LittleEndian.putInt(data, 0x36a + offset, field_234_fcPlcfgram);;
+ LittleEndian.putInt(data, 0x36e + offset, field_235_lcbPlcfgram);;
+ LittleEndian.putInt(data, 0x372 + offset, field_236_fcSttbListNames);;
+ LittleEndian.putInt(data, 0x376 + offset, field_237_lcbSttbListNames);;
+ LittleEndian.putInt(data, 0x37a + offset, field_238_fcSttbfUssr);;
+ LittleEndian.putInt(data, 0x37e + offset, field_239_lcbSttbfUssr);;
+
+ }
+
public String toString()
{
StringBuffer buffer = new StringBuffer();
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/PAPAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/PAPAbstractType.java
index 1ffac674e..f84fc682f 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/PAPAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/PAPAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -110,9 +110,9 @@ public abstract class PAPAbstractType
private byte field_33_fAutoSpaceDN;
private int field_34_wAlignFont;
private short field_35_fontAlign;
- private BitField fVertical = new BitField(0x0001);
- private BitField fBackward = new BitField(0x0002);
- private BitField fRotateFont = new BitField(0x0004);
+ private static BitField fVertical = new BitField(0x0001);
+ private static BitField fBackward = new BitField(0x0002);
+ private static BitField fRotateFont = new BitField(0x0004);
private byte field_36_fBackward;
private byte field_37_fRotateFont;
private byte field_38_fInTable;
@@ -157,7 +157,7 @@ public abstract class PAPAbstractType
*/
public int getSize()
{
- return 4 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 12 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 2 + 1 + 2 + 2 + 1 + 1 + 84 + 1 + 2 + 4 + 128 + 2 + 128 + 128;
+ return 4 + + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 12 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 2 + 1 + 2 + 2 + 1 + 1 + 84 + 1 + 2 + 4 + 128 + 2 + 128 + 128;
}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/SEPAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/SEPAbstractType.java
index 4cb2e22a6..f458441d3 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/SEPAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/SEPAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -146,7 +146,7 @@ public abstract class SEPAbstractType
*/
public int getSize()
{
- return 4 + 1 + 0 + 0 + 1 + 0 + 1 + 0 + 0 + 1 + 1 + 2 + 4 + 2 + 2 + 0 + 1 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 0 + 2 + 4 + 4 + 4 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 2 + 0 + 1 + 4 + 356 + 4 + 1 + 1 + 2 + 212;
+ return 4 + + 1 + 0 + 0 + 1 + 0 + 1 + 0 + 0 + 1 + 1 + 2 + 4 + 2 + 2 + 0 + 1 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 0 + 2 + 4 + 4 + 4 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 2 + 0 + 1 + 4 + 356 + 4 + 1 + 1 + 2 + 212;
}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TAPAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TAPAbstractType.java
index c0a714065..c5ab8e3f3 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TAPAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TAPAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -103,7 +103,7 @@ public abstract class TAPAbstractType
*/
public int getSize()
{
- return 4 + 2 + 4 + 4 + 0 + 0 + 4 + 2 + 130 + 0 + 0 + 4 + 4 + 4 + 4 + 4 + 4;
+ return 4 + + 2 + 4 + 4 + 0 + 0 + 4 + 2 + 130 + 0 + 0 + 4 + 4 + 4 + 4 + 4 + 4;
}
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TCAbstractType.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TCAbstractType.java
index 7b7233c1d..585fd0638 100644
--- a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TCAbstractType.java
+++ b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TCAbstractType.java
@@ -54,7 +54,7 @@
*/
-package org.apache.poi.hdf.model.hdftypes.definitions;
+package org.apache.poi.hwpf.model.hdftypes.definitions;
@@ -76,14 +76,14 @@ public abstract class TCAbstractType
{
private short field_1_rgf;
- private BitField fFirstMerged = new BitField(0x0001);
- private BitField fMerged = new BitField(0x0002);
- private BitField fVertical = new BitField(0x0004);
- private BitField fBackward = new BitField(0x0008);
- private BitField fRotateFont = new BitField(0x0010);
- private BitField fVertMerge = new BitField(0x0020);
- private BitField fVertRestart = new BitField(0x0040);
- private BitField vertAlign = new BitField(0x0180);
+ private static BitField fFirstMerged = new BitField(0x0001);
+ private static BitField fMerged = new BitField(0x0002);
+ private static BitField fVertical = new BitField(0x0004);
+ private static BitField fBackward = new BitField(0x0008);
+ private static BitField fRotateFont = new BitField(0x0010);
+ private static BitField fVertMerge = new BitField(0x0020);
+ private static BitField fVertRestart = new BitField(0x0040);
+ private static BitField vertAlign = new BitField(0x0180);
private short field_2_unused;
private short[] field_3_brcTop;
private short[] field_4_brcLeft;
@@ -101,7 +101,7 @@ public abstract class TCAbstractType
*/
public int getSize()
{
- return 4 + 2 + 2 + 4 + 4 + 4 + 4;
+ return 4 + + 2 + 2 + 4 + 4 + 4 + 4;
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
index 11ea7fbb0..9b685ddca 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
@@ -55,6 +55,7 @@
package org.apache.poi.hwpf;
import java.io.InputStream;
+import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@@ -75,23 +76,61 @@ public class HWPFDocument
private FileInformationBlock _fib;
/** main document stream buffer*/
- byte[] _mainDocument;
+ byte[] _mainStream;
/** table stream buffer*/
- byte[] _tableBuffer;
+ byte[] _tableStream;
public HWPFDocument(InputStream istream) throws IOException
{
//do Ole stuff
_filesystem = new POIFSFileSystem(istream);
- DocumentEntry headerProps =
+ // read in the main stream.
+ DocumentEntry documentProps =
(DocumentEntry)_filesystem.getRoot().getEntry("WordDocument");
+ _mainStream = new byte[documentProps.getSize()];
+ _filesystem.createDocumentInputStream("WordDocument").read(_mainStream);
- _mainDocument = new byte[headerProps.getSize()];
- _filesystem.createDocumentInputStream("WordDocument").read(_mainDocument);
+ // use the fib to determine the name of the table stream.
+ _fib = new FileInformationBlock(_mainStream);
+
+ String name = "0Table";
+ if (_fib.isFWhichTblStm())
+ {
+ name = "1Table";
+ }
+
+ // read in the table stream.
+ DocumentEntry tableProps =
+ (DocumentEntry)_filesystem.getRoot().getEntry(name);
+ _tableStream = new byte[tableProps.getSize()];
+ _filesystem.createDocumentInputStream(name).read(_tableStream);
+
+ // get the start of text in the main stream
+ int fcMin = _fib.getFcMin();
+
+ DocumentProperties dop = new DocumentProperties(_tableStream, _fib.getFcDop());
+ ComplexFileTable cft = new ComplexFileTable(_mainStream, _tableStream, _fib.getFcClx(), fcMin);
+ CHPBinTable cbt = new CHPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbteChpx(), _fib.getLcbPlcfbteChpx(), fcMin);
+ PAPBinTable pbt = new PAPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbtePapx(), _fib.getLcbPlcfbtePapx(), fcMin);
+ SectionTable st = new SectionTable(_mainStream, _tableStream, _fib.getFcPlcfsed(), _fib.getLcbPlcfsed(), fcMin);
+ StyleSheet ss = new StyleSheet(_tableStream, _fib.getFcStshf());
+
+ int x = 0;
- _fib = new FileInformationBlock(_mainDocument);
}
+ public static void main(String[] args)
+ {
+ try
+ {
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(args[0]));
+
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
}