commiting the latest HWPF stuff formerly HDF

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353120 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Said Ryan Ackley 2003-06-05 01:58:53 +00:00
parent 99fc06a4c6
commit cdc2beac40
28 changed files with 16865 additions and 0 deletions

View File

@ -0,0 +1,97 @@
/*
* ====================================================================
* 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;
import java.io.InputStream;
import java.io.IOException;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.hwpf.model.hdftypes.*;
/**
* @author Ryan Ackley
*/
public class HWPFDocument
{
/** OLE stuff*/
private POIFSFileSystem _filesystem;
/** The FIB*/
private FileInformationBlock _fib;
/** main document stream buffer*/
byte[] _mainDocument;
/** table stream buffer*/
byte[] _tableBuffer;
public HWPFDocument(InputStream istream) throws IOException
{
//do Ole stuff
_filesystem = new POIFSFileSystem(istream);
DocumentEntry headerProps =
(DocumentEntry)_filesystem.getRoot().getEntry("WordDocument");
_mainDocument = new byte[headerProps.getSize()];
_filesystem.createDocumentInputStream("WordDocument").read(_mainDocument);
_fib = new FileInformationBlock(_mainDocument);
}
}

View File

@ -0,0 +1,92 @@
/*
* ====================================================================
* 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.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian;
public class CHPBinTable
{
ArrayList _textRuns;
public CHPBinTable(byte[] documentStream, byte[] tableStream, int offset, int size)
{
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;
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
pageOffset);
int fkpSize = cfkp.size();
for (int y = 0; y < fkpSize; y++)
{
_textRuns.add(cfkp.getCHPX(y));
}
}
}
}

View File

@ -0,0 +1,193 @@
/* ====================================================================
* 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;
/**
* 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;
/**
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
* read from a Word file).
*
* @param fkp The 512 byte array to read data from
*/
public CHPFormattedDiskPage(byte[] documentStream, int offset)
{
super(documentStream, offset);
for (int x = 0; x < _crun; x++)
{
_chpxList.add(new CHPX(getStart(x), getEnd(x), getGrpprl(x)));
}
}
public CHPX getCHPX(int index)
{
return (CHPX)_chpxList.get(index);
}
/**
* 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, chpxOffset);
byte[] chpx = new byte[size];
System.arraycopy(_fkp, ++chpxOffset, chpx, 0, size);
return chpx;
}
protected byte[] toByteArray()
{
byte[] buf = new byte[512];
int size = _chpxList.size();
int grpprlOffset = 0;
int offsetOffset = 0;
int fcOffset = 0;
// total size is currently the size of one FC
int totalSize = FC_SIZE;
int index = 0;
for (; index < size; index++)
{
int grpprlLength = ((CHPX)_chpxList.get(index)).getGrpprl().length;
// check to see if we have enough room for an FC, a byte, and the grpprl.
totalSize += (FC_SIZE + 1 + grpprlLength);
// if size is uneven we will have to add one so the first grpprl falls
// on a word boundary
if (totalSize > 511 + (index % 2))
{
totalSize -= (FC_SIZE + 1 + grpprlLength);
break;
}
// grpprls must fall on word boundaries
if (grpprlLength % 2 > 0)
{
totalSize += 1;
}
}
// see if we couldn't fit some
if (index != size)
{
_overFlow = new ArrayList();
_overFlow.addAll(index, _chpxList);
}
// index should equal number of CHPXs that will be in this fkp now.
buf[511] = (byte)index;
offsetOffset = (FC_SIZE * index) + FC_SIZE;
grpprlOffset = offsetOffset + index + (grpprlOffset % 2);
CHPX chpx = null;
for (int x = 0; x < index; x++)
{
chpx = (CHPX)_chpxList.get(x);
byte[] grpprl = chpx.getGrpprl();
LittleEndian.putInt(buf, fcOffset, chpx.getStart());
buf[offsetOffset] = (byte)(grpprlOffset/2);
System.arraycopy(grpprl, 0, buf, grpprlOffset, grpprl.length);
grpprlOffset += grpprl.length + (grpprl.length % 2);
offsetOffset += 1;
fcOffset += FC_SIZE;
}
// put the last papx's end in
LittleEndian.putInt(buf, fcOffset, chpx.getEnd());
return buf;
}
}

View File

@ -0,0 +1,77 @@
/* ====================================================================
* 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;
/**
* Comment me
*
* @author Ryan Ackley
*/
public class CHPX extends PropertyNode
{
public CHPX(int fcStart, int fcEnd, byte[] grpprl)
{
super(fcStart, fcEnd, grpprl);
}
public byte[] getGrpprl()
{
return super.getBuf();
}
}

View File

@ -0,0 +1,90 @@
/*
* ====================================================================
* 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;
public class ComplexFileTable
{
TextPieceTable _tpt;
public ComplexFileTable(byte[] documentStream, byte[] tableStream, int offset) throws IOException
{
//skips through the prms before we reach the piece table. These contain data
//for actual fast saved files
while (tableStream[offset] == 1)
{
offset++;
int skip = LittleEndian.getShort(tableStream, offset);
offset += 2 + skip;
}
if(tableStream[offset] != 2)
{
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);
}
}
}

View File

@ -0,0 +1,92 @@
/* ====================================================================
* 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;
/**
* Comment me
*
* @author Ryan Ackley
*/
public class DocumentProperties implements HDFType
{
public boolean _fFacingPages;
public int _fpc;
public int _epc;
public int _rncFtn;
public int _nFtn;
public int _rncEdn;
public int _nEdn;
public DocumentProperties(byte[] dopArray)
{
_fFacingPages = (dopArray[0] & 0x1) > 0;
_fpc = (dopArray[0] & 0x60) >> 5;
short num = LittleEndian.getShort(dopArray, 2);
_rncFtn = (num & 0x3);
_nFtn = (short)(num & 0xfffc) >> 2;
num = LittleEndian.getShort(dopArray, 52);
_rncEdn = num & 0x3;
_nEdn = (short)(num & 0xfffc) >> 2;
num = LittleEndian.getShort(dopArray, 54);
_epc = num & 0x3;
}
}

View File

@ -0,0 +1,361 @@
/*
* ====================================================================
* 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 org.apache.poi.hwpf.model.hdftypes.definitions.FIBAbstractType;
/**
*
* @author andy
*/
public class FileInformationBlock extends FIBAbstractType
{
/*
private short field_1_id;
private short field_2_version; // 101 = Word 6.0 +
private short field_3_product_version;
private short field_4_language_stamp;
private short field_5_unknown;
private short field_6_options;
private static final BitField template = new BitField(0x0001);
private static final BitField glossary = new BitField(0x0002);
private static final BitField quicksave = new BitField(0x0004);
private static final BitField haspictr = new BitField(0x0008);
private static final BitField nquicksaves = new BitField(0x00F0);
private static final BitField encrypted = new BitField(0x0100);
private static final BitField tabletype = new BitField(0x0200);
private static final BitField readonly = new BitField(0x0400);
private static final BitField writeReservation = new BitField(0x0800);
private static final BitField extendedCharacter = new BitField(0x1000);
private static final BitField loadOverride = new BitField(0x2000);
private static final BitField farEast = new BitField(0x4000);
private static final BitField crypto = new BitField(0x8000);
private short field_7_minversion;
private short field_8_encrypted_key;
private short field_9_environment; // 0 or 1 - windows or mac
private short field_10_history;
private static final BitField history_mac = new BitField(0x01);
private static final BitField empty_special = new BitField(0x02);
private static final BitField load_override = new BitField(0x04);
private static final BitField future_undo = new BitField(0x08);
private static final BitField w97_saved = new BitField(0x10);
private static final BitField spare = new BitField(0xfe);
private short field_11_default_charset;
private short field_12_default_extcharset;
private int field_13_offset_first_char;
private int field_14_offset_last_char;
private short field_15_count_shorts;
private short field_16_beg_shorts; //why same offset?
private short field_16_creator_id;
private short field_17_revisor_id;
private short field_18_creator_private;
private short field_19_revisor_private;
private short field_20_unused;
private short field_21_unused;
private short field_22_unused;
private short field_23_unused;
private short field_24_unused;
private short field_25_unused;
private short field_26_unused;
private short field_27_unused;
private short field_28_unused;
private short field_29_fareastid;
private short field_30_count_ints;
private int field_31_beg_ints; //why same offset?
private int field_31_last_byte;
private int field_32_creator_build_date;
private int field_33_revisor_build_date; */
/** length of main document text stream*/
// private int field_34_main_streamlen;
/**length of footnote subdocument text stream*/
/* private int field_35_footnote_streamlen;
private int field_36_header_streamlen;
private int field_37_macro_streamlen;
private int field_38_annotation_streamlen;
private int field_39_endnote_streamlen;
private int field_40_textbox_streamlen;
private int field_41_headbox_streamlen; */
/**offset in table stream of character property bin table*/
// private int field_42_pointer_to_plc_list_chp; //rename me!
// private int field_43_first_chp; //rename me
// private int field_44_count_chps; //rename me
/**offset in table stream of paragraph property bin */
/* private int field_45_pointer_to_plc_list_pap; //rename me.
private int field_46_first_pap; //rename me
private int field_47_count_paps; //rename me
private int field_48_pointer_to_plc_list_lvc; //rename me
private int field_49_first_lvc; //rename me
private int field_50_count_lvc; //rename me
private int field_51_unknown;
private int field_52_unknown; */
//not sure about this array.
/*
private short field_53_fc_lcb_array_size;
private int field_54_original_stylesheet_offset;
private int field_55_original_stylesheet_size;
private int field_56_stylesheet_offset;
private int field_57_stylesheet_size;
private int field_58_footnote_ref_offset;
private int field_59_footnote_ref_size;
private int field_60_footnote_plc_offset;
private int field_61_footnote_plc_size;
private int field_62_annotation_ref_offset;
private int field_63_annotation_ref_size;
private int field_64_annotation_plc_offset;
private int field_65_annotation_plc_size; */
/** offset in table stream of section descriptor SED PLC*/
/* private int field_66_section_plc_offset;
private int field_67_section_plc_size;
private int field_68_unused;
private int field_69_unused;
private int field_70_pheplc_offset;
private int field_71_pheplc_size;
private int field_72_glossaryST_offset;
private int field_73_glossaryST_size;
private int field_74_glossaryPLC_offset;
private int field_75_glossaryPLC_size;
private int field_76_headerPLC_offset;
private int field_77_headerPLC_size;
private int field_78_chp_bin_table_offset;
private int field_79_chp_bin_table_size;
private int field_80_pap_bin_table_offset;
private int field_81_pap_bin_table_size;
private int field_82_sea_plc_offset;
private int field_83_sea_plc_size;
private int field_84_fonts_offset;
private int field_85_fonts_size;
private int field_86_main_fields_offset;
private int field_87_main_fields_size;
private int field_88_header_fields_offset;
private int field_89_header_fields_size;
private int field_90_footnote_fields_offset;
private int field_91_footnote_fields_size;
private int field_92_ann_fields_offset;
private int field_93_ann_fields_size;
private int field_94_unused;
private int field_95_unused;
private int field_96_bookmark_names_offset;
private int field_97_bookmark_names_size;
private int field_98_bookmark_offsets_offset;
private int field_99_bookmark_offsets_size;
private int field_100_macros_offset;
private int field_101_macros_size;
private int field_102_unused;
private int field_103_unused;
private int field_104_unused;
private int field_105_unused;
private int field_106_printer_offset;
private int field_107_printer_size;
private int field_108_printer_portrait_offset;
private int field_109_printer_portrait_size;
private int field_110_printer_landscape_offset;
private int field_111_printer_landscape_size;
private int field_112_wss_offset;
private int field_113_wss_size;
private int field_114_DOP_offset;
private int field_115_DOP_size;
private int field_116_sttbfassoc_offset;
private int field_117_sttbfassoc_size; */
/**offset in table stream of beginning of information for complex files.
* Also, this is the beginning of the Text piece table*/ /*
private int field_118_textPieceTable_offset;
private int field_119_textPieceTable_size;
private int field_199_list_format_offset;
private int field_200_list_format_size;
private int field_201_list_format_override_offset;
private int field_202_list_format_override_size;
^/
/** Creates a new instance of FileInformationBlock */
public FileInformationBlock(byte[] mainDocument)
{
fillFields(mainDocument, (short)0, (short)0);
/* field_1_id = LittleEndian.getShort(mainDocument, 0);
field_2_version = LittleEndian.getShort(mainDocument, 0x2); // 101 = Word 6.0 +
field_3_product_version = LittleEndian.getShort(mainDocument, 0x4);
field_4_language_stamp = LittleEndian.getShort(mainDocument, 0x6);
field_5_unknown = LittleEndian.getShort(mainDocument, 0x8);
field_6_options = LittleEndian.getShort(mainDocument, 0xa);
field_13_offset_first_char = LittleEndian.getInt(mainDocument, 0x18);
field_34_main_streamlen = LittleEndian.getInt(mainDocument, 0x4c);
field_35_footnote_streamlen = LittleEndian.getInt(mainDocument, 0x50);
field_56_stylesheet_offset = LittleEndian.getInt(mainDocument, 0xa2);
field_57_stylesheet_size = LittleEndian.getInt(mainDocument, 0xa6);
field_66_section_plc_offset = LittleEndian.getInt(mainDocument, 0xca);
field_67_section_plc_size = LittleEndian.getInt(mainDocument, 0xce);
field_78_chp_bin_table_offset = LittleEndian.getInt(mainDocument, 0xfa);
field_79_chp_bin_table_size = LittleEndian.getInt(mainDocument, 0xfe);
field_80_pap_bin_table_offset = LittleEndian.getInt(mainDocument, 0x102);
field_81_pap_bin_table_size = LittleEndian.getInt(mainDocument, 0x106);
field_84_fonts_offset = LittleEndian.getInt(mainDocument, 0x112);
field_85_fonts_size = LittleEndian.getInt(mainDocument, 0x116);
field_114_DOP_offset = LittleEndian.getInt(mainDocument, 0x192);
field_115_DOP_size = LittleEndian.getInt(mainDocument, 0x196);
field_118_textPieceTable_offset = LittleEndian.getInt(mainDocument, 0x1a2);
field_199_list_format_offset = LittleEndian.getInt(mainDocument, 0x2e2);
field_200_list_format_size = LittleEndian.getInt(mainDocument, 0x2e6);
field_201_list_format_override_offset = LittleEndian.getInt(mainDocument, 0x2ea);
field_202_list_format_override_size= LittleEndian.getInt(mainDocument, 0x2ee);*/
}
/*
public boolean useTable1()
{
return tabletype.setShort(field_6_options) > 0;
}
public int getFirstCharOffset()
{
return field_13_offset_first_char;
}
public int getStshOffset()
{
return field_56_stylesheet_offset;
}
public int getStshSize()
{
return field_57_stylesheet_size;
}
public int getSectionDescriptorOffset()
{
return field_66_section_plc_offset;
}
public int getSectionDescriptorSize()
{
return field_67_section_plc_size;
}
public int getChpBinTableOffset()
{
return field_78_chp_bin_table_offset;
}
public int getChpBinTableSize()
{
return field_79_chp_bin_table_size;
}
public int getPapBinTableOffset()
{
return field_80_pap_bin_table_offset;
}
public int getPapBinTableSize()
{
return field_81_pap_bin_table_size;
}
public int getFontsOffset()
{
return field_84_fonts_offset;
}
public int getFontsSize()
{
return field_85_fonts_size;
}
public int getDOPOffset()
{
return field_114_DOP_offset;
}
public int getDOPSize()
{
return field_115_DOP_size;
}
public int getComplexOffset()
{
return field_118_textPieceTable_offset;
}
public int getLSTOffset()
{
return field_199_list_format_offset;
}
public int getLSTSize()
{
return field_200_list_format_size;
}
public int getLFOOffset()
{
return field_201_list_format_override_offset;
}
public int getLFOSize()
{
return field_202_list_format_override_size;
}
*/
}

View File

@ -0,0 +1,121 @@
/* ====================================================================
* 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;
/**
* Uses a 512-byte array to create a FKP
*/
public FormattedDiskPage(byte[] documentStream, int offset)
{
_crun = LittleEndian.getUnsignedByte(documentStream, offset + 511);
_fkp = documentStream;
}
/**
* 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

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

View File

@ -0,0 +1,92 @@
/*
* ====================================================================
* 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.poifs.common.POIFSConstants;
import org.apache.poi.util.LittleEndian;
public class PAPBinTable
{
ArrayList _paragraphs;
public PAPBinTable(byte[] documentStream, byte[] tableStream, int offset, int size)
{
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);
int fkpSize = pfkp.size();
for (int y = 0; y < fkpSize; y++)
{
_paragraphs.add(pfkp.getPAPX(y));
}
}
}
}

View File

@ -0,0 +1,206 @@
/* ====================================================================
* 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;
/**
* 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;
/**
* Creates a PAPFormattedDiskPage from a 512 byte array
*
* @param fkp a 512 byte array.
*/
public PAPFormattedDiskPage(byte[] documentStream, int offset)
{
super(documentStream, offset);
for (int x = 0; x < _crun; x++)
{
_papxList.add(new PAPX(getStart(x), getEnd(x), getGrpprl(x), getParagraphHeight(x)));
}
_fkp = null;
}
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, papxOffset);
if(size == 0)
{
size = 2 * LittleEndian.getUnsignedByte(_fkp, ++papxOffset);
}
else
{
size--;
}
byte[] papx = new byte[size];
System.arraycopy(_fkp, ++papxOffset, papx, 0, size);
return papx;
}
protected byte[] toByteArray()
{
byte[] buf = new byte[512];
int size = _papxList.size();
int grpprlOffset = 0;
int bxOffset = 0;
int fcOffset = 0;
// total size is currently the size of one FC
int totalSize = FC_SIZE;
int index = 0;
for (; index < size; index++)
{
int grpprlLength = ((PAPX)_papxList.get(index)).getGrpprl().length;
// check to see if we have enough room for an FC, a BX, and the grpprl.
totalSize += (FC_SIZE + BX_SIZE + 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 + BX_SIZE + grpprlLength);
break;
}
// grpprls must fall on word boundaries
if (grpprlLength % 2 > 0)
{
totalSize += 1;
}
}
// see if we couldn't fit some
if (index != size)
{
_overFlow = new ArrayList();
_overFlow.addAll(index, _papxList);
}
// index should equal number of papxs that will be in this fkp now.
buf[511] = (byte)index;
bxOffset = (FC_SIZE * index) + FC_SIZE;
grpprlOffset = bxOffset + (BX_SIZE * index) + (grpprlOffset % 2);
PAPX papx = null;
for (int x = 0; x < index; x++)
{
papx = (PAPX)_papxList.get(x);
byte[] phe = papx.getParagraphHeight().toByteArray();
byte[] grpprl = papx.getGrpprl();
LittleEndian.putInt(buf, fcOffset, papx.getStart());
buf[bxOffset] = (byte)(grpprlOffset/2);
System.arraycopy(phe, 0, buf, bxOffset + 1, phe.length);
System.arraycopy(grpprl, 0, buf, grpprlOffset, grpprl.length);
grpprlOffset += grpprl.length + (grpprl.length % 2);
bxOffset += BX_SIZE;
fcOffset += FC_SIZE;
}
// put the last papx's end in
LittleEndian.putInt(buf, fcOffset, papx.getEnd());
return buf;
}
private ParagraphHeight getParagraphHeight(int index)
{
int pheOffset = 1 + (2 * LittleEndian.getUnsignedByte(_fkp, _offset + (((_crun + 1) * 4) + (index * 13))));
ParagraphHeight phe = new ParagraphHeight(_fkp, pheOffset);
return phe;
}
}

View File

@ -0,0 +1,86 @@
/* ====================================================================
* 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;
/**
* 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, papx);
_phe = phe;
}
public ParagraphHeight getParagraphHeight()
{
return _phe;
}
public byte[] getGrpprl()
{
return super.getBuf();
}
}

View File

@ -0,0 +1,113 @@
/*
* ====================================================================
* 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 dymLine;
private int dymHeight;
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;
dymLine = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
dymHeight = 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, dymLine);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(buf, offset, dymHeight);
return buf;
}
}

View File

@ -0,0 +1,133 @@
/*
* ====================================================================
* 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;
BitField fNoParaLast = new BitField(0x01);
BitField fPaphNil = new BitField(0x02);
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 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;
}
}

View File

@ -0,0 +1,139 @@
/* ====================================================================
* 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;
/**
* 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);
}
protected 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);
}
protected 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.
*/
protected int getStructOffset(int index)
{
return (4 * (_count + 1)) + (_sizeOfStruct * index);
}
}

View File

@ -0,0 +1,121 @@
/* ====================================================================
* 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;
/**
* Represents a lightweight node in the Trees used to store content
* properties.
*
* @author Ryan Ackley
*/
public class PropertyNode implements Comparable
{
private byte[] _buf;
private int _fcStart;
private int _fcEnd;
/**
* @param fcStart The start of the text for this property.
* @param fcEnd The end of the text for this property.
* @param grpprl The property description in compressed form.
*/
public PropertyNode(int fcStart, int fcEnd, byte[] buf)
{
_fcStart = fcStart;
_fcEnd = fcEnd;
_buf = buf;
}
/**
* @return The offset of this property's text.
*/
public int getStart()
{
return _fcStart;
}
/**
* @retrun The offset of the end of this property's text.
*/
public int getEnd()
{
return _fcEnd;
}
/**
* @return This property's property in copmpressed form.
*/
public byte[] getBuf()
{
return _buf;
}
/**
* Used for sorting in collections.
*/
public int compareTo(Object o)
{
int fcEnd = ((PropertyNode)o).getEnd();
if(_fcEnd == fcEnd)
{
return 0;
}
else if(_fcEnd < fcEnd)
{
return -1;
}
else
{
return 1;
}
}
}

View File

@ -0,0 +1,73 @@
/*
* ====================================================================
* 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
{
public SEPX(int start, int end, byte[] grpprl)
{
super(start, end, grpprl);
}
public byte[] getGrpprl()
{
return super.getBuf();
}
}

View File

@ -0,0 +1,85 @@
/*
* ====================================================================
* 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(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;
}
}

View File

@ -0,0 +1,96 @@
/*
* ====================================================================
* 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;
public class SectionTable
{
private static final int SED_SIZE = 12;
private ArrayList sections;
public SectionTable(byte[] documentStream, byte[] tableStream, int offset,
int size)
{
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(node.getStart(), node.getEnd(), new byte[0]));
}
else
{
// The first byte at the offset is the size of the grpprl.
byte[] buf = new byte[documentStream[fileOffset++]];
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
sections.add(new SEPX(node.getStart(), node.getEnd(), buf));
}
}
}
}

View File

@ -0,0 +1,90 @@
/* ====================================================================
* 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;
/**
* Lightweight representation of a text piece.
*
* @author Ryan Ackley
*/
public class TextPiece extends PropertyNode implements Comparable
{
private boolean _usesUnicode;
private int _length;
/**
* @param start Offset in main document stream.
* @param length The total length of the text in bytes. Note: 1 character
* does not necessarily refer to 1 byte.
* @param unicode true if this text is unicode.
*/
public TextPiece(int start, int length, boolean unicode)
{
super(start, start + length, null);
_usesUnicode = unicode;
_length = length;
}
/**
* @return If this text piece uses unicode
*/
public boolean usesUnicode()
{
return _usesUnicode;
}
}

View File

