Ryan's patch applied. Thanks Ryan!
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07911038fe
commit
f22bb9f428
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
@ -55,9 +54,9 @@
|
|||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a utility class for handling little-endian numbers, which the 80x86
|
* a utility class for handling little-endian numbers, which the 80x86
|
||||||
@ -498,8 +497,7 @@ public class LittleEndian
|
|||||||
|
|
||||||
// return a zero-filled buffer
|
// return a zero-filled buffer
|
||||||
Arrays.fill(buffer, (byte) 0);
|
Arrays.fill(buffer, (byte) 0);
|
||||||
}
|
} else if (count != size)
|
||||||
else if (count != size)
|
|
||||||
{
|
{
|
||||||
throw new BufferUnderrunException();
|
throw new BufferUnderrunException();
|
||||||
}
|
}
|
||||||
@ -539,4 +537,34 @@ public class LittleEndian
|
|||||||
{
|
{
|
||||||
return ((b & 0x80) == 0 ? (int) b : (int) (b & (byte) 0x7f) + 0x80);
|
return ((b & 0x80) == 0 ? (int) b : (int) (b & (byte) 0x7f) + 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the unsigned value of a byte.
|
||||||
|
*
|
||||||
|
* @param data the byte array.
|
||||||
|
* @param offset a starting offset into the byte array.
|
||||||
|
*
|
||||||
|
* @return the unsigned value of the byte as a 32 bit integer
|
||||||
|
*
|
||||||
|
* @exception ArrayIndexOutOfBoundsException may be thrown
|
||||||
|
*/
|
||||||
|
public static int getUnsignedByte(final byte[] data, final int offset)
|
||||||
|
{
|
||||||
|
return (int) getNumber(data, offset, BYTE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the unsigned value of a byte.
|
||||||
|
*
|
||||||
|
* @param data the byte array
|
||||||
|
*
|
||||||
|
* @return the unsigned value of the byte as a 32 bit integer
|
||||||
|
*
|
||||||
|
* @exception ArrayIndexOutOfBoundsException may be thrown
|
||||||
|
*/
|
||||||
|
public static int getUnsignedByte(final byte[] data)
|
||||||
|
{
|
||||||
|
return getUnsignedByte(data, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,350 @@
|
|||||||
|
|
||||||
package org.apache.poi.hdf.model;
|
package org.apache.poi.hdf.model;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import org.apache.poi.hdf.model.hdftypes.*;
|
||||||
|
import org.apache.poi.hdf.model.util.*;
|
||||||
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
|
import org.apache.poi.poifs.filesystem.POIFSDocument;
|
||||||
|
import org.apache.poi.poifs.filesystem.DocumentEntry;
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Object Factory takes in a stream and creates the low level objects
|
* The Object Factory takes in a stream and creates the low level objects
|
||||||
* that represent the data.
|
* that represent the data.
|
||||||
* @author andy
|
* @author andy
|
||||||
*/
|
*/
|
||||||
public class HDFObjectFactory {
|
public class HDFObjectFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
/** OLE stuff*/
|
||||||
|
private POIFSFileSystem _filesystem;
|
||||||
|
/** The FIB*/
|
||||||
|
private FileInformationBlock _fib;
|
||||||
|
/** The DOP*/
|
||||||
|
private DocumentProperties _dop;
|
||||||
|
/**the StyleSheet*/
|
||||||
|
private StyleSheet _styleSheet;
|
||||||
|
/**list info */
|
||||||
|
private ListTables _listTables;
|
||||||
|
/** Font info */
|
||||||
|
private FontTable _fonts;
|
||||||
|
|
||||||
|
/** text pieces */
|
||||||
|
BTreeSet _text = new BTreeSet();
|
||||||
|
/** document sections */
|
||||||
|
BTreeSet _sections = new BTreeSet();
|
||||||
|
/** document paragraphs */
|
||||||
|
BTreeSet _paragraphs = new BTreeSet();
|
||||||
|
/** document character runs */
|
||||||
|
BTreeSet _characterRuns = new BTreeSet();
|
||||||
|
|
||||||
|
/** main document stream buffer*/
|
||||||
|
byte[] _mainDocument;
|
||||||
|
/** table stream buffer*/
|
||||||
|
byte[] _tableBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Creates a new instance of HDFObjectFactory
|
||||||
|
*
|
||||||
|
* @param istream The InputStream that is the Word document
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public HDFObjectFactory(InputStream istream) throws IOException
|
||||||
|
{
|
||||||
|
//do Ole stuff
|
||||||
|
_filesystem = new POIFSFileSystem(istream);
|
||||||
|
|
||||||
|
DocumentEntry headerProps =
|
||||||
|
(DocumentEntry)_filesystem.getRoot().getEntry("WordDocument");
|
||||||
|
|
||||||
|
_mainDocument = new byte[headerProps.getSize()];
|
||||||
|
_filesystem.createDocumentInputStream("WordDocument").read(_mainDocument);
|
||||||
|
|
||||||
|
_fib = new FileInformationBlock(_mainDocument);
|
||||||
|
|
||||||
|
initTableStream();
|
||||||
|
initTextPieces();
|
||||||
|
initFormattingProperties();
|
||||||
|
|
||||||
|
istream.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initializes the table stream
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private void initTableStream() throws IOException
|
||||||
|
{
|
||||||
|
String tablename = null;
|
||||||
|
if(_fib.useTable1())
|
||||||
|
{
|
||||||
|
tablename="1Table";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tablename="0Table";
|
||||||
|
}
|
||||||
|
|
||||||
|
DocumentEntry tableEntry = (DocumentEntry)_filesystem.getRoot().getEntry(tablename);
|
||||||
|
|
||||||
|
//load the table stream into a buffer
|
||||||
|
int size = tableEntry.getSize();
|
||||||
|
_tableBuffer = new byte[size];
|
||||||
|
_filesystem.createDocumentInputStream(tablename).read(_tableBuffer);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initializes the text pieces. Text is divided into pieces because some
|
||||||
|
* "pieces" may only contain unicode characters.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private void initTextPieces() throws IOException
|
||||||
|
{
|
||||||
|
int pos = _fib.getComplexOffset();
|
||||||
|
|
||||||
|
//skips through the prms before we reach the piece table. These contain data
|
||||||
|
//for actual fast saved files
|
||||||
|
while (_tableBuffer[pos] == 1)
|
||||||
|
{
|
||||||
|
pos++;
|
||||||
|
int skip = LittleEndian.getShort(_tableBuffer, pos);
|
||||||
|
pos += 2 + skip;
|
||||||
|
}
|
||||||
|
if(_tableBuffer[pos] != 2)
|
||||||
|
{
|
||||||
|
throw new IOException("The text piece table is corrupted");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//parse out the text pieces
|
||||||
|
int pieceTableSize = LittleEndian.getInt(_tableBuffer, ++pos);
|
||||||
|
pos += 4;
|
||||||
|
int pieces = (pieceTableSize - 4) / 12;
|
||||||
|
for (int x = 0; x < pieces; x++)
|
||||||
|
{
|
||||||
|
int filePos = LittleEndian.getInt(_tableBuffer, pos + ((pieces + 1) * 4) + (x * 8) + 2);
|
||||||
|
boolean unicode = false;
|
||||||
|
if ((filePos & 0x40000000) == 0)
|
||||||
|
{
|
||||||
|
unicode = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unicode = false;
|
||||||
|
filePos &= ~(0x40000000);//gives me FC in doc stream
|
||||||
|
filePos /= 2;
|
||||||
|
}
|
||||||
|
int totLength = LittleEndian.getInt(_tableBuffer, pos + (x + 1) * 4) -
|
||||||
|
LittleEndian.getInt(_tableBuffer, pos + (x * 4));
|
||||||
|
|
||||||
|
TextPiece piece = new TextPiece(filePos, totLength, unicode);
|
||||||
|
_text.add(piece);
|
||||||
|
|
||||||
/** Creates a new instance of HDFObjectFactory */
|
}
|
||||||
public HDFObjectFactory() {
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* initializes all of the formatting properties for a Word Document
|
||||||
|
*/
|
||||||
|
private void initFormattingProperties()
|
||||||
|
{
|
||||||
|
createStyleSheet();
|
||||||
|
createListTables();
|
||||||
|
createFontTable();
|
||||||
|
|
||||||
|
initDocumentProperties();
|
||||||
|
initSectionProperties();
|
||||||
|
initCharacterProperties();
|
||||||
|
initParagraphProperties();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* initializes the CharacterProperties BTree
|
||||||
|
*/
|
||||||
|
private void initCharacterProperties()
|
||||||
|
{
|
||||||
|
int charOffset = _fib.getChpBinTableOffset();
|
||||||
|
int charPlcSize = _fib.getChpBinTableSize();
|
||||||
|
|
||||||
|
int arraySize = (charPlcSize - 4)/8;
|
||||||
|
|
||||||
|
//first we must go through the bin table and find the fkps
|
||||||
|
for(int x = 0; x < arraySize; x++)
|
||||||
|
{
|
||||||
|
|
||||||
|
//get page number(has nothing to do with document page)
|
||||||
|
//containing the chpx for the paragraph
|
||||||
|
int PN = LittleEndian.getInt(_tableBuffer, charOffset + (4 * (arraySize + 1) + (4 * x)));
|
||||||
|
|
||||||
|
byte[] fkp = new byte[512];
|
||||||
|
System.arraycopy(_mainDocument, (PN * 512), fkp, 0, 512);
|
||||||
|
//take each fkp and get the chpxs
|
||||||
|
int crun = LittleEndian.getUnsignedByte(fkp, 511);
|
||||||
|
for(int y = 0; y < crun; y++)
|
||||||
|
{
|
||||||
|
//get the beginning fc of each paragraph text run
|
||||||
|
int fcStart = LittleEndian.getInt(fkp, y * 4);
|
||||||
|
int fcEnd = LittleEndian.getInt(fkp, (y+1) * 4);
|
||||||
|
//get the offset in fkp of the papx for this paragraph
|
||||||
|
int chpxOffset = 2 * LittleEndian.getUnsignedByte(fkp, ((crun + 1) * 4) + y);
|
||||||
|
|
||||||
|
//optimization if offset == 0 use "Normal" style
|
||||||
|
if(chpxOffset == 0)
|
||||||
|
|
||||||
|
{
|
||||||
|
_characterRuns.add(new ChpxNode(fcStart, fcEnd, new byte[0]));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = LittleEndian.getUnsignedByte(fkp, chpxOffset);
|
||||||
|
|
||||||
|
byte[] chpx = new byte[size];
|
||||||
|
System.arraycopy(fkp, ++chpxOffset, chpx, 0, size);
|
||||||
|
//_papTable.put(new Integer(fcStart), papx);
|
||||||
|
_characterRuns.add(new ChpxNode(fcStart, fcEnd, chpx));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* intializes the Paragraph Properties BTree
|
||||||
|
*/
|
||||||
|
private void initParagraphProperties()
|
||||||
|
{
|
||||||
|
//find paragraphs
|
||||||
|
int parOffset = _fib.getPapBinTableOffset();
|
||||||
|
int parPlcSize = _fib.getPapBinTableSize();
|
||||||
|
|
||||||
|
int arraySize = (parPlcSize - 4)/8;
|
||||||
|
//first we must go through the bin table and find the fkps
|
||||||
|
for(int x = 0; x < arraySize; x++)
|
||||||
|
{
|
||||||
|
int PN = LittleEndian.getInt(_tableBuffer, parOffset + (4 * (arraySize + 1) + (4 * x)));
|
||||||
|
|
||||||
|
byte[] fkp = new byte[512];
|
||||||
|
System.arraycopy(_mainDocument, (PN * 512), fkp, 0, 512);
|
||||||
|
//take each fkp and get the paps
|
||||||
|
int crun = LittleEndian.getUnsignedByte(fkp, 511);
|
||||||
|
for(int y = 0; y < crun; y++)
|
||||||
|
{
|
||||||
|
//get the beginning fc of each paragraph text run
|
||||||
|
int fcStart = LittleEndian.getInt(fkp, y * 4);
|
||||||
|
int fcEnd = LittleEndian.getInt(fkp, (y+1) * 4);
|
||||||
|
//get the offset in fkp of the papx for this paragraph
|
||||||
|
int papxOffset = 2 * LittleEndian.getUnsignedByte(fkp, ((crun + 1) * 4) + (y * 13));
|
||||||
|
int size = 2 * LittleEndian.getUnsignedByte(fkp, papxOffset);
|
||||||
|
if(size == 0)
|
||||||
|
{
|
||||||
|
size = 2 * LittleEndian.getUnsignedByte(fkp, ++papxOffset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] papx = new byte[size];
|
||||||
|
System.arraycopy(fkp, ++papxOffset, papx, 0, size);
|
||||||
|
_paragraphs.add(new PapxNode(fcStart, fcEnd, papx));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* initializes the SectionProperties BTree
|
||||||
|
*/
|
||||||
|
private void initSectionProperties()
|
||||||
|
{
|
||||||
|
//find sections
|
||||||
|
int fcMin = _fib.getFirstCharOffset();
|
||||||
|
int plcfsedFC = _fib.getSectionDescriptorOffset();
|
||||||
|
int plcfsedSize = _fib.getSectionDescriptorSize();
|
||||||
|
byte[] plcfsed = new byte[plcfsedSize];
|
||||||
|
System.arraycopy(_tableBuffer, plcfsedFC, plcfsed, 0, plcfsedSize);
|
||||||
|
|
||||||
|
int arraySize = (plcfsedSize - 4)/16;
|
||||||
|
|
||||||
|
|
||||||
|
for(int x = 0; x < arraySize; x++)
|
||||||
|
{
|
||||||
|
int sectionStart = LittleEndian.getInt(plcfsed, x * 4) + fcMin;
|
||||||
|
int sectionEnd = LittleEndian.getInt(plcfsed, (x+1) * 4) + fcMin;
|
||||||
|
int sepxStart = LittleEndian.getInt(plcfsed, 4 * (arraySize + 1) + (x * 12) + 2);
|
||||||
|
int sepxSize = LittleEndian.getShort(_mainDocument, sepxStart);
|
||||||
|
byte[] sepx = new byte[sepxSize];
|
||||||
|
System.arraycopy(_mainDocument, sepxStart + 2, sepx, 0, sepxSize);
|
||||||
|
SepxNode node = new SepxNode(x + 1, sectionStart, sectionEnd, sepx);
|
||||||
|
_sections.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initializes the DocumentProperties object unique to this document.
|
||||||
|
*/
|
||||||
|
private void initDocumentProperties()
|
||||||
|
{
|
||||||
|
int pos = _fib.getDOPOffset();
|
||||||
|
int size = _fib.getDOPSize();
|
||||||
|
byte[] dopArray = new byte[size];
|
||||||
|
|
||||||
|
System.arraycopy(_tableBuffer, pos, dopArray, 0, size);
|
||||||
|
_dop = new DocumentProperties(dopArray);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Uncompresses the StyleSheet from file into memory.
|
||||||
|
*/
|
||||||
|
private void createStyleSheet()
|
||||||
|
{
|
||||||
|
int stshIndex = _fib.getStshOffset();
|
||||||
|
int stshSize = _fib.getStshSize();
|
||||||
|
byte[] stsh = new byte[stshSize];
|
||||||
|
System.arraycopy(_tableBuffer, stshIndex, stsh, 0, stshSize);
|
||||||
|
|
||||||
|
_styleSheet = new StyleSheet(stsh);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initializes the list tables for this document
|
||||||
|
*/
|
||||||
|
private void createListTables()
|
||||||
|
{
|
||||||
|
int lfoOffset = _fib.getLFOOffset();
|
||||||
|
int lfoSize = _fib.getLFOSize();
|
||||||
|
byte[] plflfo = new byte[lfoSize];
|
||||||
|
|
||||||
|
System.arraycopy(_tableBuffer, lfoOffset, plflfo, 0, lfoSize);
|
||||||
|
|
||||||
|
int lstOffset = _fib.getLSTOffset();
|
||||||
|
int lstSize = lstOffset;
|
||||||
|
//not sure if this is a mistake or what. I vaguely remember a trick like
|
||||||
|
//this
|
||||||
|
//int lstSize = LittleEndian.getInt(_header, 0x2e2);
|
||||||
|
if(lstOffset > 0 && lstSize > 0)
|
||||||
|
{
|
||||||
|
lstSize = lfoOffset - lstOffset;
|
||||||
|
byte[] plcflst = new byte[lstSize];
|
||||||
|
System.arraycopy(_tableBuffer, lstOffset, plcflst, 0, lstSize);
|
||||||
|
_listTables = new ListTables(plcflst, plflfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initializes this document's FontTable;
|
||||||
|
*/
|
||||||
|
private void createFontTable()
|
||||||
|
{
|
||||||
|
int fontTableIndex = _fib.getFontsOffset();
|
||||||
|
int fontTableSize = _fib.getFontsSize();
|
||||||
|
byte[] fontTable = new byte[fontTableSize];
|
||||||
|
System.arraycopy(_tableBuffer, fontTableIndex, fontTable, 0, fontTableSize);
|
||||||
|
_fonts = new FontTable(fontTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,216 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CharacterProperties implements Cloneable, HDFType
|
||||||
|
{
|
||||||
|
public boolean _bold;
|
||||||
|
public boolean _italic;
|
||||||
|
public boolean _fRMarkDel;
|
||||||
|
public boolean _fOutline;
|
||||||
|
public boolean _fSmallCaps;
|
||||||
|
public boolean _fCaps;
|
||||||
|
public boolean _fVanish;
|
||||||
|
public boolean _fRMark;
|
||||||
|
public boolean _fSpec;
|
||||||
|
public boolean _fStrike;
|
||||||
|
public boolean _fObj;
|
||||||
|
public boolean _fShadow;
|
||||||
|
public boolean _fLowerCase;
|
||||||
|
public boolean _fData;
|
||||||
|
public boolean _fOle2;
|
||||||
|
public boolean _fEmboss;
|
||||||
|
public boolean _fImprint;
|
||||||
|
public boolean _fDStrike;
|
||||||
|
|
||||||
|
public short _ftcAscii;
|
||||||
|
public short _ftcFE;
|
||||||
|
public short _ftcOther;
|
||||||
|
public short _ftc;
|
||||||
|
public int _hps;//font size in half points
|
||||||
|
public int _dxaSpace;//space following each character in the run expressed in twip units
|
||||||
|
public byte _iss;//superscript/subscript indices 0 means no super/subscripting 1 means text in run is superscripted 2 means text in run is subscripted
|
||||||
|
public byte _kul;//underline code see spec
|
||||||
|
public byte _ico;//color of text see spec
|
||||||
|
public short _hpsPos;//super/subscript position in half points; positive means text is raised; negative means text is lowered
|
||||||
|
public short _lidDefault;//language for non-Far East text
|
||||||
|
public short _lidFE;//language for Far East text
|
||||||
|
public byte _idctHint;
|
||||||
|
public int _wCharScale;
|
||||||
|
public short _chse;
|
||||||
|
|
||||||
|
public int _specialFC;//varies depending on whether this is a special char
|
||||||
|
public short _ibstRMark;//index to author IDs stored in hsttbfRMark. used when text in run was newly typed when revision marking was enabled
|
||||||
|
public short _ibstRMarkDel;//index to author IDs stored in hsttbfRMark. used when text in run was newly typed when revision marking was enabled
|
||||||
|
public int[] _dttmRMark = new int[2];//Date/time at which this run of text was
|
||||||
|
public int[] _dttmRMarkDel = new int[2];//entered/modified by the author. (Only
|
||||||
|
//recorded when revision marking is on.)Date/time at which this run of text was deleted by the author. (Only recorded when revision marking is on.)
|
||||||
|
public int _istd;
|
||||||
|
public int _baseIstd = -1;
|
||||||
|
public int _fcPic;
|
||||||
|
public short _ftcSym;// see spec
|
||||||
|
public short _xchSym;//see spec
|
||||||
|
public byte _ysr;//hyphenation rules
|
||||||
|
public byte _chYsr;//used for hyphenation see spec
|
||||||
|
public int _hpsKern;//kerning distance for characters in run recorded in half points
|
||||||
|
public int _fcObj;
|
||||||
|
public byte _icoHighlight;//highlight color
|
||||||
|
public boolean _fChsDiff;
|
||||||
|
public boolean _highlighted;//when true characters are highlighted with color specified by chp.icoHighlight
|
||||||
|
public boolean _fPropMark;//when true, properties have been changed with revision marking on
|
||||||
|
public short _ibstPropRMark;//index to author IDs stored in hsttbfRMark. used when properties have been changed when revision marking was enabled
|
||||||
|
public int _dttmPropRMark;//Date/time at which properties of this were changed for this run of text by the author
|
||||||
|
public byte _sfxtText;//text animation see spec
|
||||||
|
public boolean _fDispFldRMark;//see spec
|
||||||
|
public short _ibstDispFldRMark;//Index to author IDs stored in hsttbfRMark. used when ListNum field numbering has been changed when revision marking was enabled
|
||||||
|
public int _dttmDispFldRMark;//The date for the ListNum field number change
|
||||||
|
public byte[] _xstDispFldRMark = new byte[32];//The string value of the ListNum field when revision mark tracking began
|
||||||
|
public short _shd;//shading
|
||||||
|
public short[] _brc = new short[2];//border
|
||||||
|
public short _paddingStart = 0;
|
||||||
|
public short _paddingEnd = 0;
|
||||||
|
|
||||||
|
public CharacterProperties()
|
||||||
|
{
|
||||||
|
_istd = 10;
|
||||||
|
_hps = 20;
|
||||||
|
_lidDefault = 0x0400;
|
||||||
|
_lidFE = 0x0400;
|
||||||
|
|
||||||
|
}
|
||||||
|
public void copy(CharacterProperties toCopy)
|
||||||
|
{
|
||||||
|
_bold = toCopy._bold;
|
||||||
|
_italic = toCopy._italic;
|
||||||
|
_fRMarkDel = toCopy._fRMarkDel;
|
||||||
|
_fOutline = toCopy._fOutline;
|
||||||
|
_fSmallCaps = toCopy._fSmallCaps;
|
||||||
|
_fCaps = toCopy._fCaps;
|
||||||
|
_fVanish = toCopy._fVanish;
|
||||||
|
_fRMark = toCopy._fRMark;
|
||||||
|
_fSpec = toCopy._fSpec;
|
||||||
|
_fStrike = toCopy._fStrike;
|
||||||
|
_fObj = toCopy._fObj;
|
||||||
|
_fShadow = toCopy._fShadow;
|
||||||
|
_fLowerCase = toCopy._fLowerCase;
|
||||||
|
_fData = toCopy._fData;
|
||||||
|
_fOle2 = toCopy._fOle2;
|
||||||
|
_fEmboss = toCopy._fEmboss;
|
||||||
|
_fImprint = toCopy._fImprint;
|
||||||
|
_fDStrike = toCopy._fDStrike;
|
||||||
|
|
||||||
|
_ftcAscii = toCopy._ftcAscii;
|
||||||
|
_ftcFE = toCopy._ftcFE;
|
||||||
|
_ftcOther = toCopy._ftcOther;
|
||||||
|
_ftc = toCopy._ftc;
|
||||||
|
_hps = toCopy._hps;
|
||||||
|
_dxaSpace = toCopy._dxaSpace;
|
||||||
|
_iss = toCopy._iss;
|
||||||
|
_kul = toCopy._kul;
|
||||||
|
_ico = toCopy._ico;
|
||||||
|
_hpsPos = toCopy._hpsPos;
|
||||||
|
_lidDefault = toCopy._lidDefault;
|
||||||
|
_lidFE = toCopy._lidFE;
|
||||||
|
_idctHint = toCopy._idctHint;
|
||||||
|
_wCharScale = toCopy._wCharScale;
|
||||||
|
_chse = toCopy._chse;
|
||||||
|
|
||||||
|
_specialFC = toCopy._specialFC;
|
||||||
|
_ibstRMark = toCopy._ibstRMark;
|
||||||
|
_ibstRMarkDel = toCopy._ibstRMarkDel;
|
||||||
|
_dttmRMark = toCopy._dttmRMark;
|
||||||
|
_dttmRMarkDel = toCopy._dttmRMarkDel;
|
||||||
|
|
||||||
|
_istd = toCopy._istd;
|
||||||
|
_baseIstd = toCopy._baseIstd;
|
||||||
|
_fcPic = toCopy._fcPic;
|
||||||
|
_ftcSym = toCopy._ftcSym;
|
||||||
|
_xchSym = toCopy._xchSym;
|
||||||
|
_ysr = toCopy._ysr;
|
||||||
|
_chYsr = toCopy._chYsr;
|
||||||
|
_hpsKern = toCopy._hpsKern;
|
||||||
|
_fcObj = toCopy._fcObj;
|
||||||
|
_icoHighlight = toCopy._icoHighlight;
|
||||||
|
_fChsDiff = toCopy._fChsDiff;
|
||||||
|
_highlighted = toCopy._highlighted;
|
||||||
|
_fPropMark = toCopy._fPropMark;
|
||||||
|
_ibstPropRMark = toCopy._ibstPropRMark;
|
||||||
|
_dttmPropRMark = toCopy._dttmPropRMark;
|
||||||
|
_sfxtText = toCopy._sfxtText;
|
||||||
|
_fDispFldRMark = toCopy._fDispFldRMark;
|
||||||
|
_ibstDispFldRMark = toCopy._ibstDispFldRMark;
|
||||||
|
_dttmDispFldRMark = toCopy._dttmDispFldRMark;
|
||||||
|
_xstDispFldRMark = toCopy._xstDispFldRMark;
|
||||||
|
_shd = toCopy._shd;
|
||||||
|
_brc = toCopy._brc;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() throws CloneNotSupportedException
|
||||||
|
{
|
||||||
|
CharacterProperties clone = (CharacterProperties)super.clone();
|
||||||
|
clone._brc = new short[2];
|
||||||
|
System.arraycopy(_brc, 0, clone._brc, 0, 2);
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DocumentProperties implements HDFType
|
||||||
|
{
|
||||||
|
|
||||||
|
public boolean _fFacingPages;
|
||||||
|
public int _fpc;
|
||||||
|
public int _epc;
|
||||||
|
public int _rncFtn;
|
||||||
|
public int _nFtn;
|
||||||
|
public int _rncEdn;
|
||||||
|
public int _nEdn;
|
||||||
|
|
||||||
|
public DocumentProperties(byte[] dopArray)
|
||||||
|
{
|
||||||
|
_fFacingPages = (dopArray[0] & 0x1) > 0;
|
||||||
|
_fpc = (dopArray[0] & 0x60) >> 5;
|
||||||
|
|
||||||
|
short num = LittleEndian.getShort(dopArray, 2);
|
||||||
|
_rncFtn = (num & 0x3);
|
||||||
|
_nFtn = (short)(num & 0xfffc) >> 2;
|
||||||
|
num = LittleEndian.getShort(dopArray, 52);
|
||||||
|
_rncEdn = num & 0x3;
|
||||||
|
_nEdn = (short)(num & 0xfffc) >> 2;
|
||||||
|
num = LittleEndian.getShort(dopArray, 54);
|
||||||
|
_epc = num & 0x3;
|
||||||
|
}
|
||||||
|
}
|
@ -7,12 +7,14 @@
|
|||||||
package org.apache.poi.hdf.model.hdftypes;
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author andy
|
* @author andy
|
||||||
*/
|
*/
|
||||||
public class FileInformationBlock implements HDFType {
|
public class FileInformationBlock implements HDFType
|
||||||
|
{
|
||||||
|
|
||||||
private short field_1_id;
|
private short field_1_id;
|
||||||
private short field_2_version; // 101 = Word 6.0 +
|
private short field_2_version; // 101 = Word 6.0 +
|
||||||
@ -25,7 +27,7 @@ public class FileInformationBlock implements HDFType {
|
|||||||
private static final BitField glossary = new BitField(0x0002);
|
private static final BitField glossary = new BitField(0x0002);
|
||||||
private static final BitField quicksave = new BitField(0x0004);
|
private static final BitField quicksave = new BitField(0x0004);
|
||||||
private static final BitField haspictr = new BitField(0x0008);
|
private static final BitField haspictr = new BitField(0x0008);
|
||||||
private static final BitField nquicksaves = new BitField(0x000F);
|
private static final BitField nquicksaves = new BitField(0x00F0);
|
||||||
private static final BitField encrypted = new BitField(0x0100);
|
private static final BitField encrypted = new BitField(0x0100);
|
||||||
private static final BitField tabletype = new BitField(0x0200);
|
private static final BitField tabletype = new BitField(0x0200);
|
||||||
private static final BitField readonly = new BitField(0x0400);
|
private static final BitField readonly = new BitField(0x0400);
|
||||||
@ -79,7 +81,9 @@ public class FileInformationBlock implements HDFType {
|
|||||||
|
|
||||||
private int field_32_creator_build_date;
|
private int field_32_creator_build_date;
|
||||||
private int field_33_revisor_build_date;
|
private int field_33_revisor_build_date;
|
||||||
|
/** length of main document text stream*/
|
||||||
private int field_34_main_streamlen;
|
private int field_34_main_streamlen;
|
||||||
|
/**length of footnote subdocument text stream*/
|
||||||
private int field_35_footnote_streamlen;
|
private int field_35_footnote_streamlen;
|
||||||
private int field_36_header_streamlen;
|
private int field_36_header_streamlen;
|
||||||
private int field_37_macro_streamlen;
|
private int field_37_macro_streamlen;
|
||||||
@ -87,9 +91,11 @@ public class FileInformationBlock implements HDFType {
|
|||||||
private int field_39_endnote_streamlen;
|
private int field_39_endnote_streamlen;
|
||||||
private int field_40_textbox_streamlen;
|
private int field_40_textbox_streamlen;
|
||||||
private int field_41_headbox_streamlen;
|
private int field_41_headbox_streamlen;
|
||||||
|
/**offset in table stream of character property bin table*/
|
||||||
private int field_42_pointer_to_plc_list_chp; //rename me!
|
private int field_42_pointer_to_plc_list_chp; //rename me!
|
||||||
private int field_43_first_chp; //rename me
|
private int field_43_first_chp; //rename me
|
||||||
private int field_44_count_chps; //rename me
|
private int field_44_count_chps; //rename me
|
||||||
|
/**offset in table stream of paragraph property bin */
|
||||||
private int field_45_pointer_to_plc_list_pap; //rename me.
|
private int field_45_pointer_to_plc_list_pap; //rename me.
|
||||||
private int field_46_first_pap; //rename me
|
private int field_46_first_pap; //rename me
|
||||||
private int field_47_count_paps; //rename me
|
private int field_47_count_paps; //rename me
|
||||||
@ -99,7 +105,81 @@ public class FileInformationBlock implements HDFType {
|
|||||||
|
|
||||||
private int field_51_unknown;
|
private int field_51_unknown;
|
||||||
private int field_52_unknown;
|
private int field_52_unknown;
|
||||||
|
//not sure about this array.
|
||||||
|
private short field_53_fc_lcb_array_size;
|
||||||
|
private int field_54_original_stylesheet_offset;
|
||||||
|
private int field_55_original_stylesheet_size;
|
||||||
|
private int field_56_stylesheet_offset;
|
||||||
|
private int field_57_stylesheet_size;
|
||||||
|
private int field_58_footnote_ref_offset;
|
||||||
|
private int field_59_footnote_ref_size;
|
||||||
|
private int field_60_footnote_plc_offset;
|
||||||
|
private int field_61_footnote_plc_size;
|
||||||
|
private int field_62_annotation_ref_offset;
|
||||||
|
private int field_63_annotation_ref_size;
|
||||||
|
private int field_64_annotation_plc_offset;
|
||||||
|
private int field_65_annotation_plc_size;
|
||||||
|
/** offset in table stream of section descriptor SED PLC*/
|
||||||
|
private int field_66_section_plc_offset;
|
||||||
|
private int field_67_section_plc_size;
|
||||||
|
private int field_68_unused;
|
||||||
|
private int field_69_unused;
|
||||||
|
private int field_70_pheplc_offset;
|
||||||
|
private int field_71_pheplc_size;
|
||||||
|
private int field_72_glossaryST_offset;
|
||||||
|
private int field_73_glossaryST_size;
|
||||||
|
private int field_74_glossaryPLC_offset;
|
||||||
|
private int field_75_glossaryPLC_size;
|
||||||
|
private int field_76_headerPLC_offset;
|
||||||
|
private int field_77_headerPLC_size;
|
||||||
|
private int field_78_chp_bin_table_offset;
|
||||||
|
private int field_79_chp_bin_table_size;
|
||||||
|
private int field_80_pap_bin_table_offset;
|
||||||
|
private int field_81_pap_bin_table_size;
|
||||||
|
private int field_82_sea_plc_offset;
|
||||||
|
private int field_83_sea_plc_size;
|
||||||
|
private int field_84_fonts_offset;
|
||||||
|
private int field_85_fonts_size;
|
||||||
|
private int field_86_main_fields_offset;
|
||||||
|
private int field_87_main_fields_size;
|
||||||
|
private int field_88_header_fields_offset;
|
||||||
|
private int field_89_header_fields_size;
|
||||||
|
private int field_90_footnote_fields_offset;
|
||||||
|
private int field_91_footnote_fields_size;
|
||||||
|
private int field_92_ann_fields_offset;
|
||||||
|
private int field_93_ann_fields_size;
|
||||||
|
private int field_94_unused;
|
||||||
|
private int field_95_unused;
|
||||||
|
private int field_96_bookmark_names_offset;
|
||||||
|
private int field_97_bookmark_names_size;
|
||||||
|
private int field_98_bookmark_offsets_offset;
|
||||||
|
private int field_99_bookmark_offsets_size;
|
||||||
|
private int field_100_macros_offset;
|
||||||
|
private int field_101_macros_size;
|
||||||
|
private int field_102_unused;
|
||||||
|
private int field_103_unused;
|
||||||
|
private int field_104_unused;
|
||||||
|
private int field_105_unused;
|
||||||
|
private int field_106_printer_offset;
|
||||||
|
private int field_107_printer_size;
|
||||||
|
private int field_108_printer_portrait_offset;
|
||||||
|
private int field_109_printer_portrait_size;
|
||||||
|
private int field_110_printer_landscape_offset;
|
||||||
|
private int field_111_printer_landscape_size;
|
||||||
|
private int field_112_wss_offset;
|
||||||
|
private int field_113_wss_size;
|
||||||
|
private int field_114_DOP_offset;
|
||||||
|
private int field_115_DOP_size;
|
||||||
|
private int field_116_sttbfassoc_offset;
|
||||||
|
private int field_117_sttbfassoc_size;
|
||||||
|
/**offset in table stream of beginning of information for complex files.
|
||||||
|
* Also, this is the beginning of the Text piece table*/
|
||||||
|
private int field_118_textPieceTable_offset;
|
||||||
|
private int field_119_textPieceTable_size;
|
||||||
|
private int field_199_list_format_offset;
|
||||||
|
private int field_200_list_format_size;
|
||||||
|
private int field_201_list_format_override_offset;
|
||||||
|
private int field_202_list_format_override_size;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -107,8 +187,122 @@ public class FileInformationBlock implements HDFType {
|
|||||||
|
|
||||||
|
|
||||||
/** Creates a new instance of FileInformationBlock */
|
/** Creates a new instance of FileInformationBlock */
|
||||||
public FileInformationBlock() {
|
public FileInformationBlock(byte[] mainDocument)
|
||||||
}
|
{
|
||||||
|
field_1_id = LittleEndian.getShort(mainDocument, 0);
|
||||||
|
field_2_version = LittleEndian.getShort(mainDocument, 0x2); // 101 = Word 6.0 +
|
||||||
|
field_3_product_version = LittleEndian.getShort(mainDocument, 0x4);
|
||||||
|
field_4_language_stamp = LittleEndian.getShort(mainDocument, 0x6);
|
||||||
|
field_5_unknown = LittleEndian.getShort(mainDocument, 0x8);
|
||||||
|
field_6_options = LittleEndian.getShort(mainDocument, 0xa);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
field_13_offset_first_char = LittleEndian.getInt(mainDocument, 0x18);
|
||||||
|
field_34_main_streamlen = LittleEndian.getInt(mainDocument, 0x4c);
|
||||||
|
field_35_footnote_streamlen = LittleEndian.getInt(mainDocument, 0x50);
|
||||||
|
|
||||||
|
field_56_stylesheet_offset = LittleEndian.getInt(mainDocument, 0xa2);
|
||||||
|
field_57_stylesheet_size = LittleEndian.getInt(mainDocument, 0xa6);
|
||||||
|
field_66_section_plc_offset = LittleEndian.getInt(mainDocument, 0xca);
|
||||||
|
field_67_section_plc_size = LittleEndian.getInt(mainDocument, 0xce);
|
||||||
|
|
||||||
|
field_78_chp_bin_table_offset = LittleEndian.getInt(mainDocument, 0xfa);
|
||||||
|
field_79_chp_bin_table_size = LittleEndian.getInt(mainDocument, 0xfe);
|
||||||
|
field_80_pap_bin_table_offset = LittleEndian.getInt(mainDocument, 0x102);
|
||||||
|
field_81_pap_bin_table_size = LittleEndian.getInt(mainDocument, 0x106);
|
||||||
|
|
||||||
|
field_84_fonts_offset = LittleEndian.getInt(mainDocument, 0x112);
|
||||||
|
field_85_fonts_size = LittleEndian.getInt(mainDocument, 0x116);
|
||||||
|
|
||||||
|
field_114_DOP_offset = LittleEndian.getInt(mainDocument, 0x192);
|
||||||
|
field_115_DOP_size = LittleEndian.getInt(mainDocument, 0x196);
|
||||||
|
field_118_textPieceTable_offset = LittleEndian.getInt(mainDocument, 0x1a2);
|
||||||
|
|
||||||
|
field_199_list_format_offset = LittleEndian.getInt(mainDocument, 0x2e2);
|
||||||
|
field_200_list_format_size = LittleEndian.getInt(mainDocument, 0x2e6);
|
||||||
|
field_201_list_format_override_offset = LittleEndian.getInt(mainDocument, 0x2ea);
|
||||||
|
field_202_list_format_override_size= LittleEndian.getInt(mainDocument, 0x2ee);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean useTable1()
|
||||||
|
{
|
||||||
|
return tabletype.setShort(field_6_options) > 0;
|
||||||
|
}
|
||||||
|
public int getFirstCharOffset()
|
||||||
|
{
|
||||||
|
return field_13_offset_first_char;
|
||||||
|
}
|
||||||
|
public int getStshOffset()
|
||||||
|
{
|
||||||
|
return field_56_stylesheet_offset;
|
||||||
|
}
|
||||||
|
public int getStshSize()
|
||||||
|
{
|
||||||
|
return field_57_stylesheet_size;
|
||||||
|
}
|
||||||
|
public int getSectionDescriptorOffset()
|
||||||
|
{
|
||||||
|
return field_66_section_plc_offset;
|
||||||
|
}
|
||||||
|
public int getSectionDescriptorSize()
|
||||||
|
{
|
||||||
|
return field_67_section_plc_size;
|
||||||
|
}
|
||||||
|
public int getChpBinTableOffset()
|
||||||
|
{
|
||||||
|
return field_78_chp_bin_table_offset;
|
||||||
|
}
|
||||||
|
public int getChpBinTableSize()
|
||||||
|
{
|
||||||
|
return field_79_chp_bin_table_size;
|
||||||
|
}
|
||||||
|
public int getPapBinTableOffset()
|
||||||
|
{
|
||||||
|
return field_80_pap_bin_table_offset;
|
||||||
|
}
|
||||||
|
public int getPapBinTableSize()
|
||||||
|
{
|
||||||
|
return field_81_pap_bin_table_size;
|
||||||
|
}
|
||||||
|
public int getFontsOffset()
|
||||||
|
{
|
||||||
|
return field_84_fonts_offset;
|
||||||
|
}
|
||||||
|
public int getFontsSize()
|
||||||
|
{
|
||||||
|
return field_85_fonts_size;
|
||||||
|
}
|
||||||
|
public int getDOPOffset()
|
||||||
|
{
|
||||||
|
return field_114_DOP_offset;
|
||||||
|
}
|
||||||
|
public int getDOPSize()
|
||||||
|
{
|
||||||
|
return field_115_DOP_size;
|
||||||
|
}
|
||||||
|
public int getComplexOffset()
|
||||||
|
{
|
||||||
|
return field_118_textPieceTable_offset;
|
||||||
|
}
|
||||||
|
public int getLSTOffset()
|
||||||
|
{
|
||||||
|
return field_199_list_format_offset;
|
||||||
|
}
|
||||||
|
public int getLSTSize()
|
||||||
|
{
|
||||||
|
return field_200_list_format_size;
|
||||||
|
}
|
||||||
|
public int getLFOOffset()
|
||||||
|
{
|
||||||
|
return field_201_list_format_override_offset;
|
||||||
|
}
|
||||||
|
public int getLFOSize()
|
||||||
|
{
|
||||||
|
return field_202_list_format_override_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FontTable implements HDFType
|
||||||
|
{
|
||||||
|
String[] fontNames;
|
||||||
|
|
||||||
|
public FontTable(byte[] fontTable)
|
||||||
|
{
|
||||||
|
int size = LittleEndian.getShort(fontTable, 0);
|
||||||
|
fontNames = new String[size];
|
||||||
|
|
||||||
|
int currentIndex = 4;
|
||||||
|
for(int x = 0; x < size; x++)
|
||||||
|
{
|
||||||
|
byte ffnLength = fontTable[currentIndex];
|
||||||
|
|
||||||
|
int nameOffset = currentIndex + 40;
|
||||||
|
StringBuffer nameBuf = new StringBuffer();
|
||||||
|
//char ch = Utils.getUnicodeCharacter(fontTable, nameOffset);
|
||||||
|
char ch = (char)LittleEndian.getShort(fontTable, nameOffset);
|
||||||
|
while(ch != '\0')
|
||||||
|
{
|
||||||
|
nameBuf.append(ch);
|
||||||
|
nameOffset += 2;
|
||||||
|
ch = (char)LittleEndian.getShort(fontTable, nameOffset);
|
||||||
|
}
|
||||||
|
fontNames[x] = nameBuf.toString();
|
||||||
|
currentIndex += ffnLength + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public String getFont(int index)
|
||||||
|
{
|
||||||
|
return fontNames[index];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LFO
|
||||||
|
{
|
||||||
|
int _lsid;
|
||||||
|
int _clfolvl;
|
||||||
|
LFOLVL[] _levels;
|
||||||
|
|
||||||
|
public LFO()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LFOLVL
|
||||||
|
{
|
||||||
|
int _iStartAt;
|
||||||
|
int _ilvl;
|
||||||
|
boolean _fStartAt;
|
||||||
|
boolean _fFormatting;
|
||||||
|
LVL _override;
|
||||||
|
|
||||||
|
public LFOLVL()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LST
|
||||||
|
{
|
||||||
|
int _lsid;
|
||||||
|
int _tplc;
|
||||||
|
byte[] _rgistd = new byte[18];
|
||||||
|
boolean _fSimpleList;
|
||||||
|
LVL[] _levels;
|
||||||
|
|
||||||
|
public LST()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
102
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LVL.java
Normal file
102
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LVL.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class LVL
|
||||||
|
{
|
||||||
|
public int _iStartAt;
|
||||||
|
public byte _nfc;
|
||||||
|
byte _jc;
|
||||||
|
boolean _fLegal;
|
||||||
|
boolean _fNoRestart;
|
||||||
|
boolean _fPrev;
|
||||||
|
boolean _fPrevSpace;
|
||||||
|
boolean _fWord6;
|
||||||
|
public byte[] _rgbxchNums = new byte[9];
|
||||||
|
public byte _ixchFollow;
|
||||||
|
public byte[] _chpx;
|
||||||
|
public byte[] _papx;
|
||||||
|
public char[] _xst;
|
||||||
|
public short _istd;
|
||||||
|
|
||||||
|
//byte _cbGrpprlChpx;
|
||||||
|
//byte _cbGrpprlPapx;
|
||||||
|
|
||||||
|
|
||||||
|
public LVL()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public Object clone()
|
||||||
|
{
|
||||||
|
LVL obj = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
obj = (LVL)super.clone();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,222 @@
|
|||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.apache.poi.hdf.extractor.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ListTables implements HDFType
|
||||||
|
{
|
||||||
|
|
||||||
|
LFO[] _pllfo;
|
||||||
|
Hashtable _lists = new Hashtable();
|
||||||
|
|
||||||
|
public ListTables(byte[] plcflst, byte[] plflfo)
|
||||||
|
{
|
||||||
|
initLST(plcflst);
|
||||||
|
initLFO(plflfo);
|
||||||
|
}
|
||||||
|
public LVL getLevel(int list, int level)
|
||||||
|
{
|
||||||
|
|
||||||
|
LFO override = _pllfo[list - 1];
|
||||||
|
|
||||||
|
for(int x = 0; x < override._clfolvl; x++)
|
||||||
|
{
|
||||||
|
if(override._levels[x]._ilvl == level)
|
||||||
|
{
|
||||||
|
LFOLVL lfolvl = override._levels[x];
|
||||||
|
if(lfolvl._fFormatting)
|
||||||
|
{
|
||||||
|
LST lst = (LST)_lists.get(new Integer(override._lsid));
|
||||||
|
LVL lvl = lfolvl._override;
|
||||||
|
lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
|
||||||
|
return lvl;
|
||||||
|
}
|
||||||
|
else if(lfolvl._fStartAt)
|
||||||
|
{
|
||||||
|
LST lst = (LST)_lists.get(new Integer(override._lsid));
|
||||||
|
LVL lvl = lst._levels[level];
|
||||||
|
LVL newLvl = (LVL)lvl.clone();
|
||||||
|
newLvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
|
||||||
|
newLvl._iStartAt = lfolvl._iStartAt;
|
||||||
|
return newLvl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LST lst = (LST)_lists.get(new Integer(override._lsid));
|
||||||
|
LVL lvl = lst._levels[level];
|
||||||
|
lvl._istd = Utils.convertBytesToShort(lst._rgistd, level * 2);
|
||||||
|
return lvl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
private void initLST(byte[] plcflst)
|
||||||
|
{
|
||||||
|
short length = Utils.convertBytesToShort(plcflst, 0);
|
||||||
|
int nextLevelOffset = 0;
|
||||||
|
//LST[] lstArray = new LST[length];
|
||||||
|
for(int x = 0; x < length; x++)
|
||||||
|
{
|
||||||
|
LST lst = new LST();
|
||||||
|
lst._lsid = Utils.convertBytesToInt(plcflst, 2 + (x * 28));
|
||||||
|
lst._tplc = Utils.convertBytesToInt(plcflst, 2 + 4 + (x * 28));
|
||||||
|
System.arraycopy(plcflst, 2 + 8 + (x * 28), lst._rgistd, 0, 18);
|
||||||
|
byte code = plcflst[2 + 26 + (x * 28)];
|
||||||
|
lst._fSimpleList = StyleSheet.getFlag(code & 0x01);
|
||||||
|
//lstArray[x] = lst;
|
||||||
|
_lists.put(new Integer(lst._lsid), lst);
|
||||||
|
|
||||||
|
if(lst._fSimpleList)
|
||||||
|
{
|
||||||
|
lst._levels = new LVL[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lst._levels = new LVL[9];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int y = 0; y < lst._levels.length; y++)
|
||||||
|
{
|
||||||
|
int offset = 2 + (length * 28) + nextLevelOffset;
|
||||||
|
lst._levels[y] = new LVL();
|
||||||
|
nextLevelOffset += createLVL(plcflst, offset, lst._levels[y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
private void initLFO(byte[] plflfo)
|
||||||
|
{
|
||||||
|
int lfoSize = Utils.convertBytesToInt(plflfo, 0);
|
||||||
|
_pllfo = new LFO[lfoSize];
|
||||||
|
for(int x = 0; x < lfoSize; x++)
|
||||||
|
{
|
||||||
|
LFO nextLFO = new LFO();
|
||||||
|
nextLFO._lsid = Utils.convertBytesToInt(plflfo, 4 + (x * 16));
|
||||||
|
nextLFO._clfolvl = plflfo[4 + 12 + (x * 16)];
|
||||||
|
nextLFO._levels = new LFOLVL[nextLFO._clfolvl];
|
||||||
|
_pllfo[x] = nextLFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lfolvlOffset = (lfoSize * 16) + 4;
|
||||||
|
int lvlOffset = 0;
|
||||||
|
int lfolvlNum = 0;
|
||||||
|
for(int x = 0; x < lfoSize; x++)
|
||||||
|
{
|
||||||
|
for(int y = 0; y < _pllfo[x]._clfolvl; y++)
|
||||||
|
{
|
||||||
|
int offset = lfolvlOffset + (lfolvlNum * 8) + lvlOffset;
|
||||||
|
LFOLVL lfolvl = new LFOLVL();
|
||||||
|
lfolvl._iStartAt = Utils.convertBytesToInt(plflfo, offset);
|
||||||
|
lfolvl._ilvl = Utils.convertBytesToInt(plflfo, offset + 4);
|
||||||
|
lfolvl._fStartAt = StyleSheet.getFlag(lfolvl._ilvl & 0x10);
|
||||||
|
lfolvl._fFormatting = StyleSheet.getFlag(lfolvl._ilvl & 0x20);
|
||||||
|
lfolvl._ilvl = (lfolvl._ilvl & (byte)0x0f);
|
||||||
|
lfolvlNum++;
|
||||||
|
|
||||||
|
if(lfolvl._fFormatting)
|
||||||
|
{
|
||||||
|
offset = lfolvlOffset + (lfolvlNum * 12) + lvlOffset;
|
||||||
|
lfolvl._override = new LVL();
|
||||||
|
lvlOffset += createLVL(plflfo, offset, lfolvl._override);
|
||||||
|
}
|
||||||
|
_pllfo[x]._levels[y] = lfolvl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int createLVL(byte[] data, int offset, LVL lvl)
|
||||||
|
{
|
||||||
|
|
||||||
|
lvl._iStartAt = Utils.convertBytesToInt(data, offset);
|
||||||
|
lvl._nfc = data[offset + 4];
|
||||||
|
int code = Utils.convertBytesToInt(data, offset + 5);
|
||||||
|
lvl._jc = (byte)(code & 0x03);
|
||||||
|
lvl._fLegal = StyleSheet.getFlag(code & 0x04);
|
||||||
|
lvl._fNoRestart = StyleSheet.getFlag(code & 0x08);
|
||||||
|
lvl._fPrev = StyleSheet.getFlag(code & 0x10);
|
||||||
|
lvl._fPrevSpace = StyleSheet.getFlag(code & 0x20);
|
||||||
|
lvl._fWord6 = StyleSheet.getFlag(code & 0x40);
|
||||||
|
System.arraycopy(data, offset + 6, lvl._rgbxchNums, 0, 9);
|
||||||
|
lvl._ixchFollow = data[offset + 15];
|
||||||
|
int chpxSize = data[offset + 24];
|
||||||
|
int papxSize = data[offset + 25];
|
||||||
|
lvl._chpx = new byte[chpxSize];
|
||||||
|
lvl._papx = new byte[papxSize];
|
||||||
|
System.arraycopy(data, offset + 28, lvl._papx, 0, papxSize);
|
||||||
|
System.arraycopy(data, offset + 28 + papxSize, lvl._chpx, 0, chpxSize);
|
||||||
|
offset += 28 + papxSize + chpxSize;//modify offset
|
||||||
|
int xstSize = Utils.convertBytesToShort(data, offset);
|
||||||
|
lvl._xst = new char[xstSize];
|
||||||
|
|
||||||
|
offset += 2;
|
||||||
|
for(int x = 0; x < xstSize; x++)
|
||||||
|
{
|
||||||
|
lvl._xst[x] = (char)Utils.convertBytesToShort(data, offset + (x * 2));
|
||||||
|
}
|
||||||
|
return 28 + papxSize + chpxSize + 2 + (xstSize * 2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ParagraphProperties implements Cloneable, HDFType
|
||||||
|
{
|
||||||
|
public int _istd;//index to style descriptor.
|
||||||
|
public byte _jc;//justification code
|
||||||
|
public byte _fKeep;//keep entire paragraph on one page if possible
|
||||||
|
public byte _fKeepFollow;//keep paragraph on same page with next paragraph if possible
|
||||||
|
public byte _fPageBreakBefore;//start this paragraph on new page
|
||||||
|
public byte _positionByte;//multiple flags see spec;
|
||||||
|
public byte _brcp;//rectangle border codes for Macword 3.0
|
||||||
|
public byte _brcl;//border line styles for Macword 3.0
|
||||||
|
public byte _ilvl;//when non-zero, list level for this paragraph
|
||||||
|
public byte _fNoLnn;//no line numbering for this paragraph. (makes this an exception to the section property of line numbering)
|
||||||
|
public int _ilfo;//when non-zero, (1-based) index into the pllfo identifying the list to which the paragraph belongs
|
||||||
|
public byte _fSideBySide;//when 1, paragraph is a side by side paragraph
|
||||||
|
public byte _fNoAutoHyph;//when 0, text in paragraph may be auto hyphenated.
|
||||||
|
public byte _fWindowControl;//when 1, Word will prevent widowed lines in this paragraph from being placed at the beginning of a page
|
||||||
|
public int _dxaRight;//indent from right margin (signed).
|
||||||
|
public int _dxaLeft;//indent from left margin (signed)
|
||||||
|
public int _dxaLeft1;//first line indent; signed number relative to dxaLeft
|
||||||
|
public int[] _lspd = new int[2];//line spacing descriptor see spec
|
||||||
|
public int _dyaBefore;// vertical spacing before paragraph (unsigned)
|
||||||
|
public int _dyaAfter;//vertical spacing after paragraph (unsigned)
|
||||||
|
public byte[] _phe = new byte[12];//height of current paragraph
|
||||||
|
public byte _fCrLf;//undocumented
|
||||||
|
public byte _fUsePgsuSettings;//undocumented
|
||||||
|
public byte _fAdjustRight;//undocumented
|
||||||
|
public byte _fKinsoku;// when 1, apply kinsoku rules when performing line wrapping
|
||||||
|
public byte _fWordWrap;//when 1, perform word wrap
|
||||||
|
public byte _fOverflowPunct;//when 1, apply overflow punctuation rules when performing line wrapping
|
||||||
|
public byte _fTopLinePunct;//when 1, perform top line punctuation processing
|
||||||
|
public byte _fAutoSpaceDE;//when 1, auto space FE and alphabetic characters
|
||||||
|
public byte _fAutoSpaceDN;// when 1, auto space FE and numeric characters
|
||||||
|
public int _wAlignFont;//font alignment 0 Hanging 1 Centered 2 Roman 3 Variable 4 Auto
|
||||||
|
public short _fontAlign;//multiVal see Spec.
|
||||||
|
public byte _fInTable;//when 1, paragraph is contained in a table row
|
||||||
|
public byte _fTtp;//when 1, paragraph consists only of the row mark special character and marks the end of a table row
|
||||||
|
public byte _wr;//Wrap Code for absolute objects
|
||||||
|
public byte _fLocked;//when 1, paragraph may not be edited
|
||||||
|
public int _dxaAbs;//see spec
|
||||||
|
public int _dyaAbs;//see spec
|
||||||
|
public int _dxaWidth;//when not == 0, paragraph is constrained to be dxaWidth wide, independent of current margin or column settings
|
||||||
|
public short[] _brcTop = new short[2];//spec for border above paragraph
|
||||||
|
public short[] _brcLeft = new short[2];//specification for border to the left of
|
||||||
|
public short[] _brcBottom = new short[2];//paragraphspecification for border below
|
||||||
|
public short[] _brcRight = new short[2];//paragraphspecification for border to the
|
||||||
|
public short[] _brcBetween = new short[2];//right of paragraphsee spec
|
||||||
|
public short[] _brcBar = new short[2];//specification of border to place on
|
||||||
|
public short _brcTop1;//outside of text when facing pages are to be displayed.spec
|
||||||
|
public short _brcLeft1;//for border above paragraphspecification for border to the
|
||||||
|
public short _brcBottom1;//left ofparagraphspecification for border below
|
||||||
|
public short _brcRight1;//paragraphspecification for border to the
|
||||||
|
public short _brcBetween1;//right of paragraphsee spec
|
||||||
|
public short _brcBar1;//specification of border to place on outside of text when facing pages are to be displayed.
|
||||||
|
public int _dxaFromText;//horizontal distance to be maintained between an absolutely positioned paragraph and any non-absolute positioned text
|
||||||
|
public int _dyaFromText;//vertical distance to be maintained between an absolutely positioned paragraph and any non-absolute positioned text
|
||||||
|
public int _dyaHeight;//see spec
|
||||||
|
public int _shd;//shading
|
||||||
|
public int _dcs;//drop cap specifier
|
||||||
|
public byte[] _anld = new byte[84];//autonumber list descriptor (see ANLD definition)
|
||||||
|
public short _fPropRMark;//when 1, properties have been changed with revision marking on
|
||||||
|
public short _ibstPropRMark;//index to author IDs stored in hsttbfRMark. used when properties have been changed when revision marking was enabled
|
||||||
|
public byte[] _dttmPropRMark = new byte[4];//Date/time at which properties of this were changed for this run of text by the author. (Only recorded when revision marking is on.)
|
||||||
|
public byte[] _numrm = new byte[8];//paragraph numbering revision mark data (see NUMRM)
|
||||||
|
public short _itbdMac;//number of tabs stops defined for paragraph. Must be >= 0 and <= 64.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ParagraphProperties()
|
||||||
|
{
|
||||||
|
_fWindowControl = 1;
|
||||||
|
//lspd[0] = 240;
|
||||||
|
_lspd[1] = 1;
|
||||||
|
_ilvl = 9;
|
||||||
|
}
|
||||||
|
public Object clone() throws CloneNotSupportedException
|
||||||
|
{
|
||||||
|
ParagraphProperties clone = (ParagraphProperties)super.clone();
|
||||||
|
|
||||||
|
clone._brcBar = new short[2];
|
||||||
|
clone._brcBottom = new short[2];
|
||||||
|
clone._brcLeft = new short[2];
|
||||||
|
clone._brcBetween = new short[2];
|
||||||
|
clone._brcRight = new short[2];
|
||||||
|
clone._brcTop = new short[2];
|
||||||
|
clone._lspd = new int[2];
|
||||||
|
clone._phe = new byte[12];
|
||||||
|
clone._anld = new byte[84];
|
||||||
|
clone._dttmPropRMark = new byte[4];
|
||||||
|
clone._numrm = new byte[8];
|
||||||
|
|
||||||
|
System.arraycopy(_brcBar, 0, clone._brcBar, 0, 2);
|
||||||
|
System.arraycopy(_brcBottom, 0, clone._brcBottom, 0, 2);
|
||||||
|
System.arraycopy(_brcLeft, 0, clone._brcLeft, 0, 2);
|
||||||
|
System.arraycopy(_brcBetween, 0, clone._brcBetween, 0, 2);
|
||||||
|
System.arraycopy(_brcRight, 0, clone._brcRight, 0, 2);
|
||||||
|
System.arraycopy(_brcTop, 0, clone._brcTop, 0, 2);
|
||||||
|
System.arraycopy(_lspd, 0, clone._lspd, 0, 2);
|
||||||
|
System.arraycopy(_phe, 0, clone._phe, 0, 12);
|
||||||
|
System.arraycopy(_anld, 0, clone._anld, 0, 84);
|
||||||
|
System.arraycopy(_dttmPropRMark, 0, clone._dttmPropRMark, 0, 4);
|
||||||
|
System.arraycopy(_numrm, 0, clone._numrm, 0, 8);
|
||||||
|
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SectionProperties implements HDFType
|
||||||
|
{
|
||||||
|
int _index;
|
||||||
|
byte _bkc;
|
||||||
|
boolean _fTitlePage;
|
||||||
|
boolean _fAutoPgn;
|
||||||
|
byte _nfcPgn;
|
||||||
|
boolean _fUnlocked;
|
||||||
|
byte _cnsPgn;
|
||||||
|
boolean _fPgnRestart;
|
||||||
|
boolean _fEndNote;
|
||||||
|
byte _lnc;
|
||||||
|
byte _grpfIhdt;
|
||||||
|
short _nLnnMod;
|
||||||
|
int _dxaLnn;
|
||||||
|
short _dxaPgn;
|
||||||
|
short _dyaPgn;
|
||||||
|
boolean _fLBetween;
|
||||||
|
byte _vjc;
|
||||||
|
short _dmBinFirst;
|
||||||
|
short _dmBinOther;
|
||||||
|
short _dmPaperReq;
|
||||||
|
short[] _brcTop = new short[2];
|
||||||
|
short[] _brcLeft = new short[2];
|
||||||
|
short[] _brcBottom = new short[2];
|
||||||
|
short[] _brcRight = new short[2];
|
||||||
|
boolean _fPropMark;
|
||||||
|
int _dxtCharSpace;
|
||||||
|
int _dyaLinePitch;
|
||||||
|
short _clm;
|
||||||
|
byte _dmOrientPage;
|
||||||
|
byte _iHeadingPgn;
|
||||||
|
short _pgnStart;
|
||||||
|
short _lnnMin;
|
||||||
|
short _wTextFlow;
|
||||||
|
short _pgbProp;
|
||||||
|
int _xaPage;
|
||||||
|
int _yaPage;
|
||||||
|
int _dxaLeft;
|
||||||
|
int _dxaRight;
|
||||||
|
int _dyaTop;
|
||||||
|
int _dyaBottom;
|
||||||
|
int _dzaGutter;
|
||||||
|
int _dyaHdrTop;
|
||||||
|
int _dyaHdrBottom;
|
||||||
|
short _ccolM1;
|
||||||
|
boolean _fEvenlySpaced;
|
||||||
|
int _dxaColumns;
|
||||||
|
int[] _rgdxaColumnWidthSpacing;
|
||||||
|
byte _dmOrientFirst;
|
||||||
|
byte[] _olstAnn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SectionProperties()
|
||||||
|
{
|
||||||
|
_bkc = 2;
|
||||||
|
_dyaPgn = 720;
|
||||||
|
_dxaPgn = 720;
|
||||||
|
_fEndNote = true;
|
||||||
|
_fEvenlySpaced = true;
|
||||||
|
_xaPage = 12240;
|
||||||
|
_yaPage = 15840;
|
||||||
|
_dyaHdrTop = 720;
|
||||||
|
_dyaHdrBottom = 720;
|
||||||
|
_dmOrientPage = 1;
|
||||||
|
_dxaColumns = 720;
|
||||||
|
_dyaTop = 1440;
|
||||||
|
_dxaLeft = 1800;
|
||||||
|
_dyaBottom = 1440;
|
||||||
|
_dxaRight = 1800;
|
||||||
|
_pgnStart = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,171 @@
|
|||||||
|
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class StyleDescription implements HDFType
|
||||||
|
{
|
||||||
|
|
||||||
|
private static int PARAGRAPH_STYLE = 1;
|
||||||
|
private static int CHARACTER_STYLE = 2;
|
||||||
|
|
||||||
|
int _baseStyleIndex;
|
||||||
|
int _styleTypeCode;
|
||||||
|
int _numUPX;
|
||||||
|
byte[] _papx;
|
||||||
|
byte[] _chpx;
|
||||||
|
ParagraphProperties _pap;
|
||||||
|
CharacterProperties _chp;
|
||||||
|
|
||||||
|
public StyleDescription()
|
||||||
|
{
|
||||||
|
_pap = new ParagraphProperties();
|
||||||
|
_chp = new CharacterProperties();
|
||||||
|
}
|
||||||
|
public StyleDescription(byte[] std, int baseLength, boolean word9)
|
||||||
|
{
|
||||||
|
int infoShort = LittleEndian.getShort(std, 2);
|
||||||
|
_styleTypeCode = (infoShort & 0xf);
|
||||||
|
_baseStyleIndex = (infoShort & 0xfff0) >> 4;
|
||||||
|
|
||||||
|
infoShort = LittleEndian.getShort(std, 4);
|
||||||
|
_numUPX = infoShort & 0xf;
|
||||||
|
|
||||||
|
//first byte(s) of variable length section of std is the length of the
|
||||||
|
//style name and aliases string
|
||||||
|
int nameLength = 0;
|
||||||
|
int multiplier = 1;
|
||||||
|
if(word9)
|
||||||
|
{
|
||||||
|
nameLength = LittleEndian.getShort(std, baseLength);
|
||||||
|
multiplier = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nameLength = std[baseLength];
|
||||||
|
}
|
||||||
|
//2 bytes for length, length then null terminator.
|
||||||
|
int grupxStart = multiplier + ((nameLength + 1) * multiplier) + baseLength;
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
for(int x = 0; x < _numUPX; x++)
|
||||||
|
{
|
||||||
|
int upxSize = LittleEndian.getShort(std, grupxStart + offset);
|
||||||
|
if(_styleTypeCode == PARAGRAPH_STYLE)
|
||||||
|
{
|
||||||
|
if(x == 0)
|
||||||
|
{
|
||||||
|
_papx = new byte[upxSize];
|
||||||
|
System.arraycopy(std, grupxStart + offset + 2, _papx, 0, upxSize);
|
||||||
|
}
|
||||||
|
else if(x == 1)
|
||||||
|
{
|
||||||
|
_chpx = new byte[upxSize];
|
||||||
|
System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(_styleTypeCode == CHARACTER_STYLE && x == 0)
|
||||||
|
{
|
||||||
|
_chpx = new byte[upxSize];
|
||||||
|
System.arraycopy(std, grupxStart + offset + 2, _chpx, 0, upxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(upxSize % 2 == 1)
|
||||||
|
{
|
||||||
|
++upxSize;
|
||||||
|
}
|
||||||
|
offset += 2 + upxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public int getBaseStyle()
|
||||||
|
{
|
||||||
|
return _baseStyleIndex;
|
||||||
|
}
|
||||||
|
public byte[] getCHPX()
|
||||||
|
{
|
||||||
|
return _chpx;
|
||||||
|
}
|
||||||
|
public byte[] getPAPX()
|
||||||
|
{
|
||||||
|
return _papx;
|
||||||
|
}
|
||||||
|
public ParagraphProperties getPAP()
|
||||||
|
{
|
||||||
|
return _pap;
|
||||||
|
}
|
||||||
|
public CharacterProperties getCHP()
|
||||||
|
{
|
||||||
|
return _chp;
|
||||||
|
}
|
||||||
|
public void setPAP(ParagraphProperties pap)
|
||||||
|
{
|
||||||
|
_pap = pap;
|
||||||
|
}
|
||||||
|
public void setCHP(CharacterProperties chp)
|
||||||
|
{
|
||||||
|
_chp = chp;
|
||||||
|
}
|
||||||
|
}
|
1344
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
Normal file
1344
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,112 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TableCellDescriptor implements HDFType
|
||||||
|
{
|
||||||
|
|
||||||
|
boolean _fFirstMerged;
|
||||||
|
boolean _fMerged;
|
||||||
|
boolean _fVertical;
|
||||||
|
boolean _fBackward;
|
||||||
|
boolean _fRotateFont;
|
||||||
|
boolean _fVertMerge;
|
||||||
|
boolean _fVertRestart;
|
||||||
|
short _vertAlign;
|
||||||
|
short[] _brcTop = new short[2];
|
||||||
|
short[] _brcLeft = new short[2];
|
||||||
|
short[] _brcBottom = new short[2];
|
||||||
|
short[] _brcRight = new short [2];
|
||||||
|
|
||||||
|
public TableCellDescriptor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
static TableCellDescriptor convertBytesToTC(byte[] array, int offset)
|
||||||
|
{
|
||||||
|
TableCellDescriptor tc = new TableCellDescriptor();
|
||||||
|
int rgf = LittleEndian.getShort(array, offset);
|
||||||
|
tc._fFirstMerged = (rgf & 0x0001) > 0;
|
||||||
|
tc._fMerged = (rgf & 0x0002) > 0;
|
||||||
|
tc._fVertical = (rgf & 0x0004) > 0;
|
||||||
|
tc._fBackward = (rgf & 0x0008) > 0;
|
||||||
|
tc._fRotateFont = (rgf & 0x0010) > 0;
|
||||||
|
tc._fVertMerge = (rgf & 0x0020) > 0;
|
||||||
|
tc._fVertRestart = (rgf & 0x0040) > 0;
|
||||||
|
tc._vertAlign = (short)((rgf & 0x0180) >> 7);
|
||||||
|
|
||||||
|
tc._brcTop[0] = LittleEndian.getShort(array, offset + 4);
|
||||||
|
tc._brcTop[1] = LittleEndian.getShort(array, offset + 6);
|
||||||
|
|
||||||
|
tc._brcLeft[0] = LittleEndian.getShort(array, offset + 8);
|
||||||
|
tc._brcLeft[1] = LittleEndian.getShort(array, offset + 10);
|
||||||
|
|
||||||
|
tc._brcBottom[0] = LittleEndian.getShort(array, offset + 12);
|
||||||
|
tc._brcBottom[1] = LittleEndian.getShort(array, offset + 14);
|
||||||
|
|
||||||
|
tc._brcRight[0] = LittleEndian.getShort(array, offset + 16);
|
||||||
|
tc._brcRight[1] = LittleEndian.getShort(array, offset + 18);
|
||||||
|
|
||||||
|
return tc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.hdftypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TableProperties implements HDFType
|
||||||
|
{
|
||||||
|
short _jc;
|
||||||
|
int _dxaGapHalf;
|
||||||
|
int _dyaRowHeight;
|
||||||
|
boolean _fCantSplit;
|
||||||
|
boolean _fTableHeader;
|
||||||
|
boolean _fLastRow;
|
||||||
|
short _itcMac;
|
||||||
|
short[] _rgdxaCenter;
|
||||||
|
short[] _brcLeft = new short[2];
|
||||||
|
short[] _brcRight = new short[2];
|
||||||
|
short[] _brcTop = new short[2];
|
||||||
|
short[] _brcBottom = new short[2];
|
||||||
|
short[] _brcHorizontal = new short[2];
|
||||||
|
short[] _brcVertical = new short[2];
|
||||||
|
|
||||||
|
TableCellDescriptor[] _rgtc;
|
||||||
|
|
||||||
|
|
||||||
|
public TableProperties()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
730
src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java
Normal file
730
src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java
Normal file
@ -0,0 +1,730 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.util;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A B-Tree like implementation of the java.util.Set inteface. This is a modifiable set
|
||||||
|
* and thus allows elements to be added and removed. An instance of java.util.Comparator
|
||||||
|
* must be provided at construction else all Objects added to the set must implement
|
||||||
|
* java.util.Comparable and must be comparable to one another. No duplicate elements
|
||||||
|
* will be allowed in any BTreeSet in accordance with the specifications of the Set interface.
|
||||||
|
* Any attempt to add a null element will result in an IllegalArgumentException being thrown.
|
||||||
|
* The java.util.Iterator returned by the iterator method guarantees the elements returned
|
||||||
|
* are in ascending order. The Iterator.remove() method is supported.
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BTreeSet extends AbstractSet implements Set {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instance Variables
|
||||||
|
*/
|
||||||
|
public BTreeNode root;
|
||||||
|
private Comparator comparator = null;
|
||||||
|
private int order;
|
||||||
|
private int size = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructors
|
||||||
|
* A no-arg constructor is supported in accordance with the specifications of the
|
||||||
|
* java.util.Collections interface. If the order for the B-Tree is not specified
|
||||||
|
* at construction it defaults to 32.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public BTreeSet() {
|
||||||
|
this(6); // Default order for a BTreeSet is 32
|
||||||
|
}
|
||||||
|
|
||||||
|
public BTreeSet(Collection c) {
|
||||||
|
this(6); // Default order for a BTreeSet is 32
|
||||||
|
addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BTreeSet(int order) {
|
||||||
|
this(order, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BTreeSet(int order, Comparator comparator) {
|
||||||
|
this.order = order;
|
||||||
|
this.comparator = comparator;
|
||||||
|
root = new BTreeNode(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public Methods
|
||||||
|
*/
|
||||||
|
public boolean add(Object x) throws IllegalArgumentException {
|
||||||
|
if (x == null) throw new IllegalArgumentException();
|
||||||
|
return root.insert(x, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Object x) {
|
||||||
|
return root.includes(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove(Object x) {
|
||||||
|
if (x == null) return false;
|
||||||
|
return root.delete(x, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
root = new BTreeNode(null);
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.util.Iterator iterator() {
|
||||||
|
return new Iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private methods
|
||||||
|
*/
|
||||||
|
private int compare(Object x, Object y) {
|
||||||
|
return (comparator == null ? ((Comparable)x).compareTo(y) : comparator.compare(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inner Classes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Guarantees that the Objects are returned in ascending order. Due to the volatile
|
||||||
|
* structure of a B-Tree (many splits, steals and merges can happen in a single call to remove)
|
||||||
|
* this Iterator does not attempt to track any concurrent changes that are happening to
|
||||||
|
* it's BTreeSet. Therefore, after every call to BTreeSet.remove or BTreeSet.add a new
|
||||||
|
* Iterator should be constructed. If no new Iterator is constructed than there is a
|
||||||
|
* chance of receiving a NullPointerException. The Iterator.delete method is supported.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private class Iterator implements java.util.Iterator {
|
||||||
|
private int index = 0;
|
||||||
|
private Stack parentIndex = new Stack(); // Contains all parentIndicies for currentNode
|
||||||
|
private Object lastReturned = null;
|
||||||
|
private Object next;
|
||||||
|
private BTreeNode currentNode;
|
||||||
|
|
||||||
|
Iterator() {
|
||||||
|
currentNode = firstNode();
|
||||||
|
next = nextElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return next != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object next() {
|
||||||
|
if (next == null) throw new NoSuchElementException();
|
||||||
|
|
||||||
|
lastReturned = next;
|
||||||
|
next = nextElement();
|
||||||
|
return lastReturned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
if (lastReturned == null) throw new NoSuchElementException();
|
||||||
|
|
||||||
|
BTreeSet.this.remove(lastReturned);
|
||||||
|
lastReturned = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BTreeNode firstNode() {
|
||||||
|
BTreeNode temp = BTreeSet.this.root;
|
||||||
|
|
||||||
|
while (temp.entries[0].child != null) {
|
||||||
|
temp = temp.entries[0].child;
|
||||||
|
parentIndex.push(new Integer(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object nextElement() {
|
||||||
|
if (currentNode.isLeaf()) {
|
||||||
|
if (index < currentNode.nrElements) return currentNode.entries[index++].element;
|
||||||
|
|
||||||
|
else if (!parentIndex.empty()) { //All elements have been returned, return successor of lastReturned if it exists
|
||||||
|
currentNode = currentNode.parent;
|
||||||
|
index = ((Integer)parentIndex.pop()).intValue();
|
||||||
|
|
||||||
|
while (index == currentNode.nrElements) {
|
||||||
|
if (parentIndex.empty()) break;
|
||||||
|
currentNode = currentNode.parent;
|
||||||
|
index = ((Integer)parentIndex.pop()).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == currentNode.nrElements) return null; //Reached root and he has no more children
|
||||||
|
return currentNode.entries[index++].element;
|
||||||
|
}
|
||||||
|
|
||||||
|
else { //Your a leaf and the root
|
||||||
|
if (index == currentNode.nrElements) return null;
|
||||||
|
return currentNode.entries[index++].element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else { //Your not a leaf so simply find and return the successor of lastReturned
|
||||||
|
currentNode = currentNode.entries[index].child;
|
||||||
|
parentIndex.push(new Integer(index));
|
||||||
|
|
||||||
|
while (currentNode.entries[0].child != null) {
|
||||||
|
currentNode = currentNode.entries[0].child;
|
||||||
|
parentIndex.push(new Integer(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
index = 1;
|
||||||
|
return currentNode.entries[0].element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class Entry {
|
||||||
|
|
||||||
|
public Object element;
|
||||||
|
public BTreeNode child;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class BTreeNode {
|
||||||
|
|
||||||
|
public Entry[] entries;
|
||||||
|
public BTreeNode parent;
|
||||||
|
private int nrElements = 0;
|
||||||
|
private final int MIN = (BTreeSet.this.order - 1) / 2;
|
||||||
|
|
||||||
|
BTreeNode(BTreeNode parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
entries = new Entry[BTreeSet.this.order];
|
||||||
|
entries[0] = new Entry();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean insert(Object x, int parentIndex) {
|
||||||
|
if (isFull()) { // If full, you must split and promote splitNode before inserting
|
||||||
|
Object splitNode = entries[nrElements / 2].element;
|
||||||
|
BTreeNode rightSibling = split();
|
||||||
|
|
||||||
|
if (isRoot()) { // Grow a level
|
||||||
|
splitRoot(splitNode, this, rightSibling);
|
||||||
|
// Determine where to insert
|
||||||
|
if (BTreeSet.this.compare(x, BTreeSet.this.root.entries[0].element) < 0) insert(x, 0);
|
||||||
|
else rightSibling.insert(x, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // Promote splitNode
|
||||||
|
parent.insertSplitNode(splitNode, this, rightSibling, parentIndex);
|
||||||
|
if (BTreeSet.this.compare(x, parent.entries[parentIndex].element) < 0) return insert(x, parentIndex);
|
||||||
|
else return rightSibling.insert(x, parentIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (isLeaf()) { // If leaf, simply insert the non-duplicate element
|
||||||
|
int insertAt = childToInsertAt(x, true);
|
||||||
|
if (insertAt == -1) return false; // Determine if the element already exists
|
||||||
|
else {
|
||||||
|
insertNewElement(x, insertAt);
|
||||||
|
BTreeSet.this.size++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // If not full and not leaf recursively find correct node to insert at
|
||||||
|
int insertAt = childToInsertAt(x, true);
|
||||||
|
return (insertAt == -1 ? false : entries[insertAt].child.insert(x, insertAt));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean includes(Object x) {
|
||||||
|
int index = childToInsertAt(x, true);
|
||||||
|
if (index == -1) return true;
|
||||||
|
if (entries[index] == null || entries[index].child == null) return false;
|
||||||
|
return entries[index].child.includes(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean delete(Object x, int parentIndex) {
|
||||||
|
int i = childToInsertAt(x, true);
|
||||||
|
int priorParentIndex = parentIndex;
|
||||||
|
BTreeNode temp = this;
|
||||||
|
if (i != -1) {
|
||||||
|
do {
|
||||||
|
if (temp.entries[i] == null || temp.entries[i].child == null) return false;
|
||||||
|
temp = temp.entries[i].child;
|
||||||
|
priorParentIndex = parentIndex;
|
||||||
|
parentIndex = i;
|
||||||
|
i = temp.childToInsertAt(x, true);
|
||||||
|
} while (i != -1);
|
||||||
|
} // Now temp contains element to delete and temp's parentIndex is parentIndex
|
||||||
|
|
||||||
|
if (temp.isLeaf()) { // If leaf and have more than MIN elements, simply delete
|
||||||
|
if (temp.nrElements > MIN) {
|
||||||
|
temp.deleteElement(x);
|
||||||
|
BTreeSet.this.size--;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // If leaf and have less than MIN elements, than prepare the BTreeSet for deletion
|
||||||
|
temp.prepareForDeletion(parentIndex);
|
||||||
|
temp.deleteElement(x);
|
||||||
|
BTreeSet.this.size--;
|
||||||
|
temp.fixAfterDeletion(priorParentIndex);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // Only delete at leaf so first switch with successor than delete
|
||||||
|
temp.switchWithSuccessor(x);
|
||||||
|
parentIndex = temp.childToInsertAt(x, false) + 1;
|
||||||
|
return temp.entries[parentIndex].child.delete(x, parentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isFull() { return nrElements == (BTreeSet.this.order - 1); }
|
||||||
|
|
||||||
|
private boolean isLeaf() { return entries[0].child == null; }
|
||||||
|
|
||||||
|
private boolean isRoot() { return parent == null; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Splits a BTreeNode into two BTreeNodes, removing the splitNode from the
|
||||||
|
* calling BTreeNode.
|
||||||
|
*/
|
||||||
|
private BTreeNode split() {
|
||||||
|
BTreeNode rightSibling = new BTreeNode(parent);
|
||||||
|
int index = nrElements / 2;
|
||||||
|
entries[index++].element = null;
|
||||||
|
|
||||||
|
for (int i = 0, nr = nrElements; index <= nr; i++, index++) {
|
||||||
|
rightSibling.entries[i] = entries[index];
|
||||||
|
if (rightSibling.entries[i] != null && rightSibling.entries[i].child != null)
|
||||||
|
rightSibling.entries[i].child.parent = rightSibling;
|
||||||
|
entries[index] = null;
|
||||||
|
nrElements--;
|
||||||
|
rightSibling.nrElements++;
|
||||||
|
}
|
||||||
|
|
||||||
|
rightSibling.nrElements--; // Need to correct for copying the last Entry which has a null element and a child
|
||||||
|
return rightSibling;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new BTreeSet.root which contains only the splitNode and pointers
|
||||||
|
* to it's left and right child.
|
||||||
|
*/
|
||||||
|
private void splitRoot(Object splitNode, BTreeNode left, BTreeNode right) {
|
||||||
|
BTreeNode newRoot = new BTreeNode(null);
|
||||||
|
newRoot.entries[0].element = splitNode;
|
||||||
|
newRoot.entries[0].child = left;
|
||||||
|
newRoot.entries[1] = new Entry();
|
||||||
|
newRoot.entries[1].child = right;
|
||||||
|
newRoot.nrElements = 1;
|
||||||
|
left.parent = right.parent = newRoot;
|
||||||
|
BTreeSet.this.root = newRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertSplitNode(Object splitNode, BTreeNode left, BTreeNode right, int insertAt) {
|
||||||
|
for (int i = nrElements; i >= insertAt; i--) entries[i + 1] = entries[i];
|
||||||
|
|
||||||
|
entries[insertAt] = new Entry();
|
||||||
|
entries[insertAt].element = splitNode;
|
||||||
|
entries[insertAt].child = left;
|
||||||
|
entries[insertAt + 1].child = right;
|
||||||
|
|
||||||
|
nrElements++;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertNewElement(Object x, int insertAt) {
|
||||||
|
|
||||||
|
for (int i = nrElements; i > insertAt; i--) entries[i] = entries[i - 1];
|
||||||
|
|
||||||
|
entries[insertAt] = new Entry();
|
||||||
|
entries[insertAt].element = x;
|
||||||
|
|
||||||
|
nrElements++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Possibly a deceptive name for a pretty cool method. Uses binary search
|
||||||
|
* to determine the postion in entries[] in which to traverse to find the correct
|
||||||
|
* BTreeNode in which to insert a new element. If the element exists in the calling
|
||||||
|
* BTreeNode than -1 is returned. When the parameter position is true and the element
|
||||||
|
* is present in the calling BTreeNode -1 is returned, if position is false and the
|
||||||
|
* element is contained in the calling BTreeNode than the position of the element
|
||||||
|
* in entries[] is returned.
|
||||||
|
*/
|
||||||
|
private int childToInsertAt(Object x, boolean position) {
|
||||||
|
int index = nrElements / 2;
|
||||||
|
|
||||||
|
if (entries[index] == null || entries[index].element == null) return index;
|
||||||
|
|
||||||
|
int lo = 0, hi = nrElements - 1;
|
||||||
|
while (lo <= hi) {
|
||||||
|
if (BTreeSet.this.compare(x, entries[index].element) > 0) {
|
||||||
|
lo = index + 1;
|
||||||
|
index = (hi + lo) / 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hi = index - 1;
|
||||||
|
index = (hi + lo) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hi++;
|
||||||
|
if (entries[hi] == null || entries[hi].element == null) return hi;
|
||||||
|
return (!position ? hi : BTreeSet.this.compare(x, entries[hi].element) == 0 ? -1 : hi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void deleteElement(Object x) {
|
||||||
|
int index = childToInsertAt(x, false);
|
||||||
|
for (; index < (nrElements - 1); index++) entries[index] = entries[index + 1];
|
||||||
|
|
||||||
|
if (nrElements == 1) entries[index] = new Entry(); // This is root and it is empty
|
||||||
|
else entries[index] = null;
|
||||||
|
|
||||||
|
nrElements--;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareForDeletion(int parentIndex) {
|
||||||
|
if (isRoot()) return; // Don't attempt to steal or merge if your the root
|
||||||
|
|
||||||
|
// If not root then try to steal left
|
||||||
|
else if (parentIndex != 0 && parent.entries[parentIndex - 1].child.nrElements > MIN) {
|
||||||
|
stealLeft(parentIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not root and can't steal left try to steal right
|
||||||
|
else if (parentIndex < entries.length && parent.entries[parentIndex + 1] != null && parent.entries[parentIndex + 1].child != null && parent.entries[parentIndex + 1].child.nrElements > MIN) {
|
||||||
|
stealRight(parentIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not root and can't steal left or right then try to merge left
|
||||||
|
else if (parentIndex != 0) {
|
||||||
|
mergeLeft(parentIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not root and can't steal left or right and can't merge left you must be able to merge right
|
||||||
|
else mergeRight(parentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixAfterDeletion(int parentIndex) {
|
||||||
|
if (isRoot() || parent.isRoot()) return; // No fixing needed
|
||||||
|
|
||||||
|
if (parent.nrElements < MIN) { // If parent lost it's n/2 element repair it
|
||||||
|
BTreeNode temp = parent;
|
||||||
|
temp.prepareForDeletion(parentIndex);
|
||||||
|
if (temp.parent == null) return; // Root changed
|
||||||
|
if (!temp.parent.isRoot() && temp.parent.nrElements < MIN) { // If need be recurse
|
||||||
|
BTreeNode x = temp.parent.parent;
|
||||||
|
int i = 0;
|
||||||
|
// Find parent's parentIndex
|
||||||
|
for (; i < entries.length; i++) if (x.entries[i].child == temp.parent) break;
|
||||||
|
temp.parent.fixAfterDeletion(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchWithSuccessor(Object x) {
|
||||||
|
int index = childToInsertAt(x, false);
|
||||||
|
BTreeNode temp = entries[index + 1].child;
|
||||||
|
while (temp.entries[0] != null && temp.entries[0].child != null) temp = temp.entries[0].child;
|
||||||
|
Object successor = temp.entries[0].element;
|
||||||
|
temp.entries[0].element = entries[index].element;
|
||||||
|
entries[index].element = successor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This method is called only when the BTreeNode has the minimum number of elements,
|
||||||
|
* has a leftSibling, and the leftSibling has more than the minimum number of elements.
|
||||||
|
*/
|
||||||
|
private void stealLeft(int parentIndex) {
|
||||||
|
BTreeNode p = parent;
|
||||||
|
BTreeNode ls = parent.entries[parentIndex - 1].child;
|
||||||
|
|
||||||
|
if (isLeaf()) { // When stealing from leaf to leaf don't worry about children
|
||||||
|
int add = childToInsertAt(p.entries[parentIndex - 1].element, true);
|
||||||
|
insertNewElement(p.entries[parentIndex - 1].element, add);
|
||||||
|
p.entries[parentIndex - 1].element = ls.entries[ls.nrElements - 1].element;
|
||||||
|
ls.entries[ls.nrElements - 1] = null;
|
||||||
|
ls.nrElements--;
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // Was called recursively to fix an undermanned parent
|
||||||
|
entries[0].element = p.entries[parentIndex - 1].element;
|
||||||
|
p.entries[parentIndex - 1].element = ls.entries[ls.nrElements - 1].element;
|
||||||
|
entries[0].child = ls.entries[ls.nrElements].child;
|
||||||
|
entries[0].child.parent = this;
|
||||||
|
ls.entries[ls.nrElements] = null;
|
||||||
|
ls.entries[ls.nrElements - 1].element = null;
|
||||||
|
nrElements++;
|
||||||
|
ls.nrElements--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This method is called only when stealLeft can't be called, the BTreeNode
|
||||||
|
* has the minimum number of elements, has a rightSibling, and the rightSibling
|
||||||
|
* has more than the minimum number of elements.
|
||||||
|
*/
|
||||||
|
private void stealRight(int parentIndex) {
|
||||||
|
BTreeNode p = parent;
|
||||||
|
BTreeNode rs = p.entries[parentIndex + 1].child;
|
||||||
|
|
||||||
|
if (isLeaf()) { // When stealing from leaf to leaf don't worry about children
|
||||||
|
entries[nrElements] = new Entry();
|
||||||
|
entries[nrElements].element = p.entries[parentIndex].element;
|
||||||
|
p.entries[parentIndex].element = rs.entries[0].element;
|
||||||
|
for (int i = 0; i < rs.nrElements; i++) rs.entries[i] = rs.entries[i + 1];
|
||||||
|
rs.entries[rs.nrElements - 1] = null;
|
||||||
|
nrElements++;
|
||||||
|
rs.nrElements--;
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // Was called recursively to fix an undermanned parent
|
||||||
|
for (int i = 0; i <= nrElements; i++) entries[i] = entries[i + 1];
|
||||||
|
entries[nrElements].element = p.entries[parentIndex].element;
|
||||||
|
p.entries[parentIndex].element = rs.entries[0].element;
|
||||||
|
entries[nrElements + 1] = new Entry();
|
||||||
|
entries[nrElements + 1].child = rs.entries[0].child;
|
||||||
|
entries[nrElements + 1].child.parent = this;
|
||||||
|
for (int i = 0; i <= rs.nrElements; i++) rs.entries[i] = rs.entries[i + 1];
|
||||||
|
rs.entries[rs.nrElements] = null;
|
||||||
|
nrElements++;
|
||||||
|
rs.nrElements--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This method is called only when stealLeft and stealRight could not be called,
|
||||||
|
* the BTreeNode has the minimum number of elements, has a leftSibling, and the
|
||||||
|
* leftSibling has more than the minimum number of elements. If after completion
|
||||||
|
* parent has fewer than the minimum number of elements than the parents entries[0]
|
||||||
|
* slot is left empty in anticipation of a recursive call to stealLeft, stealRight,
|
||||||
|
* mergeLeft, or mergeRight to fix the parent. All of the before-mentioned methods
|
||||||
|
* expect the parent to be in such a condition.
|
||||||
|
*/
|
||||||
|
private void mergeLeft(int parentIndex) {
|
||||||
|
BTreeNode p = parent;
|
||||||
|
BTreeNode ls = p.entries[parentIndex - 1].child;
|
||||||
|
|
||||||
|
if (isLeaf()) { // Don't worry about children
|
||||||
|
int add = childToInsertAt(p.entries[parentIndex - 1].element, true);
|
||||||
|
insertNewElement(p.entries[parentIndex - 1].element, add); // Could have been a successor switch
|
||||||
|
p.entries[parentIndex - 1].element = null;
|
||||||
|
|
||||||
|
for (int i = nrElements - 1, nr = ls.nrElements; i >= 0; i--)
|
||||||
|
entries[i + nr] = entries[i];
|
||||||
|
|
||||||
|
for (int i = ls.nrElements - 1; i >= 0; i--) {
|
||||||
|
entries[i] = ls.entries[i];
|
||||||
|
nrElements++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.nrElements == MIN && p != BTreeSet.this.root) {
|
||||||
|
|
||||||
|
for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x--, y--)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[0] = new Entry();
|
||||||
|
p.entries[0].child = ls; //So p doesn't think it's a leaf this will be deleted in the next recursive call
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[p.nrElements] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.nrElements--;
|
||||||
|
|
||||||
|
if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
|
||||||
|
BTreeSet.this.root = this;
|
||||||
|
parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // I'm not a leaf but fixing the tree structure
|
||||||
|
entries[0].element = p.entries[parentIndex - 1].element;
|
||||||
|
entries[0].child = ls.entries[ls.nrElements].child;
|
||||||
|
nrElements++;
|
||||||
|
|
||||||
|
for (int x = nrElements, nr = ls.nrElements; x >= 0; x--)
|
||||||
|
entries[x + nr] = entries[x];
|
||||||
|
|
||||||
|
for (int x = ls.nrElements - 1; x >= 0; x--) {
|
||||||
|
entries[x] = ls.entries[x];
|
||||||
|
entries[x].child.parent = this;
|
||||||
|
nrElements++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.nrElements == MIN && p != BTreeSet.this.root) { // Push everything to the right
|
||||||
|
for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x++, y++){
|
||||||
|
System.out.println(x + " " + y);
|
||||||
|
p.entries[x] = p.entries[y];}
|
||||||
|
p.entries[0] = new Entry();
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // Either p.nrElements > MIN or p == BTreeSet.this.root so push everything to the left
|
||||||
|
for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[p.nrElements] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.nrElements--;
|
||||||
|
|
||||||
|
if (p.isRoot() && p.nrElements == 0) { // p == BTreeSet.this.root and it's empty
|
||||||
|
BTreeSet.this.root = this;
|
||||||
|
parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This method is called only when stealLeft, stealRight, and mergeLeft could not be called,
|
||||||
|
* the BTreeNode has the minimum number of elements, has a rightSibling, and the
|
||||||
|
* rightSibling has more than the minimum number of elements. If after completion
|
||||||
|
* parent has fewer than the minimum number of elements than the parents entries[0]
|
||||||
|
* slot is left empty in anticipation of a recursive call to stealLeft, stealRight,
|
||||||
|
* mergeLeft, or mergeRight to fix the parent. All of the before-mentioned methods
|
||||||
|
* expect the parent to be in such a condition.
|
||||||
|
*/
|
||||||
|
private void mergeRight(int parentIndex) {
|
||||||
|
BTreeNode p = parent;
|
||||||
|
BTreeNode rs = p.entries[parentIndex + 1].child;
|
||||||
|
|
||||||
|
if (isLeaf()) { // Don't worry about children
|
||||||
|
entries[nrElements] = new Entry();
|
||||||
|
entries[nrElements].element = p.entries[parentIndex].element;
|
||||||
|
nrElements++;
|
||||||
|
for (int i = 0, nr = nrElements; i < rs.nrElements; i++, nr++) {
|
||||||
|
entries[nr] = rs.entries[i];
|
||||||
|
nrElements++;
|
||||||
|
}
|
||||||
|
p.entries[parentIndex].element = p.entries[parentIndex + 1].element;
|
||||||
|
if (p.nrElements == MIN && p != BTreeSet.this.root) {
|
||||||
|
for (int x = parentIndex + 1, y = parentIndex; y >= 0; x--, y--)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[0] = new Entry();
|
||||||
|
p.entries[0].child = rs; // So it doesn't think it's a leaf, this child will be deleted in the next recursive call
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
for (int x = parentIndex + 1, y = parentIndex + 2; y <= p.nrElements; x++, y++)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[p.nrElements] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.nrElements--;
|
||||||
|
if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
|
||||||
|
BTreeSet.this.root = this;
|
||||||
|
parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else { // It's not a leaf
|
||||||
|
|
||||||
|
entries[nrElements].element = p.entries[parentIndex].element;
|
||||||
|
nrElements++;
|
||||||
|
|
||||||
|
for (int x = nrElements + 1, y = 0; y <= rs.nrElements; x++, y++) {
|
||||||
|
entries[x] = rs.entries[y];
|
||||||
|
rs.entries[y].child.parent = this;
|
||||||
|
nrElements++;
|
||||||
|
}
|
||||||
|
nrElements--;
|
||||||
|
|
||||||
|
p.entries[++parentIndex].child = this;
|
||||||
|
|
||||||
|
if (p.nrElements == MIN && p != BTreeSet.this.root) {
|
||||||
|
for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x--, y--)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[0] = new Entry();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
|
||||||
|
p.entries[x] = p.entries[y];
|
||||||
|
p.entries[p.nrElements] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.nrElements--;
|
||||||
|
|
||||||
|
if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
|
||||||
|
BTreeSet.this.root = this;
|
||||||
|
parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.util;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ChpxNode extends PropertyNode
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public ChpxNode(int fcStart, int fcEnd, byte[] chpx)
|
||||||
|
{
|
||||||
|
super(fcStart, fcEnd, chpx);
|
||||||
|
}
|
||||||
|
public byte[] getChpx()
|
||||||
|
{
|
||||||
|
return super.getGrpprl();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PapxNode extends PropertyNode
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public PapxNode(int fcStart, int fcEnd, byte[] papx)
|
||||||
|
{
|
||||||
|
super(fcStart, fcEnd, papx);
|
||||||
|
}
|
||||||
|
public byte[] getPapx()
|
||||||
|
{
|
||||||
|
return super.getGrpprl();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
package org.apache.poi.hdf.model.util;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class PropertyNode implements Comparable
|
||||||
|
{
|
||||||
|
private byte[] _grpprl;
|
||||||
|
private int _fcStart;
|
||||||
|
private int _fcEnd;
|
||||||
|
|
||||||
|
public PropertyNode(int fcStart, int fcEnd, byte[] grpprl)
|
||||||
|
{
|
||||||
|
_fcStart = fcStart;
|
||||||
|
_fcEnd = fcEnd;
|
||||||
|
_grpprl = grpprl;
|
||||||
|
}
|
||||||
|
public int getStart()
|
||||||
|
{
|
||||||
|
return _fcStart;
|
||||||
|
}
|
||||||
|
public int getEnd()
|
||||||
|
{
|
||||||
|
return _fcEnd;
|
||||||
|
}
|
||||||
|
protected byte[] getGrpprl()
|
||||||
|
{
|
||||||
|
return _grpprl;
|
||||||
|
}
|
||||||
|
public int compareTo(Object o)
|
||||||
|
{
|
||||||
|
int fcStart = ((PropertyNode)o).getStart();
|
||||||
|
if(_fcStart == fcStart)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(_fcStart < fcStart)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SepxNode extends PropertyNode
|
||||||
|
{
|
||||||
|
|
||||||
|
int _index;
|
||||||
|
|
||||||
|
public SepxNode(int index, int start, int end, byte[] sepx)
|
||||||
|
{
|
||||||
|
super(start, end, sepx);
|
||||||
|
}
|
||||||
|
public byte[] getSepx()
|
||||||
|
{
|
||||||
|
return getGrpprl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object obj) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.poi.hdf.model.util;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment me
|
||||||
|
*
|
||||||
|
* @author Ryan Ackley
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TextPiece extends PropertyNode implements Comparable
|
||||||
|
{
|
||||||
|
private boolean _usesUnicode;
|
||||||
|
private int _length;
|
||||||
|
|
||||||
|
public TextPiece(int start, int length, boolean unicode)
|
||||||
|
{
|
||||||
|
super(start, start + length, null);
|
||||||
|
_usesUnicode = unicode;
|
||||||
|
_length = length;
|
||||||
|
//_fcStart = start;
|
||||||
|
//_fcEnd = start + length;
|
||||||
|
|
||||||
|
}
|
||||||
|
public boolean usesUnicode()
|
||||||
|
{
|
||||||
|
return _usesUnicode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object obj) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -15,6 +15,10 @@
|
|||||||
<property name="build.compiler.depend" value="true"/>
|
<property name="build.compiler.depend" value="true"/>
|
||||||
<property name="build.compiler.fulldepend" value="true"/>
|
<property name="build.compiler.fulldepend" value="true"/>
|
||||||
|
|
||||||
|
<!-- Temporary fix. Longer term solution to be discussed. -->
|
||||||
|
<property name="build.root" value="./build"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- =================================================================== -->
|
<!-- =================================================================== -->
|
||||||
<!-- Indentify Classpath -->
|
<!-- Indentify Classpath -->
|
||||||
<!-- =================================================================== -->
|
<!-- =================================================================== -->
|
||||||
@ -44,7 +48,7 @@
|
|||||||
<include name="*.jar"/>
|
<include name="*.jar"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
<!-- FIXME : how to build a path that references a property set in 'init' target ? -->
|
<!-- FIXME : how to build a path that references a property set in 'init' target ? -->
|
||||||
<pathelement path="./build/jakarta-poi/classes"/>
|
<pathelement path="${build.root}/jakarta-poi/classes"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<path id="scratchpad.classpath">
|
<path id="scratchpad.classpath">
|
||||||
@ -61,7 +65,7 @@
|
|||||||
<include name="*.jar"/>
|
<include name="*.jar"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
<!-- FIXME : how to build a path that references a property set in 'init' target ? -->
|
<!-- FIXME : how to build a path that references a property set in 'init' target ? -->
|
||||||
<pathelement path="./build/jakarta-poi/classes"/>
|
<pathelement path="${build.root}/jakarta-poi/classes"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<path id="contrib.classpath">
|
<path id="contrib.classpath">
|
||||||
@ -78,7 +82,7 @@
|
|||||||
<include name="*.jar"/>
|
<include name="*.jar"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
<!-- FIXME : how to build a path that references a property set in 'init' target ? -->
|
<!-- FIXME : how to build a path that references a property set in 'init' target ? -->
|
||||||
<pathelement path="./build/jakarta-poi/classes"/>
|
<pathelement path="${build.root}/jakarta-poi/classes"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user