<No Comment Entered>

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353523 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Said Ryan Ackley 2004-03-03 00:12:00 +00:00
parent 0e1f9ab329
commit 462b3aaba1
36 changed files with 0 additions and 18399 deletions

View File

@ -1,211 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.util.List;
import java.util.ArrayList;
import org.apache.poi.util.LittleEndian;
/**
* Represents a CHP fkp. The style properties for paragraph and character runs
* are stored in fkps. There are PAP fkps for paragraph properties and CHP fkps
* for character run properties. The first part of the fkp for both CHP and PAP
* fkps consists of an array of 4 byte int offsets that represent a
* Paragraph's or Character run's text offset in the main stream. The ending
* offset is the next value in the array. For example, if an fkp has X number of
* Paragraph's stored in it then there are (x + 1) 4 byte ints in the beginning
* array. The number X is determined by the last byte in a 512 byte fkp.
*
* CHP and PAP fkps also store the compressed styles(grpprl) that correspond to
* the offsets on the front of the fkp. The offset of the grpprls is determined
* differently for CHP fkps and PAP fkps.
*
* @author Ryan Ackley
*/
public class CHPFormattedDiskPage extends FormattedDiskPage
{
private static final int FC_SIZE = 4;
private ArrayList _chpxList = new ArrayList();
private ArrayList _overFlow;
public CHPFormattedDiskPage()
{
}
/**
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
* read from a Word file).
*/
public CHPFormattedDiskPage(byte[] documentStream, int offset, int fcMin)
{
super(documentStream, offset);
for (int x = 0; x < _crun; x++)
{
_chpxList.add(new CHPX(getStart(x) - fcMin, getEnd(x) - fcMin, getGrpprl(x)));
}
}
public CHPX getCHPX(int index)
{
return (CHPX)_chpxList.get(index);
}
public void fill(List filler)
{
_chpxList.addAll(filler);
}
public ArrayList getOverflow()
{
return _overFlow;
}
/**
* Gets the chpx for the character run at index in this fkp.
*
* @param index The index of the chpx to get.
* @return a chpx grpprl.
*/
protected byte[] getGrpprl(int index)
{
int chpxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * 4) + index));
//optimization if offset == 0 use "Normal" style
if(chpxOffset == 0)
{
return new byte[0];
}
int size = LittleEndian.getUnsignedByte(_fkp, _offset + chpxOffset);
byte[] chpx = new byte[size];
System.arraycopy(_fkp, _offset + ++chpxOffset, chpx, 0, size);
return chpx;
}
protected byte[] toByteArray(int fcMin)
{
byte[] buf = new byte[512];
int size = _chpxList.size();
int grpprlOffset = 511;
int offsetOffset = 0;
int fcOffset = 0;
// total size is currently the size of one FC
int totalSize = FC_SIZE + 1;
int index = 0;
for (; index < size; index++)
{
int grpprlLength = ((CHPX)_chpxList.get(index)).getGrpprl().length;
// check to see if we have enough room for an FC, the grpprl offset,
// the grpprl size byte and the grpprl.
totalSize += (FC_SIZE + 2 + grpprlLength);
// if size is uneven we will have to add one so the first grpprl falls
// on a word boundary
if (totalSize > 511 + (index % 2))
{
totalSize -= (FC_SIZE + 2 + grpprlLength);
break;
}
// grpprls must fall on word boundaries
if ((1 + grpprlLength) % 2 > 0)
{
totalSize += 1;
}
}
// see if we couldn't fit some
if (index != size)
{
_overFlow = new ArrayList();
_overFlow.addAll(_chpxList.subList(index, size));
}
// index should equal number of CHPXs that will be in this fkp now.
buf[511] = (byte)index;
offsetOffset = (FC_SIZE * index) + FC_SIZE;
//grpprlOffset = offsetOffset + index + (grpprlOffset % 2);
CHPX chpx = null;
for (int x = 0; x < index; x++)
{
chpx = (CHPX)_chpxList.get(x);
byte[] grpprl = chpx.getGrpprl();
LittleEndian.putInt(buf, fcOffset, chpx.getStart() + fcMin);
grpprlOffset -= (1 + grpprl.length);
grpprlOffset -= (grpprlOffset % 2);
buf[offsetOffset] = (byte)(grpprlOffset/2);
buf[grpprlOffset] = (byte)grpprl.length;
System.arraycopy(grpprl, 0, buf, grpprlOffset + 1, grpprl.length);
offsetOffset += 1;
fcOffset += FC_SIZE;
}
// put the last chpx's end in
LittleEndian.putInt(buf, fcOffset, chpx.getEnd() + fcMin);
return buf;
}
}

View File

@ -1,85 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.hwpf.sprm.SprmBuffer;
/**
* Comment me
*
* @author Ryan Ackley
*/
public class CHPX extends PropertyNode
{
public CHPX(int fcStart, int fcEnd, byte[] grpprl)
{
super(fcStart, fcEnd, new SprmBuffer(grpprl));
}
public byte[] getGrpprl()
{
return ((SprmBuffer)_buf).toByteArray();
}
public byte[] getBuf()
{
return getGrpprl();
}
}

View File

@ -1,116 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.io.IOException;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.io.*;
public class ComplexFileTable
{
private static final byte GRPPRL_TYPE = 1;
private static final byte TEXT_PIECE_TABLE_TYPE = 2;
TextPieceTable _tpt;
public ComplexFileTable(byte[] documentStream, byte[] tableStream, int offset, int fcMin) throws IOException
{
//skips through the prms before we reach the piece table. These contain data
//for actual fast saved files
while (tableStream[offset] == GRPPRL_TYPE)
{
offset++;
int skip = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE + skip;
}
if(tableStream[offset] != TEXT_PIECE_TABLE_TYPE)
{
throw new IOException("The text piece table is corrupted");
}
else
{
int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
offset += LittleEndian.INT_SIZE;
_tpt = new TextPieceTable(documentStream, tableStream, offset, pieceTableSize, fcMin);
}
}
public TextPieceTable getTextPieceTable()
{
return _tpt;
}
public void writeTo(HWPFFileSystem sys)
throws IOException
{
HWPFOutputStream docStream = sys.getStream("WordDocument");
HWPFOutputStream tableStream = sys.getStream("1Table");
tableStream.write(TEXT_PIECE_TABLE_TYPE);
byte[] table = _tpt.writeTo(docStream);
byte[] numHolder = new byte[LittleEndian.INT_SIZE];
LittleEndian.putInt(numHolder, table.length);
tableStream.write(numHolder);
tableStream.write(table);
}
}

View File

@ -1,77 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.hdftypes.definitions.DOPAbstractType;
/**
* Comment me
*
* @author Ryan Ackley
*/
public class DocumentProperties extends DOPAbstractType
{
public DocumentProperties(byte[] tableStream, int offset)
{
super.fillFields(tableStream, offset);
}
}

View File

@ -1,267 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
import java.util.Arrays;
/**
* FFN - Font Family Name. FFN is a data structure that stores the names of the Main
* Font and that of Alternate font as an array of characters. It has also a header
* that stores info about the whole structure and the fonts
*
* @author Praveen Mathew
*/
public class Ffn
{
private int field_1_cbFfnM1;//total length of FFN - 1.
private byte field_2;
private static BitField _prq = new BitField(0x0003);// pitch request
private static BitField _fTrueType = new BitField(0x0004);// when 1, font is a TrueType font
private static BitField _ff = new BitField(0x0070);
private short field_3_wWeight;// base weight of font
private byte field_4_chs;// character set identifier
private byte field_5_ixchSzAlt; // index into ffn.szFfn to the name of
// the alternate font
private byte [] field_6_panose = new byte[10];//????
private byte [] field_7_fontSig = new byte[24];//????
// zero terminated string that records name of font, cuurently not
// supporting Extended chars
private char [] field_8_xszFfn;
// extra facilitator members
private int xszFfnLength;
public Ffn(byte[] buf, int offset)
{
int offsetTmp = offset;
field_1_cbFfnM1 = LittleEndian.getUnsignedByte(buf,offset);
offset += LittleEndian.BYTE_SIZE;
field_2 = buf[offset];
offset += LittleEndian.BYTE_SIZE;
field_3_wWeight = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
field_4_chs = buf[offset];
offset += LittleEndian.BYTE_SIZE;
field_5_ixchSzAlt = buf[offset];
offset += LittleEndian.BYTE_SIZE;
// read panose and fs so we can write them back out.
System.arraycopy(buf, offset, field_6_panose, 0, field_6_panose.length);
offset += field_6_panose.length;
System.arraycopy(buf, offset, field_7_fontSig, 0, field_7_fontSig.length);
offset += field_7_fontSig.length;
offsetTmp = offset - offsetTmp;
xszFfnLength = this.getSize() - offsetTmp;
field_8_xszFfn = new char[xszFfnLength];
for(int i = 0; i < xszFfnLength; i++)
{
field_8_xszFfn[i] = (char)LittleEndian.getUnsignedByte(buf, offset);
offset += LittleEndian.BYTE_SIZE;
}
}
public int getField_1_cbFfnM1()
{
return field_1_cbFfnM1;
}
public byte getField_2()
{
return field_2;
}
public short getField_3_wWeight()
{
return field_3_wWeight;
}
public byte getField_4_chs()
{
return field_4_chs;
}
public byte getField_5_ixchSzAlt()
{
return field_5_ixchSzAlt;
}
public byte [] getField_6_panose()
{
return field_6_panose;
}
public byte [] getField_7_fontSig()
{
return field_7_fontSig;
}
public char [] getField_8_xszFfn()
{
return field_8_xszFfn;
}
public int getSize()
{
return (field_1_cbFfnM1 + 1);
}
public char [] getMainFontName()
{
char [] temp = new char[field_5_ixchSzAlt];
System.arraycopy(field_8_xszFfn,0,temp,0,temp.length);
return temp;
}
public char [] getAltFontName()
{
char [] temp = new char[xszFfnLength - field_5_ixchSzAlt];
System.arraycopy(field_8_xszFfn, field_5_ixchSzAlt, temp, 0, temp.length);
return temp;
}
public void setField_1_cbFfnM1(int field_1_cbFfnM1)
{
this.field_1_cbFfnM1 = field_1_cbFfnM1;
}
// changed protected to public
public byte[] toByteArray()
{
int offset = 0;
byte[] buf = new byte[this.getSize()];
buf[offset] = (byte)field_1_cbFfnM1;
offset += LittleEndian.BYTE_SIZE;
buf[offset] = field_2;
offset += LittleEndian.BYTE_SIZE;
LittleEndian.putShort(buf, offset, field_3_wWeight);
offset += LittleEndian.SHORT_SIZE;
buf[offset] = field_4_chs;
offset += LittleEndian.BYTE_SIZE;
buf[offset] = field_5_ixchSzAlt;
offset += LittleEndian.BYTE_SIZE;
System.arraycopy(field_6_panose,0,buf, offset,field_6_panose.length);
offset += field_6_panose.length;
System.arraycopy(field_7_fontSig,0,buf, offset, field_7_fontSig.length);
offset += field_7_fontSig.length;
for(int i = 0; i < field_8_xszFfn.length; i++)
{
buf[offset] = (byte)field_8_xszFfn[i];
offset += LittleEndian.BYTE_SIZE;
}
return buf;
}
public boolean equals(Object o)
{
boolean retVal = true;
if (((Ffn)o).getField_1_cbFfnM1() == field_1_cbFfnM1)
{
if(((Ffn)o).getField_2() == field_2)
{
if(((Ffn)o).getField_3_wWeight() == field_3_wWeight)
{
if(((Ffn)o).getField_4_chs() == field_4_chs)
{
if(((Ffn)o).getField_5_ixchSzAlt() == field_5_ixchSzAlt)
{
if(Arrays.equals(((Ffn)o).getField_6_panose(),field_6_panose))
{
if(Arrays.equals(((Ffn)o).getField_7_fontSig(),field_7_fontSig))
{
if(!(Arrays.equals(((Ffn)o).getField_8_xszFfn(),field_8_xszFfn)))
retVal = false;
}
else
retVal = false;
}
else
retVal = false;
}
else
retVal = false;
}
else
retVal = false;
}
else
retVal = false;
}
else
retVal = false;
}
else
retVal = false;
return retVal;
}
}

View File

@ -1,125 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.hdftypes.definitions.FIBAbstractType;
/**
*
* @author andy
*/
public class FileInformationBlock extends FIBAbstractType
implements Cloneable
{
/** Creates a new instance of FileInformationBlock */
public FileInformationBlock(byte[] mainDocument)
{
fillFields(mainDocument, 0);
}
public void clearOffsetsSizes()
{
try
{
Field[] fields = FileInformationBlock.class.getSuperclass().getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (int x = 0; x < fields.length; x++)
{
String name = fields[x].getName();
int index = name.indexOf('_');
if (index != -1)
{
int nextIndex = name.indexOf('_', index + 1);
if (nextIndex != -1)
{
// clear any field greater than field_53
if (Integer.parseInt(name.substring(index + 1, nextIndex)) > 53)
{
fields[x].setInt(this, 0);
}
}
}
}
}
catch (IllegalAccessException iae)
{
iae.printStackTrace();
}
}
public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
e.printStackTrace();
return null;
}
}
}

View File

@ -1,196 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.io.IOException;
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
import org.apache.poi.hwpf.model.io.HWPFOutputStream;
import org.apache.poi.util.LittleEndian;
/**
* FontTable or in MS terminology sttbfffn is a common data structure written in all
* Word files. The sttbfffn is an sttbf where each string is an FFN structure instead
* of pascal-style strings. An sttbf is a string Table stored in file. Thus sttbffn
* is like an Sttbf with an array of FFN structures that stores the font name strings
*
* @author Praveen Mathew
*/
public class FontTable
{
private short _stringCount;// how many strings are included in the string table
private short _extraDataSz;// size in bytes of the extra data
// added extra facilitator members
private int lcbSttbfffn;// count of bytes in sttbfffn
private int fcSttbfffn;// table stream offset for sttbfffn
// FFN structure containing strings of font names
private Ffn[] _fontNames = null;
public FontTable(byte[] buf, int offset, int lcbSttbfffn)
{
this.lcbSttbfffn = lcbSttbfffn;
this.fcSttbfffn = offset;
_stringCount = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
_extraDataSz = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
_fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
for(int i = 0;i<_stringCount; i++)
{
_fontNames[i] = new Ffn(buf,offset);
offset += _fontNames[i].getSize();
}
}
public short getStringCount()
{
return _stringCount;
}
public short getExtraDataSz()
{
return _extraDataSz;
}
public Ffn[] getFontNames()
{
return _fontNames;
}
public int getSize()
{
return lcbSttbfffn;
}
public char [] getMainFont(int chpFtc )
{
if(chpFtc >= _stringCount)
{
System.out.println("Mismatch in chpFtc with stringCount");
return null;
}
return _fontNames[chpFtc].getMainFontName();
}
public char [] getAltFont(int chpFtc )
{
if(chpFtc >= _stringCount)
{
System.out.println("Mismatch in chpFtc with stringCount");
return null;
}
return _fontNames[chpFtc].getAltFontName();
}
public void setStringCount(short stringCount)
{
this._stringCount = stringCount;
}
public void writeTo(HWPFFileSystem sys)
throws IOException
{
HWPFOutputStream tableStream = sys.getStream("1Table");
byte[] buf = new byte[LittleEndian.SHORT_SIZE];
LittleEndian.putShort(buf, _stringCount);
tableStream.write(buf);
LittleEndian.putShort(buf, _extraDataSz);
tableStream.write(buf);
for(int i = 0; i < _fontNames.length; i++)
{
tableStream.write(_fontNames[i].toByteArray());
}
}
public boolean equals(Object o)
{
boolean retVal = true;
if(((FontTable)o).getStringCount() == _stringCount)
{
if(((FontTable)o).getExtraDataSz() == _extraDataSz)
{
Ffn[] fontNamesNew = ((FontTable)o).getFontNames();
for(int i = 0;i<_stringCount; i++)
{
if(!(_fontNames[i].equals(fontNamesNew[i])))
retVal = false;
}
}
else
retVal = false;
}
else
retVal = false;
return retVal;
}
}

View File

@ -1,128 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
/**
* Represents an FKP data structure. This data structure is used to store the
* grpprls of the paragraph and character properties of the document. A grpprl
* is a list of sprms(decompression operations) to perform on a parent style.
*
* The style properties for paragraph and character runs
* are stored in fkps. There are PAP fkps for paragraph properties and CHP fkps
* for character run properties. The first part of the fkp for both CHP and PAP
* fkps consists of an array of 4 byte int offsets in the main stream for that
* Paragraph's or Character run's text. The ending offset is the next
* value in the array. For example, if an fkp has X number of Paragraph's
* stored in it then there are (x + 1) 4 byte ints in the beginning array. The
* number X is determined by the last byte in a 512 byte fkp.
*
* CHP and PAP fkps also store the compressed styles(grpprl) that correspond to
* the offsets on the front of the fkp. The offset of the grpprls is determined
* differently for CHP fkps and PAP fkps.
*
* @author Ryan Ackley
*/
public abstract class FormattedDiskPage
{
protected byte[] _fkp;
protected int _crun;
protected int _offset;
public FormattedDiskPage()
{
}
/**
* Uses a 512-byte array to create a FKP
*/
public FormattedDiskPage(byte[] documentStream, int offset)
{
_crun = LittleEndian.getUnsignedByte(documentStream, offset + 511);
_fkp = documentStream;
_offset = offset;
}
/**
* Used to get a text offset corresponding to a grpprl in this fkp.
* @param index The index of the property in this FKP
* @return an int representing an offset in the "WordDocument" stream
*/
protected int getStart(int index)
{
return LittleEndian.getInt(_fkp, _offset + (index * 4));
}
/**
* Used to get the end of the text corresponding to a grpprl in this fkp.
* @param index The index of the property in this fkp.
* @return an int representing an offset in the "WordDocument" stream
*/
protected int getEnd(int index)
{
return LittleEndian.getInt(_fkp, _offset + ((index + 1) * 4));
}
/**
* Used to get the total number of grrprl's stored int this FKP
* @return The number of grpprls in this FKP
*/
public int size()
{
return _crun;
}
protected abstract byte[] getGrpprl(int index);
}

View File

@ -1,16 +0,0 @@
/*
* HDFType.java
*
* Created on February 24, 2002, 2:37 PM
*/
package org.apache.poi.hwpf.model.hdftypes;
/**
*
* @author andy
*/
public interface HDFType {
}

View File

@ -1,133 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
public class ListData
{
private int _lsid;
private int _tplc;
private short[] _rglst;
private byte _info;
private static BitField _fSimpleList = new BitField(0x1);
private static BitField _fRestartHdn = new BitField(0x2);
private byte _reserved;
ListLevel[] _levels;
public ListData(byte[] buf, int offset)
{
_lsid = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_tplc = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_rglst = new short[9];
for (int x = 0; x < 9; x++)
{
_rglst[x] = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
}
_info = buf[offset++];
_reserved = buf[offset];
if (_fSimpleList.getValue(_info) > 0)
{
_levels = new ListLevel[1];
}
else
{
_levels = new ListLevel[9];
}
}
public int getLsid()
{
return _lsid;
}
public int numLevels()
{
return _levels.length;
}
public void setLevel(int index, ListLevel level)
{
_levels[index] = level;
}
public ListLevel[] getLevels()
{
return _levels;
}
public byte[] toByteArray()
{
byte[] buf = new byte[28];
int offset = 0;
LittleEndian.putInt(buf, _lsid);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, _tplc);
offset += LittleEndian.INT_SIZE;
for (int x = 0; x < 9; x++)
{
LittleEndian.putShort(buf, offset, _rglst[x]);
offset += LittleEndian.SHORT_SIZE;
}
buf[offset++] = _info;
buf[offset] = _reserved;
return buf;
}
}

View File

@ -1,116 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
public class ListFormatOverride
{
int _lsid;
int _reserved1;
int _reserved2;
byte _clfolvl;
byte[] _reserved3 = new byte[3];
ListFormatOverrideLevel[] _levelOverrides;
public ListFormatOverride(byte[] buf, int offset)
{
_lsid = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_reserved1 = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_reserved2 = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_clfolvl = buf[offset++];
System.arraycopy(buf, offset, _reserved3, 0, _reserved3.length);
_levelOverrides = new ListFormatOverrideLevel[_clfolvl];
}
public int numOverrides()
{
return _clfolvl;
}
public int getLsid()
{
return _lsid;
}
public ListFormatOverrideLevel[] getLevelOverrides()
{
return _levelOverrides;
}
public void setOverride(int index, ListFormatOverrideLevel lfolvl)
{
_levelOverrides[index] = lfolvl;
}
public byte[] toByteArray()
{
byte[] buf = new byte[16];
int offset = 0;
LittleEndian.putInt(buf, offset, _lsid);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, _reserved1);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, _reserved2);
offset += LittleEndian.INT_SIZE;
buf[offset++] = _clfolvl;
System.arraycopy(_reserved3, 0, buf, offset, 3);
return buf;
}
}

View File

@ -1,106 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField;
public class ListFormatOverrideLevel
{
private static final int BASE_SIZE = 8;
int _iStartAt;
byte _info;
private static BitField _ilvl = new BitField(0xf);
private static BitField _fStartAt = new BitField(0x10);
private static BitField _fFormatting = new BitField(0x20);
byte[] _reserved = new byte[3];
ListLevel _lvl;
public ListFormatOverrideLevel(byte[] buf, int offset)
{
_iStartAt = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_info = buf[offset++];
System.arraycopy(buf, offset, _reserved, 0, _reserved.length);
offset += _reserved.length;
if (_fFormatting.getValue(_info) > 0)
{
_lvl = new ListLevel(buf, offset);
}
}
public int getSizeInBytes()
{
return (_lvl == null ? BASE_SIZE : BASE_SIZE + _lvl.getSizeInBytes());
}
public byte[] toByteArray()
{
byte[] buf = new byte[getSizeInBytes()];
int offset = 0;
LittleEndian.putInt(buf, _iStartAt);
offset += LittleEndian.INT_SIZE;
buf[offset++] = _info;
System.arraycopy(_reserved, 0, buf, offset, 3);
byte[] levelBuf = _lvl.toByteArray();
System.arraycopy(levelBuf, 0, buf, offset, levelBuf.length);
return buf;
}
}

View File

@ -1,159 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
public class ListLevel
{
private int _iStartAt;
private byte _nfc;
private byte _info;
private static BitField _jc;
private static BitField _fLegal;
private static BitField _fNoRestart;
private static BitField _fPrev;
private static BitField _fPrevSpace;
private static BitField _fWord6;
private byte[] _rgbxchNums;
private byte _ixchFollow;
private int _dxaSpace;
private int _dxaIndent;
private int _cbGrpprlChpx;
private int _cbGrpprlPapx;
private byte _reserved;
private byte[] _grpprlPapx;
private byte[] _grpprlChpx;
private char[] _numberText;
public ListLevel(byte[] buf, int offset)
{
_iStartAt = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_nfc = buf[offset++];
_info = buf[offset++];
_rgbxchNums = new byte[9];
for (int x = 0; x < 9; x++)
{
_rgbxchNums[x] = buf[offset++];
}
_ixchFollow = buf[offset++];
_dxaSpace = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_dxaIndent = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
_cbGrpprlChpx = LittleEndian.getUnsignedByte(buf, offset++);
_cbGrpprlPapx = LittleEndian.getUnsignedByte(buf, offset++);
_reserved = buf[offset++];
_grpprlPapx = new byte[_cbGrpprlPapx];
_grpprlChpx = new byte[_cbGrpprlChpx];
System.arraycopy(buf, offset, _grpprlPapx, 0, _cbGrpprlPapx);
offset += _cbGrpprlPapx;
System.arraycopy(buf, offset, _grpprlChpx, 0, _cbGrpprlChpx);
offset += _cbGrpprlChpx;
int numberTextLength = LittleEndian.getShort(buf, offset);
_numberText = new char[numberTextLength];
offset += LittleEndian.SHORT_SIZE;
for (int x = 0; x < numberTextLength; x++)
{
_numberText[x] = (char)LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
}
}
public byte[] toByteArray()
{
byte[] buf = new byte[getSizeInBytes()];
int offset = 0;
LittleEndian.putInt(buf, offset, _iStartAt);
offset += LittleEndian.INT_SIZE;
buf[offset++] = _nfc;
buf[offset++] = _info;
System.arraycopy(_rgbxchNums, 0, buf, offset, _rgbxchNums.length);
offset += _rgbxchNums.length;
buf[offset++] = _ixchFollow;
LittleEndian.putInt(buf, offset, _dxaSpace);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, _dxaIndent);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, _cbGrpprlChpx);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, _cbGrpprlPapx);
offset += LittleEndian.INT_SIZE;
System.arraycopy(_grpprlPapx, 0, buf, offset, _cbGrpprlPapx);
offset += _cbGrpprlPapx;
System.arraycopy(_grpprlChpx, 0, buf, offset, _cbGrpprlChpx);
offset += _cbGrpprlChpx;
LittleEndian.putShort(buf, offset, (short)_numberText.length);
offset += LittleEndian.SHORT_SIZE;
for (int x = 0; x < _numberText.length; x++)
{
LittleEndian.putShort(buf, offset, (short)_numberText[x]);
offset += LittleEndian.SHORT_SIZE;
}
return buf;
}
public int getSizeInBytes()
{
return 28 + _cbGrpprlChpx + _cbGrpprlPapx + _numberText.length + 2;
}
}

View File

@ -1,164 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.io.*;
import java.util.HashMap;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class ListTables
{
private static final int LIST_DATA_SIZE = 28;
private static final int LIST_FORMAT_OVERRIDE_SIZE = 16;
HashMap listMap = new HashMap();
HashMap overrideMap = new HashMap();
public ListTables(byte[] tableStream, int lstOffset, int lfoOffset)
{
// get the list data
int length = LittleEndian.getShort(tableStream, lstOffset);
lstOffset += LittleEndian.SHORT_SIZE;
int levelOffset = lstOffset + (length * LIST_DATA_SIZE);
for (int x = 0; x < length; x++)
{
ListData lst = new ListData(tableStream, lstOffset);
listMap.put(new Integer(lst.getLsid()), lst);
lstOffset += LIST_DATA_SIZE;
int num = lst.numLevels();
for (int y = 0; y < num; y++)
{
ListLevel lvl = new ListLevel(tableStream, levelOffset);
lst.setLevel(y, lvl);
levelOffset += lvl.getSizeInBytes();
}
}
// now get the list format overrides. The size is an int unlike the LST size
length = LittleEndian.getInt(tableStream, lfoOffset);
lfoOffset += LittleEndian.INT_SIZE;
int lfolvlOffset = LIST_FORMAT_OVERRIDE_SIZE * length + 4;
for (int x = 0; x < length; x++)
{
ListFormatOverride lfo = new ListFormatOverride(tableStream, lfoOffset);
lfoOffset += LIST_FORMAT_OVERRIDE_SIZE;
int num = lfo.numOverrides();
for (int y = 0; y < num; y++)
{
ListFormatOverrideLevel lfolvl = new ListFormatOverrideLevel(tableStream, lfolvlOffset);
lfo.setOverride(y, lfolvl);
lfolvlOffset += lfolvl.getSizeInBytes();
}
overrideMap.put(new Integer(lfo.getLsid()), lfo);
}
}
public void writeListDataTo(HWPFOutputStream tableStream)
throws IOException
{
Integer[] intList = (Integer[])listMap.keySet().toArray(new Integer[0]);
// use this stream as a buffer for the levels since their size varies.
ByteArrayOutputStream levelBuf = new ByteArrayOutputStream();
// use a byte array for the lists because we know their size.
byte[] listBuf = new byte[intList.length * LIST_DATA_SIZE];
for (int x = 0; x < intList.length; x++)
{
ListData lst = (ListData)listMap.get(intList[x]);
tableStream.write(lst.toByteArray());
ListLevel[] lvls = lst.getLevels();
for (int y = 0; y < lvls.length; y++)
{
levelBuf.write(lvls[y].toByteArray());
}
}
tableStream.write(levelBuf.toByteArray());
}
public void writeListOverridesTo(HWPFOutputStream tableStream)
throws IOException
{
Integer[] intList = (Integer[])overrideMap.keySet().toArray(new Integer[0]);
// use this stream as a buffer for the levels since their size varies.
ByteArrayOutputStream levelBuf = new ByteArrayOutputStream();
// use a byte array for the lists because we know their size.
byte[] overrideBuf = new byte[intList.length * LIST_FORMAT_OVERRIDE_SIZE];
for (int x = 0; x < intList.length; x++)
{
ListFormatOverride lfo = (ListFormatOverride)overrideMap.get(intList[x]);
tableStream.write(lfo.toByteArray());
ListFormatOverrideLevel[] lfolvls = lfo.getLevelOverrides();
for (int y = 0; y < lfolvls.length; y++)
{
levelBuf.write(lfolvls[y].toByteArray());
}
}
tableStream.write(levelBuf.toByteArray());
}
}

View File

@ -1,212 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.util.ArrayList;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.poi.hwpf.model.io.*;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian;
public class PAPBinTable
{
ArrayList _paragraphs = new ArrayList();
public PAPBinTable(byte[] documentStream, byte[] tableStream, int offset,
int size, int fcMin)
{
PlexOfCps binTable = new PlexOfCps(tableStream, offset, size, 4);
int length = binTable.length();
for (int x = 0; x < length; x++)
{
PropertyNode node = binTable.getProperty(x);
int pageNum = LittleEndian.getInt(node.getBuf());
int pageOffset = POIFSConstants.BIG_BLOCK_SIZE * pageNum;
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(documentStream,
pageOffset, fcMin);
int fkpSize = pfkp.size();
for (int y = 0; y < fkpSize; y++)
{
_paragraphs.add(pfkp.getPAPX(y));
}
}
}
public void adjustForDelete(int listIndex, int offset, int length)
{
int size = _paragraphs.size();
int endMark = offset + length;
int endIndex = listIndex;
PAPX papx = (PAPX)_paragraphs.get(endIndex);
while (papx.getEnd() < endMark)
{
papx = (PAPX)_paragraphs.get(++endIndex);
}
if (listIndex == endIndex)
{
papx = (PAPX)_paragraphs.get(endIndex);
papx.setEnd((papx.getEnd() - endMark) + offset);
}
else
{
papx = (PAPX)_paragraphs.get(listIndex);
papx.setEnd(offset);
for (int x = listIndex + 1; x < endIndex; x++)
{
papx = (PAPX)_paragraphs.get(x);
papx.setStart(offset);
papx.setEnd(offset);
}
papx = (PAPX)_paragraphs.get(endIndex);
papx.setEnd((papx.getEnd() - endMark) + offset);
}
for (int x = endIndex + 1; x < size; x++)
{
papx = (PAPX)_paragraphs.get(x);
papx.setStart(papx.getStart() - length);
papx.setEnd(papx.getEnd() - length);
}
}
public void adjustForInsert(int listIndex, int length)
{
int size = _paragraphs.size();
PAPX papx = (PAPX)_paragraphs.get(listIndex);
papx.setEnd(papx.getEnd() + length);
for (int x = listIndex + 1; x < size; x++)
{
papx = (PAPX)_paragraphs.get(x);
papx.setStart(papx.getStart() + length);
papx.setEnd(papx.getEnd() + length);
}
}
public ArrayList getParagraphs()
{
return _paragraphs;
}
public void writeTo(HWPFFileSystem sys, int fcMin)
throws IOException
{
HWPFOutputStream docStream = sys.getStream("WordDocument");
OutputStream tableStream = sys.getStream("1Table");
PlexOfCps binTable = new PlexOfCps(4);
// each FKP must start on a 512 byte page.
int docOffset = docStream.getOffset();
int mod = docOffset % POIFSConstants.BIG_BLOCK_SIZE;
if (mod != 0)
{
byte[] padding = new byte[POIFSConstants.BIG_BLOCK_SIZE - mod];
docStream.write(padding);
}
// get the page number for the first fkp
docOffset = docStream.getOffset();
int pageNum = docOffset/POIFSConstants.BIG_BLOCK_SIZE;
// get the ending fc
int endingFc = ((PropertyNode)_paragraphs.get(_paragraphs.size() - 1)).getEnd();
endingFc += fcMin;
ArrayList overflow = _paragraphs;
do
{
PropertyNode startingProp = (PropertyNode)overflow.get(0);
int start = startingProp.getStart() + fcMin;
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage();
pfkp.fill(overflow);
byte[] bufFkp = pfkp.toByteArray(fcMin);
docStream.write(bufFkp);
overflow = pfkp.getOverflow();
int end = endingFc;
if (overflow != null)
{
end = ((PropertyNode)overflow.get(0)).getStart() + fcMin;
}
byte[] intHolder = new byte[4];
LittleEndian.putInt(intHolder, pageNum++);
binTable.addProperty(new PropertyNode(start, end, intHolder));
}
while (overflow != null);
tableStream.write(binTable.toByteArray());
}
}

View File

@ -1,266 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
/**
* Represents a PAP FKP. The style properties for paragraph and character runs
* are stored in fkps. There are PAP fkps for paragraph properties and CHP fkps
* for character run properties. The first part of the fkp for both CHP and PAP
* fkps consists of an array of 4 byte int offsets in the main stream for that
* Paragraph's or Character run's text. The ending offset is the next
* value in the array. For example, if an fkp has X number of Paragraph's
* stored in it then there are (x + 1) 4 byte ints in the beginning array. The
* number X is determined by the last byte in a 512 byte fkp.
*
* CHP and PAP fkps also store the compressed styles(grpprl) that correspond to
* the offsets on the front of the fkp. The offset of the grpprls is determined
* differently for CHP fkps and PAP fkps.
*
* @author Ryan Ackley
*/
public class PAPFormattedDiskPage extends FormattedDiskPage
{
private static final int BX_SIZE = 13;
private static final int FC_SIZE = 4;
private ArrayList _papxList = new ArrayList();
private ArrayList _overFlow;
public PAPFormattedDiskPage()
{
}
/**
* Creates a PAPFormattedDiskPage from a 512 byte array
*/
public PAPFormattedDiskPage(byte[] documentStream, int offset, int fcMin)
{
super(documentStream, offset);
for (int x = 0; x < _crun; x++)
{
_papxList.add(new PAPX(getStart(x) - fcMin, getEnd(x) - fcMin, getGrpprl(x), getParagraphHeight(x)));
}
_fkp = null;
}
public void fill(List filler)
{
_papxList.addAll(filler);
}
public ArrayList getOverflow()
{
return _overFlow;
}
public PAPX getPAPX(int index)
{
return (PAPX)_papxList.get(index);
}
/**
* Gets the papx for the paragraph at index in this fkp.
*
* @param index The index of the papx to get.
* @return a papx grpprl.
*/
protected byte[] getGrpprl(int index)
{
int papxOffset = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * FC_SIZE) + (index * BX_SIZE)));
int size = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + papxOffset);
if(size == 0)
{
size = 2 * LittleEndian.getUnsignedByte(_fkp, _offset + ++papxOffset);
}
else
{
size--;
}
byte[] papx = new byte[size];
System.arraycopy(_fkp, _offset + ++papxOffset, papx, 0, size);
return papx;
}
protected byte[] toByteArray(int fcMin)
{
byte[] buf = new byte[512];
int size = _papxList.size();
int grpprlOffset = 0;
int bxOffset = 0;
int fcOffset = 0;
byte[] lastGrpprl = new byte[0];
// total size is currently the size of one FC
int totalSize = FC_SIZE;
int index = 0;
for (; index < size; index++)
{
byte[] grpprl = ((PAPX)_papxList.get(index)).getGrpprl();
int grpprlLength = grpprl.length;
// check to see if we have enough room for an FC, a BX, and the grpprl
// and the 1 byte size of the grpprl.
int addition = 0;
if (!Arrays.equals(grpprl, lastGrpprl))
{
addition = (FC_SIZE + BX_SIZE + grpprlLength + 1);
}
else
{
addition = (FC_SIZE + BX_SIZE);
}
totalSize += addition;
// if size is uneven we will have to add one so the first grpprl falls
// on a word boundary
if (totalSize > 511 + (index % 2))
{
totalSize -= addition;
break;
}
// grpprls must fall on word boundaries
if (grpprlLength % 2 > 0)
{
totalSize += 1;
}
else
{
totalSize += 2;
}
lastGrpprl = grpprl;
}
// see if we couldn't fit some
if (index != size)
{
_overFlow = new ArrayList();
_overFlow.addAll(_papxList.subList(index, size));
}
// index should equal number of papxs that will be in this fkp now.
buf[511] = (byte)index;
bxOffset = (FC_SIZE * index) + FC_SIZE;
grpprlOffset = 511;
PAPX papx = null;
lastGrpprl = new byte[0];
for (int x = 0; x < index; x++)
{
papx = (PAPX)_papxList.get(x);
byte[] phe = papx.getParagraphHeight().toByteArray();
byte[] grpprl = papx.getGrpprl();
boolean same = Arrays.equals(lastGrpprl, grpprl);
if (!same)
{
grpprlOffset -= (grpprl.length + (2 - grpprl.length % 2));
grpprlOffset -= (grpprlOffset % 2);
}
LittleEndian.putInt(buf, fcOffset, papx.getStart() + fcMin);
buf[bxOffset] = (byte)(grpprlOffset/2);
System.arraycopy(phe, 0, buf, bxOffset + 1, phe.length);
// refer to the section on PAPX in the spec. Places a size on the front
// of the PAPX. Has to do with how the grpprl stays on word
// boundaries.
if (!same)
{
int copyOffset = grpprlOffset;
if ( (grpprl.length % 2) > 0)
{
buf[copyOffset++] = (byte) ( (grpprl.length + 1) / 2);
}
else
{
buf[++copyOffset] = (byte) ( (grpprl.length) / 2);
copyOffset++;
}
System.arraycopy(grpprl, 0, buf, copyOffset, grpprl.length);
lastGrpprl = grpprl;
}
bxOffset += BX_SIZE;
fcOffset += FC_SIZE;
}
// put the last papx's end in
LittleEndian.putInt(buf, fcOffset, papx.getEnd() + fcMin);
return buf;
}
private ParagraphHeight getParagraphHeight(int index)
{
int pheOffset = _offset + 1 + (((_crun + 1) * 4) + (index * 13));
ParagraphHeight phe = new ParagraphHeight(_fkp, pheOffset);
return phe;
}
}

View File

@ -1,117 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.sprm.SprmBuffer;
/**
* Comment me
*
* @author Ryan Ackley
*/
public class PAPX extends PropertyNode
{
private ParagraphHeight _phe;
public PAPX(int fcStart, int fcEnd, byte[] papx, ParagraphHeight phe)
{
super(fcStart, fcEnd, new SprmBuffer(papx));
_phe = phe;
}
public ParagraphHeight getParagraphHeight()
{
return _phe;
}
public byte[] getGrpprl()
{
return ((SprmBuffer)_buf).toByteArray();
}
public byte[] getBuf()
{
return getGrpprl();
}
public short getIstd()
{
byte[] buf = getGrpprl();
if (buf.length == 0)
{
return 0;
}
else
{
return LittleEndian.getShort(buf);
}
}
public boolean equals(Object o)
{
if (super.equals(o))
{
return _phe.equals(((PAPX)o)._phe);
}
return false;
}
}

View File

@ -1,115 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.io.OutputStream;
import java.io.IOException;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
public class ParagraphHeight
{
private short infoField;
private BitField fSpare = new BitField(0x0001);
private BitField fUnk = new BitField(0x0002);
private BitField fDiffLines = new BitField(0x0004);
private BitField clMac = new BitField(0xff00);
private short reserved;
private int dxaCol;
private int dymLineOrHeight;
public ParagraphHeight(byte[] buf, int offset)
{
infoField = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
reserved = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
dxaCol = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
dymLineOrHeight = LittleEndian.getInt(buf, offset);
}
public void write(OutputStream out)
throws IOException
{
out.write(toByteArray());
}
protected byte[] toByteArray()
{
byte[] buf = new byte[12];
int offset = 0;
LittleEndian.putShort(buf, offset, infoField);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, reserved);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, dxaCol);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, dymLineOrHeight);
return buf;
}
public boolean equals(Object o)
{
ParagraphHeight ph = (ParagraphHeight)o;
return infoField == ph.infoField && reserved == ph.reserved &&
dxaCol == ph.dxaCol && dymLineOrHeight == ph.dymLineOrHeight;
}
}

View File

@ -1,144 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
public class PieceDescriptor
{
short descriptor;
private static BitField fNoParaLast = new BitField(0x01);
private static BitField fPaphNil = new BitField(0x02);
private static BitField fCopied = new BitField(0x04);
int fc;
short prm;
boolean unicode;
public PieceDescriptor(byte[] buf, int offset)
{
descriptor = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
fc = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
prm = LittleEndian.getShort(buf, offset);
// see if this piece uses unicode.
if ((fc & 0x40000000) == 0)
{
unicode = true;
}
else
{
unicode = false;
fc &= ~(0x40000000);//gives me FC in doc stream
fc /= 2;
}
}
public int getFilePosition()
{
return fc;
}
public void setFilePosition(int pos)
{
fc = pos;
}
public boolean isUnicode()
{
return unicode;
}
protected byte[] toByteArray()
{
// set up the fc
int tempFc = fc;
if (!unicode)
{
tempFc *= 2;
tempFc |= (0x40000000);
}
int offset = 0;
byte[] buf = new byte[8];
LittleEndian.putShort(buf, offset, descriptor);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, tempFc);
offset += LittleEndian.INT_SIZE;
LittleEndian.putShort(buf, offset, prm);
return buf;
}
public static int getSizeInBytes()
{
return 8;
}
public boolean equals(Object o)
{
PieceDescriptor pd = (PieceDescriptor)o;
return descriptor == pd.descriptor && prm == pd.prm && unicode == pd.unicode;
}
}

View File

@ -1,179 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.util.ArrayList;
import org.apache.poi.util.LittleEndian;
/**
* common data structure in a Word file. Contains an array of 4 byte ints in
* the front that relate to an array of abitrary data structures in the back.
*
*
* @author Ryan Ackley
*/
public class PlexOfCps
{
private int _count;
private int _offset;
private int _sizeOfStruct;
private ArrayList _props;
public PlexOfCps(int sizeOfStruct)
{
_props = new ArrayList();
_sizeOfStruct = sizeOfStruct;
}
/**
* Constructor
*
* @param size The size in bytes of this PlexOfCps
* @param sizeOfStruct The size of the data structure type stored in
* this PlexOfCps.
*/
public PlexOfCps(byte[] buf, int start, int size, int sizeOfStruct)
{
_count = (size - 4)/(4 + sizeOfStruct);
_sizeOfStruct = sizeOfStruct;
_props = new ArrayList(_count);
for (int x = 0; x < _count; x++)
{
_props.add(getProperty(x, buf, start));
}
}
public PropertyNode getProperty(int index)
{
return (PropertyNode)_props.get(index);
}
public void addProperty(PropertyNode node)
{
_props.add(node);
}
public byte[] toByteArray()
{
int size = _props.size();
int cpBufSize = ((size + 1) * LittleEndian.INT_SIZE);
int structBufSize = + (_sizeOfStruct * size);
int bufSize = cpBufSize + structBufSize;
byte[] buf = new byte[bufSize];
PropertyNode node = null;
for (int x = 0; x < size; x++)
{
node = (PropertyNode)_props.get(x);
// put the starting offset of the property into the plcf.
LittleEndian.putInt(buf, (LittleEndian.INT_SIZE * x), node.getStart());
// put the struct into the plcf
System.arraycopy(node.getBuf(), 0, buf, cpBufSize + (x * _sizeOfStruct),
_sizeOfStruct);
}
// put the ending offset of the last property into the plcf.
LittleEndian.putInt(buf, LittleEndian.INT_SIZE * size, node.getEnd());
return buf;
}
private PropertyNode getProperty(int index, byte[] buf, int offset)
{
int start = LittleEndian.getInt(buf, offset + getIntOffset(index));
int end = LittleEndian.getInt(buf, offset + getIntOffset(index+1));
byte[] struct = new byte[_sizeOfStruct];
System.arraycopy(buf, offset + getStructOffset(index), struct, 0, _sizeOfStruct);
return new PropertyNode(start, end, struct);
}
private int getIntOffset(int index)
{
return index * 4;
}
/**
* returns the number of data structures in this PlexOfCps.
*
* @return The number of data structures in this PlexOfCps
*/
public int length()
{
return _count;
}
/**
* Returns the offset, in bytes, from the beginning if this PlexOfCps to
* the data structure at index.
*
* @param index The index of the data structure.
*
* @return The offset, in bytes, from the beginning if this PlexOfCps to
* the data structure at index.
*/
private int getStructOffset(int index)
{
return (4 * (_count + 1)) + (_sizeOfStruct * index);
}
}

View File

@ -1,173 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.lang.ref.SoftReference;
import java.io.ByteArrayOutputStream;
import org.apache.poi.hwpf.sprm.SprmBuffer;
/**
* Represents a lightweight node in the Trees used to store content
* properties.
*
* @author Ryan Ackley
*/
public class PropertyNode implements Comparable
{
protected Object _buf;
private int _cpStart;
private int _cpEnd;
protected SoftReference _propCache;
/**
* @param fcStart The start of the text for this property.
* @param fcEnd The end of the text for this property.
*/
public PropertyNode(int fcStart, int fcEnd, Object buf)
{
_cpStart = fcStart;
_cpEnd = fcEnd;
_buf = buf;
}
/**
* @return The offset of this property's text.
*/
public int getStart()
{
return _cpStart;
}
void setStart(int start)
{
_cpStart = start;
}
/**
* @return The offset of the end of this property's text.
*/
public int getEnd()
{
return _cpEnd;
}
void setEnd(int end)
{
_cpEnd = end;
}
/**
* @return This property's property in copmpressed form.
*/
public byte[] getBuf()
{
return ((byte[])_buf);
}
public boolean equals(Object o)
{
byte[] buf = getBuf();
if (((PropertyNode)o).getStart() == _cpStart &&
((PropertyNode)o).getEnd() == _cpEnd)
{
byte[] testBuf = ((PropertyNode)o).getBuf();
if (testBuf.length == buf.length)
{
for (int x = 0; x < buf.length; x++)
{
if (testBuf[x] != buf[x])
{
return false;
}
}
return true;
}
}
return false;
}
/**
* Used for sorting in collections.
*/
public int compareTo(Object o)
{
int cpEnd = ((PropertyNode)o).getEnd();
if(_cpEnd == cpEnd)
{
return 0;
}
else if(_cpEnd < cpEnd)
{
return -1;
}
else
{
return 1;
}
}
public void fillCache(Object ref)
{
_propCache = new SoftReference(ref);
}
public Object getCacheContents()
{
return _propCache == null ? null : _propCache.get();
}
}

View File

@ -1,90 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
public class SEPX extends PropertyNode
{
SectionDescriptor _sed;
public SEPX(SectionDescriptor sed, int start, int end, byte[] grpprl)
{
super(start, end, grpprl);
_sed = sed;
}
public byte[] getGrpprl()
{
return super.getBuf();
}
public SectionDescriptor getSectionDescriptor()
{
return _sed;
}
public boolean equals(Object o)
{
SEPX sepx = (SEPX)o;
if (super.equals(o))
{
return sepx._sed.equals(_sed);
}
return false;
}
}

View File

@ -1,115 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import org.apache.poi.util.LittleEndian;
public class SectionDescriptor
{
private short fn;
private int fc;
private short fnMpr;
private int fcMpr;
public SectionDescriptor()
{
}
public SectionDescriptor(byte[] buf, int offset)
{
fn = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
fc = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
fnMpr = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
fcMpr = LittleEndian.getInt(buf, offset);
}
public int getFc()
{
return fc;
}
public void setFc(int fc)
{
this.fc = fc;
}
public boolean equals(Object o)
{
SectionDescriptor sed = (SectionDescriptor)o;
return sed.fn == fn && sed.fnMpr == fnMpr;
}
public byte[] toByteArray()
{
int offset = 0;
byte[] buf = new byte[12];
LittleEndian.putShort(buf, offset, fn);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, fc);
offset += LittleEndian.INT_SIZE;
LittleEndian.putShort(buf, offset, fnMpr);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, fcMpr);
return buf;
}
}

View File

@ -1,159 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.io.*;
public class SectionTable
{
private static final int SED_SIZE = 12;
private ArrayList _sections = new ArrayList();
public SectionTable(byte[] documentStream, byte[] tableStream, int offset,
int size, int fcMin)
{
PlexOfCps sedPlex = new PlexOfCps(tableStream, offset, size, SED_SIZE);
int length = sedPlex.length();
for (int x = 0; x < length; x++)
{
PropertyNode node = sedPlex.getProperty(x);
SectionDescriptor sed = new SectionDescriptor(node.getBuf(), 0);
int fileOffset = sed.getFc();
// check for the optimization
if (fileOffset == 0xffffffff)
{
_sections.add(new SEPX(sed, node.getStart(), node.getEnd(), new byte[0]));
}
else
{
// The first short at the offset is the size of the grpprl.
int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
byte[] buf = new byte[sepxSize];
fileOffset += LittleEndian.SHORT_SIZE;
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
_sections.add(new SEPX(sed, node.getStart(), node.getEnd(), buf));
}
}
}
public void adjustForInsert(int listIndex, int length)
{
int size = _sections.size();
SEPX sepx = (SEPX)_sections.get(listIndex);
sepx.setEnd(sepx.getEnd() + length);
for (int x = listIndex + 1; x < size; x++)
{
sepx = (SEPX)_sections.get(x);
sepx.setStart(sepx.getStart() + length);
sepx.setEnd(sepx.getEnd() + length);
}
}
public ArrayList getSections()
{
return _sections;
}
public void writeTo(HWPFFileSystem sys, int fcMin)
throws IOException
{
HWPFOutputStream docStream = sys.getStream("WordDocument");
HWPFOutputStream tableStream = sys.getStream("1Table");
int offset = docStream.getOffset();
int len = _sections.size();
PlexOfCps plex = new PlexOfCps(SED_SIZE);
for (int x = 0; x < len; x++)
{
SEPX sepx = (SEPX)_sections.get(x);
byte[] grpprl = sepx.getGrpprl();
// write the sepx to the document stream. starts with a 2 byte size
// followed by the grpprl
byte[] shortBuf = new byte[2];
LittleEndian.putShort(shortBuf, (short)grpprl.length);
docStream.write(shortBuf);
docStream.write(grpprl);
// set the fc in the section descriptor
SectionDescriptor sed = sepx.getSectionDescriptor();
sed.setFc(offset);
// add the section descriptor bytes to the PlexOfCps.
PropertyNode property = new PropertyNode(sepx.getStart(), sepx.getEnd(), sed.toByteArray());
plex.addProperty(property);
offset = docStream.getOffset();
}
tableStream.write(plex.toByteArray());
}
}

View File

@ -1,294 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import org.apache.poi.hwpf.usermodel.CharacterRun;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField;
/**
* Comment me
*
* @author Ryan Ackley
*/
public class StyleDescription implements HDFType
{
private final static int PARAGRAPH_STYLE = 1;
private final static int CHARACTER_STYLE = 2;
private int _istd;
private int _baseLength;
private short _infoShort;
private static BitField _sti = new BitField(0xfff);
private static BitField _fScratch = new BitField(0x1000);
private static BitField _fInvalHeight = new BitField(0x2000);
private static BitField _fHasUpe = new BitField(0x4000);
private static BitField _fMassCopy = new BitField(0x8000);
private short _infoShort2;
private static BitField _styleTypeCode = new BitField(0xf);
private static BitField _baseStyle = new BitField(0xfff0);
private short _infoShort3;
private static BitField _numUPX = new BitField(0xf);
private static BitField _nextStyle = new BitField(0xfff0);
private short _bchUpe;
private short _infoShort4;
private static BitField _fAutoRedef = new BitField(0x1);
private static BitField _fHidden = new BitField(0x2);
UPX[] _upxs;
String _name;
Paragraph _pap;
CharacterRun _chp;
public StyleDescription()
{
// _pap = new ParagraphProperties();
// _chp = new CharacterProperties();
}
public StyleDescription(byte[] std, int baseLength, int offset, boolean word9)
{
_baseLength = baseLength;
int nameStart = offset + baseLength;
_infoShort = LittleEndian.getShort(std, offset);
offset += LittleEndian.SHORT_SIZE;
_infoShort2 = LittleEndian.getShort(std, offset);
offset += LittleEndian.SHORT_SIZE;
_infoShort3 = LittleEndian.getShort(std, offset);
offset += LittleEndian.SHORT_SIZE;
_bchUpe = LittleEndian.getShort(std, offset);
offset += LittleEndian.SHORT_SIZE;
_infoShort4 = LittleEndian.getShort(std, offset);
offset += LittleEndian.SHORT_SIZE;
//first byte(s) of variable length section of std is the length of the
//style name and aliases string
int nameLength = 0;
int multiplier = 1;
if(word9)
{
nameLength = LittleEndian.getShort(std, nameStart);
multiplier = 2;
nameStart += LittleEndian.SHORT_SIZE;
}
else
{
nameLength = std[nameStart];
}
try
{
_name = new String(std, nameStart, nameLength * multiplier, "UTF-16LE");
}
catch (UnsupportedEncodingException ignore)
{
// ignore
}
//length then null terminator.
int grupxStart = ((nameLength + 1) * multiplier) + nameStart;
// the spec only refers to two possible upxs but it mentions
// that more may be added in the future
int varOffset = grupxStart;
int numUPX = _numUPX.getValue(_infoShort3);
_upxs = new UPX[numUPX];
for(int x = 0; x < numUPX; x++)
{
int upxSize = LittleEndian.getShort(std, varOffset);
varOffset += LittleEndian.SHORT_SIZE;
byte[] upx = new byte[upxSize];
System.arraycopy(std, varOffset, upx, 0, upxSize);
_upxs[x] = new UPX(upx);
varOffset += upxSize;
// the upx will always start on a word boundary.
if(upxSize % 2 == 1)
{
++varOffset;
}
}
}
public int getBaseStyle()
{
return _baseStyle.getValue(_infoShort2);
}
public byte[] getCHPX()
{
switch (_styleTypeCode.getValue(_infoShort2))
{
case PARAGRAPH_STYLE:
if (_upxs.length > 1)
{
return _upxs[1].getUPX();
}
return null;
case CHARACTER_STYLE:
return _upxs[0].getUPX();
default:
return null;
}
}
public byte[] getPAPX()
{
switch (_styleTypeCode.getValue(_infoShort2))
{
case PARAGRAPH_STYLE:
return _upxs[0].getUPX();
default:
return null;
}
}
public Paragraph getPAP()
{
return _pap;
}
public CharacterRun getCHP()
{
return _chp;
}
void setPAP(Paragraph pap)
{
_pap = pap;
}
void setCHP(CharacterRun chp)
{
_chp = chp;
}
public byte[] toByteArray()
{
// size equals _baseLength bytes for known variables plus 2 bytes for name
// length plus name length * 2 plus 2 bytes for null plus upx's preceded by
// length
int size = _baseLength + 2 + ((_name.length() + 1) * 2);
// determine the size needed for the upxs. They always fall on word
// boundaries.
size += _upxs[0].size() + 2;
for (int x = 1; x < _upxs.length; x++)
{
size += _upxs[x-1].size() % 2;
size += _upxs[x].size() + 2;
}
byte[] buf = new byte[size];
int offset = 0;
LittleEndian.putShort(buf, offset, _infoShort);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, _infoShort2);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, _infoShort3);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, _bchUpe);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, _infoShort4);
offset = _baseLength;
char[] letters = _name.toCharArray();
LittleEndian.putShort(buf, _baseLength, (short)letters.length);
offset += LittleEndian.SHORT_SIZE;
for (int x = 0; x < letters.length; x++)
{
LittleEndian.putShort(buf, offset, (short)letters[x]);
offset += LittleEndian.SHORT_SIZE;
}
// get past the null delimiter for the name.
offset += LittleEndian.SHORT_SIZE;
for (int x = 0; x < _upxs.length; x++)
{
short upxSize = (short)_upxs[x].size();
LittleEndian.putShort(buf, offset, upxSize);
offset += LittleEndian.SHORT_SIZE;
System.arraycopy(_upxs[x].getUPX(), 0, buf, offset, upxSize);
offset += upxSize + (upxSize % 2);
}
return buf;
}
public boolean equals(Object o)
{
StyleDescription sd = (StyleDescription)o;
if (sd._infoShort == _infoShort && sd._infoShort2 == _infoShort2 &&
sd._infoShort3 == _infoShort3 && sd._bchUpe == _bchUpe &&
sd._infoShort4 == _infoShort4 &&
_name.equals(sd._name))
{
if (!Arrays.equals(_upxs, sd._upxs))
{
return false;
}
return true;
}
return false;
}
}

View File

@ -1,325 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.util.*;
import java.io.IOException;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.io.HWPFOutputStream;
import org.apache.poi.hwpf.usermodel.CharacterRun;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.sprm.ParagraphSprmUncompressor;
import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor;
/**
* Represents a document's stylesheet. A word documents formatting is stored as
* compressed styles that are based on styles contained in the stylesheet. This
* class also contains static utility functions to uncompress different
* formatting properties.
*
* @author Ryan Ackley
*/
public class StyleSheet implements HDFType
{
private static final int NIL_STYLE = 4095;
private static final int PAP_TYPE = 1;
private static final int CHP_TYPE = 2;
private static final int SEP_TYPE = 4;
private static final int TAP_TYPE = 5;
private int _stshiLength;
private int _baseLength;
private int _flags;
private int _maxIndex;
private int _maxFixedIndex;
private int _stylenameVersion;
private int[] _rgftc;
StyleDescription[] _styleDescriptions;
/**
* StyleSheet constructor. Loads a document's stylesheet information,
*/
public StyleSheet(byte[] tableStream, int offset)
{
_stshiLength = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
int stdCount = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_baseLength = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_flags = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_maxIndex = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_maxFixedIndex = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_stylenameVersion = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_rgftc = new int[3];
_rgftc[0] = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_rgftc[1] = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
_rgftc[2] = LittleEndian.getShort(tableStream, offset);
offset += LittleEndian.SHORT_SIZE;
offset = (LittleEndian.SHORT_SIZE + _stshiLength);
_styleDescriptions = new StyleDescription[stdCount];
for(int x = 0; x < stdCount; x++)
{
int stdSize = LittleEndian.getShort(tableStream, offset);
//get past the size
offset += 2;
if(stdSize > 0)
{
//byte[] std = new byte[stdSize];
StyleDescription aStyle = new StyleDescription(tableStream,
_baseLength, offset, true);
_styleDescriptions[x] = aStyle;
}
offset += stdSize;
}
for(int x = 0; x < _styleDescriptions.length; x++)
{
if(_styleDescriptions[x] != null)
{
createPap(x);
createChp(x);
}
}
}
public void writeTo(HWPFOutputStream out)
throws IOException
{
int offset = 0;
// add two bytes so we can prepend the stylesheet w/ its size
byte[] buf = new byte[_stshiLength + 2];
LittleEndian.putShort(buf, offset, (short)_stshiLength);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_styleDescriptions.length);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_baseLength);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_flags);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_maxIndex);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_maxFixedIndex);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_stylenameVersion);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_rgftc[0]);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_rgftc[1]);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putShort(buf, offset, (short)_rgftc[2]);
out.write(buf);
byte[] sizeHolder = new byte[2];
for (int x = 0; x < _styleDescriptions.length; x++)
{
if(_styleDescriptions[x] != null)
{
byte[] std = _styleDescriptions[x].toByteArray();
LittleEndian.putShort(sizeHolder, (short)(std.length));
out.write(sizeHolder);
out.write(std);
}
else
{
sizeHolder[0] = 0;
sizeHolder[1] = 0;
out.write(sizeHolder);
}
}
}
public boolean equals(Object o)
{
StyleSheet ss = (StyleSheet)o;
if (ss._baseLength == _baseLength && ss._flags == _flags &&
ss._maxFixedIndex ==_maxFixedIndex && ss._maxIndex == _maxIndex &&
ss._rgftc[0] == _rgftc[0] && ss._rgftc[1] == _rgftc[1] &&
ss._rgftc[2] == _rgftc[2] && ss._stshiLength == _stshiLength &&
ss._stylenameVersion == _stylenameVersion)
{
if (ss._styleDescriptions.length == _styleDescriptions.length)
{
for (int x = 0; x < _styleDescriptions.length; x++)
{
// check for null
if (ss._styleDescriptions[x] != _styleDescriptions[x])
{
// check for equality
if (!ss._styleDescriptions[x].equals(_styleDescriptions[x]))
{
return false;
}
}
}
return true;
}
}
return false;
}
/**
* Creates a PartagraphProperties object from a papx stored in the
* StyleDescription at the index istd in the StyleDescription array. The PAP
* is placed in the StyleDescription at istd after its been created. Not
* every StyleDescription will contain a papx. In these cases this function
* does nothing
*
* @param istd The index of the StyleDescription to create the
* ParagraphProperties from (and also place the finished PAP in)
*/
private void createPap(int istd)
{
StyleDescription sd = _styleDescriptions[istd];
Paragraph pap = sd.getPAP();
byte[] papx = sd.getPAPX();
int baseIndex = sd.getBaseStyle();
if(pap == null && papx != null)
{
Paragraph parentPAP = new Paragraph();
if(baseIndex != NIL_STYLE)
{
parentPAP = _styleDescriptions[baseIndex].getPAP();
if(parentPAP == null)
{
createPap(baseIndex);
parentPAP = _styleDescriptions[baseIndex].getPAP();
}
}
pap = (Paragraph)ParagraphSprmUncompressor.uncompressPAP(parentPAP, papx, 2);
sd.setPAP(pap);
}
}
/**
* Creates a CharacterProperties object from a chpx stored in the
* StyleDescription at the index istd in the StyleDescription array. The
* CharacterProperties object is placed in the StyleDescription at istd after
* its been created. Not every StyleDescription will contain a chpx. In these
* cases this function does nothing.
*
* @param istd The index of the StyleDescription to create the
* CharacterProperties object from.
*/
private void createChp(int istd)
{
StyleDescription sd = _styleDescriptions[istd];
CharacterRun chp = sd.getCHP();
byte[] chpx = sd.getCHPX();
int baseIndex = sd.getBaseStyle();
if(chp == null && chpx != null)
{
CharacterRun parentCHP = new CharacterRun();
if(baseIndex != NIL_STYLE)
{
parentCHP = _styleDescriptions[baseIndex].getCHP();
if(parentCHP == null)
{
createChp(baseIndex);
parentCHP = _styleDescriptions[baseIndex].getCHP();
}
}
chp = (CharacterRun)CharacterSprmUncompressor.uncompressCHP(parentCHP, chpx, 0);
sd.setCHP(chp);
}
}
/**
* Gets the StyleDescription at index x.
*
* @param x the index of the desired StyleDescription.
*/
public StyleDescription getStyleDescription(int x)
{
return _styleDescriptions[x];
}
public CharacterRun getCharacterStyle(int x)
{
return (_styleDescriptions[x] != null ? _styleDescriptions[x].getCHP() : null);
}
public Paragraph getParagraphStyle(int x)
{
return (_styleDescriptions[x] != null ? _styleDescriptions[x].getPAP() : null);
}
}