@ -0,0 +1,108 @@
/*
* ====================================================================
* 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;
public class TextPieceTable
{
StringBuffer _text = new StringBuffer();
public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset, int size)
throws UnsupportedEncodingException
{
PlexOfCps pieceTable = new PlexOfCps(tableStream, offset, size, PieceDescriptor.getSizeInBytes());
int multiple = 2;
int length = pieceTable.length();
PieceDescriptor[] pieces = new PieceDescriptor[length];
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;
}
}
for (int x = 0; x < pieces.length; x++)
{
int start = pieces[x].getFilePosition();
PropertyNode node = pieceTable.getProperty(x);
int textSize = node.getEnd() - node.getStart();
boolean unicode = pieces[x].isUnicode();
String toStr = null;
if (unicode)
{
toStr = new String(documentStream, start, length * multiple, "UTF-16LE");
}
else
{
toStr = new String(documentStream, start, length, "ISO-8859-1");
}
_text.append(toStr);
}
}
}

View File

@ -0,0 +1,372 @@
/* ====================================================================
* 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.hwpf.model.hdftypes.HDFType;
/**
* 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
{
private int field_1_jc;
private int field_2_dxaGapHalf;
private int field_3_dyaRowHeight;
private boolean field_4_fCantSplit;
private boolean field_5_fTableHeader;
private int field_6_tlp;
private short field_7_itcMac;
private short[] field_8_rgdxaCenter;
private TCAbstractType[] field_9_rgtc;
private byte[] field_10_rgshd;
private short[] field_11_brcBottom;
private short[] field_12_brcTop;
private short[] field_13_brcLeft;
private short[] field_14_brcRight;
private short[] field_15_brcVertical;
private short[] 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 TCAbstractType[] getRgtc()
{
return field_9_rgtc;
}
/**
* Set the rgtc field for the TAP record.
*/
public void setRgtc(TCAbstractType[] field_9_rgtc)
{
this.field_9_rgtc = field_9_rgtc;
}
/**
* Get the rgshd field for the TAP record.
*/
public byte[] getRgshd()
{
return field_10_rgshd;
}
/**
* Set the rgshd field for the TAP record.
*/
public void setRgshd(byte[] field_10_rgshd)
{
this.field_10_rgshd = field_10_rgshd;
}
/**
* Get the brcBottom field for the TAP record.
*/
public short[] getBrcBottom()
{
return field_11_brcBottom;
}
/**
* Set the brcBottom field for the TAP record.
*/
public void setBrcBottom(short[] field_11_brcBottom)
{
this.field_11_brcBottom = field_11_brcBottom;
}
/**
* Get the brcTop field for the TAP record.
*/
public short[] getBrcTop()
{
return field_12_brcTop;
}
/**
* Set the brcTop field for the TAP record.
*/
public void setBrcTop(short[] field_12_brcTop)
{
this.field_12_brcTop = field_12_brcTop;
}
/**
* Get the brcLeft field for the TAP record.
*/
public short[] getBrcLeft()
{
return field_13_brcLeft;
}
/**
* Set the brcLeft field for the TAP record.
*/
public void setBrcLeft(short[] field_13_brcLeft)
{
this.field_13_brcLeft = field_13_brcLeft;
}
/**
* Get the brcRight field for the TAP record.
*/
public short[] getBrcRight()
{
return field_14_brcRight;
}
/**
* Set the brcRight field for the TAP record.
*/
public void setBrcRight(short[] field_14_brcRight)
{
this.field_14_brcRight = field_14_brcRight;
}
/**
* Get the brcVertical field for the TAP record.
*/
public short[] getBrcVertical()
{
return field_15_brcVertical;
}
/**
* Set the brcVertical field for the TAP record.
*/
public void setBrcVertical(short[] field_15_brcVertical)
{
this.field_15_brcVertical = field_15_brcVertical;
}
/**
* Get the brcHorizontal field for the TAP record.
*/
public short[] getBrcHorizontal()
{
return field_16_brcHorizontal;
}
/**
* Set the brcHorizontal field for the TAP record.
*/
public void setBrcHorizontal(short[] field_16_brcHorizontal)
{
this.field_16_brcHorizontal = field_16_brcHorizontal;
}
} // END OF CLASS

View File

@ -0,0 +1,378 @@
/* ====================================================================
* 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.hwpf.model.hdftypes.HDFType;
/**
* 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
{
private short field_1_rgf;
private BitField fFirstMerged = new BitField(0x0001);
private BitField fMerged = new BitField(0x0002);
private BitField fVertical = new BitField(0x0004);
private BitField fBackward = new BitField(0x0008);
private BitField fRotateFont = new BitField(0x0010);
private BitField fVertMerge = new BitField(0x0020);
private BitField fVertRestart = new BitField(0x0040);
private BitField vertAlign = new BitField(0x0180);
private short field_2_unused;
private short[] field_3_brcTop;
private short[] field_4_brcLeft;
private short[] field_5_brcBottom;
private short[] field_6_brcRight;
public TCAbstractType()
{
}
/**
* 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 short[] getBrcTop()
{
return field_3_brcTop;
}
/**
* Set the brcTop field for the TC record.
*/
public void setBrcTop(short[] field_3_brcTop)
{
this.field_3_brcTop = field_3_brcTop;
}
/**
* Get the brcLeft field for the TC record.
*/
public short[] getBrcLeft()
{
return field_4_brcLeft;
}
/**
* Set the brcLeft field for the TC record.
*/
public void setBrcLeft(short[] field_4_brcLeft)
{
this.field_4_brcLeft = field_4_brcLeft;
}
/**
* Get the brcBottom field for the TC record.
*/
public short[] getBrcBottom()
{
return field_5_brcBottom;
}
/**
* Set the brcBottom field for the TC record.
*/
public void setBrcBottom(short[] field_5_brcBottom)
{
this.field_5_brcBottom = field_5_brcBottom;
}
/**
* Get the brcRight field for the TC record.
*/
public short[] getBrcRight()
{
return field_6_brcRight;
}
/**
* Set the brcRight field for the TC record.
*/
public void setBrcRight(short[] 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