<No Comment Entered>

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Said Ryan Ackley 2004-04-19 23:49:49 +00:00
parent e16b4b948d
commit e90590e97d
14 changed files with 60 additions and 20 deletions

View File

@ -89,6 +89,11 @@ public class HWPFDocument
/** Hold list tables */
protected ListTables _lt;
protected HWPFDocument()
{
}
/**
* This constructor loads a Word document from an InputStream.
*
@ -181,11 +186,21 @@ public class HWPFDocument
return _ss;
}
public FileInformationBlock getFileInformationBlock()
{
return _fib;
}
public DocumentProperties getDocProperties()
{
return _dop;
}
public Range getRange()
{
// hack to get the ending cp of the document, Have to revisit this.
java.util.List paragraphs = _pbt.getParagraphs();
PAPX p = (PAPX)paragraphs.get(paragraphs.size() - 1);
java.util.List text = _tpt.getTextPieces();
PropertyNode p = (PropertyNode)text.get(text.size() - 1);
return new Range(0, p.getEnd(), this);
}
@ -226,7 +241,7 @@ public class HWPFDocument
HWPFFileSystem docSys = new HWPFFileSystem();
HWPFOutputStream mainStream = docSys.getStream("WordDocument");
HWPFOutputStream tableStream = docSys.getStream("1Table");
HWPFOutputStream dataStream = docSys.getStream("Data");
//HWPFOutputStream dataStream = docSys.getStream("Data");
int tableOffset = 0;
// FileInformationBlock fib = (FileInformationBlock)_fib.clone();
@ -332,6 +347,10 @@ public class HWPFDocument
}
byte[] dataBuf = _dataStream;
if (dataBuf == null)
{
dataBuf = new byte[4096];
}
if (dataBuf.length < 4096)
{
byte[] tempBuf = new byte[4096];

View File

@ -34,7 +34,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
public class CHPBinTable
{
/** List of character properties.*/
ArrayList _textRuns = new ArrayList();
protected ArrayList _textRuns = new ArrayList();
public CHPBinTable()

View File

@ -114,7 +114,7 @@ public class CHPFormattedDiskPage extends FormattedDiskPage
int fcOffset = 0;
// total size is currently the size of one FC
int totalSize = FC_SIZE + 1;
int totalSize = FC_SIZE + 2;
int index = 0;
for (; index < size; index++)
@ -165,7 +165,6 @@ public class CHPFormattedDiskPage extends FormattedDiskPage
buf[grpprlOffset] = (byte)grpprl.length;
System.arraycopy(grpprl, 0, buf, grpprlOffset + 1, grpprl.length);
offsetOffset += 1;
fcOffset += FC_SIZE;
}

View File

@ -30,7 +30,7 @@ public class ComplexFileTable
private static final byte GRPPRL_TYPE = 1;
private static final byte TEXT_PIECE_TABLE_TYPE = 2;
TextPieceTable _tpt;
protected TextPieceTable _tpt;
public ComplexFileTable()
{

View File

@ -80,10 +80,19 @@ public class ListFormatOverrideLevel
{
return false;
}
ListFormatOverrideLevel lfolvl = (ListFormatOverrideLevel)obj;
return lfolvl._iStartAt == _iStartAt && lfolvl._info == _info &&
lfolvl._lvl.equals(_lvl) && Arrays.equals(lfolvl._reserved, _reserved);
boolean lvlEquality = false;
if (_lvl != null)
{
lvlEquality = _lvl.equals(lfolvl._lvl);
}
else
{
lvlEquality = lfolvl._lvl == null;
}
return lvlEquality && lfolvl._iStartAt == _iStartAt && lfolvl._info == _info &&
Arrays.equals(lfolvl._reserved, _reserved);
}
public byte[] toByteArray()

View File

@ -35,7 +35,7 @@ import org.apache.poi.util.LittleEndian;
*/
public class PAPBinTable
{
ArrayList _paragraphs = new ArrayList();
protected ArrayList _paragraphs = new ArrayList();
byte[] _dataStream;
public PAPBinTable()

View File

@ -28,7 +28,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
*
* @author Ryan Ackley
*/
public abstract class PropertyNode implements Comparable
public abstract class PropertyNode implements Comparable, Cloneable
{
protected Object _buf;
private int _cpStart;
@ -56,7 +56,7 @@ public abstract class PropertyNode implements Comparable
return _cpStart;
}
void setStart(int start)
public void setStart(int start)
{
_cpStart = start;
}
@ -69,7 +69,7 @@ public abstract class PropertyNode implements Comparable
return _cpEnd;
}
void setEnd(int end)
public void setEnd(int end)
{
_cpEnd = end;
}
@ -118,6 +118,13 @@ public abstract class PropertyNode implements Comparable
}
return false;
}
public Object clone()
throws CloneNotSupportedException
{
return super.clone();
}
/**
* Used for sorting in collections.
*/

View File

@ -31,8 +31,8 @@ public class SectionTable
{
private static final int SED_SIZE = 12;
private ArrayList _sections = new ArrayList();
private List _text;
protected ArrayList _sections = new ArrayList();
protected List _text;
public SectionTable()
{

View File

@ -159,7 +159,8 @@ public class StyleSheet implements HDFType
{
byte[] std = _styleDescriptions[x].toByteArray();
LittleEndian.putShort(sizeHolder, (short)(std.length));
// adjust the size so it is always on a word boundary
LittleEndian.putShort(sizeHolder, (short)((std.length) + (std.length % 2)));
out.write(sizeHolder);
out.write(std);

View File

@ -64,6 +64,11 @@ public class TextPiece extends PropertyNode implements Comparable
return (StringBuffer)_buf;
}
public void setStringBuffer(StringBuffer buf)
{
_buf = buf;
}
public byte[] getRawBytes()
{
try

View File

@ -33,7 +33,7 @@ import org.apache.poi.hwpf.model.io.*;
*/
public class TextPieceTable
{
ArrayList _textPieces = new ArrayList();
protected ArrayList _textPieces = new ArrayList();
//int _multiple;
int _cpMin;

View File

@ -38,6 +38,7 @@ public class HWPFFileSystem
{
_streams.put("WordDocument", new HWPFOutputStream());
_streams.put("1Table", new HWPFOutputStream());
_streams.put("Data", new HWPFOutputStream());
}
public HWPFOutputStream getStream(String name)

View File

@ -719,7 +719,7 @@ public class Range
/**
* loads all of the list indexes.
*/
private void initAll()
protected void initAll()
{
initText();
initCharacterRuns();

View File

@ -68,7 +68,6 @@ public class TestCHPBinTable
{
PropertyNode oldNode = (PropertyNode)oldTextRuns.get(x);
PropertyNode newNode = (PropertyNode)newTextRuns.get(x);
assertTrue(oldNode.equals(newNode));
}