View File

@ -1,126 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.io.UnsupportedEncodingException;
/**
* Lightweight representation of a text piece.
*
* @author Ryan Ackley
*/
public class TextPiece extends PropertyNode implements Comparable
{
private boolean _usesUnicode;
private int _length;
private PieceDescriptor _pd;
/**
* @param start Offset in main document stream.
*/
public TextPiece(int start, int end, byte[] text, PieceDescriptor pd)
throws UnsupportedEncodingException
{
super(start, end, new StringBuffer(new String(text, pd.isUnicode() ? "UTF-16LE" : "Cp1252")));
_usesUnicode = pd.isUnicode();
_length = end - start;
_pd = pd;
}
/**
* @return If this text piece uses unicode
*/
public boolean usesUnicode()
{
return _usesUnicode;
}
public PieceDescriptor getPieceDescriptor()
{
return _pd;
}
public StringBuffer getStringBuffer()
{
return (StringBuffer)_buf;
}
public byte[] getBuf()
{
try
{
return ((StringBuffer)_buf).toString().getBytes(_usesUnicode ?
"UTF-16LE" : "Cp1252");
}
catch (UnsupportedEncodingException ignore)
{
// shouldn't ever happen considering we wouldn't have been able to
// create the StringBuffer w/o getting this exception
return ((StringBuffer)_buf).toString().getBytes();
}
}
public boolean equals(Object o)
{
if (super.equals(o))
{
TextPiece tp = (TextPiece)o;
return tp._usesUnicode == _usesUnicode && _pd.equals(tp._pd);
}
return false;
}
}

View File

@ -1,238 +0,0 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.hwpf.model.io.*;
public class TextPieceTable
{
ArrayList _textPieces = new ArrayList();
//int _multiple;
int _cpMin;
public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset,
int size, int fcMin)
throws UnsupportedEncodingException
{
// get our plex of PieceDescriptors
PlexOfCps pieceTable = new PlexOfCps(tableStream, offset, size, PieceDescriptor.getSizeInBytes());
//_multiple = 2;
int length = pieceTable.length();
PieceDescriptor[] pieces = new PieceDescriptor[length];
// iterate through piece descriptors raw bytes and create
// PieceDescriptor objects
for (int x = 0; x < length; x++)
{
PropertyNode node = pieceTable.getProperty(x);
pieces[x] = new PieceDescriptor(node.getBuf(), 0);
// if (!pieces[x].isUnicode())
// {
// _multiple = 1;
// }
}
_cpMin = pieces[0].getFilePosition() - fcMin;
// if a piece is unicode the actual offset may be bumped because of the
// doubling of the needed size.
int bump = 0;
// using the PieceDescriptors, build our list of TextPieces.
for (int x = 0; x < pieces.length; x++)
{
int start = pieces[x].getFilePosition();
PropertyNode node = pieceTable.getProperty(x);
int nodeStart = node.getStart();
// multiple will be 2 if there is only one piece and its unicode. Some
// type of optimization.
boolean unicode = pieces[x].isUnicode();
int multiple = 1;
if (unicode)
{
multiple = 2;
}
int nodeEnd = ((node.getEnd() - nodeStart) * multiple) + nodeStart;
int textSize = nodeEnd - nodeStart;
byte[] buf = new byte[textSize];
System.arraycopy(documentStream, start, buf, 0, textSize);
_textPieces.add(new TextPiece(nodeStart + bump, nodeEnd + bump, buf, pieces[x]));
if (unicode)
{
bump += (node.getEnd() - nodeStart);
}
}
}
public int getCpMin()
{
return _cpMin;
}
public List getTextPieces()
{
return _textPieces;
}
public byte[] writeTo(HWPFOutputStream docStream)
throws IOException
{
PlexOfCps textPlex = new PlexOfCps(PieceDescriptor.getSizeInBytes());
//int fcMin = docStream.getOffset();
int size = _textPieces.size();
int bumpDown = 0;
for (int x = 0; x < size; x++)
{
TextPiece next = (TextPiece)_textPieces.get(x);
PieceDescriptor pd = next.getPieceDescriptor();
int offset = docStream.getOffset();
int mod = (offset % POIFSConstants.BIG_BLOCK_SIZE);
if (mod != 0)
{
mod = POIFSConstants.BIG_BLOCK_SIZE - mod;
byte[] buf = new byte[mod];
docStream.write(buf);
}
// set the text piece position to the current docStream offset.
pd.setFilePosition(docStream.getOffset());
// write the text to the docstream and save the piece descriptor to the
// plex which will be written later to the tableStream.
//if (_multiple == 1 && pd.isUnicode() &&
docStream.write(next.getBuf());
int nodeStart = next.getStart();
int multiple = 1;
if (pd.isUnicode())
{
multiple = 2;
}
textPlex.addProperty(new PropertyNode(nodeStart - bumpDown,
((next.getEnd() - nodeStart)/multiple + nodeStart) - bumpDown,
pd.toByteArray()));
if (pd.isUnicode())
{
bumpDown += ((next.getEnd() - nodeStart)/multiple);
}
}
return textPlex.toByteArray();
}
public int adjustForInsert(int listIndex, int length)
{
int size = _textPieces.size();
TextPiece tp = (TextPiece)_textPieces.get(listIndex);
length = length * (tp.usesUnicode() ? 2 : 1);
tp.setEnd(tp.getEnd() + length);
for (int x = listIndex + 1; x < size; x++)
{
tp = (TextPiece)_textPieces.get(x);
tp.setStart(tp.getStart() + length);
tp.setEnd(tp.getEnd() + length);
}
return length;
}
public boolean equals(Object o)
{
TextPieceTable tpt = (TextPieceTable)o;
int size = tpt._textPieces.size();
if (size == _textPieces.size())
{
for (int x = 0; x < size; x++)
{
if (!tpt._textPieces.get(x).equals(_textPieces.get(x)))
{
return false;
}
}
return true;
}
return false;
}
}

View File

@ -1,82 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes;
import java.util.Arrays;
public class UPX
{
private byte[] _upx;
public UPX(byte[] upx)
{
_upx = upx;
}
public byte[] getUPX()
{
return _upx;
}
public int size()
{
return _upx.length;
}
public boolean equals(Object o)
{
UPX upx = (UPX)o;
return Arrays.equals(_upx, upx._upx);
}
}

View File

@ -1,373 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes.definitions;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.HexDump;
import org.apache.poi.hdf.model.hdftypes.HDFType;
import org.apache.poi.hwpf.usermodel.*;
/**
* Table Properties.
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/records/definitions.
* @author S. Ryan Ackley
*/
public abstract class TAPAbstractType
implements HDFType
{
protected int field_1_jc;
protected int field_2_dxaGapHalf;
protected int field_3_dyaRowHeight;
protected boolean field_4_fCantSplit;
protected boolean field_5_fTableHeader;
protected int field_6_tlp;
protected short field_7_itcMac;
protected short[] field_8_rgdxaCenter;
protected TableCellDescriptor[] field_9_rgtc;
protected ShadingDescriptor[] field_10_rgshd;
protected BorderCode field_11_brcBottom;
protected BorderCode field_12_brcTop;
protected BorderCode field_13_brcLeft;
protected BorderCode field_14_brcRight;
protected BorderCode field_15_brcVertical;
protected BorderCode field_16_brcHorizontal;
public TAPAbstractType()
{
}
/**
* Size of record (exluding 4 byte header)
*/
public int getSize()
{
return 4 + + 2 + 4 + 4 + 0 + 0 + 4 + 2 + 130 + 0 + 0 + 4 + 4 + 4 + 4 + 4 + 4;
}
/**
* Get the jc field for the TAP record.
*/
public int getJc()
{
return field_1_jc;
}
/**
* Set the jc field for the TAP record.
*/
public void setJc(int field_1_jc)
{
this.field_1_jc = field_1_jc;
}
/**
* Get the dxaGapHalf field for the TAP record.
*/
public int getDxaGapHalf()
{
return field_2_dxaGapHalf;
}
/**
* Set the dxaGapHalf field for the TAP record.
*/
public void setDxaGapHalf(int field_2_dxaGapHalf)
{
this.field_2_dxaGapHalf = field_2_dxaGapHalf;
}
/**
* Get the dyaRowHeight field for the TAP record.
*/
public int getDyaRowHeight()
{
return field_3_dyaRowHeight;
}
/**
* Set the dyaRowHeight field for the TAP record.
*/
public void setDyaRowHeight(int field_3_dyaRowHeight)
{
this.field_3_dyaRowHeight = field_3_dyaRowHeight;
}
/**
* Get the fCantSplit field for the TAP record.
*/
public boolean getFCantSplit()
{
return field_4_fCantSplit;
}
/**
* Set the fCantSplit field for the TAP record.
*/
public void setFCantSplit(boolean field_4_fCantSplit)
{
this.field_4_fCantSplit = field_4_fCantSplit;
}
/**
* Get the fTableHeader field for the TAP record.
*/
public boolean getFTableHeader()
{
return field_5_fTableHeader;
}
/**
* Set the fTableHeader field for the TAP record.
*/
public void setFTableHeader(boolean field_5_fTableHeader)
{
this.field_5_fTableHeader = field_5_fTableHeader;
}
/**
* Get the tlp field for the TAP record.
*/
public int getTlp()
{
return field_6_tlp;
}
/**
* Set the tlp field for the TAP record.
*/
public void setTlp(int field_6_tlp)
{
this.field_6_tlp = field_6_tlp;
}
/**
* Get the itcMac field for the TAP record.
*/
public short getItcMac()
{
return field_7_itcMac;
}
/**
* Set the itcMac field for the TAP record.
*/
public void setItcMac(short field_7_itcMac)
{
this.field_7_itcMac = field_7_itcMac;
}
/**
* Get the rgdxaCenter field for the TAP record.
*/
public short[] getRgdxaCenter()
{
return field_8_rgdxaCenter;
}
/**
* Set the rgdxaCenter field for the TAP record.
*/
public void setRgdxaCenter(short[] field_8_rgdxaCenter)
{
this.field_8_rgdxaCenter = field_8_rgdxaCenter;
}
/**
* Get the rgtc field for the TAP record.
*/
public TableCellDescriptor[] getRgtc()
{
return field_9_rgtc;
}
/**
* Set the rgtc field for the TAP record.
*/
public void setRgtc(TableCellDescriptor[] field_9_rgtc)
{
this.field_9_rgtc = field_9_rgtc;
}
/**
* Get the rgshd field for the TAP record.
*/
public ShadingDescriptor[] getRgshd()
{
return field_10_rgshd;
}
/**
* Set the rgshd field for the TAP record.
*/
public void setRgshd(ShadingDescriptor[] field_10_rgshd)
{
this.field_10_rgshd = field_10_rgshd;
}
/**
* Get the brcBottom field for the TAP record.
*/
public BorderCode getBrcBottom()
{
return field_11_brcBottom;
}
/**
* Set the brcBottom field for the TAP record.
*/
public void setBrcBottom(BorderCode field_11_brcBottom)
{
this.field_11_brcBottom = field_11_brcBottom;
}
/**
* Get the brcTop field for the TAP record.
*/
public BorderCode getBrcTop()
{
return field_12_brcTop;
}
/**
* Set the brcTop field for the TAP record.
*/
public void setBrcTop(BorderCode field_12_brcTop)
{
this.field_12_brcTop = field_12_brcTop;
}
/**
* Get the brcLeft field for the TAP record.
*/
public BorderCode getBrcLeft()
{
return field_13_brcLeft;
}
/**
* Set the brcLeft field for the TAP record.
*/
public void setBrcLeft(BorderCode field_13_brcLeft)
{
this.field_13_brcLeft = field_13_brcLeft;
}
/**
* Get the brcRight field for the TAP record.
*/
public BorderCode getBrcRight()
{
return field_14_brcRight;
}
/**
* Set the brcRight field for the TAP record.
*/
public void setBrcRight(BorderCode field_14_brcRight)
{
this.field_14_brcRight = field_14_brcRight;
}
/**
* Get the brcVertical field for the TAP record.
*/
public BorderCode getBrcVertical()
{
return field_15_brcVertical;
}
/**
* Set the brcVertical field for the TAP record.
*/
public void setBrcVertical(BorderCode field_15_brcVertical)
{
this.field_15_brcVertical = field_15_brcVertical;
}
/**
* Get the brcHorizontal field for the TAP record.
*/
public BorderCode getBrcHorizontal()
{
return field_16_brcHorizontal;
}
/**
* Set the brcHorizontal field for the TAP record.
*/
public void setBrcHorizontal(BorderCode field_16_brcHorizontal)
{
this.field_16_brcHorizontal = field_16_brcHorizontal;
}
} // END OF CLASS

