mirror of https://github.com/apache/poi.git
Added Ryan Akland's new contributions... THANKS RYAN!!! - Schneider Aventinus is the world's best beer
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352116 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bb3e527d0a
commit
57302c699c
|
@ -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.extractor;
|
||||
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class CHP implements Cloneable
|
||||
{
|
||||
boolean _bold;
|
||||
boolean _italic;
|
||||
boolean _fRMarkDel;
|
||||
boolean _fOutline;
|
||||
boolean _fSmallCaps;
|
||||
boolean _fCaps;
|
||||
boolean _fVanish;
|
||||
boolean _fRMark;
|
||||
boolean _fSpec;
|
||||
boolean _fStrike;
|
||||
boolean _fObj;
|
||||
boolean _fShadow;
|
||||
boolean _fLowerCase;
|
||||
boolean _fData;
|
||||
boolean _fOle2;
|
||||
boolean _fEmboss;
|
||||
boolean _fImprint;
|
||||
boolean _fDStrike;
|
||||
|
||||
short _ftcAscii;
|
||||
short _ftcFE;
|
||||
short _ftcOther;
|
||||
short _ftc;
|
||||
int _hps;//font size in half points
|
||||
int _dxaSpace;//space following each character in the run expressed in twip units
|
||||
byte _iss;//superscript/subscript indices 0 means no super/subscripting 1 means text in run is superscripted 2 means text in run is subscripted
|
||||
byte _kul;//underline code see spec
|
||||
byte _ico;//color of text see spec
|
||||
short _hpsPos;//super/subscript position in half points; positive means text is raised; negative means text is lowered
|
||||
short _lidDefault;//language for non-Far East text
|
||||
short _lidFE;//language for Far East text
|
||||
byte _idctHint;
|
||||
int _wCharScale;
|
||||
short _chse;
|
||||
|
||||
int _specialFC;//varies depending on whether this is a special char
|
||||
short _ibstRMark;//index to author IDs stored in hsttbfRMark. used when text in run was newly typed when revision marking was enabled
|
||||
short _ibstRMarkDel;//index to author IDs stored in hsttbfRMark. used when text in run was newly typed when revision marking was enabled
|
||||
int[] _dttmRMark = new int[2];//Date/time at which this run of text was
|
||||
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.)
|
||||
int _istd;
|
||||
int _baseIstd = -1;
|
||||
int _fcPic;
|
||||
short _ftcSym;// see spec
|
||||
short _xchSym;//see spec
|
||||
byte _ysr;//hyphenation rules
|
||||
byte _chYsr;//used for hyphenation see spec
|
||||
int _hpsKern;//kerning distance for characters in run recorded in half points
|
||||
int _fcObj;
|
||||
byte _icoHighlight;//highlight color
|
||||
boolean _fChsDiff;
|
||||
boolean _highlighted;//when true characters are highlighted with color specified by chp.icoHighlight
|
||||
boolean _fPropMark;//when true, properties have been changed with revision marking on
|
||||
short _ibstPropRMark;//index to author IDs stored in hsttbfRMark. used when properties have been changed when revision marking was enabled
|
||||
int _dttmPropRMark;//Date/time at which properties of this were changed for this run of text by the author
|
||||
byte _sfxtText;//text animation see spec
|
||||
boolean _fDispFldRMark;//see spec
|
||||
short _ibstDispFldRMark;//Index to author IDs stored in hsttbfRMark. used when ListNum field numbering has been changed when revision marking was enabled
|
||||
int _dttmDispFldRMark;//The date for the ListNum field number change
|
||||
byte[] _xstDispFldRMark = new byte[32];//The string value of the ListNum field when revision mark tracking began
|
||||
short _shd;//shading
|
||||
short[] _brc = new short[2];//border
|
||||
short _paddingStart = 0;
|
||||
short _paddingEnd = 0;
|
||||
|
||||
public CHP()
|
||||
{
|
||||
_istd = 10;
|
||||
_hps = 20;
|
||||
_lidDefault = 0x0400;
|
||||
_lidFE = 0x0400;
|
||||
|
||||
}
|
||||
public void copy(CHP 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
|
||||
{
|
||||
CHP clone = (CHP)super.clone();
|
||||
clone._brc = new short[2];
|
||||
System.arraycopy(_brc, 0, clone._brc, 0, 2);
|
||||
return clone;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class FontTable
|
||||
{
|
||||
String[] fontNames;
|
||||
|
||||
public FontTable(byte[] fontTable)
|
||||
{
|
||||
int size = Utils.convertBytesToShort(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);
|
||||
while(ch != '\0')
|
||||
{
|
||||
nameBuf.append(ch);
|
||||
nameOffset += 2;
|
||||
ch = Utils.getUnicodeCharacter(fontTable, nameOffset);
|
||||
}
|
||||
fontNames[x] = nameBuf.toString();
|
||||
if(fontNames[x].startsWith("Times"))
|
||||
{
|
||||
fontNames[x] = "Times";
|
||||
}
|
||||
|
||||
currentIndex += ffnLength + 1;
|
||||
}
|
||||
|
||||
}
|
||||
public String getFont(int index)
|
||||
{
|
||||
return fontNames[index];
|
||||
}
|
||||
}
|
|
@ -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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class HeaderFooter
|
||||
{
|
||||
public static final int HEADER_EVEN = 1;
|
||||
public static final int HEADER_ODD = 2;
|
||||
public static final int FOOTER_EVEN = 3;
|
||||
public static final int FOOTER_ODD = 4;
|
||||
public static final int HEADER_FIRST = 5;
|
||||
public static final int FOOTER_FIRST = 6;
|
||||
|
||||
private int _type;
|
||||
private int _start;
|
||||
private int _end;
|
||||
|
||||
public HeaderFooter(int type, int startFC, int endFC)
|
||||
{
|
||||
_type = type;
|
||||
_start = startFC;
|
||||
_end = endFC;
|
||||
}
|
||||
public int getStart()
|
||||
{
|
||||
return _start;
|
||||
}
|
||||
public int getEnd()
|
||||
{
|
||||
return _end;
|
||||
}
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if(_start - _end == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,282 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class NewOleFile extends RandomAccessFile
|
||||
{
|
||||
private byte[] LAOLA_ID_ARRAY = new byte[]{(byte)0xd0, (byte)0xcf, (byte)0x11,
|
||||
(byte)0xe0, (byte)0xa1, (byte)0xb1,
|
||||
(byte)0x1a, (byte)0xe1};
|
||||
private int _num_bbd_blocks;
|
||||
private int _root_startblock;
|
||||
private int _sbd_startblock;
|
||||
private long _size;
|
||||
private int[] _bbd_list;
|
||||
protected int[] _big_block_depot;
|
||||
protected int[] _small_block_depot;
|
||||
Hashtable _propertySetsHT = new Hashtable();
|
||||
Vector _propertySetsV = new Vector();
|
||||
|
||||
public NewOleFile(String fileName, String mode) throws FileNotFoundException
|
||||
{
|
||||
super(fileName, mode);
|
||||
try
|
||||
{
|
||||
init();
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() throws IOException
|
||||
{
|
||||
|
||||
for(int x = 0; x < LAOLA_ID_ARRAY.length; x++)
|
||||
{
|
||||
if(LAOLA_ID_ARRAY[x] != readByte())
|
||||
{
|
||||
throw new IOException("Not an OLE file");
|
||||
}
|
||||
}
|
||||
_size = length();
|
||||
_num_bbd_blocks = readInt(0x2c);
|
||||
_root_startblock = readInt(0x30);
|
||||
_sbd_startblock = readInt(0x3c);
|
||||
_bbd_list = new int[_num_bbd_blocks];
|
||||
//populate bbd_list. If _num_bbd_blocks > 109 I have to do it
|
||||
//differently
|
||||
if(_num_bbd_blocks <= 109)
|
||||
{
|
||||
seek(0x4c);
|
||||
for(int x = 0; x < _num_bbd_blocks; x++)
|
||||
{
|
||||
_bbd_list[x] = readIntLE();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
populateBbdList();
|
||||
}
|
||||
//populate the big block depot
|
||||
_big_block_depot = new int[_num_bbd_blocks * 128];
|
||||
int counter = 0;
|
||||
for(int x = 0; x < _num_bbd_blocks; x++)
|
||||
{
|
||||
byte[] bigBlock = new byte[512];
|
||||
int offset = (_bbd_list[x] + 1) * 512;
|
||||
seek(offset);
|
||||
for(int y = 0; y < 128; y++)
|
||||
{
|
||||
_big_block_depot[counter++] = readIntLE();
|
||||
}
|
||||
}
|
||||
_small_block_depot = createSmallBlockDepot();
|
||||
int[] rootChain = readChain(_big_block_depot, _root_startblock);
|
||||
initializePropertySets(rootChain);
|
||||
|
||||
}
|
||||
public static void main(String args[])
|
||||
{
|
||||
try
|
||||
{
|
||||
NewOleFile file = new NewOleFile(args[0], "r");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
protected int[] readChain(int[] blockChain, int startBlock) throws IOException
|
||||
{
|
||||
|
||||
int[] tempChain = new int[blockChain.length];
|
||||
tempChain[0] = startBlock;
|
||||
int x = 1;
|
||||
for(;;x++)
|
||||
{
|
||||
int nextVal = blockChain[tempChain[x-1]];
|
||||
if(nextVal != -2)
|
||||
{
|
||||
tempChain[x] = nextVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
int[] newChain = new int[x];
|
||||
System.arraycopy(tempChain, 0, newChain, 0, x);
|
||||
|
||||
return newChain;
|
||||
}
|
||||
private void initializePropertySets(int[] rootChain) throws IOException
|
||||
{
|
||||
for(int x = 0; x < rootChain.length; x++)
|
||||
{
|
||||
int offset = (rootChain[x] + 1) * 512;
|
||||
seek(offset);
|
||||
for(int y = 0; y < 4; y++)
|
||||
{
|
||||
//read the block the makes up the property set
|
||||
byte[] propArray = new byte[128];
|
||||
read(propArray);
|
||||
|
||||
//parse the byte array for properties
|
||||
int nameSize = Utils.convertBytesToShort(propArray[0x41], propArray[0x40])/2 - 1;
|
||||
if(nameSize > 0)
|
||||
{
|
||||
StringBuffer nameBuffer = new StringBuffer(nameSize);
|
||||
for(int z = 0; z < nameSize; z++)
|
||||
{
|
||||
nameBuffer.append((char)propArray[z*2]);
|
||||
}
|
||||
int type = propArray[0x42];
|
||||
int previous_pps = Utils.convertBytesToInt(propArray[0x47], propArray[0x46], propArray[0x45], propArray[0x44]);
|
||||
int next_pps = Utils.convertBytesToInt(propArray[0x4b], propArray[0x4a], propArray[0x49], propArray[0x48]);
|
||||
int pps_dir = Utils.convertBytesToInt(propArray[0x4f], propArray[0x4e], propArray[0x4d], propArray[0x4c]);
|
||||
int pps_sb = Utils.convertBytesToInt(propArray[0x77], propArray[0x76], propArray[0x75], propArray[0x74]);
|
||||
int pps_size = Utils.convertBytesToInt(propArray[0x7b], propArray[0x7a], propArray[0x79], propArray[0x78]);
|
||||
|
||||
PropertySet propSet = new PropertySet(nameBuffer.toString(),
|
||||
type, previous_pps, next_pps,
|
||||
pps_dir, pps_sb, pps_size,
|
||||
(x*4) + y);
|
||||
_propertySetsHT.put(nameBuffer.toString(), propSet);
|
||||
_propertySetsV.add(propSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private int[] createSmallBlockDepot() throws IOException
|
||||
{
|
||||
|
||||
int[] sbd_list = readChain(_big_block_depot, _sbd_startblock);
|
||||
int[] small_block_depot = new int[sbd_list.length * 128];
|
||||
|
||||
for(int x = 0; x < sbd_list.length && sbd_list[x] != -2; x++)
|
||||
{
|
||||
int offset = ((sbd_list[x] + 1) * 512);
|
||||
seek(offset);
|
||||
for(int y = 0; y < 128; y++)
|
||||
{
|
||||
small_block_depot[y] = readIntLE();
|
||||
}
|
||||
}
|
||||
return small_block_depot;
|
||||
}
|
||||
|
||||
private void populateBbdList() throws IOException
|
||||
{
|
||||
seek(0x4c);
|
||||
for(int x = 0; x < 109; x++)
|
||||
{
|
||||
_bbd_list[x] = readIntLE();
|
||||
}
|
||||
int pos = 109;
|
||||
int remainder = _num_bbd_blocks - 109;
|
||||
seek(0x48);
|
||||
int numLists = readIntLE();
|
||||
seek(0x44);
|
||||
int firstList = readIntLE();
|
||||
|
||||
firstList = (firstList + 1) * 512;
|
||||
|
||||
for(int y = 0; y < numLists; y++)
|
||||
{
|
||||
int size = Math.min(127, remainder);
|
||||
for(int z = 0; z < size; z++)
|
||||
{
|
||||
seek(firstList + (z * 4));
|
||||
_bbd_list[pos++] = readIntLE();
|
||||
}
|
||||
if(size == 127)
|
||||
{
|
||||
seek(firstList + (127 * 4));
|
||||
firstList = readIntLE();
|
||||
firstList = (firstList + 1) * 512;
|
||||
remainder -= 127;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private int readInt(long offset) throws IOException
|
||||
{
|
||||
seek(offset);
|
||||
return readIntLE();
|
||||
}
|
||||
private int readIntLE() throws IOException
|
||||
{
|
||||
byte[] intBytes = new byte[4];
|
||||
read(intBytes);
|
||||
return Utils.convertBytesToInt(intBytes[3], intBytes[2], intBytes[1], intBytes[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class PAP implements Cloneable
|
||||
{
|
||||
int _istd;//index to style descriptor.
|
||||
byte _jc;//justification code
|
||||
byte _fKeep;//keep entire paragraph on one page if possible
|
||||
byte _fKeepFollow;//keep paragraph on same page with next paragraph if possible
|
||||
byte _fPageBreakBefore;//start this paragraph on new page
|
||||
byte _positionByte;//multiple flags see spec;
|
||||
byte _brcp;//rectangle border codes for Macword 3.0
|
||||
byte _brcl;//border line styles for Macword 3.0
|
||||
byte _ilvl;//when non-zero, list level for this paragraph
|
||||
byte _fNoLnn;//no line numbering for this paragraph. (makes this an exception to the section property of line numbering)
|
||||
int _ilfo;//when non-zero, (1-based) index into the pllfo identifying the list to which the paragraph belongs
|
||||
byte _fSideBySide;//when 1, paragraph is a side by side paragraph
|
||||
byte _fNoAutoHyph;//when 0, text in paragraph may be auto hyphenated.
|
||||
byte _fWindowControl;//when 1, Word will prevent widowed lines in this paragraph from being placed at the beginning of a page
|
||||
int _dxaRight;//indent from right margin (signed).
|
||||
int _dxaLeft;//indent from left margin (signed)
|
||||
int _dxaLeft1;//first line indent; signed number relative to dxaLeft
|
||||
int[] _lspd = new int[2];//line spacing descriptor see spec
|
||||
int _dyaBefore;// vertical spacing before paragraph (unsigned)
|
||||
int _dyaAfter;//vertical spacing after paragraph (unsigned)
|
||||
byte[] _phe = new byte[12];//height of current paragraph
|
||||
byte _fCrLf;//undocumented
|
||||
byte _fUsePgsuSettings;//undocumented
|
||||
byte _fAdjustRight;//undocumented
|
||||
byte _fKinsoku;// when 1, apply kinsoku rules when performing line wrapping
|
||||
byte _fWordWrap;//when 1, perform word wrap
|
||||
byte _fOverflowPunct;//when 1, apply overflow punctuation rules when performing line wrapping
|
||||
byte _fTopLinePunct;//when 1, perform top line punctuation processing
|
||||
byte _fAutoSpaceDE;//when 1, auto space FE and alphabetic characters
|
||||
byte _fAutoSpaceDN;// when 1, auto space FE and numeric characters
|
||||
int _wAlignFont;//font alignment 0 Hanging 1 Centered 2 Roman 3 Variable 4 Auto
|
||||
short _fontAlign;//multiVal see Spec.
|
||||
byte _fInTable;//when 1, paragraph is contained in a table row
|
||||
byte _fTtp;//when 1, paragraph consists only of the row mark special character and marks the end of a table row
|
||||
byte _wr;//Wrap Code for absolute objects
|
||||
byte _fLocked;//when 1, paragraph may not be edited
|
||||
int _dxaAbs;//see spec
|
||||
int _dyaAbs;//see spec
|
||||
int _dxaWidth;//when not == 0, paragraph is constrained to be dxaWidth wide, independent of current margin or column settings
|
||||
short[] _brcTop = new short[2];//spec for border above paragraph
|
||||
short[] _brcLeft = new short[2];//specification for border to the left of
|
||||
short[] _brcBottom = new short[2];//paragraphspecification for border below
|
||||
short[] _brcRight = new short[2];//paragraphspecification for border to the
|
||||
short[] _brcBetween = new short[2];//right of paragraphsee spec
|
||||
short[] _brcBar = new short[2];//specification of border to place on
|
||||
short _brcTop1;//outside of text when facing pages are to be displayed.spec
|
||||
short _brcLeft1;//for border above paragraphspecification for border to the
|
||||
short _brcBottom1;//left ofparagraphspecification for border below
|
||||
short _brcRight1;//paragraphspecification for border to the
|
||||
short _brcBetween1;//right of paragraphsee spec
|
||||
short _brcBar1;//specification of border to place on outside of text when facing pages are to be displayed.
|
||||
int _dxaFromText;//horizontal distance to be maintained between an absolutely positioned paragraph and any non-absolute positioned text
|
||||
int _dyaFromText;//vertical distance to be maintained between an absolutely positioned paragraph and any non-absolute positioned text
|
||||
int _dyaHeight;//see spec
|
||||
int _shd;//shading
|
||||
int _dcs;//drop cap specifier
|
||||
byte[] _anld = new byte[84];//autonumber list descriptor (see ANLD definition)
|
||||
short _fPropRMark;//when 1, properties have been changed with revision marking on
|
||||
short _ibstPropRMark;//index to author IDs stored in hsttbfRMark. used when properties have been changed when revision marking was enabled
|
||||
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.)
|
||||
byte[] _numrm = new byte[8];//paragraph numbering revision mark data (see NUMRM)
|
||||
short _itbdMac;//number of tabs stops defined for paragraph. Must be >= 0 and <= 64.
|
||||
|
||||
|
||||
|
||||
public PAP()
|
||||
{
|
||||
_fWindowControl = 1;
|
||||
//lspd[0] = 240;
|
||||
_lspd[1] = 1;
|
||||
_ilvl = 9;
|
||||
}
|
||||
public Object clone() throws CloneNotSupportedException
|
||||
{
|
||||
PAP clone = (PAP)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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class PropertySet
|
||||
{
|
||||
private String _name;
|
||||
private int _type;
|
||||
private int _previous;
|
||||
private int _next;
|
||||
private int _dir;
|
||||
private int _sb;
|
||||
private int _size;
|
||||
private int _num;
|
||||
|
||||
public PropertySet(String name, int type, int previous, int next, int dir,
|
||||
int sb, int size, int num)
|
||||
{
|
||||
_name = name;
|
||||
_type = type;
|
||||
_previous = previous;
|
||||
_next = next;
|
||||
_dir = dir;
|
||||
_sb = sb;
|
||||
_size = size;
|
||||
_num = num;
|
||||
}
|
||||
public int getSize()
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
public int getStartBlock()
|
||||
{
|
||||
return _sb;
|
||||
}
|
||||
}
|
|
@ -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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class SEP
|
||||
{
|
||||
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 SEP()
|
||||
{
|
||||
_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;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor;
|
||||
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class StyleDescription
|
||||
{
|
||||
|
||||
private static int PARAGRAPH_STYLE = 1;
|
||||
private static int CHARACTER_STYLE = 2;
|
||||
|
||||
int _baseStyleIndex;
|
||||
int _styleTypeCode;
|
||||
int _numUPX;
|
||||
byte[] _papx;
|
||||
byte[] _chpx;
|
||||
PAP _pap;
|
||||
CHP _chp;
|
||||
|
||||
public StyleDescription()
|
||||
{
|
||||
_pap = new PAP();
|
||||
_chp = new CHP();
|
||||
}
|
||||
public StyleDescription(byte[] std, int baseLength, boolean word9)
|
||||
{
|
||||
int infoShort = Utils.convertBytesToShort(std, 2);
|
||||
_styleTypeCode = (infoShort & 0xf);
|
||||
_baseStyleIndex = (infoShort & 0xfff0) >> 4;
|
||||
|
||||
infoShort = Utils.convertBytesToShort(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 = Utils.convertBytesToShort(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 = Utils.convertBytesToShort(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 PAP getPAP()
|
||||
{
|
||||
return _pap;
|
||||
}
|
||||
public CHP getCHP()
|
||||
{
|
||||
return _chp;
|
||||
}
|
||||
public void setPAP(PAP pap)
|
||||
{
|
||||
_pap = pap;
|
||||
}
|
||||
public void setCHP(CHP chp)
|
||||
{
|
||||
_chp = chp;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class TAP
|
||||
{
|
||||
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];
|
||||
|
||||
TC[] _rgtc;
|
||||
|
||||
|
||||
public TAP()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class TC
|
||||
{
|
||||
|
||||
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 TC()
|
||||
{
|
||||
}
|
||||
static TC convertBytesToTC(byte[] array, int offset)
|
||||
{
|
||||
TC tc = new TC();
|
||||
int rgf = Utils.convertBytesToShort(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] = Utils.convertBytesToShort(array, offset + 4);
|
||||
tc._brcTop[1] = Utils.convertBytesToShort(array, offset + 6);
|
||||
|
||||
tc._brcLeft[0] = Utils.convertBytesToShort(array, offset + 8);
|
||||
tc._brcLeft[1] = Utils.convertBytesToShort(array, offset + 10);
|
||||
|
||||
tc._brcBottom[0] = Utils.convertBytesToShort(array, offset + 12);
|
||||
tc._brcBottom[1] = Utils.convertBytesToShort(array, offset + 14);
|
||||
|
||||
tc._brcRight[0] = Utils.convertBytesToShort(array, offset + 16);
|
||||
tc._brcRight[1] = Utils.convertBytesToShort(array, offset + 18);
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class TableRow
|
||||
{
|
||||
TAP _descriptor;
|
||||
Vector _cells;
|
||||
|
||||
public TableRow(Vector cells, TAP descriptor)
|
||||
{
|
||||
_cells = cells;
|
||||
_descriptor = descriptor;
|
||||
}
|
||||
public TAP getTAP()
|
||||
{
|
||||
return _descriptor;
|
||||
}
|
||||
public Vector getCells()
|
||||
{
|
||||
return _cells;
|
||||
}
|
||||
}
|
|
@ -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.extractor;
|
||||
|
||||
import org.apache.poi.hdf.extractor.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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.extractor;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class Utils
|
||||
{
|
||||
|
||||
public static short convertBytesToShort(byte firstByte, byte secondByte)
|
||||
{
|
||||
return (short)convertBytesToInt((byte)0, (byte)0, firstByte, secondByte);
|
||||
}
|
||||
public static int convertBytesToInt(byte firstByte, byte secondByte,
|
||||
byte thirdByte, byte fourthByte)
|
||||
{
|
||||
int firstInt = 0xff & firstByte;
|
||||
int secondInt = 0xff & secondByte;
|
||||
int thirdInt = 0xff & thirdByte;
|
||||
int fourthInt = 0xff & fourthByte;
|
||||
|
||||
return (firstInt << 24) | (secondInt << 16) | (thirdInt << 8) | fourthInt;
|
||||
}
|
||||
public static short convertBytesToShort(byte[] array, int offset)
|
||||
{
|
||||
return convertBytesToShort(array[offset + 1], array[offset]);
|
||||
}
|
||||
public static int convertBytesToInt(byte[] array, int offset)
|
||||
{
|
||||
return convertBytesToInt(array[offset + 3], array[offset + 2], array[offset + 1], array[offset]);
|
||||
}
|
||||
public static int convertUnsignedByteToInt(byte b)
|
||||
{
|
||||
return (0xff & b);
|
||||
}
|
||||
public static char getUnicodeCharacter(byte[] array, int offset)
|
||||
{
|
||||
return (char)convertBytesToShort(array, offset);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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.extractor.data;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class DOP
|
||||
{
|
||||
|
||||
public boolean _fFacingPages;
|
||||
public int _fpc;
|
||||
public int _epc;
|
||||
public int _rncFtn;
|
||||
public int _nFtn;
|
||||
public int _rncEdn;
|
||||
public int _nEdn;
|
||||
|
||||
public DOP()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor.data;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class LFO
|
||||
{
|
||||
int _lsid;
|
||||
int _clfolvl;
|
||||
LFOLVL[] _levels;
|
||||
|
||||
public LFO()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor.data;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class LFOLVL
|
||||
{
|
||||
int _iStartAt;
|
||||
int _ilvl;
|
||||
boolean _fStartAt;
|
||||
boolean _fFormatting;
|
||||
LVL _override;
|
||||
|
||||
public LFOLVL()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor.data;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class LST
|
||||
{
|
||||
int _lsid;
|
||||
int _tplc;
|
||||
byte[] _rgistd = new byte[18];
|
||||
boolean _fSimpleList;
|
||||
LVL[] _levels;
|
||||
|
||||
public LST()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -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.extractor.data;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,221 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor.data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.poi.hdf.extractor.*;
|
||||
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class ListTables
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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.extractor.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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.extractor.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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor.util;
|
||||
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
public class NumberFormatter
|
||||
{
|
||||
private final static int ARABIC = 0;
|
||||
private final static int UPPER_ROMAN = 1;
|
||||
private final static int LOWER_ROMAN = 2;
|
||||
private final static int UPPER_LETTER = 3;
|
||||
private final static int LOWER_LETTER = 4;
|
||||
private final static int ORDINAL = 5;
|
||||
|
||||
private static String[] _arabic = new String[] {"1", "2", "3", "4", "5", "6",
|
||||
"7", "8", "9", "10", "11", "12",
|
||||
"13", "14", "15", "16", "17", "18",
|
||||
"19", "20", "21", "22", "23",
|
||||
"24", "25", "26", "27", "28",
|
||||
"29", "30", "31", "32", "33",
|
||||
"34", "35", "36", "37", "38",
|
||||
"39", "40", "41", "42", "43",
|
||||
"44", "45", "46", "47", "48",
|
||||
"49", "50", "51", "52", "53"};
|
||||
private static String[] _roman = new String[]{"i", "ii", "iii", "iv", "v", "vi",
|
||||
"vii", "viii", "ix", "x", "xi", "xii",
|
||||
"xiii","xiv", "xv", "xvi", "xvii",
|
||||
"xviii", "xix", "xx", "xxi", "xxii",
|
||||
"xxiii", "xxiv", "xxv", "xxvi",
|
||||
"xxvii", "xxviii", "xxix", "xxx",
|
||||
"xxxi", "xxxii", "xxxiii", "xxxiv",
|
||||
"xxxv", "xxxvi", "xxxvii", "xxxvii",
|
||||
"xxxviii", "xxxix", "xl", "xli", "xlii",
|
||||
"xliii", "xliv", "xlv", "xlvi", "xlvii",
|
||||
"xlviii", "xlix", "l"};
|
||||
private static String[] _letter = new String[]{"a", "b", "c", "d", "e", "f", "g",
|
||||
"h", "i", "j", "k", "l", "m", "n",
|
||||
"o", "p", "q", "r", "s", "t", "u",
|
||||
"v", "x", "y", "z"};
|
||||
public NumberFormatter()
|
||||
{
|
||||
}
|
||||
public static String getNumber(int num, int style)
|
||||
{
|
||||
switch(style)
|
||||
{
|
||||
case ARABIC:
|
||||
return _arabic[num - 1];
|
||||
case UPPER_ROMAN:
|
||||
return _roman[num-1].toUpperCase();
|
||||
case LOWER_ROMAN:
|
||||
return _roman[num-1];
|
||||
case UPPER_LETTER:
|
||||
return _letter[num-1].toUpperCase();
|
||||
case LOWER_LETTER:
|
||||
return _letter[num-1];
|
||||
case ORDINAL:
|
||||
return _arabic[num - 1];
|
||||
default:
|
||||
return _arabic[num - 1];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.extractor.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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/* ====================================================================
|
||||
* 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.extractor.util;
|
||||
|
||||
/**
|
||||
* Comment me
|
||||
*
|
||||
* @author Ryan Ackley
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.extractor.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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue