]> source.dussan.org Git - poi.git/commitdiff
Ryan's patch applied. Thanks Ryan!
authorGlen Stampoultzis <glens@apache.org>
Wed, 20 Mar 2002 12:35:26 +0000 (12:35 +0000)
committerGlen Stampoultzis <glens@apache.org>
Wed, 20 Mar 2002 12:35:26 +0000 (12:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352257 13f79535-47bb-0310-9956-ffa450edef68

24 files changed:
src/java/org/apache/poi/util/LittleEndian.java
src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CharacterProperties.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/DocumentProperties.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FontTable.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFO.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFOLVL.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LST.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LVL.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ParagraphProperties.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/SectionProperties.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleDescription.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableCellDescriptor.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableProperties.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/util/ChpxNode.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/util/PapxNode.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/util/PropertyNode.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/util/SepxNode.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hdf/model/util/TextPiece.java [new file with mode: 0644]
tools/centipede/targets/preinit.xtarget

index 7574ce6f99dc63f8844130f16f1bb81d62296aa6..3621423a9a248ab549e8a4803b1ffafc46bddfe8 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
  * The Apache Software License, Version 1.1
  *
@@ -55,9 +54,9 @@
 
 package org.apache.poi.util;
 
-import java.io.*;
-
-import java.util.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
 
 /**
  * a utility class for handling little-endian numbers, which the 80x86
@@ -70,7 +69,7 @@ import java.util.*;
  */
 
 public class LittleEndian
-    implements LittleEndianConsts
+        implements LittleEndianConsts
 {
 
     // all methods are static, so an accessible constructor makes no
@@ -90,22 +89,22 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static short getShort(final byte [] data, final int offset)
+    public static short getShort(final byte[] data, final int offset)
     {
-        return ( short ) getNumber(data, offset, SHORT_SIZE);
+        return (short) getNumber(data, offset, SHORT_SIZE);
     }
 
     /**
      * get a short array from a byte array.  The short array is assumed
      * to start with a word describing the length of the array.
      */
-    public static short[] getShortArray(final byte [] data, final int offset)
+    public static short[] getShortArray(final byte[] data, final int offset)
     {
-        int size = ( short) getNumber(data, offset, SHORT_SIZE);
+        int size = (short) getNumber(data, offset, SHORT_SIZE);
         short[] results = new short[size];
         for (int i = 0; i < size; i++)
         {
-            results[i] = getShort(data, offset + 2 + (i*2));
+            results[i] = getShort(data, offset + 2 + (i * 2));
         }
         return results;
     }
@@ -120,7 +119,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static short getShort(final byte [] data)
+    public static short getShort(final byte[] data)
     {
         return getShort(data, 0);
     }
@@ -136,9 +135,9 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static int getInt(final byte [] data, final int offset)
+    public static int getInt(final byte[] data, final int offset)
     {
-        return ( int ) getNumber(data, offset, INT_SIZE);
+        return (int) getNumber(data, offset, INT_SIZE);
     }
 
     /**
@@ -151,7 +150,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static int getInt(final byte [] data)
+    public static int getInt(final byte[] data)
     {
         return getInt(data, 0);
     }
@@ -167,7 +166,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static long getLong(final byte [] data, final int offset)
+    public static long getLong(final byte[] data, final int offset)
     {
         return getNumber(data, offset, LONG_SIZE);
     }
@@ -182,7 +181,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static long getLong(final byte [] data)
+    public static long getLong(final byte[] data)
     {
         return getLong(data, 0);
     }
@@ -200,7 +199,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static double getDouble(final byte [] data, final int offset)
+    public static double getDouble(final byte[] data, final int offset)
     {
         return Double.longBitsToDouble(getNumber(data, offset, DOUBLE_SIZE));
     }
@@ -215,7 +214,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static double getDouble(final byte [] data)
+    public static double getDouble(final byte[] data)
     {
         return getDouble(data, 0);
     }
@@ -230,7 +229,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putShort(final byte [] data, final int offset,
+    public static void putShort(final byte[] data, final int offset,
                                 final short value)
     {
         putNumber(data, offset, value, SHORT_SIZE);
@@ -245,7 +244,7 @@ public class LittleEndian
      *
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
-    public static void putShortArray(final byte [] data, final int offset, final short[] value)
+    public static void putShortArray(final byte[] data, final int offset, final short[] value)
     {
         putNumber(data, offset, value.length, SHORT_SIZE);
         for (int i = 0; i < value.length; i++)
@@ -263,7 +262,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putShort(final byte [] data, final short value)
+    public static void putShort(final byte[] data, final short value)
     {
         putShort(data, 0, value);
     }
@@ -278,7 +277,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putInt(final byte [] data, final int offset,
+    public static void putInt(final byte[] data, final int offset,
                               final int value)
     {
         putNumber(data, offset, value, INT_SIZE);
@@ -293,7 +292,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putInt(final byte [] data, final int value)
+    public static void putInt(final byte[] data, final int value)
     {
         putInt(data, 0, value);
     }
@@ -308,7 +307,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putLong(final byte [] data, final int offset,
+    public static void putLong(final byte[] data, final int offset,
                                final long value)
     {
         putNumber(data, offset, value, LONG_SIZE);
@@ -323,7 +322,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putLong(final byte [] data, final long value)
+    public static void putLong(final byte[] data, final long value)
     {
         putLong(data, 0, value);
     }
@@ -338,7 +337,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putDouble(final byte [] data, final int offset,
+    public static void putDouble(final byte[] data, final int offset,
                                  final double value)
     {
         putNumber(data, offset, Double.doubleToLongBits(value), DOUBLE_SIZE);
@@ -353,7 +352,7 @@ public class LittleEndian
      * @exception ArrayIndexOutOfBoundsException may be thrown
      */
 
-    public static void putDouble(final byte [] data, final double value)
+    public static void putDouble(final byte[] data, final double value)
     {
         putDouble(data, 0, value);
     }
@@ -365,7 +364,7 @@ public class LittleEndian
      */
 
     public static class BufferUnderrunException
-        extends IOException
+            extends IOException
     {
 
         /**
@@ -392,7 +391,7 @@ public class LittleEndian
      */
 
     public static short readShort(final InputStream stream)
-        throws IOException, BufferUnderrunException
+            throws IOException, BufferUnderrunException
     {
         return getShort(readFromStream(stream, SHORT_SIZE));
     }
@@ -410,7 +409,7 @@ public class LittleEndian
      */
 
     public static int readInt(final InputStream stream)
-        throws IOException, BufferUnderrunException
+            throws IOException, BufferUnderrunException
     {
         return getInt(readFromStream(stream, INT_SIZE));
     }
@@ -428,14 +427,14 @@ public class LittleEndian
      */
 
     public static long readLong(final InputStream stream)
-        throws IOException, BufferUnderrunException
+            throws IOException, BufferUnderrunException
     {
         return getLong(readFromStream(stream, LONG_SIZE));
     }
 
-    private static final byte[] _short_buffer = new byte[ SHORT_SIZE ];
-    private static final byte[] _int_buffer   = new byte[ INT_SIZE ];
-    private static final byte[] _long_buffer  = new byte[ LONG_SIZE ];
+    private static final byte[] _short_buffer = new byte[SHORT_SIZE];
+    private static final byte[] _int_buffer = new byte[INT_SIZE];
+    private static final byte[] _long_buffer = new byte[LONG_SIZE];
 
     /**
      * Read the appropriate number of bytes from the stream and return
@@ -466,29 +465,29 @@ public class LittleEndian
      *            enough bytes
      */
 
-    public static byte [] readFromStream(final InputStream stream,
-                                         final int size)
-        throws IOException, BufferUnderrunException
+    public static byte[] readFromStream(final InputStream stream,
+                                        final int size)
+            throws IOException, BufferUnderrunException
     {
         byte[] buffer = null;
 
         switch (size)
         {
 
-            case SHORT_SIZE :
+            case SHORT_SIZE:
                 buffer = _short_buffer;
                 break;
 
-            case INT_SIZE :
+            case INT_SIZE:
                 buffer = _int_buffer;
                 break;
 
-            case LONG_SIZE :
+            case LONG_SIZE:
                 buffer = _long_buffer;
                 break;
 
             default :
-                buffer = new byte[ size ];
+                buffer = new byte[size];
                 break;
         }
         int count = stream.read(buffer);
@@ -497,16 +496,15 @@ public class LittleEndian
         {
 
             // return a zero-filled buffer
-            Arrays.fill(buffer, ( byte ) 0);
-        }
-        else if (count != size)
+            Arrays.fill(buffer, (byte) 0);
+        } else if (count != size)
         {
             throw new BufferUnderrunException();
         }
         return buffer;
     }
 
-    private static long getNumber(final byte [] data, final int offset,
+    private static long getNumber(final byte[] data, final int offset,
                                   final int size)
     {
         long result = 0;
@@ -514,21 +512,21 @@ public class LittleEndian
         for (int j = offset + size - 1; j >= offset; j--)
         {
             result <<= 8;
-            result |= 0xff & data[ j ];
+            result |= 0xff & data[j];
         }
         return result;
     }
 
-    private static void putNumber(final byte [] data, final int offset,
+    private static void putNumber(final byte[] data, final int offset,
                                   final long value, final int size)
     {
-        int  limit = size + offset;
-        long v     = value;
+        int limit = size + offset;
+        long v = value;
 
         for (int j = offset; j < limit; j++)
         {
-            data[ j ] = ( byte ) (v & 0xFF);
-            v         >>= 8;
+            data[j] = (byte) (v & 0xFF);
+            v >>= 8;
         }
     }
 
@@ -537,6 +535,36 @@ public class LittleEndian
      */
     public static int ubyteToInt(byte b)
     {
-        return ((b & 0x80) == 0 ? (int)b : (int)(b & (byte)0x7f) + 0x80 );
+        return ((b & 0x80) == 0 ? (int) b : (int) (b & (byte) 0x7f) + 0x80);
+    }
+
+    /**
+     * get the unsigned value of a byte.
+     *
+     * @param data the byte array.
+     * @param offset a starting offset into the byte array.
+     *
+     * @return the unsigned value of the byte as a 32 bit integer
+     *
+     * @exception ArrayIndexOutOfBoundsException may be thrown
+     */
+    public static int getUnsignedByte(final byte[] data, final int offset)
+    {
+        return (int) getNumber(data, offset, BYTE_SIZE);
     }
+
+    /**
+     * get the unsigned value of a byte.
+     *
+     * @param data the byte array
+     *
+     * @return the unsigned value of the byte as a 32 bit integer
+     *
+     * @exception ArrayIndexOutOfBoundsException may be thrown
+     */
+    public static int getUnsignedByte(final byte[] data)
+    {
+        return getUnsignedByte(data, 0);
+    }
+
 }
index c5001fda97fbbd71580d0f946e6682743c1ced73..ba7f5c30ea6d5f292f2a5b68953a1fa777066d22 100644 (file)
 
 package org.apache.poi.hdf.model;
 
+
+import java.io.*;
+
+import org.apache.poi.hdf.model.hdftypes.*;
+import org.apache.poi.hdf.model.util.*;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSDocument;
+import org.apache.poi.poifs.filesystem.DocumentEntry;
+import org.apache.poi.util.LittleEndian;
+
+
+
+
 /**
- * The Object Factory takes in a stream and creates the low level objects 
+ * The Object Factory takes in a stream and creates the low level objects
  * that represent the data.
  * @author  andy
  */
-public class HDFObjectFactory {
+public class HDFObjectFactory
+{
+
+    /** OLE stuff*/
+    private POIFSFileSystem _filesystem;
+    /** The FIB*/
+    private FileInformationBlock _fib;
+    /** The DOP*/
+    private DocumentProperties _dop;
+    /**the StyleSheet*/
+    private StyleSheet _styleSheet;
+    /**list info */
+    private ListTables _listTables;
+    /** Font info */
+    private FontTable _fonts;
+
+    /** text pieces */
+    BTreeSet _text = new BTreeSet();
+    /** document sections */
+    BTreeSet _sections = new BTreeSet();
+    /** document paragraphs */
+    BTreeSet _paragraphs = new BTreeSet();
+    /** document character runs */
+    BTreeSet _characterRuns = new BTreeSet();
+
+    /** main document stream buffer*/
+    byte[] _mainDocument;
+    /** table stream buffer*/
+    byte[] _tableBuffer;
+
+
+
+    /** Creates a new instance of HDFObjectFactory
+     *
+     * @param istream The InputStream that is the Word document
+     *
+     */
+    public HDFObjectFactory(InputStream istream) throws IOException
+    {
+        //do Ole stuff
+        _filesystem = new POIFSFileSystem(istream);
+
+        DocumentEntry headerProps =
+            (DocumentEntry)_filesystem.getRoot().getEntry("WordDocument");
+
+        _mainDocument = new byte[headerProps.getSize()];
+        _filesystem.createDocumentInputStream("WordDocument").read(_mainDocument);
+
+        _fib = new FileInformationBlock(_mainDocument);
 
-    /** Creates a new instance of HDFObjectFactory */
-    public HDFObjectFactory() {
+        initTableStream();
+        initTextPieces();
+        initFormattingProperties();
+
+        istream.close();
+
+    }
+    /**
+     * Initializes the table stream
+     *
+     * @throws IOException
+     */
+    private void initTableStream() throws IOException
+    {
+        String tablename = null;
+        if(_fib.useTable1())
+        {
+            tablename="1Table";
+        }
+        else
+        {
+          tablename="0Table";
+        }
+
+        DocumentEntry tableEntry = (DocumentEntry)_filesystem.getRoot().getEntry(tablename);
+
+        //load the table stream into a buffer
+        int size = tableEntry.getSize();
+        _tableBuffer = new byte[size];
+        _filesystem.createDocumentInputStream(tablename).read(_tableBuffer);
+    }
+    /**
+     * Initializes the text pieces. Text is divided into pieces because some
+     * "pieces" may only contain unicode characters.
+     *
+     * @throws IOException
+     */
+    private void initTextPieces() throws IOException
+    {
+        int pos = _fib.getComplexOffset();
+
+        //skips through the prms before we reach the piece table. These contain data
+        //for actual fast saved files
+        while (_tableBuffer[pos] == 1)
+        {
+            pos++;
+            int skip = LittleEndian.getShort(_tableBuffer, pos);
+            pos += 2 + skip;
+        }
+        if(_tableBuffer[pos] != 2)
+        {
+            throw new IOException("The text piece table is corrupted");
+        }
+        else
+        {
+            //parse out the text pieces
+            int pieceTableSize = LittleEndian.getInt(_tableBuffer, ++pos);
+            pos += 4;
+            int pieces = (pieceTableSize - 4) / 12;
+            for (int x = 0; x < pieces; x++)
+            {
+                int filePos = LittleEndian.getInt(_tableBuffer, pos + ((pieces + 1) * 4) + (x * 8) + 2);
+                boolean unicode = false;
+                if ((filePos & 0x40000000) == 0)
+                {
+                    unicode = true;
+                }
+                else
+                {
+                    unicode = false;
+                    filePos &= ~(0x40000000);//gives me FC in doc stream
+                    filePos /= 2;
+                }
+                int totLength = LittleEndian.getInt(_tableBuffer, pos + (x + 1) * 4) -
+                                LittleEndian.getInt(_tableBuffer, pos + (x * 4));
+
+                TextPiece piece = new TextPiece(filePos, totLength, unicode);
+                _text.add(piece);
+
+            }
+
+        }
+
+    }
+    /**
+     * initializes all of the formatting properties for a Word Document
+     */
+    private void initFormattingProperties()
+    {
+        createStyleSheet();
+        createListTables();
+        createFontTable();
+
+        initDocumentProperties();
+        initSectionProperties();
+        initCharacterProperties();
+        initParagraphProperties();
+    }
+    /**
+     * initializes the CharacterProperties BTree
+     */
+    private void initCharacterProperties()
+    {
+        int charOffset = _fib.getChpBinTableOffset();
+        int charPlcSize = _fib.getChpBinTableSize();
+
+        int arraySize = (charPlcSize - 4)/8;
+
+        //first we must go through the bin table and find the fkps
+        for(int x = 0; x < arraySize; x++)
+        {
+
+            //get page number(has nothing to do with document page)
+            //containing the chpx for the paragraph
+            int PN = LittleEndian.getInt(_tableBuffer, charOffset + (4 * (arraySize + 1) + (4 * x)));
+
+            byte[] fkp = new byte[512];
+            System.arraycopy(_mainDocument, (PN * 512), fkp, 0, 512);
+            //take each fkp and get the chpxs
+            int crun = LittleEndian.getUnsignedByte(fkp, 511);
+            for(int y = 0; y < crun; y++)
+            {
+                //get the beginning fc of each paragraph text run
+                int fcStart = LittleEndian.getInt(fkp, y * 4);
+                int fcEnd = LittleEndian.getInt(fkp, (y+1) * 4);
+                //get the offset in fkp of the papx for this paragraph
+                int chpxOffset = 2 * LittleEndian.getUnsignedByte(fkp, ((crun + 1) * 4) + y);
+
+                //optimization if offset == 0 use "Normal" style
+                if(chpxOffset == 0)
+
+                {
+                    _characterRuns.add(new ChpxNode(fcStart, fcEnd, new byte[0]));
+                    continue;
+                }
+
+                int size = LittleEndian.getUnsignedByte(fkp, chpxOffset);
+
+                byte[] chpx = new byte[size];
+                System.arraycopy(fkp, ++chpxOffset, chpx, 0, size);
+                //_papTable.put(new Integer(fcStart), papx);
+                _characterRuns.add(new ChpxNode(fcStart, fcEnd, chpx));
+            }
+
+        }
+    }
+    /**
+     * intializes the Paragraph Properties BTree
+     */
+    private void initParagraphProperties()
+    {
+        //find paragraphs
+        int parOffset = _fib.getPapBinTableOffset();
+        int parPlcSize = _fib.getPapBinTableSize();
+
+        int arraySize = (parPlcSize - 4)/8;
+        //first we must go through the bin table and find the fkps
+        for(int x = 0; x < arraySize; x++)
+        {
+            int PN = LittleEndian.getInt(_tableBuffer, parOffset + (4 * (arraySize + 1) + (4 * x)));
+
+            byte[] fkp = new byte[512];
+            System.arraycopy(_mainDocument, (PN * 512), fkp, 0, 512);
+            //take each fkp and get the paps
+            int crun = LittleEndian.getUnsignedByte(fkp, 511);
+            for(int y = 0; y < crun; y++)
+            {
+                //get the beginning fc of each paragraph text run
+                int fcStart = LittleEndian.getInt(fkp, y * 4);
+                int fcEnd = LittleEndian.getInt(fkp, (y+1) * 4);
+                //get the offset in fkp of the papx for this paragraph
+                int papxOffset = 2 * LittleEndian.getUnsignedByte(fkp, ((crun + 1) * 4) + (y * 13));
+                int size = 2 * LittleEndian.getUnsignedByte(fkp, papxOffset);
+                if(size == 0)
+                {
+                    size = 2 * LittleEndian.getUnsignedByte(fkp, ++papxOffset);
+                }
+                else
+                {
+                    size--;
+                }
+
+                byte[] papx = new byte[size];
+                System.arraycopy(fkp, ++papxOffset, papx, 0, size);
+                _paragraphs.add(new PapxNode(fcStart, fcEnd, papx));
+
+            }
+
+        }
+
+    }
+    /**
+     * initializes the SectionProperties BTree
+     */
+    private void initSectionProperties()
+    {
+      //find sections
+      int fcMin = _fib.getFirstCharOffset();
+      int plcfsedFC = _fib.getSectionDescriptorOffset();
+      int plcfsedSize = _fib.getSectionDescriptorSize();
+      byte[] plcfsed = new byte[plcfsedSize];
+      System.arraycopy(_tableBuffer, plcfsedFC, plcfsed, 0, plcfsedSize);
+
+      int arraySize = (plcfsedSize - 4)/16;
+
+
+      for(int x = 0; x < arraySize; x++)
+      {
+          int sectionStart = LittleEndian.getInt(plcfsed, x * 4) + fcMin;
+          int sectionEnd = LittleEndian.getInt(plcfsed, (x+1) * 4) + fcMin;
+          int sepxStart = LittleEndian.getInt(plcfsed, 4 * (arraySize + 1) + (x * 12) + 2);
+          int sepxSize = LittleEndian.getShort(_mainDocument, sepxStart);
+          byte[] sepx = new byte[sepxSize];
+          System.arraycopy(_mainDocument, sepxStart + 2, sepx, 0, sepxSize);
+          SepxNode node = new SepxNode(x + 1, sectionStart, sectionEnd, sepx);
+          _sections.add(node);
+      }
+    }
+    /**
+     * Initializes the DocumentProperties object unique to this document.
+     */
+    private void initDocumentProperties()
+    {
+        int pos = _fib.getDOPOffset();
+        int size = _fib.getDOPSize();
+        byte[] dopArray = new byte[size];
+
+        System.arraycopy(_tableBuffer, pos, dopArray, 0, size);
+        _dop = new DocumentProperties(dopArray);
+    }
+    /**
+     * Uncompresses the StyleSheet from file into memory.
+     */
+    private void createStyleSheet()
+    {
+      int stshIndex = _fib.getStshOffset();
+      int stshSize = _fib.getStshSize();
+      byte[] stsh = new byte[stshSize];
+      System.arraycopy(_tableBuffer, stshIndex, stsh, 0, stshSize);
+
+      _styleSheet = new StyleSheet(stsh);
+    }
+    /**
+     * Initializes the list tables for this document
+     */
+    private void createListTables()
+    {
+        int lfoOffset = _fib.getLFOOffset();
+        int lfoSize = _fib.getLFOSize();
+        byte[] plflfo = new byte[lfoSize];
+
+        System.arraycopy(_tableBuffer, lfoOffset, plflfo, 0, lfoSize);
+
+        int lstOffset = _fib.getLSTOffset();
+        int lstSize = lstOffset;
+        //not sure if this is a mistake or what. I vaguely remember a trick like
+        //this
+        //int lstSize = LittleEndian.getInt(_header, 0x2e2);
+        if(lstOffset > 0 && lstSize > 0)
+        {
+          lstSize = lfoOffset - lstOffset;
+          byte[] plcflst = new byte[lstSize];
+          System.arraycopy(_tableBuffer, lstOffset, plcflst, 0, lstSize);
+          _listTables = new ListTables(plcflst, plflfo);
+        }
+    }
+    /**
+     * Initializes this document's FontTable;
+     */
+    private void createFontTable()
+    {
+        int fontTableIndex = _fib.getFontsOffset();
+        int fontTableSize = _fib.getFontsSize();
+        byte[] fontTable = new byte[fontTableSize];
+        System.arraycopy(_tableBuffer, fontTableIndex, fontTable, 0, fontTableSize);
+        _fonts = new FontTable(fontTable);
     }
 
 }
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CharacterProperties.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CharacterProperties.java
new file mode 100644 (file)
index 0000000..22893e4
--- /dev/null
@@ -0,0 +1,216 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class CharacterProperties implements Cloneable, HDFType
+{
+  public boolean _bold;
+  public boolean _italic;
+  public boolean _fRMarkDel;
+  public boolean _fOutline;
+  public boolean _fSmallCaps;
+  public boolean _fCaps;
+  public boolean _fVanish;
+  public boolean _fRMark;
+  public boolean _fSpec;
+  public boolean _fStrike;
+  public boolean _fObj;
+  public boolean _fShadow;
+  public boolean _fLowerCase;
+  public boolean _fData;
+  public boolean _fOle2;
+  public boolean _fEmboss;
+  public boolean _fImprint;
+  public boolean _fDStrike;
+
+  public short _ftcAscii;
+  public short _ftcFE;
+  public short _ftcOther;
+  public short _ftc;
+  public int _hps;//font size in half points
+  public int _dxaSpace;//space following each character in the run expressed in twip units
+  public byte _iss;//superscript/subscript indices 0 means no super/subscripting 1 means text in run is superscripted 2 means text in run is subscripted
+  public byte _kul;//underline code see spec
+  public byte _ico;//color of text see spec
+  public short _hpsPos;//super/subscript position in half points; positive means text is raised; negative means text is lowered
+  public short _lidDefault;//language for non-Far East text
+  public short _lidFE;//language for Far East text
+  public byte _idctHint;
+  public int _wCharScale;
+  public short _chse;
+
+  public int _specialFC;//varies depending on whether this is a special char
+  public short _ibstRMark;//index to author IDs stored in hsttbfRMark. used when text in run was newly typed when revision marking was enabled
+  public short _ibstRMarkDel;//index to author IDs stored in hsttbfRMark. used when text in run was newly typed when revision marking was enabled
+  public int[] _dttmRMark = new int[2];//Date/time at which this run of text was
+  public int[] _dttmRMarkDel = new int[2];//entered/modified by the author. (Only
+                                     //recorded when revision marking is on.)Date/time at which this run of text was deleted by the author. (Only recorded when revision marking is on.)
+  public int _istd;
+  public int _baseIstd = -1;
+  public int _fcPic;
+  public short _ftcSym;// see spec
+  public short _xchSym;//see spec
+  public byte _ysr;//hyphenation rules
+  public byte _chYsr;//used for hyphenation see spec
+  public int _hpsKern;//kerning distance for characters in run recorded in half points
+  public int _fcObj;
+  public byte _icoHighlight;//highlight color
+  public boolean _fChsDiff;
+  public boolean _highlighted;//when true characters are highlighted with color specified by chp.icoHighlight
+  public boolean _fPropMark;//when true, properties have been changed with revision marking on
+  public short _ibstPropRMark;//index to author IDs stored in hsttbfRMark. used when properties have been changed when revision marking was enabled
+  public int _dttmPropRMark;//Date/time at which properties of this were changed for this run of text by the author
+  public byte _sfxtText;//text animation see spec
+  public boolean _fDispFldRMark;//see spec
+  public short _ibstDispFldRMark;//Index to author IDs stored in hsttbfRMark. used when ListNum field numbering has been changed when revision marking was enabled
+  public int _dttmDispFldRMark;//The date for the ListNum field number change
+  public byte[] _xstDispFldRMark = new byte[32];//The string value of the ListNum field when revision mark tracking began
+  public short _shd;//shading
+  public short[] _brc = new short[2];//border
+  public short _paddingStart = 0;
+  public short _paddingEnd = 0;
+
+  public CharacterProperties()
+  {
+      _istd = 10;
+      _hps = 20;
+      _lidDefault = 0x0400;
+      _lidFE = 0x0400;
+
+  }
+  public void copy(CharacterProperties toCopy)
+  {
+      _bold = toCopy._bold;
+      _italic = toCopy._italic;
+       _fRMarkDel = toCopy._fRMarkDel;
+       _fOutline = toCopy._fOutline;
+       _fSmallCaps = toCopy._fSmallCaps;
+       _fCaps = toCopy._fCaps;
+       _fVanish = toCopy._fVanish;
+       _fRMark = toCopy._fRMark;
+       _fSpec = toCopy._fSpec;
+       _fStrike = toCopy._fStrike;
+       _fObj = toCopy._fObj;
+       _fShadow = toCopy._fShadow;
+       _fLowerCase = toCopy._fLowerCase;
+       _fData = toCopy._fData;
+       _fOle2 = toCopy._fOle2;
+       _fEmboss = toCopy._fEmboss;
+       _fImprint = toCopy._fImprint;
+       _fDStrike = toCopy._fDStrike;
+
+       _ftcAscii = toCopy._ftcAscii;
+       _ftcFE = toCopy._ftcFE;
+       _ftcOther = toCopy._ftcOther;
+       _ftc = toCopy._ftc;
+       _hps = toCopy._hps;
+       _dxaSpace = toCopy._dxaSpace;
+       _iss = toCopy._iss;
+       _kul = toCopy._kul;
+       _ico = toCopy._ico;
+       _hpsPos = toCopy._hpsPos;
+       _lidDefault = toCopy._lidDefault;
+       _lidFE = toCopy._lidFE;
+       _idctHint = toCopy._idctHint;
+       _wCharScale = toCopy._wCharScale;
+       _chse = toCopy._chse;
+
+       _specialFC = toCopy._specialFC;
+       _ibstRMark = toCopy._ibstRMark;
+       _ibstRMarkDel = toCopy._ibstRMarkDel;
+       _dttmRMark = toCopy._dttmRMark;
+       _dttmRMarkDel  = toCopy._dttmRMarkDel;
+
+       _istd = toCopy._istd;
+       _baseIstd = toCopy._baseIstd;
+       _fcPic = toCopy._fcPic;
+       _ftcSym = toCopy._ftcSym;
+       _xchSym = toCopy._xchSym;
+       _ysr = toCopy._ysr;
+       _chYsr = toCopy._chYsr;
+       _hpsKern = toCopy._hpsKern;
+       _fcObj = toCopy._fcObj;
+       _icoHighlight = toCopy._icoHighlight;
+       _fChsDiff = toCopy._fChsDiff;
+       _highlighted = toCopy._highlighted;
+       _fPropMark = toCopy._fPropMark;
+       _ibstPropRMark = toCopy._ibstPropRMark;
+       _dttmPropRMark = toCopy._dttmPropRMark;
+       _sfxtText = toCopy._sfxtText;
+       _fDispFldRMark = toCopy._fDispFldRMark;
+       _ibstDispFldRMark = toCopy._ibstDispFldRMark;
+       _dttmDispFldRMark = toCopy._dttmDispFldRMark;
+       _xstDispFldRMark = toCopy._xstDispFldRMark;
+       _shd = toCopy._shd;
+       _brc = toCopy._brc;
+
+  }
+
+  public Object clone() throws CloneNotSupportedException
+  {
+    CharacterProperties clone = (CharacterProperties)super.clone();
+    clone._brc = new short[2];
+    System.arraycopy(_brc, 0, clone._brc, 0, 2);
+    return clone;
+  }
+}
\ No newline at end of file
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
new file mode 100644 (file)
index 0000000..21e0fe7
--- /dev/null
@@ -0,0 +1,92 @@
+
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+import org.apache.poi.util.LittleEndian;
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class DocumentProperties implements HDFType
+{
+
+  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)
+  {
+        _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;
+  }
+}
\ No newline at end of file
index 7443984c061d68bed77b322e9ef3d99c57148cdb..2d6bff78235a5048ef14dd6cf28ec9f061f4286f 100644 (file)
@@ -7,61 +7,63 @@
 package org.apache.poi.hdf.model.hdftypes;
 
 import org.apache.poi.util.BitField;
+import org.apache.poi.util.LittleEndian;
 
 /**
  *
  * @author  andy
  */
-public class FileInformationBlock implements HDFType {
+public class FileInformationBlock implements HDFType
+{
 
     private  short field_1_id;
     private  short field_2_version; // 101 = Word 6.0 +
     private  short field_3_product_version;
     private  short field_4_language_stamp;
     private  short field_5_unknown;
-    private  short field_6_options;    
-    
+    private  short field_6_options;
+
         private static final BitField template          = new BitField(0x0001);
         private static final BitField glossary          = new BitField(0x0002);
         private static final BitField quicksave         = new BitField(0x0004);
-        private static final BitField haspictr          = new BitField(0x0008);        
-        private static final BitField nquicksaves       = new BitField(0x000F);
-        private static final BitField encrypted         = new BitField(0x0100);        
-        private static final BitField tabletype         = new BitField(0x0200);        
+        private static final BitField haspictr          = new BitField(0x0008);
+        private static final BitField nquicksaves       = new BitField(0x00F0);
+        private static final BitField encrypted         = new BitField(0x0100);
+        private static final BitField tabletype         = new BitField(0x0200);
         private static final BitField readonly          = new BitField(0x0400);
         private static final BitField writeReservation  = new BitField(0x0800);
         private static final BitField extendedCharacter = new BitField(0x1000);
         private static final BitField loadOverride      = new BitField(0x2000);
         private static final BitField farEast           = new BitField(0x4000);
         private static final BitField crypto            = new BitField(0x8000);
-   
+
     private short field_7_minversion;
     private short field_8_encrypted_key;
     private short field_9_environment; // 0 or 1 - windows or mac
     private short field_10_history;
-        
+
         private static final BitField history_mac   = new BitField(0x01);
         private static final BitField empty_special = new BitField(0x02);
         private static final BitField load_override = new BitField(0x04);
         private static final BitField future_undo   = new BitField(0x08);
         private static final BitField w97_saved     = new BitField(0x10);
-        private static final BitField spare         = new BitField(0xfe); 
-        
+        private static final BitField spare         = new BitField(0xfe);
+
     private short field_11_default_charset;
     private short field_12_default_extcharset;
     private int  field_13_offset_first_char;
     private int  field_14_offset_last_char;
     private short field_15_count_shorts;
-    
+
     private short field_16_beg_shorts; //why same offset?
-    
+
     private short field_16_creator_id;
     private short field_17_revisor_id;
     private short field_18_creator_private;
     private short field_19_revisor_private;
-    
+
     private short field_20_unused;
-    private short field_21_unused;    
+    private short field_21_unused;
     private short field_22_unused;
     private short field_23_unused;
     private short field_24_unused;
@@ -69,17 +71,19 @@ public class FileInformationBlock implements HDFType {
     private short field_26_unused;
     private short field_27_unused;
     private short field_28_unused;
-    
-    private short field_29_fareastid; 
+
+    private short field_29_fareastid;
     private short field_30_count_ints;
-    
+
     private int field_31_beg_ints; //why same offset?
-    
+
     private int field_31_last_byte;
-    
+
     private int field_32_creator_build_date;
     private int field_33_revisor_build_date;
+    /** length of main document text stream*/
     private int field_34_main_streamlen;
+    /**length of footnote subdocument text stream*/
     private int field_35_footnote_streamlen;
     private int field_36_header_streamlen;
     private int field_37_macro_streamlen;
@@ -87,28 +91,218 @@ public class FileInformationBlock implements HDFType {
     private int field_39_endnote_streamlen;
     private int field_40_textbox_streamlen;
     private int field_41_headbox_streamlen;
+    /**offset in table stream of character property bin table*/
     private int field_42_pointer_to_plc_list_chp; //rename me!
     private int field_43_first_chp; //rename me
     private int field_44_count_chps; //rename me
+    /**offset in table stream of paragraph property bin */
     private int field_45_pointer_to_plc_list_pap; //rename me.
     private int field_46_first_pap; //rename me
     private int field_47_count_paps; //rename me
     private int field_48_pointer_to_plc_list_lvc; //rename me
     private int field_49_first_lvc; //rename me
     private int field_50_count_lvc; //rename me
-    
+
     private int field_51_unknown;
     private int field_52_unknown;
-    
-    
-    
-    
-    
-    
-        
+    //not sure about this array.
+    private short field_53_fc_lcb_array_size;
+    private int field_54_original_stylesheet_offset;
+    private int field_55_original_stylesheet_size;
+    private int field_56_stylesheet_offset;
+    private int field_57_stylesheet_size;
+    private int field_58_footnote_ref_offset;
+    private int field_59_footnote_ref_size;
+    private int field_60_footnote_plc_offset;
+    private int field_61_footnote_plc_size;
+    private int field_62_annotation_ref_offset;
+    private int field_63_annotation_ref_size;
+    private int field_64_annotation_plc_offset;
+    private int field_65_annotation_plc_size;
+    /** offset in table stream of section descriptor SED PLC*/
+    private int field_66_section_plc_offset;
+    private int field_67_section_plc_size;
+    private int field_68_unused;
+    private int field_69_unused;
+    private int field_70_pheplc_offset;
+    private int field_71_pheplc_size;
+    private int field_72_glossaryST_offset;
+    private int field_73_glossaryST_size;
+    private int field_74_glossaryPLC_offset;
+    private int field_75_glossaryPLC_size;
+    private int field_76_headerPLC_offset;
+    private int field_77_headerPLC_size;
+    private int field_78_chp_bin_table_offset;
+    private int field_79_chp_bin_table_size;
+    private int field_80_pap_bin_table_offset;
+    private int field_81_pap_bin_table_size;
+    private int field_82_sea_plc_offset;
+    private int field_83_sea_plc_size;
+    private int field_84_fonts_offset;
+    private int field_85_fonts_size;
+    private int field_86_main_fields_offset;
+    private int field_87_main_fields_size;
+    private int field_88_header_fields_offset;
+    private int field_89_header_fields_size;
+    private int field_90_footnote_fields_offset;
+    private int field_91_footnote_fields_size;
+    private int field_92_ann_fields_offset;
+    private int field_93_ann_fields_size;
+    private int field_94_unused;
+    private int field_95_unused;
+    private int field_96_bookmark_names_offset;
+    private int field_97_bookmark_names_size;
+    private int field_98_bookmark_offsets_offset;
+    private int field_99_bookmark_offsets_size;
+    private int field_100_macros_offset;
+    private int field_101_macros_size;
+    private int field_102_unused;
+    private int field_103_unused;
+    private int field_104_unused;
+    private int field_105_unused;
+    private int field_106_printer_offset;
+    private int field_107_printer_size;
+    private int field_108_printer_portrait_offset;
+    private int field_109_printer_portrait_size;
+    private int field_110_printer_landscape_offset;
+    private int field_111_printer_landscape_size;
+    private int field_112_wss_offset;
+    private int field_113_wss_size;
+    private int field_114_DOP_offset;
+    private int field_115_DOP_size;
+    private int field_116_sttbfassoc_offset;
+    private int field_117_sttbfassoc_size;
+    /**offset in table stream of beginning of information for complex files.
+     * Also, this is the beginning of the Text piece table*/
+    private int field_118_textPieceTable_offset;
+    private int field_119_textPieceTable_size;
+    private int field_199_list_format_offset;
+    private int field_200_list_format_size;
+    private int field_201_list_format_override_offset;
+    private int field_202_list_format_override_size;
+
+
+
+
+
+
     /** Creates a new instance of FileInformationBlock */
-    public FileInformationBlock() {
+    public FileInformationBlock(byte[] mainDocument)
+    {
+        field_1_id = LittleEndian.getShort(mainDocument, 0);
+        field_2_version = LittleEndian.getShort(mainDocument, 0x2); // 101 = Word 6.0 +
+        field_3_product_version = LittleEndian.getShort(mainDocument, 0x4);
+        field_4_language_stamp = LittleEndian.getShort(mainDocument, 0x6);
+        field_5_unknown = LittleEndian.getShort(mainDocument, 0x8);
+        field_6_options = LittleEndian.getShort(mainDocument, 0xa);
+
+
+
+        field_13_offset_first_char = LittleEndian.getInt(mainDocument, 0x18);
+        field_34_main_streamlen = LittleEndian.getInt(mainDocument, 0x4c);
+        field_35_footnote_streamlen = LittleEndian.getInt(mainDocument, 0x50);
+
+        field_56_stylesheet_offset = LittleEndian.getInt(mainDocument, 0xa2);
+        field_57_stylesheet_size = LittleEndian.getInt(mainDocument, 0xa6);
+        field_66_section_plc_offset = LittleEndian.getInt(mainDocument, 0xca);
+        field_67_section_plc_size = LittleEndian.getInt(mainDocument, 0xce);
+
+        field_78_chp_bin_table_offset = LittleEndian.getInt(mainDocument, 0xfa);
+        field_79_chp_bin_table_size = LittleEndian.getInt(mainDocument, 0xfe);
+        field_80_pap_bin_table_offset = LittleEndian.getInt(mainDocument, 0x102);
+        field_81_pap_bin_table_size = LittleEndian.getInt(mainDocument, 0x106);
+
+        field_84_fonts_offset = LittleEndian.getInt(mainDocument, 0x112);
+        field_85_fonts_size = LittleEndian.getInt(mainDocument, 0x116);
+
+        field_114_DOP_offset = LittleEndian.getInt(mainDocument, 0x192);
+        field_115_DOP_size = LittleEndian.getInt(mainDocument, 0x196);
+        field_118_textPieceTable_offset = LittleEndian.getInt(mainDocument, 0x1a2);
+
+        field_199_list_format_offset = LittleEndian.getInt(mainDocument, 0x2e2);
+        field_200_list_format_size = LittleEndian.getInt(mainDocument, 0x2e6);
+        field_201_list_format_override_offset = LittleEndian.getInt(mainDocument, 0x2ea);
+        field_202_list_format_override_size= LittleEndian.getInt(mainDocument, 0x2ee);
+
+    }
+
+    public boolean useTable1()
+    {
+        return tabletype.setShort(field_6_options) > 0;
+    }
+    public int getFirstCharOffset()
+    {
+        return field_13_offset_first_char;
+    }
+    public int getStshOffset()
+    {
+        return field_56_stylesheet_offset;
+    }
+    public int getStshSize()
+    {
+        return field_57_stylesheet_size;
+    }
+    public int getSectionDescriptorOffset()
+    {
+        return field_66_section_plc_offset;
+    }
+    public int getSectionDescriptorSize()
+    {
+        return field_67_section_plc_size;
+    }
+    public int getChpBinTableOffset()
+    {
+        return field_78_chp_bin_table_offset;
+    }
+    public int getChpBinTableSize()
+    {
+        return field_79_chp_bin_table_size;
     }
+    public int getPapBinTableOffset()
+    {
+        return field_80_pap_bin_table_offset;
+    }
+    public int getPapBinTableSize()
+    {
+        return field_81_pap_bin_table_size;
+    }
+    public int getFontsOffset()
+    {
+        return field_84_fonts_offset;
+    }
+    public int getFontsSize()
+    {
+        return field_85_fonts_size;
+    }
+    public int getDOPOffset()
+    {
+         return field_114_DOP_offset;
+    }
+    public int getDOPSize()
+    {
+        return field_115_DOP_size;
+    }
+    public int getComplexOffset()
+    {
+        return field_118_textPieceTable_offset;
+    }
+    public int getLSTOffset()
+    {
+        return field_199_list_format_offset;
+    }
+    public int getLSTSize()
+    {
+        return field_200_list_format_size;
+    }
+    public int getLFOOffset()
+    {
+        return field_201_list_format_override_offset;
+    }
+    public int getLFOSize()
+    {
+        return field_202_list_format_override_size;
+    }
+
 
 }
 
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FontTable.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FontTable.java
new file mode 100644 (file)
index 0000000..a9f0ce5
--- /dev/null
@@ -0,0 +1,97 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hdf.model.hdftypes;
+
+import org.apache.poi.util.LittleEndian;
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class FontTable implements HDFType
+{
+  String[] fontNames;
+
+  public FontTable(byte[] fontTable)
+  {
+    int size = LittleEndian.getShort(fontTable, 0);
+    fontNames = new String[size];
+
+    int currentIndex = 4;
+    for(int x = 0; x < size; x++)
+    {
+      byte ffnLength = fontTable[currentIndex];
+
+      int nameOffset = currentIndex + 40;
+      StringBuffer nameBuf = new StringBuffer();
+      //char ch = Utils.getUnicodeCharacter(fontTable, nameOffset);
+      char ch = (char)LittleEndian.getShort(fontTable, nameOffset);
+      while(ch != '\0')
+      {
+        nameBuf.append(ch);
+        nameOffset += 2;
+        ch = (char)LittleEndian.getShort(fontTable, nameOffset);
+      }
+      fontNames[x] = nameBuf.toString();
+      currentIndex += ffnLength + 1;
+    }
+
+  }
+  public String getFont(int index)
+  {
+    return fontNames[index];
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFO.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFO.java
new file mode 100644 (file)
index 0000000..0dab490
--- /dev/null
@@ -0,0 +1,76 @@
+
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class LFO
+{
+  int _lsid;
+  int _clfolvl;
+  LFOLVL[] _levels;
+
+  public LFO()
+  {
+
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFOLVL.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFOLVL.java
new file mode 100644 (file)
index 0000000..bd26d22
--- /dev/null
@@ -0,0 +1,76 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class LFOLVL
+{
+  int _iStartAt;
+  int _ilvl;
+  boolean _fStartAt;
+  boolean _fFormatting;
+  LVL _override;
+
+  public LFOLVL()
+  {
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LST.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LST.java
new file mode 100644 (file)
index 0000000..df32a22
--- /dev/null
@@ -0,0 +1,76 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class LST
+{
+  int _lsid;
+  int _tplc;
+  byte[] _rgistd = new byte[18];
+  boolean _fSimpleList;
+  LVL[] _levels;
+
+  public LST()
+  {
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LVL.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LVL.java
new file mode 100644 (file)
index 0000000..2def47b
--- /dev/null
@@ -0,0 +1,102 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+
+public class LVL
+{
+  public int _iStartAt;
+  public byte _nfc;
+  byte _jc;
+  boolean _fLegal;
+  boolean _fNoRestart;
+  boolean _fPrev;
+  boolean _fPrevSpace;
+  boolean _fWord6;
+  public byte[] _rgbxchNums = new byte[9];
+  public byte _ixchFollow;
+  public byte[] _chpx;
+  public byte[] _papx;
+  public char[] _xst;
+  public short _istd;
+
+  //byte _cbGrpprlChpx;
+  //byte _cbGrpprlPapx;
+
+
+  public LVL()
+  {
+  }
+  public Object clone()
+  {
+    LVL obj = null;
+    try
+    {
+      obj = (LVL)super.clone();
+    }
+    catch(Exception e)
+    {
+      e.printStackTrace();
+    }
+    return obj;
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java
new file mode 100644 (file)
index 0000000..f7b1731
--- /dev/null
@@ -0,0 +1,222 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+import java.util.*;
+
+import org.apache.poi.hdf.extractor.*;
+
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class ListTables implements HDFType
+{
+
+  LFO[] _pllfo;
+  Hashtable _lists = new Hashtable();
+
+  public ListTables(byte[] plcflst, byte[] plflfo)
+  {
+    initLST(plcflst);
+    initLFO(plflfo);
+  }
+  public LVL getLevel(int list, int level)
+  {
+
+    LFO override = _pllfo[list - 1];
+
+    for(int x = 0; x < override._clfolvl; x++)
+    {
+      if(override._levels[x]._ilvl == level)
+      {
+        LFOLVL lfolvl = override._levels[x];
+        if(lfolvl._fFormatting)
+        {
+          LST lst = (LST)_lists.get(new Integer(override._lsid));
+          LVL lvl = lfolvl._override;
+          lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
+          return lvl;
+        }
+        else if(lfolvl._fStartAt)
+        {
+          LST lst = (LST)_lists.get(new Integer(override._lsid));
+          LVL lvl = lst._levels[level];
+          LVL newLvl = (LVL)lvl.clone();
+          newLvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
+          newLvl._iStartAt = lfolvl._iStartAt;
+          return newLvl;
+        }
+      }
+    }
+
+    LST lst = (LST)_lists.get(new Integer(override._lsid));
+    LVL lvl = lst._levels[level];
+    lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
+    return lvl;
+
+
+  }
+  private void initLST(byte[] plcflst)
+  {
+    short length = Utils.convertBytesToShort(plcflst, 0);
+    int nextLevelOffset = 0;
+    //LST[] lstArray = new LST[length];
+    for(int x = 0; x < length; x++)
+    {
+      LST lst = new LST();
+      lst._lsid = Utils.convertBytesToInt(plcflst, 2 + (x * 28));
+      lst._tplc = Utils.convertBytesToInt(plcflst, 2 + 4 + (x * 28));
+      System.arraycopy(plcflst, 2 + 8 + (x * 28), lst._rgistd, 0, 18);
+      byte code = plcflst[2 + 26 + (x * 28)];
+      lst._fSimpleList = StyleSheet.getFlag(code & 0x01);
+      //lstArray[x] = lst;
+      _lists.put(new Integer(lst._lsid), lst);
+
+      if(lst._fSimpleList)
+      {
+        lst._levels = new LVL[1];
+      }
+      else
+      {
+        lst._levels = new LVL[9];
+      }
+
+      for(int y = 0; y < lst._levels.length; y++)
+      {
+        int offset = 2 + (length * 28) + nextLevelOffset;
+        lst._levels[y] = new LVL();
+        nextLevelOffset += createLVL(plcflst, offset, lst._levels[y]);
+      }
+    }
+
+
+  }
+  private void initLFO(byte[] plflfo)
+  {
+    int lfoSize = Utils.convertBytesToInt(plflfo, 0);
+    _pllfo = new LFO[lfoSize];
+    for(int x = 0; x < lfoSize; x++)
+    {
+      LFO nextLFO = new LFO();
+      nextLFO._lsid = Utils.convertBytesToInt(plflfo, 4 + (x * 16));
+      nextLFO._clfolvl = plflfo[4 + 12 + (x * 16)];
+      nextLFO._levels = new LFOLVL[nextLFO._clfolvl];
+      _pllfo[x] = nextLFO;
+    }
+
+    int lfolvlOffset = (lfoSize * 16) + 4;
+    int lvlOffset = 0;
+    int lfolvlNum = 0;
+    for(int x = 0; x < lfoSize; x++)
+    {
+      for(int y = 0; y < _pllfo[x]._clfolvl; y++)
+      {
+        int offset = lfolvlOffset + (lfolvlNum * 8) + lvlOffset;
+        LFOLVL lfolvl = new LFOLVL();
+        lfolvl._iStartAt = Utils.convertBytesToInt(plflfo, offset);
+        lfolvl._ilvl = Utils.convertBytesToInt(plflfo, offset + 4);
+        lfolvl._fStartAt = StyleSheet.getFlag(lfolvl._ilvl & 0x10);
+        lfolvl._fFormatting = StyleSheet.getFlag(lfolvl._ilvl & 0x20);
+        lfolvl._ilvl = (lfolvl._ilvl & (byte)0x0f);
+        lfolvlNum++;
+
+        if(lfolvl._fFormatting)
+        {
+          offset = lfolvlOffset + (lfolvlNum * 12) + lvlOffset;
+          lfolvl._override = new LVL();
+          lvlOffset += createLVL(plflfo, offset, lfolvl._override);
+        }
+        _pllfo[x]._levels[y] = lfolvl;
+      }
+    }
+  }
+  private int createLVL(byte[] data, int offset, LVL lvl)
+  {
+
+    lvl._iStartAt = Utils.convertBytesToInt(data, offset);
+    lvl._nfc = data[offset + 4];
+    int code = Utils.convertBytesToInt(data, offset + 5);
+    lvl._jc = (byte)(code & 0x03);
+    lvl._fLegal = StyleSheet.getFlag(code & 0x04);
+    lvl._fNoRestart = StyleSheet.getFlag(code & 0x08);
+    lvl._fPrev = StyleSheet.getFlag(code & 0x10);
+    lvl._fPrevSpace = StyleSheet.getFlag(code & 0x20);
+    lvl._fWord6 = StyleSheet.getFlag(code & 0x40);
+    System.arraycopy(data, offset + 6, lvl._rgbxchNums, 0, 9);
+    lvl._ixchFollow = data[offset + 15];
+    int chpxSize = data[offset + 24];
+    int papxSize = data[offset + 25];
+    lvl._chpx = new byte[chpxSize];
+    lvl._papx = new byte[papxSize];
+    System.arraycopy(data, offset + 28, lvl._papx, 0, papxSize);
+    System.arraycopy(data, offset + 28 + papxSize, lvl._chpx, 0, chpxSize);
+    offset += 28 + papxSize + chpxSize;//modify offset
+    int xstSize = Utils.convertBytesToShort(data, offset);
+    lvl._xst = new char[xstSize];
+
+    offset += 2;
+    for(int x = 0; x < xstSize; x++)
+    {
+      lvl._xst[x] = (char)Utils.convertBytesToShort(data, offset + (x * 2));
+    }
+    return 28 + papxSize + chpxSize + 2 + (xstSize * 2);
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ParagraphProperties.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ParagraphProperties.java
new file mode 100644 (file)
index 0000000..15cc3ff
--- /dev/null
@@ -0,0 +1,169 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class ParagraphProperties implements Cloneable, HDFType
+{
+  public int _istd;//index to style descriptor.
+  public byte _jc;//justification code
+  public byte _fKeep;//keep entire paragraph on one page if possible
+  public byte _fKeepFollow;//keep paragraph on same page with next paragraph if possible
+  public byte _fPageBreakBefore;//start this paragraph on new page
+  public byte _positionByte;//multiple flags see spec;
+  public byte _brcp;//rectangle border codes for Macword 3.0
+  public byte _brcl;//border line styles for Macword 3.0
+  public byte _ilvl;//when non-zero, list level for this paragraph
+  public byte _fNoLnn;//no line numbering for this paragraph. (makes this an exception to the section property of line numbering)
+  public int  _ilfo;//when non-zero, (1-based) index into the pllfo identifying the list to which the paragraph belongs
+  public byte _fSideBySide;//when 1, paragraph is a side by side paragraph
+  public byte _fNoAutoHyph;//when 0, text in paragraph may be auto hyphenated.
+  public byte _fWindowControl;//when 1, Word will prevent widowed lines in this paragraph from being placed at the beginning of a page
+  public int _dxaRight;//indent from right margin (signed).
+  public int _dxaLeft;//indent from left margin (signed)
+  public int _dxaLeft1;//first line indent; signed number relative to dxaLeft
+  public int[] _lspd = new int[2];//line spacing descriptor see spec
+  public int _dyaBefore;// vertical spacing before paragraph (unsigned)
+  public int _dyaAfter;//vertical spacing after paragraph (unsigned)
+  public byte[] _phe = new byte[12];//height of current paragraph
+  public byte _fCrLf;//undocumented
+  public byte _fUsePgsuSettings;//undocumented
+  public byte _fAdjustRight;//undocumented
+  public byte _fKinsoku;// when 1, apply kinsoku rules when performing line wrapping
+  public byte _fWordWrap;//when 1, perform word wrap
+  public byte _fOverflowPunct;//when 1, apply overflow punctuation rules when performing line wrapping
+  public byte _fTopLinePunct;//when 1, perform top line punctuation processing
+  public byte _fAutoSpaceDE;//when 1, auto space FE and alphabetic characters
+  public byte _fAutoSpaceDN;// when 1, auto space FE and numeric characters
+  public int _wAlignFont;//font alignment 0 Hanging 1 Centered 2 Roman 3 Variable 4 Auto
+  public short _fontAlign;//multiVal see Spec.
+  public byte _fInTable;//when 1, paragraph is contained in a table row
+  public byte _fTtp;//when 1, paragraph consists only of the row mark special character and marks the end of a table row
+  public byte _wr;//Wrap Code for absolute objects
+  public byte _fLocked;//when 1, paragraph may not be edited
+  public int _dxaAbs;//see spec
+  public int _dyaAbs;//see spec
+  public int _dxaWidth;//when not == 0, paragraph is constrained to be dxaWidth wide, independent of current margin or column settings
+  public short[] _brcTop = new short[2];//spec for border above paragraph
+  public short[] _brcLeft = new short[2];//specification for border to the left of
+  public short[] _brcBottom = new short[2];//paragraphspecification for border below
+  public short[] _brcRight = new short[2];//paragraphspecification for border to the
+  public short[] _brcBetween = new short[2];//right of paragraphsee spec
+  public short[] _brcBar = new short[2];//specification of border to place on
+  public short _brcTop1;//outside of text when facing pages are to be displayed.spec
+  public short _brcLeft1;//for border above paragraphspecification for border to the
+  public short _brcBottom1;//left ofparagraphspecification for border below
+  public short _brcRight1;//paragraphspecification for border to the
+  public short _brcBetween1;//right of paragraphsee spec
+  public short _brcBar1;//specification of border to place on outside of text when facing pages are to be displayed.
+  public int _dxaFromText;//horizontal distance to be maintained between an absolutely positioned paragraph and any non-absolute positioned text
+  public int _dyaFromText;//vertical distance to be maintained between an absolutely positioned paragraph and any non-absolute positioned text
+  public int _dyaHeight;//see spec
+  public int _shd;//shading
+  public int _dcs;//drop cap specifier
+  public byte[] _anld = new byte[84];//autonumber list descriptor (see ANLD definition)
+  public short _fPropRMark;//when 1, properties have been changed with revision marking on
+  public short _ibstPropRMark;//index to author IDs stored in hsttbfRMark. used when properties have been changed when revision marking was enabled
+  public byte[] _dttmPropRMark = new byte[4];//Date/time at which properties of this were changed for this run of text by the author. (Only recorded when revision marking is on.)
+  public byte[] _numrm = new byte[8];//paragraph numbering revision mark data (see NUMRM)
+  public short _itbdMac;//number of tabs stops defined for paragraph. Must be >= 0 and <= 64.
+
+
+
+  public ParagraphProperties()
+  {
+    _fWindowControl = 1;
+    //lspd[0] = 240;
+    _lspd[1] = 1;
+    _ilvl = 9;
+  }
+  public Object clone() throws CloneNotSupportedException
+  {
+      ParagraphProperties clone =  (ParagraphProperties)super.clone();
+
+      clone._brcBar = new short[2];
+      clone._brcBottom = new short[2];
+      clone._brcLeft = new short[2];
+      clone._brcBetween = new short[2];
+      clone._brcRight = new short[2];
+      clone._brcTop = new short[2];
+      clone._lspd = new int[2];
+      clone._phe = new byte[12];
+      clone._anld = new byte[84];
+      clone._dttmPropRMark = new byte[4];
+      clone._numrm = new byte[8];
+
+      System.arraycopy(_brcBar, 0, clone._brcBar, 0, 2);
+      System.arraycopy(_brcBottom, 0, clone._brcBottom, 0, 2);
+      System.arraycopy(_brcLeft, 0, clone._brcLeft, 0, 2);
+      System.arraycopy(_brcBetween, 0, clone._brcBetween, 0, 2);
+      System.arraycopy(_brcRight, 0, clone._brcRight, 0, 2);
+      System.arraycopy(_brcTop, 0, clone._brcTop, 0, 2);
+      System.arraycopy(_lspd, 0, clone._lspd, 0, 2);
+      System.arraycopy(_phe, 0, clone._phe, 0, 12);
+      System.arraycopy(_anld, 0, clone._anld, 0, 84);
+      System.arraycopy(_dttmPropRMark, 0, clone._dttmPropRMark, 0, 4);
+      System.arraycopy(_numrm, 0, clone._numrm, 0, 8);
+
+      return clone;
+  }
+
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/SectionProperties.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/SectionProperties.java
new file mode 100644 (file)
index 0000000..009df86
--- /dev/null
@@ -0,0 +1,138 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class SectionProperties implements HDFType
+{
+  int _index;
+  byte _bkc;
+  boolean _fTitlePage;
+  boolean _fAutoPgn;
+  byte _nfcPgn;
+  boolean _fUnlocked;
+  byte _cnsPgn;
+  boolean _fPgnRestart;
+  boolean _fEndNote;
+  byte _lnc;
+  byte _grpfIhdt;
+  short _nLnnMod;
+  int _dxaLnn;
+  short _dxaPgn;
+  short _dyaPgn;
+  boolean _fLBetween;
+  byte _vjc;
+  short _dmBinFirst;
+  short _dmBinOther;
+  short _dmPaperReq;
+  short[] _brcTop = new short[2];
+  short[] _brcLeft = new short[2];
+  short[] _brcBottom = new short[2];
+  short[] _brcRight = new short[2];
+  boolean _fPropMark;
+  int _dxtCharSpace;
+  int _dyaLinePitch;
+  short _clm;
+  byte _dmOrientPage;
+  byte _iHeadingPgn;
+  short _pgnStart;
+  short _lnnMin;
+  short _wTextFlow;
+  short _pgbProp;
+  int _xaPage;
+  int _yaPage;
+  int _dxaLeft;
+  int _dxaRight;
+  int _dyaTop;
+  int _dyaBottom;
+  int _dzaGutter;
+  int _dyaHdrTop;
+  int _dyaHdrBottom;
+  short _ccolM1;
+  boolean _fEvenlySpaced;
+  int _dxaColumns;
+  int[] _rgdxaColumnWidthSpacing;
+  byte _dmOrientFirst;
+  byte[] _olstAnn;
+
+
+
+  public SectionProperties()
+  {
+      _bkc = 2;
+      _dyaPgn = 720;
+      _dxaPgn = 720;
+      _fEndNote = true;
+      _fEvenlySpaced = true;
+      _xaPage = 12240;
+      _yaPage = 15840;
+      _dyaHdrTop = 720;
+      _dyaHdrBottom = 720;
+      _dmOrientPage = 1;
+      _dxaColumns = 720;
+      _dyaTop = 1440;
+      _dxaLeft = 1800;
+      _dyaBottom = 1440;
+      _dxaRight = 1800;
+      _pgnStart = 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
new file mode 100644 (file)
index 0000000..183819b
--- /dev/null
@@ -0,0 +1,171 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+import org.apache.poi.util.LittleEndian;
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class StyleDescription implements HDFType
+{
+
+  private static int PARAGRAPH_STYLE = 1;
+  private static int CHARACTER_STYLE = 2;
+
+  int _baseStyleIndex;
+  int _styleTypeCode;
+  int _numUPX;
+  byte[] _papx;
+  byte[] _chpx;
+  ParagraphProperties _pap;
+  CharacterProperties _chp;
+
+  public StyleDescription()
+  {
+      _pap = new ParagraphProperties();
+      _chp = new CharacterProperties();
+  }
+  public StyleDescription(byte[] std, int baseLength, boolean word9)
+  {
+      int infoShort = LittleEndian.getShort(std, 2);
+      _styleTypeCode = (infoShort & 0xf);
+      _baseStyleIndex = (infoShort & 0xfff0) >> 4;
+
+      infoShort = LittleEndian.getShort(std, 4);
+      _numUPX = infoShort & 0xf;
+
+      //first byte(s) of variable length section of std is the length of the
+      //style name and aliases string
+      int nameLength = 0;
+      int multiplier = 1;
+      if(word9)
+      {
+          nameLength = LittleEndian.getShort(std, baseLength);
+          multiplier = 2;
+      }
+      else
+      {
+          nameLength = std[baseLength];
+      }
+      //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++)
+      {
+          int upxSize = LittleEndian.getShort(std, grupxStart + offset);
+          if(_styleTypeCode == PARAGRAPH_STYLE)
+          {
+              if(x == 0)
+              {
+                  _papx = new byte[upxSize];
+                  System.arraycopy(std, grupxStart + offset + 2, _papx, 0, upxSize);
+              }
+              else if(x == 1)
+              {
+                  _chpx = new byte[upxSize];
+                  System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
+              }
+          }
+          else if(_styleTypeCode == CHARACTER_STYLE && x == 0)
+          {
+              _chpx = new byte[upxSize];
+              System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
+          }
+
+          if(upxSize % 2 == 1)
+          {
+              ++upxSize;
+          }
+          offset += 2 + upxSize;
+      }
+
+
+
+  }
+  public int getBaseStyle()
+  {
+      return _baseStyleIndex;
+  }
+  public byte[] getCHPX()
+  {
+      return _chpx;
+  }
+  public byte[] getPAPX()
+  {
+      return _papx;
+  }
+  public ParagraphProperties getPAP()
+  {
+      return _pap;
+  }
+  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
new file mode 100644 (file)
index 0000000..7b464e3
--- /dev/null
@@ -0,0 +1,1344 @@
+
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+import java.util.*;
+import org.apache.poi.util.LittleEndian;
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class StyleSheet implements HDFType
+{
+
+  private static final int NIL_STYLE = 4095;
+  private static final int PAP_TYPE = 1;
+  private static final int CHP_TYPE = 2;
+  private static final int SEP_TYPE = 4;
+  private static final int TAP_TYPE = 5;
+  //Vector _styleDescriptions;
+  StyleDescription _nilStyle = new StyleDescription();
+  StyleDescription[] _styleDescriptions;
+
+  public StyleSheet(byte[] styleSheet)
+  {
+      int stshiLength = LittleEndian.getShort(styleSheet, 0);
+      int stdCount = LittleEndian.getShort(styleSheet, 2);
+      int baseLength = LittleEndian.getShort(styleSheet, 4);
+      int[] rgftc = new int[3];
+
+      rgftc[0] = LittleEndian.getInt(styleSheet, 14);
+      rgftc[1] = LittleEndian.getInt(styleSheet, 18);
+      rgftc[2] = LittleEndian.getInt(styleSheet, 22);
+
+      int offset = 0;
+      _styleDescriptions = new StyleDescription[stdCount];
+      for(int x = 0; x < stdCount; x++)
+      {
+          int stdOffset = (2 + stshiLength) + offset;
+          int stdSize = LittleEndian.getShort(styleSheet, stdOffset);
+          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);
+
+              _styleDescriptions[x] = aStyle;
+          }
+
+
+          offset += stdSize + 2;
+
+      }
+      for(int x = 0; x < _styleDescriptions.length; x++)
+      {
+          if(_styleDescriptions[x] != null)
+          {
+              createPap(x);
+              createChp(x);
+          }
+      }
+  }
+  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);
+      }
+  }
+  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);
+      }
+  }
+  public StyleDescription getStyleDescription(int x)
+  {
+      return _styleDescriptions[x];
+  }
+  static void doCHPOperation(CharacterProperties oldCHP, CharacterProperties newCHP,
+                             int operand, int param,
+                             byte[] varParam, byte[] grpprl, int offset,
+                             StyleSheet styleSheet)
+  {
+      switch(operand)
+      {
+          case 0:
+               newCHP._fRMarkDel = getFlag(param);
+               break;
+          case 0x1:
+               newCHP._fRMark = getFlag(param);
+               break;
+          case 0x2:
+               break;
+          case 0x3:
+               newCHP._fcPic = param;
+               newCHP._fSpec = true;
+               break;
+          case 0x4:
+               newCHP._ibstRMark = (short)param;
+               break;
+          case 0x5:
+               newCHP._dttmRMark[0] = LittleEndian.getShort(grpprl, (offset - 4));
+               newCHP._dttmRMark[1] = LittleEndian.getShort(grpprl, (offset - 2));
+               break;
+          case 0x6:
+               newCHP._fData = getFlag(param);
+               break;
+          case 0x7:
+               //don't care about this
+               break;
+          case 0x8:
+               short chsDiff = (short)((param & 0xff0000) >>> 8);
+               newCHP._fChsDiff = getFlag(chsDiff);
+               newCHP._chse = (short)(param & 0xffff);
+               break;
+          case 0x9:
+               newCHP._fSpec = true;
+               newCHP._ftcSym = (short)LittleEndian.getShort(varParam, 0);
+               newCHP._xchSym = (short)LittleEndian.getShort(varParam, 2);
+               break;
+          case 0xa:
+               newCHP._fOle2 = getFlag(param);
+               break;
+          case 0xb:
+               //?
+               break;
+          case 0xc:
+               newCHP._icoHighlight = (byte)param;
+               newCHP._highlighted = getFlag(param);
+               break;
+          case 0xd:
+               break;
+          case 0xe:
+               newCHP._fcObj = 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._istd = param;
+               break;
+          case 0x31:
+               //permutation vector for fast saves who cares!
+               break;
+          case 0x32:
+               newCHP._bold = false;
+               newCHP._italic = false;
+               newCHP._fOutline = false;
+               newCHP._fStrike = false;
+               newCHP._fShadow = false;
+               newCHP._fSmallCaps = false;
+               newCHP._fCaps = false;
+               newCHP._fVanish = false;
+               newCHP._kul = 0;
+               newCHP._ico = 0;
+               break;
+          case 0x33:
+               newCHP.copy(oldCHP);
+               return;
+          case 0x34:
+               break;
+          case 0x35:
+               newCHP._bold = getCHPFlag((byte)param, oldCHP._bold);
+               break;
+          case 0x36:
+               newCHP._italic = getCHPFlag((byte)param, oldCHP._italic);
+               break;
+          case 0x37:
+               newCHP._fStrike = getCHPFlag((byte)param, oldCHP._fStrike);
+               break;
+          case 0x38:
+               newCHP._fOutline = getCHPFlag((byte)param, oldCHP._fOutline);
+               break;
+          case 0x39:
+               newCHP._fShadow = getCHPFlag((byte)param, oldCHP._fShadow);
+               break;
+          case 0x3a:
+               newCHP._fSmallCaps = getCHPFlag((byte)param, oldCHP._fSmallCaps);
+               break;
+          case 0x3b:
+               newCHP._fCaps = getCHPFlag((byte)param, oldCHP._fCaps);
+               break;
+          case 0x3c:
+               newCHP._fVanish = getCHPFlag((byte)param, oldCHP._fVanish);
+               break;
+          case 0x3d:
+               newCHP._ftc = (short)param;
+               break;
+          case 0x3e:
+               newCHP._kul = (byte)param;
+               break;
+          case 0x3f:
+               int hps = param & 0xff;
+               if(hps != 0)
+               {
+                  newCHP._hps = hps;
+               }
+               byte cInc = (byte)(((byte)(param & 0xfe00) >>> 4) >> 1);
+               if(cInc != 0)
+               {
+                  newCHP._hps = Math.max(newCHP._hps + (cInc * 2), 2);
+               }
+               byte hpsPos = (byte)((param & 0xff0000) >>> 8);
+               if(hpsPos != 0x80)
+               {
+                  newCHP._hpsPos = hpsPos;
+               }
+               boolean fAdjust = (param & 0x0100) > 0;
+               if(fAdjust && hpsPos != 128 && hpsPos != 0 && oldCHP._hpsPos == 0)
+               {
+                  newCHP._hps = Math.max(newCHP._hps + (-2), 2);
+               }
+               if(fAdjust && hpsPos == 0 && oldCHP._hpsPos != 0)
+               {
+                  newCHP._hps = Math.max(newCHP._hps + 2, 2);
+               }
+               break;
+          case 0x40:
+               newCHP._dxaSpace = param;
+               break;
+          case 0x41:
+               newCHP._lidDefault = (short)param;
+               break;
+          case 0x42:
+               newCHP._ico = (byte)param;
+               break;
+          case 0x43:
+               newCHP._hps = param;
+               break;
+          case 0x44:
+               byte hpsLvl = (byte)param;
+               newCHP._hps = Math.max(newCHP._hps + (hpsLvl * 2), 2);
+               break;
+          case 0x45:
+               newCHP._hpsPos = (short)param;
+               break;
+          case 0x46:
+               if(param != 0)
+               {
+                  if(oldCHP._hpsPos == 0)
+                  {
+                      newCHP._hps = Math.max(newCHP._hps + (-2), 2);
+                  }
+               }
+               else
+               {
+                  if(oldCHP._hpsPos != 0)
+                  {
+                      newCHP._hps = Math.max(newCHP._hps + 2, 2);
+                  }
+               }
+               break;
+          case 0x47:
+               CharacterProperties genCHP = new CharacterProperties();
+               genCHP._ftc = 4;
+               genCHP = (CharacterProperties)uncompressProperty(varParam, genCHP, styleSheet);
+               CharacterProperties styleCHP = styleSheet.getStyleDescription(oldCHP._baseIstd).getCHP();
+               if(genCHP._bold == newCHP._bold)
+               {
+                  newCHP._bold = styleCHP._bold;
+               }
+               if(genCHP._italic == newCHP._italic)
+               {
+                  newCHP._italic = styleCHP._italic;
+               }
+               if(genCHP._fSmallCaps == newCHP._fSmallCaps)
+               {
+                  newCHP._fSmallCaps = styleCHP._fSmallCaps;
+               }
+               if(genCHP._fVanish == newCHP._fVanish)
+               {
+                  newCHP._fVanish = styleCHP._fVanish;
+               }
+               if(genCHP._fStrike == newCHP._fStrike)
+               {
+                  newCHP._fStrike = styleCHP._fStrike;
+               }
+               if(genCHP._fCaps == newCHP._fCaps)
+               {
+                  newCHP._fCaps = styleCHP._fCaps;
+               }
+               if(genCHP._ftcAscii == newCHP._ftcAscii)
+               {
+                  newCHP._ftcAscii = styleCHP._ftcAscii;
+               }
+               if(genCHP._ftcFE == newCHP._ftcFE)
+               {
+                  newCHP._ftcFE = styleCHP._ftcFE;
+               }
+               if(genCHP._ftcOther == newCHP._ftcOther)
+               {
+                  newCHP._ftcOther = styleCHP._ftcOther;
+               }
+               if(genCHP._hps == newCHP._hps)
+               {
+                  newCHP._hps = styleCHP._hps;
+               }
+               if(genCHP._hpsPos == newCHP._hpsPos)
+               {
+                  newCHP._hpsPos = styleCHP._hpsPos;
+               }
+               if(genCHP._kul == newCHP._kul)
+               {
+                  newCHP._kul = styleCHP._kul;
+               }
+               if(genCHP._dxaSpace == newCHP._dxaSpace)
+               {
+                  newCHP._dxaSpace = styleCHP._dxaSpace;
+               }
+               if(genCHP._ico == newCHP._ico)
+               {
+                  newCHP._ico = styleCHP._ico;
+               }
+               if(genCHP._lidDefault == newCHP._lidDefault)
+               {
+                  newCHP._lidDefault = styleCHP._lidDefault;
+               }
+               if(genCHP._lidFE == newCHP._lidFE)
+               {
+                  newCHP._lidFE = styleCHP._lidFE;
+               }
+               break;
+          case 0x48:
+               newCHP._iss = (byte)param;
+               break;
+          case 0x49:
+               newCHP._hps = LittleEndian.getShort(varParam, 0);
+               break;
+          case 0x4a:
+               int increment = LittleEndian.getShort(varParam, 0);
+               newCHP._hps = Math.max(newCHP._hps + increment, 8);
+               break;
+          case 0x4b:
+               newCHP._hpsKern = 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._hps);
+               newCHP._hps += add;
+               break;
+          case 0x4e:
+               newCHP._ysr = (byte)param;
+               break;
+          case 0x4f:
+               newCHP._ftcAscii = (short)param;
+               break;
+          case 0x50:
+               newCHP._ftcFE = (short)param;
+               break;
+          case 0x51:
+               newCHP._ftcOther = (short)param;
+               break;
+          case 0x52:
+               break;
+          case 0x53:
+               newCHP._fDStrike = getFlag(param);
+               break;
+          case 0x54:
+               newCHP._fImprint = getFlag(param);
+               break;
+          case 0x55:
+               newCHP._fSpec = getFlag(param);
+               break;
+          case 0x56:
+               newCHP._fObj = getFlag(param);
+               break;
+          case 0x57:
+               newCHP._fPropMark = getFlag(varParam[0]);
+               newCHP._ibstPropRMark = (short)LittleEndian.getShort(varParam, 1);
+               newCHP._dttmPropRMark = LittleEndian.getInt(varParam, 3);
+               break;
+          case 0x58:
+               newCHP._fEmboss = getFlag(param);
+               break;
+          case 0x59:
+               newCHP._sfxtText = (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:
+               newCHP._fDispFldRMark = getFlag(varParam[0]);
+               newCHP._ibstDispFldRMark = (short)LittleEndian.getShort(varParam, 1);
+               newCHP._dttmDispFldRMark = LittleEndian.getInt(varParam, 3);
+               System.arraycopy(varParam, 7, newCHP._xstDispFldRMark, 0, 32);
+               break;
+          case 0x63:
+               newCHP._ibstRMarkDel = (short)param;
+               break;
+          case 0x64:
+               newCHP._dttmRMarkDel[0] = LittleEndian.getShort(grpprl, offset - 4);
+               newCHP._dttmRMarkDel[1] = LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x65:
+               newCHP._brc[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newCHP._brc[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x66:
+               newCHP._shd = (short)param;
+               break;
+          case 0x67:
+               break;
+          case 0x68:
+               break;
+          case 0x69:
+               break;
+          case 0x6a:
+               break;
+          case 0x6b:
+               break;
+          case 0x6c:
+               break;
+          case 0x6d:
+               newCHP._lidDefault = (short)param;
+               break;
+          case 0x6e:
+               newCHP._lidFE = (short)param;
+               break;
+          case 0x6f:
+               newCHP._idctHint = (byte)param;
+               break;
+      }
+  }
+
+  static Object uncompressProperty(byte[] grpprl, Object parent, StyleSheet styleSheet)
+  {
+    return uncompressProperty(grpprl, parent, styleSheet, true);
+  }
+
+
+  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)._istd = LittleEndian.getShort(grpprl, 0);
+
+            offset = 2;
+          }
+      }
+      else if(parent instanceof CharacterProperties)
+      {
+          try
+          {
+              newProperty = ((CharacterProperties)parent).clone();
+              ((CharacterProperties)newProperty)._baseIstd = ((CharacterProperties)parent)._istd;
+          }
+          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;
+
+  }
+  static void doPAPOperation(ParagraphProperties newPAP, int operand, int param,
+                             byte[] varParam, byte[] grpprl, int offset,
+                             int spra)
+  {
+      switch(operand)
+      {
+          case 0:
+               newPAP._istd = param;
+               break;
+          case 0x1:
+               //permuteIstd(newPAP, varParam);
+               break;
+          case 0x2:
+               if(newPAP._istd <=9 || newPAP._istd >=1)
+               {
+                  newPAP._istd += param;
+                  if(param > 0)
+                  {
+                      newPAP._istd = Math.max(newPAP._istd, 9);
+                  }
+                  else
+                  {
+                      newPAP._istd = Math.min(newPAP._istd, 1);
+                  }
+               }
+               break;
+          case 0x3:
+               newPAP._jc = (byte)param;
+               break;
+          case 0x4:
+               newPAP._fSideBySide = (byte)param;
+               break;
+          case 0x5:
+               newPAP._fKeep = (byte)param;
+               break;
+          case 0x6:
+               newPAP._fKeepFollow = (byte)param;
+               break;
+          case 0x7:
+               newPAP._fPageBreakBefore = (byte)param;
+               break;
+          case 0x8:
+               newPAP._brcl = (byte)param;
+               break;
+          case 0x9:
+               newPAP._brcp = (byte)param;
+               break;
+          case 0xa:
+               newPAP._ilvl = (byte)param;
+               break;
+          case 0xb:
+               newPAP._ilfo = param;
+               break;
+          case 0xc:
+               newPAP._fNoLnn = (byte)param;
+               break;
+          case 0xd:
+               /**@todo handle tabs*/
+               break;
+          case 0xe:
+               newPAP._dxaRight = param;
+               break;
+          case 0xf:
+               newPAP._dxaLeft = param;
+               break;
+          case 0x10:
+               newPAP._dxaLeft += param;
+               newPAP._dxaLeft = Math.max(0, newPAP._dxaLeft);
+               break;
+          case 0x11:
+               newPAP._dxaLeft1 = param;
+               break;
+          case 0x12:
+               newPAP._lspd[0] = LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._lspd[1] = LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x13:
+               newPAP._dyaBefore = param;
+               break;
+          case 0x14:
+               newPAP._dyaAfter = param;
+               break;
+          case 0x15:
+               /**@todo handle tabs*/
+               break;
+          case 0x16:
+               newPAP._fInTable = (byte)param;
+               break;
+          case 0x17:
+               newPAP._fTtp =(byte)param;
+               break;
+          case 0x18:
+               newPAP._dxaAbs = param;
+               break;
+          case 0x19:
+               newPAP._dyaAbs = param;
+               break;
+          case 0x1a:
+               newPAP._dxaWidth = 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._brcTop1 = (short)param;
+               break;
+          case 0x1d:
+               newPAP._brcLeft1 = (short)param;
+               break;
+          case 0x1e:
+               newPAP._brcBottom1 = (short)param;
+               break;
+          case 0x1f:
+               newPAP._brcRight1 = (short)param;
+               break;
+          case 0x20:
+               newPAP._brcBetween1 = (short)param;
+               break;
+          case 0x21:
+               newPAP._brcBar1 = (byte)param;
+               break;
+          case 0x22:
+               newPAP._dxaFromText = param;
+               break;
+          case 0x23:
+               newPAP._wr = (byte)param;
+               break;
+          case 0x24:
+               newPAP._brcTop[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._brcTop[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x25:
+               newPAP._brcLeft[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._brcLeft[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x26:
+               newPAP._brcBottom[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._brcBottom[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x27:
+               newPAP._brcRight[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._brcRight[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x28:
+               newPAP._brcBetween[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._brcBetween[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x29:
+               newPAP._brcBar[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
+               newPAP._brcBar[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
+               break;
+          case 0x2a:
+               newPAP._fNoAutoHyph = (byte)param;
+               break;
+          case 0x2b:
+               newPAP._dyaHeight = param;
+               break;
+          case 0x2c:
+               newPAP._dcs = param;
+               break;
+          case 0x2d:
+               newPAP._shd = param;
+               break;
+          case 0x2e:
+               newPAP._dyaFromText = param;
+               break;
+          case 0x2f:
+               newPAP._dxaFromText = param;
+               break;
+          case 0x30:
+               newPAP._fLocked = (byte)param;
+               break;
+          case 0x31:
+               newPAP._fWindowControl = (byte)param;
+               break;
+          case 0x32:
+               //undocumented
+               break;
+          case 0x33:
+               newPAP._fKinsoku = (byte)param;
+               break;
+          case 0x34:
+               newPAP._fWordWrap = (byte)param;
+               break;
+          case 0x35:
+               newPAP._fOverflowPunct = (byte)param;
+               break;
+          case 0x36:
+               newPAP._fTopLinePunct = (byte)param;
+               break;
+          case 0x37:
+               newPAP._fAutoSpaceDE = (byte)param;
+               break;
+          case 0x38:
+               newPAP._fAutoSpaceDN = (byte)param;
+               break;
+          case 0x39:
+               newPAP._wAlignFont = param;
+               break;
+          case 0x3a:
+               newPAP._fontAlign = (short)param;
+               break;
+          case 0x3b:
+               //obsolete
+               break;
+          case 0x3e:
+               newPAP._anld = 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._numrm = varParam;
+               }
+               else
+               {
+                  /**@todo handle large PAPX from data stream*/
+               }
+               break;
+
+          case 0x47:
+               newPAP._fUsePgsuSettings = (byte)param;
+               break;
+          case 0x48:
+               newPAP._fAdjustRight = (byte)param;
+               break;
+          default:
+               break;
+      }
+  }
+  static void doTAPOperation(TableProperties newTAP, int operand, int param, byte[] varParam)
+  {
+      switch(operand)
+      {
+          case 0:
+               newTAP._jc = (short)param;
+               break;
+          case 0x01:
+          {
+               int adjust = param - (newTAP._rgdxaCenter[0] + newTAP._dxaGapHalf);
+               for(int x = 0; x < newTAP._itcMac; x++)
+               {
+                  newTAP._rgdxaCenter[x] += adjust;
+               }
+               break;
+          }
+          case 0x02:
+               if(newTAP._rgdxaCenter != null)
+               {
+                 int adjust = newTAP._dxaGapHalf - param;
+                 newTAP._rgdxaCenter[0] += adjust;
+               }
+               newTAP._dxaGapHalf = param;
+               break;
+          case 0x03:
+               newTAP._fCantSplit = getFlag(param);
+               break;
+          case 0x04:
+               newTAP._fTableHeader = getFlag(param);
+               break;
+          case 0x05:
+
+               newTAP._brcTop[0] = LittleEndian.getShort(varParam, 0);
+               newTAP._brcTop[1] = LittleEndian.getShort(varParam, 2);
+
+               newTAP._brcLeft[0] = LittleEndian.getShort(varParam, 4);
+               newTAP._brcLeft[1] = LittleEndian.getShort(varParam, 6);
+
+               newTAP._brcBottom[0] = LittleEndian.getShort(varParam, 8);
+               newTAP._brcBottom[1] = LittleEndian.getShort(varParam, 10);
+
+               newTAP._brcRight[0] = LittleEndian.getShort(varParam, 12);
+               newTAP._brcRight[1] = LittleEndian.getShort(varParam, 14);
+
+               newTAP._brcHorizontal[0] = LittleEndian.getShort(varParam, 16);
+               newTAP._brcHorizontal[1] = LittleEndian.getShort(varParam, 18);
+
+               newTAP._brcVertical[0] = LittleEndian.getShort(varParam, 20);
+               newTAP._brcVertical[1] = LittleEndian.getShort(varParam, 22);
+               break;
+          case 0x06:
+               //obsolete, used in word 1.x
+               break;
+          case 0x07:
+               newTAP._dyaRowHeight = param;
+               break;
+          case 0x08:
+               //I use varParam[0] and newTAP._itcMac interchangably
+               newTAP._itcMac = varParam[0];
+               newTAP._rgdxaCenter = new short[varParam[0] + 1];
+               newTAP._rgtc = new TableCellDescriptor[varParam[0]];
+
+               for(int x = 0; x < newTAP._itcMac; x++)
+               {
+                 newTAP._rgdxaCenter[x] = LittleEndian.getShort(varParam , 1 + (x * 2));
+                 newTAP._rgtc[x] = TableCellDescriptor.convertBytesToTC(varParam, 1 + ((varParam[0] + 1) * 2) + (x * 20));
+               }
+               newTAP._rgdxaCenter[newTAP._itcMac] = LittleEndian.getShort(varParam , 1 + (newTAP._itcMac * 2));
+               break;
+          case 0x09:
+               /** @todo handle cell shading*/
+               break;
+          case 0x0a:
+               /** @todo handle word defined table styles*/
+               break;
+          case 0x20:
+               for(int x = varParam[0]; x < varParam[1]; x++)
+               {
+                 if((varParam[2] & 0x08) > 0)
+                 {
+                   newTAP._rgtc[x]._brcRight[0] = LittleEndian.getShort(varParam, 6);
+                   newTAP._rgtc[x]._brcRight[1] = LittleEndian.getShort(varParam, 8);
+                 }
+                 else if((varParam[2] & 0x04) > 0)
+                 {
+                   newTAP._rgtc[x]._brcBottom[0] = LittleEndian.getShort(varParam, 6);
+                   newTAP._rgtc[x]._brcBottom[1] = LittleEndian.getShort(varParam, 8);
+                 }
+                 else if((varParam[2] & 0x02) > 0)
+                 {
+                   newTAP._rgtc[x]._brcLeft[0] = LittleEndian.getShort(varParam, 6);
+                   newTAP._rgtc[x]._brcLeft[1] = LittleEndian.getShort(varParam, 8);
+                 }
+                 else if((varParam[2] & 0x01) > 0)
+                 {
+                   newTAP._rgtc[x]._brcTop[0] = LittleEndian.getShort(varParam, 6);
+                   newTAP._rgtc[x]._brcTop[1] = LittleEndian.getShort(varParam, 8);
+                 }
+               }
+               break;
+          case 0x21:
+               int index = (param & 0xff000000) >> 24;
+               int count = (param & 0x00ff0000) >> 16;
+               int width = (param & 0x0000ffff);
+
+               short[] rgdxaCenter = new short[newTAP._itcMac + count + 1];
+               TableCellDescriptor[] rgtc = new TableCellDescriptor[newTAP._itcMac + count];
+               if(index >= newTAP._itcMac)
+               {
+                 index = newTAP._itcMac;
+                 System.arraycopy(newTAP._rgdxaCenter, 0, rgdxaCenter, 0, newTAP._itcMac + 1);
+                 System.arraycopy(newTAP._rgtc, 0, rgtc, 0, newTAP._itcMac);
+               }
+               else
+               {
+                 //copy rgdxaCenter
+                 System.arraycopy(newTAP._rgdxaCenter, 0, rgdxaCenter, 0, index + 1);
+                 System.arraycopy(newTAP._rgdxaCenter, index + 1, rgdxaCenter, index + count, (newTAP._itcMac) - (index));
+                 //copy rgtc
+                 System.arraycopy(newTAP._rgtc, 0, rgtc, 0, index);
+                 System.arraycopy(newTAP._rgtc, index, rgtc, index + count, newTAP._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;
+      }
+  }
+  static void doSEPOperation(SectionProperties newSEP, int operand, int param, byte[] varParam)
+  {
+      switch(operand)
+      {
+          case 0:
+               newSEP._cnsPgn = (byte)param;
+               break;
+          case 0x1:
+               newSEP._iHeadingPgn = (byte)param;
+               break;
+          case 0x2:
+               newSEP._olstAnn = varParam;
+               break;
+          case 0x3:
+               //not quite sure
+               break;
+          case 0x4:
+               //not quite sure
+               break;
+          case 0x5:
+               newSEP._fEvenlySpaced = getFlag(param);
+               break;
+          case 0x6:
+               newSEP._fUnlocked = getFlag(param);
+               break;
+          case 0x7:
+               newSEP._dmBinFirst = (short)param;
+               break;
+          case 0x8:
+               newSEP._dmBinOther = (short)param;
+               break;
+          case 0x9:
+               newSEP._bkc = (byte)param;
+               break;
+          case 0xa:
+               newSEP._fTitlePage = getFlag(param);
+               break;
+          case 0xb:
+               newSEP._ccolM1 = (short)param;
+               break;
+          case 0xc:
+               newSEP._dxaColumns = param;
+               break;
+          case 0xd:
+               newSEP._fAutoPgn = getFlag(param);
+               break;
+          case 0xe:
+               newSEP._nfcPgn = (byte)param;
+               break;
+          case 0xf:
+               newSEP._dyaPgn = (short)param;
+               break;
+          case 0x10:
+               newSEP._dxaPgn = (short)param;
+               break;
+          case 0x11:
+               newSEP._fPgnRestart = getFlag(param);
+               break;
+          case 0x12:
+               newSEP._fEndNote = getFlag(param);
+               break;
+          case 0x13:
+               newSEP._lnc = (byte)param;
+               break;
+          case 0x14:
+               newSEP._grpfIhdt = (byte)param;
+               break;
+          case 0x15:
+               newSEP._nLnnMod = (short)param;
+               break;
+          case 0x16:
+               newSEP._dxaLnn = param;
+               break;
+          case 0x17:
+               newSEP._dyaHdrTop = param;
+               break;
+          case 0x18:
+               newSEP._dyaHdrBottom = param;
+               break;
+          case 0x19:
+               newSEP._fLBetween = getFlag(param);
+               break;
+          case 0x1a:
+               newSEP._vjc = (byte)param;
+               break;
+          case 0x1b:
+               newSEP._lnnMin = (short)param;
+               break;
+          case 0x1c:
+               newSEP._pgnStart = (short)param;
+               break;
+          case 0x1d:
+               newSEP._dmOrientPage = (byte)param;
+               break;
+          case 0x1e:
+               //nothing
+               break;
+          case 0x1f:
+               newSEP._xaPage = param;
+               break;
+          case 0x20:
+               newSEP._yaPage = param;
+               break;
+          case 0x21:
+               newSEP._dxaLeft = param;
+               break;
+          case 0x22:
+               newSEP._dxaRight = param;
+               break;
+          case 0x23:
+               newSEP._dyaTop = param;
+               break;
+          case 0x24:
+               newSEP._dyaBottom = param;
+               break;
+          case 0x25:
+               newSEP._dzaGutter = param;
+               break;
+          case 0x26:
+               newSEP._dmPaperReq = (short)param;
+               break;
+          case 0x27:
+               newSEP._fPropMark = getFlag(varParam[0]);
+               break;
+          case 0x28:
+               break;
+          case 0x29:
+               break;
+          case 0x2a:
+               break;
+          case 0x2b:
+               newSEP._brcTop[0] = (short)(param & 0xffff);
+               newSEP._brcTop[1] = (short)((param & 0xffff0000) >> 16);
+               break;
+          case 0x2c:
+               newSEP._brcLeft[0] = (short)(param & 0xffff);
+               newSEP._brcLeft[1] = (short)((param & 0xffff0000) >> 16);
+               break;
+          case 0x2d:
+               newSEP._brcBottom[0] = (short)(param & 0xffff);
+               newSEP._brcBottom[1] = (short)((param & 0xffff0000) >> 16);
+               break;
+          case 0x2e:
+               newSEP._brcRight[0] = (short)(param & 0xffff);
+               newSEP._brcRight[1] = (short)((param & 0xffff0000) >> 16);
+               break;
+          case 0x2f:
+               newSEP._pgbProp = (short)param;
+               break;
+          case 0x30:
+               newSEP._dxtCharSpace = param;
+               break;
+          case 0x31:
+               newSEP._dyaLinePitch = param;
+               break;
+          case 0x33:
+               newSEP._wTextFlow = (short)param;
+               break;
+          default:
+               break;
+      }
+
+  }
+  private static boolean getCHPFlag(byte x, boolean oldVal)
+  {
+      switch(x)
+      {
+          case 0:
+               return false;
+          case 1:
+               return true;
+          case (byte)0x80:
+               return oldVal;
+          case (byte)0x81:
+               return !oldVal;
+          default:
+               return false;
+      }
+  }
+  public static boolean getFlag(int x)
+  {
+      if(x != 0)
+      {
+          return true;
+      }
+      else
+      {
+          return false;
+      }
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableCellDescriptor.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableCellDescriptor.java
new file mode 100644 (file)
index 0000000..d94d29c
--- /dev/null
@@ -0,0 +1,112 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+import org.apache.poi.util.LittleEndian;
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class TableCellDescriptor implements HDFType
+{
+
+  boolean _fFirstMerged;
+  boolean _fMerged;
+  boolean _fVertical;
+  boolean _fBackward;
+  boolean _fRotateFont;
+  boolean _fVertMerge;
+  boolean _fVertRestart;
+  short _vertAlign;
+  short[] _brcTop = new short[2];
+  short[] _brcLeft = new short[2];
+  short[] _brcBottom = new short[2];
+  short[] _brcRight = new short [2];
+
+  public TableCellDescriptor()
+  {
+  }
+  static TableCellDescriptor convertBytesToTC(byte[] array, int offset)
+  {
+    TableCellDescriptor tc = new TableCellDescriptor();
+    int rgf = LittleEndian.getShort(array, offset);
+    tc._fFirstMerged = (rgf & 0x0001) > 0;
+    tc._fMerged = (rgf & 0x0002) > 0;
+    tc._fVertical = (rgf & 0x0004) > 0;
+    tc._fBackward = (rgf & 0x0008) > 0;
+    tc._fRotateFont = (rgf & 0x0010) > 0;
+    tc._fVertMerge = (rgf & 0x0020) > 0;
+    tc._fVertRestart = (rgf & 0x0040) > 0;
+    tc._vertAlign = (short)((rgf & 0x0180) >> 7);
+
+    tc._brcTop[0] = LittleEndian.getShort(array, offset + 4);
+    tc._brcTop[1] = LittleEndian.getShort(array, offset + 6);
+
+    tc._brcLeft[0] = LittleEndian.getShort(array, offset + 8);
+    tc._brcLeft[1] = LittleEndian.getShort(array, offset + 10);
+
+    tc._brcBottom[0] = LittleEndian.getShort(array, offset + 12);
+    tc._brcBottom[1] = LittleEndian.getShort(array, offset + 14);
+
+    tc._brcRight[0] = LittleEndian.getShort(array, offset + 16);
+    tc._brcRight[1] = LittleEndian.getShort(array, offset + 18);
+
+    return tc;
+  }
+
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableProperties.java b/src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableProperties.java
new file mode 100644 (file)
index 0000000..303a15a
--- /dev/null
@@ -0,0 +1,87 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.hdftypes;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class TableProperties implements HDFType
+{
+  short _jc;
+  int _dxaGapHalf;
+  int _dyaRowHeight;
+  boolean _fCantSplit;
+  boolean _fTableHeader;
+  boolean _fLastRow;
+  short _itcMac;
+  short[] _rgdxaCenter;
+  short[] _brcLeft = new short[2];
+  short[] _brcRight = new short[2];
+  short[] _brcTop = new short[2];
+  short[] _brcBottom = new short[2];
+  short[] _brcHorizontal = new short[2];
+  short[] _brcVertical = new short[2];
+
+  TableCellDescriptor[] _rgtc;
+
+
+  public TableProperties()
+  {
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java
new file mode 100644 (file)
index 0000000..aac3ebf
--- /dev/null
@@ -0,0 +1,730 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.util;
+
+import java.util.*;
+
+
+/*
+ * A B-Tree like implementation of the java.util.Set inteface.  This is a modifiable set
+ * and thus allows elements to be added and removed.  An instance of java.util.Comparator
+ * must be provided at construction else all Objects added to the set must implement
+ * java.util.Comparable and must be comparable to one another.  No duplicate elements
+ * will be allowed in any BTreeSet in accordance with the specifications of the Set interface.
+ * Any attempt to add a null element will result in an IllegalArgumentException being thrown.
+ * The java.util.Iterator returned by the iterator method guarantees the elements returned
+ * are in ascending order.  The Iterator.remove() method is supported.
+ * Comment me
+ *
+ * @author Ryan Ackley
+ *
+*/
+
+public class BTreeSet extends AbstractSet implements Set {
+
+    /*
+     * Instance Variables
+    */
+    public BTreeNode root;
+    private Comparator comparator = null;
+    private int order;
+    private int size = 0;
+
+    /*
+     *                             Constructors
+     * A no-arg constructor is supported in accordance with the specifications of the
+     * java.util.Collections interface.  If the order for the B-Tree is not specified
+     * at construction it defaults to 32.
+    */
+
+    public BTreeSet() {
+        this(6);           // Default order for a BTreeSet is 32
+    }
+
+    public BTreeSet(Collection c) {
+        this(6);           // Default order for a BTreeSet is 32
+        addAll(c);
+    }
+
+    public BTreeSet(int order) {
+        this(order, null);
+    }
+
+    public BTreeSet(int order, Comparator comparator) {
+        this.order = order;
+        this.comparator = comparator;
+        root = new BTreeNode(null);
+    }
+
+
+    /*
+     * Public Methods
+    */
+    public boolean add(Object x) throws IllegalArgumentException {
+        if (x == null) throw new IllegalArgumentException();
+        return root.insert(x, -1);
+    }
+
+    public boolean contains(Object x) {
+        return root.includes(x);
+    }
+
+    public boolean remove(Object x) {
+        if (x == null) return false;
+        return root.delete(x, -1);
+    }
+
+    public int size() {
+        return size;
+    }
+
+    public void clear() {
+        root = new BTreeNode(null);
+        size = 0;
+    }
+
+    public java.util.Iterator iterator() {
+        return new Iterator();
+    }
+
+
+    /*
+     * Private methods
+    */
+    private int compare(Object x, Object y) {
+        return (comparator == null ? ((Comparable)x).compareTo(y) : comparator.compare(x, y));
+    }
+
+
+
+    /*
+     * Inner Classes
+    */
+
+    /*
+     * Guarantees that the Objects are returned in ascending order.  Due to the volatile
+     * structure of a B-Tree (many splits, steals and merges can happen in a single call to remove)
+     * this Iterator does not attempt to track any concurrent changes that are happening to
+     * it's BTreeSet.  Therefore, after every call to BTreeSet.remove or BTreeSet.add a new
+     * Iterator should be constructed.  If no new Iterator is constructed than there is a
+     * chance of receiving a NullPointerException. The Iterator.delete method is supported.
+    */
+
+    private class Iterator implements java.util.Iterator {
+        private int index = 0;
+        private Stack parentIndex = new Stack(); // Contains all parentIndicies for currentNode
+        private Object lastReturned = null;
+        private Object next;
+        private BTreeNode currentNode;
+
+        Iterator() {
+            currentNode = firstNode();
+            next = nextElement();
+        }
+
+        public boolean hasNext() {
+            return next != null;
+        }
+
+        public Object next() {
+            if (next == null) throw new NoSuchElementException();
+
+            lastReturned = next;
+            next = nextElement();
+            return lastReturned;
+        }
+
+        public void remove() {
+            if (lastReturned == null) throw new NoSuchElementException();
+
+            BTreeSet.this.remove(lastReturned);
+            lastReturned = null;
+        }
+
+        private BTreeNode firstNode() {
+            BTreeNode temp = BTreeSet.this.root;
+
+            while (temp.entries[0].child != null) {
+                temp = temp.entries[0].child;
+                parentIndex.push(new Integer(0));
+            }
+
+            return temp;
+        }
+
+        private Object nextElement() {
+            if (currentNode.isLeaf()) {
+                if (index < currentNode.nrElements) return currentNode.entries[index++].element;
+
+                else if (!parentIndex.empty()) { //All elements have been returned, return successor of lastReturned if it exists
+                    currentNode = currentNode.parent;
+                    index = ((Integer)parentIndex.pop()).intValue();
+
+                    while (index == currentNode.nrElements) {
+                        if (parentIndex.empty()) break;
+                        currentNode = currentNode.parent;
+                        index = ((Integer)parentIndex.pop()).intValue();
+                    }
+
+                    if (index == currentNode.nrElements) return null; //Reached root and he has no more children
+                    return currentNode.entries[index++].element;
+                }
+
+                else { //Your a leaf and the root
+                    if (index == currentNode.nrElements) return null;
+                    return currentNode.entries[index++].element;
+                }
+            }
+
+            else { //Your not a leaf so simply find and return the successor of lastReturned
+                currentNode = currentNode.entries[index].child;
+                parentIndex.push(new Integer(index));
+
+                while (currentNode.entries[0].child != null) {
+                    currentNode = currentNode.entries[0].child;
+                    parentIndex.push(new Integer(0));
+                }
+
+                index = 1;
+                return currentNode.entries[0].element;
+            }
+        }
+    }
+
+
+    public static class Entry {
+
+        public Object element;
+        public BTreeNode child;
+    }
+
+
+    public class BTreeNode {
+
+        public Entry[] entries;
+        public BTreeNode parent;
+        private int nrElements = 0;
+        private final int MIN = (BTreeSet.this.order - 1) / 2;
+
+        BTreeNode(BTreeNode parent) {
+            this.parent = parent;
+            entries = new Entry[BTreeSet.this.order];
+            entries[0] = new Entry();
+        }
+
+        boolean insert(Object x, int parentIndex) {
+            if (isFull()) { // If full, you must split and promote splitNode before inserting
+                Object splitNode = entries[nrElements / 2].element;
+                BTreeNode rightSibling = split();
+
+                if (isRoot()) { // Grow a level
+                    splitRoot(splitNode, this, rightSibling);
+                    // Determine where to insert
+                    if (BTreeSet.this.compare(x, BTreeSet.this.root.entries[0].element) < 0) insert(x, 0);
+                    else rightSibling.insert(x, 1);
+                }
+
+                else { // Promote splitNode
+                    parent.insertSplitNode(splitNode, this, rightSibling, parentIndex);
+                    if (BTreeSet.this.compare(x, parent.entries[parentIndex].element) < 0) return insert(x, parentIndex);
+                    else return rightSibling.insert(x, parentIndex + 1);
+                }
+            }
+
+            else if (isLeaf()) { // If leaf, simply insert the non-duplicate element
+                int insertAt = childToInsertAt(x, true);
+                if (insertAt == -1) return false; // Determine if the element already exists
+                else {
+                    insertNewElement(x, insertAt);
+                    BTreeSet.this.size++;
+                    return true;
+                }
+            }
+
+            else { // If not full and not leaf recursively find correct node to insert at
+                int insertAt = childToInsertAt(x, true);
+                return (insertAt == -1 ? false : entries[insertAt].child.insert(x, insertAt));
+            }
+            return false;
+        }
+
+        boolean includes(Object x) {
+            int index = childToInsertAt(x, true);
+            if (index == -1) return true;
+            if (entries[index] == null || entries[index].child == null) return false;
+            return entries[index].child.includes(x);
+        }
+
+        boolean delete(Object x, int parentIndex) {
+            int i = childToInsertAt(x, true);
+            int priorParentIndex = parentIndex;
+            BTreeNode temp = this;
+            if (i != -1) {
+                do {
+                    if (temp.entries[i] == null || temp.entries[i].child == null) return false;
+                    temp = temp.entries[i].child;
+                    priorParentIndex = parentIndex;
+                    parentIndex = i;
+                    i = temp.childToInsertAt(x, true);
+                } while (i != -1);
+            } // Now temp contains element to delete and temp's parentIndex is parentIndex
+
+            if (temp.isLeaf()) { // If leaf and have more than MIN elements, simply delete
+                if (temp.nrElements > MIN) {
+                    temp.deleteElement(x);
+                    BTreeSet.this.size--;
+                    return true;
+                }
+
+                else { // If leaf and have less than MIN elements, than prepare the BTreeSet for deletion
+                    temp.prepareForDeletion(parentIndex);
+                    temp.deleteElement(x);
+                    BTreeSet.this.size--;
+                    temp.fixAfterDeletion(priorParentIndex);
+                    return true;
+                }
+            }
+
+            else { // Only delete at leaf so first switch with successor than delete
+                temp.switchWithSuccessor(x);
+                parentIndex = temp.childToInsertAt(x, false) + 1;
+                return temp.entries[parentIndex].child.delete(x, parentIndex);
+            }
+        }
+
+
+        private boolean isFull() { return nrElements == (BTreeSet.this.order - 1); }
+
+        private boolean isLeaf() { return entries[0].child == null; }
+
+        private boolean isRoot() { return parent == null; }
+
+        /*
+         * Splits a BTreeNode into two BTreeNodes, removing the splitNode from the
+         * calling BTreeNode.
+        */
+        private BTreeNode split() {
+            BTreeNode rightSibling = new BTreeNode(parent);
+            int index = nrElements / 2;
+            entries[index++].element = null;
+
+            for (int i = 0, nr = nrElements; index <= nr; i++, index++) {
+                rightSibling.entries[i] = entries[index];
+                if (rightSibling.entries[i] != null && rightSibling.entries[i].child != null)
+                    rightSibling.entries[i].child.parent = rightSibling;
+                entries[index] = null;
+                nrElements--;
+                rightSibling.nrElements++;
+            }
+
+            rightSibling.nrElements--; // Need to correct for copying the last Entry which has a null element and a child
+            return rightSibling;
+        }
+
+        /*
+         * Creates a new BTreeSet.root which contains only the splitNode and pointers
+         * to it's left and right child.
+        */
+        private void splitRoot(Object splitNode, BTreeNode left, BTreeNode right) {
+            BTreeNode newRoot = new BTreeNode(null);
+            newRoot.entries[0].element = splitNode;
+            newRoot.entries[0].child = left;
+            newRoot.entries[1] = new Entry();
+            newRoot.entries[1].child = right;
+            newRoot.nrElements = 1;
+            left.parent = right.parent = newRoot;
+            BTreeSet.this.root = newRoot;
+        }
+
+        private void insertSplitNode(Object splitNode, BTreeNode left, BTreeNode right, int insertAt) {
+            for (int i = nrElements; i >= insertAt; i--) entries[i + 1] = entries[i];
+
+            entries[insertAt] = new Entry();
+            entries[insertAt].element = splitNode;
+            entries[insertAt].child = left;
+            entries[insertAt + 1].child = right;
+
+            nrElements++;
+        }
+
+        private void insertNewElement(Object x, int insertAt) {
+
+            for (int i = nrElements; i > insertAt; i--) entries[i] = entries[i - 1];
+
+            entries[insertAt] = new Entry();
+            entries[insertAt].element = x;
+
+            nrElements++;
+        }
+
+        /*
+         * Possibly a deceptive name for a pretty cool method.  Uses binary search
+         * to determine the postion in entries[] in which to traverse to find the correct
+         * BTreeNode in which to insert a new element.  If the element exists in the calling
+         * BTreeNode than -1 is returned.  When the parameter position is true and the element
+         * is present in the calling BTreeNode -1 is returned, if position is false and the
+         * element is contained in the calling BTreeNode than the position of the element
+         * in entries[] is returned.
+        */
+        private int childToInsertAt(Object x, boolean position) {
+            int index = nrElements / 2;
+
+            if (entries[index] == null || entries[index].element == null) return index;
+
+            int lo = 0, hi = nrElements - 1;
+            while (lo <= hi) {
+                if (BTreeSet.this.compare(x, entries[index].element) > 0) {
+                    lo = index + 1;
+                    index = (hi + lo) / 2;
+                }
+                else {
+                    hi = index - 1;
+                    index = (hi + lo) / 2;
+                }
+            }
+
+            hi++;
+            if (entries[hi] == null || entries[hi].element == null) return hi;
+            return (!position ? hi : BTreeSet.this.compare(x, entries[hi].element) == 0 ? -1 : hi);
+        }
+
+
+        private void deleteElement(Object x) {
+            int index = childToInsertAt(x, false);
+            for (; index < (nrElements - 1); index++) entries[index] = entries[index + 1];
+
+            if (nrElements == 1) entries[index] = new Entry(); // This is root and it is empty
+            else entries[index] = null;
+
+            nrElements--;
+        }
+
+        private void prepareForDeletion(int parentIndex) {
+            if (isRoot()) return; // Don't attempt to steal or merge if your the root
+
+            // If not root then try to steal left
+            else if (parentIndex != 0 && parent.entries[parentIndex - 1].child.nrElements > MIN) {
+                stealLeft(parentIndex);
+                return;
+            }
+
+            // If not root and can't steal left try to steal right
+            else if (parentIndex < entries.length && parent.entries[parentIndex + 1] != null && parent.entries[parentIndex + 1].child != null && parent.entries[parentIndex + 1].child.nrElements > MIN) {
+                    stealRight(parentIndex);
+                    return;
+            }
+
+            // If not root and can't steal left or right then try to merge left
+            else if (parentIndex != 0) {
+                mergeLeft(parentIndex);
+                return;
+            }
+
+            // If not root and can't steal left or right and can't merge left you must be able to merge right
+            else mergeRight(parentIndex);
+        }
+
+        private void fixAfterDeletion(int parentIndex) {
+            if (isRoot() || parent.isRoot()) return; // No fixing needed
+
+            if (parent.nrElements < MIN) { // If parent lost it's n/2 element repair it
+                BTreeNode temp = parent;
+                temp.prepareForDeletion(parentIndex);
+                if (temp.parent == null) return; // Root changed
+                if (!temp.parent.isRoot() && temp.parent.nrElements < MIN) { // If need be recurse
+                    BTreeNode x = temp.parent.parent;
+                    int i = 0;
+                    // Find parent's parentIndex
+                    for (; i < entries.length; i++) if (x.entries[i].child == temp.parent) break;
+                    temp.parent.fixAfterDeletion(i);
+                }
+            }
+        }
+
+        private void switchWithSuccessor(Object x) {
+            int index = childToInsertAt(x, false);
+            BTreeNode temp = entries[index + 1].child;
+            while (temp.entries[0] != null && temp.entries[0].child != null) temp = temp.entries[0].child;
+            Object successor = temp.entries[0].element;
+            temp.entries[0].element = entries[index].element;
+            entries[index].element = successor;
+        }
+
+        /*
+         * This method is called only when the BTreeNode has the minimum number of elements,
+         * has a leftSibling, and the leftSibling has more than the minimum number of elements.
+        */
+        private void stealLeft(int parentIndex) {
+            BTreeNode p = parent;
+            BTreeNode ls = parent.entries[parentIndex - 1].child;
+
+            if (isLeaf()) { // When stealing from leaf to leaf don't worry about children
+                int add = childToInsertAt(p.entries[parentIndex - 1].element, true);
+                insertNewElement(p.entries[parentIndex - 1].element, add);
+                p.entries[parentIndex - 1].element = ls.entries[ls.nrElements - 1].element;
+                ls.entries[ls.nrElements - 1] = null;
+                ls.nrElements--;
+            }
+
+            else { // Was called recursively to fix an undermanned parent
+                entries[0].element = p.entries[parentIndex - 1].element;
+                p.entries[parentIndex - 1].element = ls.entries[ls.nrElements - 1].element;
+                entries[0].child = ls.entries[ls.nrElements].child;
+                entries[0].child.parent = this;
+                ls.entries[ls.nrElements] = null;
+                ls.entries[ls.nrElements - 1].element = null;
+                nrElements++;
+                ls.nrElements--;
+            }
+        }
+
+        /*
+         * This method is called only when stealLeft can't be called, the BTreeNode
+         * has the minimum number of elements, has a rightSibling, and the rightSibling
+         * has more than the minimum number of elements.
+        */
+        private void stealRight(int parentIndex) {
+            BTreeNode p = parent;
+            BTreeNode rs = p.entries[parentIndex + 1].child;
+
+            if (isLeaf()) { // When stealing from leaf to leaf don't worry about children
+                entries[nrElements] = new Entry();
+                entries[nrElements].element = p.entries[parentIndex].element;
+                p.entries[parentIndex].element = rs.entries[0].element;
+                for (int i = 0; i < rs.nrElements; i++) rs.entries[i] = rs.entries[i + 1];
+                rs.entries[rs.nrElements - 1] = null;
+                nrElements++;
+                rs.nrElements--;
+            }
+
+            else { // Was called recursively to fix an undermanned parent
+                for (int i = 0; i <= nrElements; i++) entries[i] = entries[i + 1];
+                entries[nrElements].element = p.entries[parentIndex].element;
+                p.entries[parentIndex].element = rs.entries[0].element;
+                entries[nrElements + 1] = new Entry();
+                entries[nrElements + 1].child = rs.entries[0].child;
+                entries[nrElements + 1].child.parent = this;
+                for (int i = 0; i <= rs.nrElements; i++) rs.entries[i] = rs.entries[i + 1];
+                rs.entries[rs.nrElements] = null;
+                nrElements++;
+                rs.nrElements--;
+            }
+        }
+
+        /*
+         * This method is called only when stealLeft and stealRight could not be called,
+         * the BTreeNode has the minimum number of elements, has a leftSibling, and the
+         * leftSibling has more than the minimum number of elements.  If after completion
+         * parent has fewer than the minimum number of elements than the parents entries[0]
+         * slot is left empty in anticipation of a recursive call to stealLeft, stealRight,
+         * mergeLeft, or mergeRight to fix the parent. All of the before-mentioned methods
+         * expect the parent to be in such a condition.
+        */
+        private void mergeLeft(int parentIndex) {
+            BTreeNode p = parent;
+            BTreeNode ls = p.entries[parentIndex - 1].child;
+
+            if (isLeaf()) { // Don't worry about children
+                int add = childToInsertAt(p.entries[parentIndex - 1].element, true);
+                insertNewElement(p.entries[parentIndex - 1].element, add); // Could have been a successor switch
+                p.entries[parentIndex - 1].element = null;
+
+                for (int i = nrElements - 1, nr = ls.nrElements; i >= 0; i--)
+                    entries[i + nr] = entries[i];
+
+                for (int i = ls.nrElements - 1; i >= 0; i--) {
+                    entries[i] = ls.entries[i];
+                    nrElements++;
+                }
+
+                if (p.nrElements == MIN && p != BTreeSet.this.root) {
+
+                    for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x--, y--)
+                        p.entries[x] = p.entries[y];
+                    p.entries[0] = new Entry();
+                    p.entries[0].child = ls; //So p doesn't think it's a leaf this will be deleted in the next recursive call
+                }
+
+                else {
+
+                    for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
+                        p.entries[x] = p.entries[y];
+                    p.entries[p.nrElements] = null;
+                }
+
+                p.nrElements--;
+
+                if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
+                    BTreeSet.this.root = this;
+                    parent = null;
+                }
+            }
+
+            else { // I'm not a leaf but fixing the tree structure
+                entries[0].element = p.entries[parentIndex - 1].element;
+                entries[0].child = ls.entries[ls.nrElements].child;
+                nrElements++;
+
+                for (int x = nrElements, nr = ls.nrElements; x >= 0; x--)
+                    entries[x + nr] = entries[x];
+
+                for (int x = ls.nrElements - 1; x >= 0; x--) {
+                    entries[x] = ls.entries[x];
+                    entries[x].child.parent = this;
+                    nrElements++;
+                }
+
+                if (p.nrElements == MIN && p != BTreeSet.this.root) { // Push everything to the right
+                    for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x++, y++){
+                        System.out.println(x + " " + y);
+                        p.entries[x] = p.entries[y];}
+                    p.entries[0] = new Entry();
+                }
+
+                else { // Either p.nrElements > MIN or p == BTreeSet.this.root so push everything to the left
+                    for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
+                        p.entries[x] = p.entries[y];
+                    p.entries[p.nrElements] = null;
+                }
+
+                p.nrElements--;
+
+                if (p.isRoot() && p.nrElements == 0) { // p == BTreeSet.this.root and it's empty
+                    BTreeSet.this.root = this;
+                    parent = null;
+                }
+            }
+        }
+
+        /*
+         * This method is called only when stealLeft, stealRight, and mergeLeft could not be called,
+         * the BTreeNode has the minimum number of elements, has a rightSibling, and the
+         * rightSibling has more than the minimum number of elements.  If after completion
+         * parent has fewer than the minimum number of elements than the parents entries[0]
+         * slot is left empty in anticipation of a recursive call to stealLeft, stealRight,
+         * mergeLeft, or mergeRight to fix the parent. All of the before-mentioned methods
+         * expect the parent to be in such a condition.
+        */
+        private void mergeRight(int parentIndex) {
+            BTreeNode p = parent;
+            BTreeNode rs = p.entries[parentIndex + 1].child;
+
+            if (isLeaf()) { // Don't worry about children
+                entries[nrElements] = new Entry();
+                entries[nrElements].element = p.entries[parentIndex].element;
+                nrElements++;
+                for (int i = 0, nr = nrElements; i < rs.nrElements; i++, nr++) {
+                    entries[nr] = rs.entries[i];
+                    nrElements++;
+                }
+                p.entries[parentIndex].element = p.entries[parentIndex + 1].element;
+                if (p.nrElements == MIN && p != BTreeSet.this.root) {
+                    for (int x = parentIndex + 1, y = parentIndex; y >= 0; x--, y--)
+                        p.entries[x] = p.entries[y];
+                    p.entries[0] = new Entry();
+                    p.entries[0].child = rs; // So it doesn't think it's a leaf, this child will be deleted in the next recursive call
+                }
+
+                else {
+                    for (int x = parentIndex + 1, y = parentIndex + 2; y <= p.nrElements; x++, y++)
+                        p.entries[x] = p.entries[y];
+                    p.entries[p.nrElements] = null;
+                }
+
+                p.nrElements--;
+                if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
+                    BTreeSet.this.root = this;
+                    parent = null;
+                }
+           }
+
+           else { // It's not a leaf
+
+               entries[nrElements].element = p.entries[parentIndex].element;
+               nrElements++;
+
+               for (int x = nrElements + 1, y = 0; y <= rs.nrElements; x++, y++) {
+                   entries[x] = rs.entries[y];
+                   rs.entries[y].child.parent = this;
+                   nrElements++;
+               }
+               nrElements--;
+
+               p.entries[++parentIndex].child = this;
+
+               if (p.nrElements == MIN && p != BTreeSet.this.root) {
+                  for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x--, y--)
+                      p.entries[x] = p.entries[y];
+                  p.entries[0] = new Entry();
+               }
+
+               else {
+                   for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
+                       p.entries[x] = p.entries[y];
+                   p.entries[p.nrElements] = null;
+               }
+
+               p.nrElements--;
+
+               if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
+                   BTreeSet.this.root = this;
+                   parent = null;
+               }
+            }
+        }
+  }
+}
+
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/ChpxNode.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/ChpxNode.java
new file mode 100644 (file)
index 0000000..e447d1e
--- /dev/null
@@ -0,0 +1,78 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.util;
+
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class ChpxNode extends PropertyNode
+{
+
+
+  public ChpxNode(int fcStart, int fcEnd, byte[] chpx)
+  {
+    super(fcStart, fcEnd, chpx);
+  }
+  public byte[] getChpx()
+  {
+    return super.getGrpprl();
+  }
+
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/PapxNode.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/PapxNode.java
new file mode 100644 (file)
index 0000000..7f876cf
--- /dev/null
@@ -0,0 +1,77 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.util;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class PapxNode extends PropertyNode
+{
+
+
+  public PapxNode(int fcStart, int fcEnd, byte[] papx)
+  {
+    super(fcStart, fcEnd, papx);
+  }
+  public byte[] getPapx()
+  {
+    return super.getGrpprl();
+  }
+
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/PropertyNode.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/PropertyNode.java
new file mode 100644 (file)
index 0000000..c7d648e
--- /dev/null
@@ -0,0 +1,98 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+package org.apache.poi.hdf.model.util;
+
+
+
+public class PropertyNode implements Comparable
+{
+  private byte[] _grpprl;
+  private int _fcStart;
+  private int _fcEnd;
+
+  public PropertyNode(int fcStart, int fcEnd, byte[] grpprl)
+  {
+      _fcStart = fcStart;
+      _fcEnd = fcEnd;
+      _grpprl = grpprl;
+  }
+  public int getStart()
+  {
+      return _fcStart;
+  }
+  public int getEnd()
+  {
+    return _fcEnd;
+  }
+  protected byte[] getGrpprl()
+  {
+    return _grpprl;
+  }
+  public int compareTo(Object o)
+  {
+      int fcStart = ((PropertyNode)o).getStart();
+      if(_fcStart == fcStart)
+      {
+        return 0;
+      }
+      else if(_fcStart < fcStart)
+      {
+        return -1;
+      }
+      else
+      {
+        return 1;
+      }
+  }
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/SepxNode.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/SepxNode.java
new file mode 100644 (file)
index 0000000..5270fc5
--- /dev/null
@@ -0,0 +1,82 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hdf.model.util;
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class SepxNode extends PropertyNode
+{
+
+  int _index;
+
+  public SepxNode(int index, int start, int end, byte[] sepx)
+  {
+    super(start, end, sepx);
+  }
+  public byte[] getSepx()
+  {
+    return getGrpprl();
+  }
+
+  public int compareTo(Object obj) {
+      return 0;
+  }
+
+}
\ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/TextPiece.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/TextPiece.java
new file mode 100644 (file)
index 0000000..75b692f
--- /dev/null
@@ -0,0 +1,88 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hdf.model.util;
+
+
+
+/**
+ * Comment me
+ *
+ * @author Ryan Ackley
+ */
+
+public class TextPiece extends PropertyNode implements Comparable
+{
+  private boolean _usesUnicode;
+  private int _length;
+
+  public TextPiece(int start, int length, boolean unicode)
+  {
+    super(start, start + length, null);
+      _usesUnicode = unicode;
+      _length = length;
+      //_fcStart = start;
+      //_fcEnd = start + length;
+
+  }
+   public boolean usesUnicode()
+  {
+      return _usesUnicode;
+  }
+
+   public int compareTo(Object obj) {
+       return 0;
+   }
+
+}
\ No newline at end of file
index a3896926cc334dc68a849821cb03f63e29f5b26e..6fb6325edcfc24d19e44e7393aedd9b4c1fd6fa9 100644 (file)
   <property name="build.compiler.pedantic" value="false"/>
   <property name="build.compiler.depend" value="true"/>
   <property name="build.compiler.fulldepend" value="true"/>
-  
+
+  <!-- Temporary fix.  Longer term solution to be discussed. -->
+  <property name="build.root"            value="./build"/>
+
+
   <!-- =================================================================== -->
   <!-- Indentify Classpath                                                 -->
   <!-- =================================================================== -->
@@ -44,7 +48,7 @@
       <include name="*.jar"/>
     </fileset>    
     <!-- FIXME : how to build a path that references a property set in 'init' target ? -->
-    <pathelement path="./build/jakarta-poi/classes"/>
+    <pathelement path="${build.root}/jakarta-poi/classes"/>
   </path>
 
   <path id="scratchpad.classpath">
@@ -61,7 +65,7 @@
       <include name="*.jar"/>
     </fileset>
     <!-- FIXME : how to build a path that references a property set in 'init' target ? -->
-    <pathelement path="./build/jakarta-poi/classes"/>
+    <pathelement path="${build.root}/jakarta-poi/classes"/>
   </path>
 
   <path id="contrib.classpath">
@@ -78,7 +82,7 @@
       <include name="*.jar"/>
     </fileset>    
     <!-- FIXME : how to build a path that references a property set in 'init' target ? -->
-    <pathelement path="./build/jakarta-poi/classes"/>
+    <pathelement path="${build.root}/jakarta-poi/classes"/>
   </path>