View File

@ -1,437 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hwpf.model.hdftypes.definitions;
import org.apache.poi.util.BitField;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.HexDump;
import org.apache.poi.hdf.model.hdftypes.HDFType;
import org.apache.poi.hwpf.usermodel.*;
/**
* Table Cell Descriptor.
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/records/definitions.
* @author S. Ryan Ackley
*/
public abstract class TCAbstractType
implements HDFType
{
protected short field_1_rgf;
private static BitField fFirstMerged = new BitField(0x0001);
private static BitField fMerged = new BitField(0x0002);
private static BitField fVertical = new BitField(0x0004);
private static BitField fBackward = new BitField(0x0008);
private static BitField fRotateFont = new BitField(0x0010);
private static BitField fVertMerge = new BitField(0x0020);
private static BitField fVertRestart = new BitField(0x0040);
private static BitField vertAlign = new BitField(0x0180);
protected short field_2_unused;
protected BorderCode field_3_brcTop;
protected BorderCode field_4_brcLeft;
protected BorderCode field_5_brcBottom;
protected BorderCode field_6_brcRight;
public TCAbstractType()
{
}
protected void fillFields(byte [] data, int offset)
{
field_1_rgf = LittleEndian.getShort(data, 0x0 + offset);
field_2_unused = LittleEndian.getShort(data, 0x2 + offset);
field_3_brcTop = new BorderCode(data, 0x4 + offset);
field_4_brcLeft = new BorderCode(data, 0x8 + offset);
field_5_brcBottom = new BorderCode(data, 0xc + offset);
field_6_brcRight = new BorderCode(data, 0x10 + offset);
}
public void serialize(byte[] data, int offset)
{
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_rgf);;
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_unused);;
field_3_brcTop.serialize(data, 0x4 + offset);;
field_4_brcLeft.serialize(data, 0x8 + offset);;
field_5_brcBottom.serialize(data, 0xc + offset);;
field_6_brcRight.serialize(data, 0x10 + offset);;
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
buffer.append("[TC]\n");
buffer.append(" .rgf = ");
buffer.append(" (").append(getRgf()).append(" )\n");
buffer.append(" .fFirstMerged = ").append(isFFirstMerged()).append('\n');
buffer.append(" .fMerged = ").append(isFMerged()).append('\n');
buffer.append(" .fVertical = ").append(isFVertical()).append('\n');
buffer.append(" .fBackward = ").append(isFBackward()).append('\n');
buffer.append(" .fRotateFont = ").append(isFRotateFont()).append('\n');
buffer.append(" .fVertMerge = ").append(isFVertMerge()).append('\n');
buffer.append(" .fVertRestart = ").append(isFVertRestart()).append('\n');
buffer.append(" .vertAlign = ").append(getVertAlign()).append('\n');
buffer.append(" .unused = ");
buffer.append(" (").append(getUnused()).append(" )\n");
buffer.append(" .brcTop = ");
buffer.append(" (").append(getBrcTop()).append(" )\n");
buffer.append(" .brcLeft = ");
buffer.append(" (").append(getBrcLeft()).append(" )\n");
buffer.append(" .brcBottom = ");
buffer.append(" (").append(getBrcBottom()).append(" )\n");
buffer.append(" .brcRight = ");
buffer.append(" (").append(getBrcRight()).append(" )\n");
buffer.append("[/TC]\n");
return buffer.toString();
}
/**
* Size of record (exluding 4 byte header)
*/
public int getSize()
{
return 4 + + 2 + 2 + 4 + 4 + 4 + 4;
}
/**
* Get the rgf field for the TC record.
*/
public short getRgf()
{
return field_1_rgf;
}
/**
* Set the rgf field for the TC record.
*/
public void setRgf(short field_1_rgf)
{
this.field_1_rgf = field_1_rgf;
}
/**
* Get the unused field for the TC record.
*/
public short getUnused()
{
return field_2_unused;
}
/**
* Set the unused field for the TC record.
*/
public void setUnused(short field_2_unused)
{
this.field_2_unused = field_2_unused;
}
/**
* Get the brcTop field for the TC record.
*/
public BorderCode getBrcTop()
{
return field_3_brcTop;
}
/**
* Set the brcTop field for the TC record.
*/
public void setBrcTop(BorderCode field_3_brcTop)
{
this.field_3_brcTop = field_3_brcTop;
}
/**
* Get the brcLeft field for the TC record.
*/
public BorderCode getBrcLeft()
{
return field_4_brcLeft;
}
/**
* Set the brcLeft field for the TC record.
*/
public void setBrcLeft(BorderCode field_4_brcLeft)
{
this.field_4_brcLeft = field_4_brcLeft;
}
/**
* Get the brcBottom field for the TC record.
*/
public BorderCode getBrcBottom()
{
return field_5_brcBottom;
}
/**
* Set the brcBottom field for the TC record.
*/
public void setBrcBottom(BorderCode field_5_brcBottom)
{
this.field_5_brcBottom = field_5_brcBottom;
}
/**
* Get the brcRight field for the TC record.
*/
public BorderCode getBrcRight()
{
return field_6_brcRight;
}
/**
* Set the brcRight field for the TC record.
*/
public void setBrcRight(BorderCode field_6_brcRight)
{
this.field_6_brcRight = field_6_brcRight;
}
/**
* Sets the fFirstMerged field value.
*
*/
public void setFFirstMerged(boolean value)
{
field_1_rgf = (short)fFirstMerged.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fFirstMerged field value.
*/
public boolean isFFirstMerged()
{
return fFirstMerged.isSet(field_1_rgf);
}
/**
* Sets the fMerged field value.
*
*/
public void setFMerged(boolean value)
{
field_1_rgf = (short)fMerged.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fMerged field value.
*/
public boolean isFMerged()
{
return fMerged.isSet(field_1_rgf);
}
/**
* Sets the fVertical field value.
*
*/
public void setFVertical(boolean value)
{
field_1_rgf = (short)fVertical.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fVertical field value.
*/
public boolean isFVertical()
{
return fVertical.isSet(field_1_rgf);
}
/**
* Sets the fBackward field value.
*
*/
public void setFBackward(boolean value)
{
field_1_rgf = (short)fBackward.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fBackward field value.
*/
public boolean isFBackward()
{
return fBackward.isSet(field_1_rgf);
}
/**
* Sets the fRotateFont field value.
*
*/
public void setFRotateFont(boolean value)
{
field_1_rgf = (short)fRotateFont.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fRotateFont field value.
*/
public boolean isFRotateFont()
{
return fRotateFont.isSet(field_1_rgf);
}
/**
* Sets the fVertMerge field value.
*
*/
public void setFVertMerge(boolean value)
{
field_1_rgf = (short)fVertMerge.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fVertMerge field value.
*/
public boolean isFVertMerge()
{
return fVertMerge.isSet(field_1_rgf);
}
/**
* Sets the fVertRestart field value.
*
*/
public void setFVertRestart(boolean value)
{
field_1_rgf = (short)fVertRestart.setBoolean(field_1_rgf, value);
}
/**
*
* @return the fVertRestart field value.
*/
public boolean isFVertRestart()
{
return fVertRestart.isSet(field_1_rgf);
}
/**
* Sets the vertAlign field value.
*
*/
public void setVertAlign(byte value)
{
field_1_rgf = (short)vertAlign.setValue(field_1_rgf, value);
}
/**
*
* @return the vertAlign field value.
*/
public byte getVertAlign()
{
return ( byte )vertAlign.getValue(field_1_rgf);
}
} // END OF CLASS