latest patches and changes

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Said Ryan Ackley 2004-04-06 04:44:04 +00:00
parent 364ed73cf1
commit 437880b1d6
13 changed files with 234 additions and 263 deletions

View File

@ -48,12 +48,10 @@ import org.apache.poi.hwpf.usermodel.*;
* @author Ryan Ackley * @author Ryan Ackley
*/ */
public class HWPFDocument public class HWPFDocument
// implements Cloneable
{ {
/** OLE stuff*/
private POIFSFileSystem _filesystem;
/** The FIB*/ /** The FIB*/
private FileInformationBlock _fib; protected FileInformationBlock _fib;
/** main document stream buffer*/ /** main document stream buffer*/
private byte[] _mainStream; private byte[] _mainStream;
@ -62,34 +60,34 @@ public class HWPFDocument
private byte[] _tableStream; private byte[] _tableStream;
/** data stream buffer*/ /** data stream buffer*/
private byte[] _dataStream; protected byte[] _dataStream;
/** Document wide Properties*/ /** Document wide Properties*/
private DocumentProperties _dop; protected DocumentProperties _dop;
/** Contains text of the document wrapped in a obfuscated Wod data structure*/ /** Contains text of the document wrapped in a obfuscated Word data
private ComplexFileTable _cft; * structure*/
protected ComplexFileTable _cft;
private TextPieceTable _tpt; protected TextPieceTable _tpt;
/** Contains formatting properties for text*/ /** Contains formatting properties for text*/
private CHPBinTable _cbt; protected CHPBinTable _cbt;
/** Contains formatting properties for paragraphs*/ /** Contains formatting properties for paragraphs*/
private PAPBinTable _pbt; protected PAPBinTable _pbt;
/** Contains formatting properties for sections.*/ /** Contains formatting properties for sections.*/
private SectionTable _st; protected SectionTable _st;
/** Holds styles for this document.*/ /** Holds styles for this document.*/
private StyleSheet _ss; protected StyleSheet _ss;
/** Holds fonts for this document.*/ /** Holds fonts for this document.*/
private FontTable _ft; protected FontTable _ft;
/** Hold list tables */ /** Hold list tables */
private ListTables _lt; protected ListTables _lt;
/** /**
* This constructor loads a Word document from an InputStream. * This constructor loads a Word document from an InputStream.
@ -101,13 +99,13 @@ public class HWPFDocument
public HWPFDocument(InputStream istream) throws IOException public HWPFDocument(InputStream istream) throws IOException
{ {
//do Ole stuff //do Ole stuff
_filesystem = new POIFSFileSystem(istream); POIFSFileSystem filesystem = new POIFSFileSystem(istream);
// read in the main stream. // read in the main stream.
DocumentEntry documentProps = DocumentEntry documentProps =
(DocumentEntry)_filesystem.getRoot().getEntry("WordDocument"); (DocumentEntry)filesystem.getRoot().getEntry("WordDocument");
_mainStream = new byte[documentProps.getSize()]; _mainStream = new byte[documentProps.getSize()];
_filesystem.createDocumentInputStream("WordDocument").read(_mainStream); filesystem.createDocumentInputStream("WordDocument").read(_mainStream);
// use the fib to determine the name of the table stream. // use the fib to determine the name of the table stream.
_fib = new FileInformationBlock(_mainStream); _fib = new FileInformationBlock(_mainStream);
@ -120,9 +118,9 @@ public class HWPFDocument
// read in the table stream. // read in the table stream.
DocumentEntry tableProps = DocumentEntry tableProps =
(DocumentEntry)_filesystem.getRoot().getEntry(name); (DocumentEntry)filesystem.getRoot().getEntry(name);
_tableStream = new byte[tableProps.getSize()]; _tableStream = new byte[tableProps.getSize()];
_filesystem.createDocumentInputStream(name).read(_tableStream); filesystem.createDocumentInputStream(name).read(_tableStream);
_fib.fillVariableFields(_mainStream, _tableStream); _fib.fillVariableFields(_mainStream, _tableStream);
@ -130,9 +128,9 @@ public class HWPFDocument
try try
{ {
DocumentEntry dataProps = DocumentEntry dataProps =
(DocumentEntry) _filesystem.getRoot().getEntry("Data"); (DocumentEntry) filesystem.getRoot().getEntry("Data");
_dataStream = new byte[dataProps.getSize()]; _dataStream = new byte[dataProps.getSize()];
_filesystem.createDocumentInputStream("Data").read(_dataStream); filesystem.createDocumentInputStream("Data").read(_dataStream);
} }
catch(java.io.FileNotFoundException e) catch(java.io.FileNotFoundException e)
{ {
@ -431,4 +429,17 @@ public class HWPFDocument
t.printStackTrace(); t.printStackTrace();
} }
} }
// public Object clone()
// throws CloneNotSupportedException
// {
// _tpt;
//
// _cbt;
//
// _pbt;
//
// _st;
//
// }
} }

View File

@ -1,58 +1,18 @@
/* /* ====================================================================
* ==================================================================== Copyright 2002-2004 Apache Software Foundation
* 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/>.
*/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
@ -76,6 +36,11 @@ public class CHPBinTable
/** List of character properties.*/ /** List of character properties.*/
ArrayList _textRuns = new ArrayList(); ArrayList _textRuns = new ArrayList();
public CHPBinTable()
{
}
/** /**
* Constructor used to read a binTable in from a Word document. * Constructor used to read a binTable in from a Word document.
* *

View File

@ -69,6 +69,11 @@ public class ComplexFileTable
TextPieceTable _tpt; TextPieceTable _tpt;
public ComplexFileTable()
{
_tpt = new TextPieceTable();
}
public ComplexFileTable(byte[] documentStream, byte[] tableStream, int offset, int fcMin) throws IOException public ComplexFileTable(byte[] documentStream, byte[] tableStream, int offset, int fcMin) throws IOException
{ {
//skips through the prms before we reach the piece table. These contain data //skips through the prms before we reach the piece table. These contain data
@ -110,7 +115,6 @@ public class ComplexFileTable
LittleEndian.putInt(numHolder, table.length); LittleEndian.putInt(numHolder, table.length);
tableStream.write(numHolder); tableStream.write(numHolder);
tableStream.write(table); tableStream.write(table);
} }
} }

View File

@ -73,10 +73,6 @@ public class ListFormatOverrideLevel
public ListFormatOverrideLevel(byte[] buf, int offset) public ListFormatOverrideLevel(byte[] buf, int offset)
{ {
while(buf[offset] == -1)
{
offset++;
}
_iStartAt = LittleEndian.getInt(buf, offset); _iStartAt = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE; offset += LittleEndian.INT_SIZE;
_info = buf[offset++]; _info = buf[offset++];

View File

@ -112,6 +112,10 @@ public class ListTables
int num = lfo.numOverrides(); int num = lfo.numOverrides();
for (int y = 0; y < num; y++) for (int y = 0; y < num; y++)
{ {
while(tableStream[lfolvlOffset] == -1)
{
lfolvlOffset++;
}
ListFormatOverrideLevel lfolvl = new ListFormatOverrideLevel(tableStream, lfolvlOffset); ListFormatOverrideLevel lfolvl = new ListFormatOverrideLevel(tableStream, lfolvlOffset);
lfo.setOverride(y, lfolvl); lfo.setOverride(y, lfolvl);
lfolvlOffset += lfolvl.getSizeInBytes(); lfolvlOffset += lfolvl.getSizeInBytes();

View File

@ -1,57 +1,18 @@
/* /* ====================================================================
* ==================================================================== Copyright 2002-2004 Apache Software Foundation
* The Apache Software License, Version 1.1
* Licensed under the Apache License, Version 2.0 (the "License");
* Copyright (c) 2003 The Apache Software Foundation. All rights you may not use this file except in compliance with the License.
* reserved. You may obtain a copy of the License at
*
* Redistribution and use in source and binary forms, with or without http://www.apache.org/licenses/LICENSE-2.0
* modification, are permitted provided that the following conditions
* are met: Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 1. Redistributions of source code must retain the above copyright WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* notice, this list of conditions and the following disclaimer. See the License for the specific language governing permissions and
* limitations under the License.
* 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; package org.apache.poi.hwpf.model;
@ -69,12 +30,18 @@ import org.apache.poi.util.LittleEndian;
* This class represents the bin table of Word document but it also serves as a * This class represents the bin table of Word document but it also serves as a
* holder for all of the paragraphs of document that have been loaded into * holder for all of the paragraphs of document that have been loaded into
* memory. * memory.
*
* @author Ryan Ackley
*/ */
public class PAPBinTable public class PAPBinTable
{ {
ArrayList _paragraphs = new ArrayList(); ArrayList _paragraphs = new ArrayList();
byte[] _dataStream; byte[] _dataStream;
public PAPBinTable()
{
}
public PAPBinTable(byte[] documentStream, byte[] tableStream, byte[] dataStream, int offset, public PAPBinTable(byte[] documentStream, byte[] tableStream, byte[] dataStream, int offset,
int size, int fcMin) int size, int fcMin)
{ {

View File

@ -1,58 +1,18 @@
/* /* ====================================================================
* ==================================================================== Copyright 2002-2004 Apache Software Foundation
* 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/>.
*/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
@ -63,12 +23,19 @@ import java.io.IOException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.model.io.*; import org.apache.poi.hwpf.model.io.*;
/**
* @author Ryan Ackley
*/
public class SectionTable public class SectionTable
{ {
private static final int SED_SIZE = 12; private static final int SED_SIZE = 12;
private ArrayList _sections = new ArrayList(); private ArrayList _sections = new ArrayList();
public SectionTable()
{
}
public SectionTable(byte[] documentStream, byte[] tableStream, int offset, public SectionTable(byte[] documentStream, byte[] tableStream, int offset,
int size, int fcMin) int size, int fcMin)
{ {

View File

@ -1,57 +1,18 @@
/* /* ====================================================================
* ==================================================================== Copyright 2002-2004 Apache Software Foundation
* The Apache Software License, Version 1.1
* Licensed under the Apache License, Version 2.0 (the "License");
* Copyright (c) 2003 The Apache Software Foundation. All rights you may not use this file except in compliance with the License.
* reserved. You may obtain a copy of the License at
*
* Redistribution and use in source and binary forms, with or without http://www.apache.org/licenses/LICENSE-2.0
* modification, are permitted provided that the following conditions
* are met: Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 1. Redistributions of source code must retain the above copyright WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* notice, this list of conditions and the following disclaimer. See the License for the specific language governing permissions and
* limitations under the License.
* 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; package org.apache.poi.hwpf.model;
@ -67,13 +28,19 @@ import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.hwpf.model.io.*; import org.apache.poi.hwpf.model.io.*;
/**
* @author Ryan Ackley
*/
public class TextPieceTable public class TextPieceTable
{ {
ArrayList _textPieces = new ArrayList(); ArrayList _textPieces = new ArrayList();
//int _multiple; //int _multiple;
int _cpMin; int _cpMin;
public TextPieceTable()
{
}
public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset, public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset,
int size, int fcMin) int size, int fcMin)
throws UnsupportedEncodingException throws UnsupportedEncodingException
@ -236,5 +203,4 @@ public class TextPieceTable
} }
return false; return false;
} }
} }

View File

@ -444,7 +444,7 @@ public class ParagraphSprmUncompressor
for (int x = 0; x < delSize; x++) for (int x = 0; x < delSize; x++)
{ {
tabMap.remove(new Integer(LittleEndian.getInt(grpprl, offset))); tabMap.remove(new Integer(LittleEndian.getInt(grpprl, offset)));
offset += LittleEndian.INT_SIZE;; offset += LittleEndian.SHORT_SIZE;
} }
int addSize = grpprl[offset++]; int addSize = grpprl[offset++];

View File

@ -268,7 +268,7 @@ public class CharacterProperties
return isFDStrike(); return isFDStrike();
} }
public void setDoubleStrikethrough(boolean dstrike) public void setDoubleStrikeThrough(boolean dstrike)
{ {
super.setFDStrike(dstrike); super.setFDStrike(dstrike);
} }

View File

@ -662,15 +662,15 @@ public class Range
r.initAll(); r.initAll();
int tableEnd = r._parEnd; int tableEnd = r._parEnd;
if (r._parStart != 0 && ((Paragraph)r._paragraphs.get(r._parStart - 1)).isInTable()) if (r._parStart != 0 && getParagraph(r._parStart - 1).isInTable())
{ {
throw new IllegalArgumentException("This paragraph is not the first one in the table"); throw new IllegalArgumentException("This paragraph is not the first one in the table");
} }
int limit = r._paragraphs.size(); int limit = _paragraphs.size();
for (; tableEnd < limit; tableEnd++) for (; tableEnd < limit; tableEnd++)
{ {
if (!((Paragraph)r._paragraphs.get(tableEnd)).isInTable()) if (!getParagraph(tableEnd).isInTable())
{ {
break; break;
} }

View File

@ -1,16 +1,90 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
public class TableCell public class TableCell
extends Range extends Range
{ {
int _levelNum; private int _levelNum;
private TableCellDescriptor _tcd;
private int _leftEdge;
private int _width;
public TableCell(int startIdx, int endIdx, TableRow parent, int levelNum, TableCellDescriptor tcd) public TableCell(int startIdx, int endIdx, TableRow parent, int levelNum, TableCellDescriptor tcd, int leftEdge, int width)
{ {
super(startIdx, endIdx, Range.TYPE_PARAGRAPH, parent); super(startIdx, endIdx, Range.TYPE_PARAGRAPH, parent);
_tcd = tcd;
_leftEdge = leftEdge;
_width = width;
_levelNum = levelNum; _levelNum = levelNum;
} }
public boolean isFirstMerged()
{
return _tcd.isFFirstMerged();
}
public boolean isMerged()
{
return _tcd.isFMerged();
}
public boolean isVertical()
{
return _tcd.isFVertical();
}
public boolean isBackward()
{
return _tcd.isFBackward();
}
public boolean isRotateFont()
{
return _tcd.isFRotateFont();
}
public boolean isVerticallyMerged()
{
return _tcd.isFVertMerge();
}
public boolean isFirstVerticallyMerged()
{
return _tcd.isFVertRestart();
}
public byte getVertAlign()
{
return _tcd.getVertAlign();
}
public BorderCode getBrcTop()
{
return _tcd.getBrcTop();
}
public BorderCode getBrcBottom()
{
return _tcd.getBrcBottom();
}
public BorderCode getBrcLeft()
{
return _tcd.getBrcLeft();
}
public BorderCode getBrcRight()
{
return _tcd.getBrcRight();
}
public int getLeftEdge() // twips
{
return _leftEdge;
}
public int getWidth() // twips
{
return _width;
}
} }

View File

@ -1,6 +1,5 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.hwpf.sprm.TableSprmUncompressor; import org.apache.poi.hwpf.sprm.TableSprmUncompressor;
import org.apache.poi.hwpf.sprm.SprmBuffer; import org.apache.poi.hwpf.sprm.SprmBuffer;
@ -16,8 +15,8 @@ public class TableRow
private final static short SPRM_DYAROWHEIGHT = (short)0x9407; private final static short SPRM_DYAROWHEIGHT = (short)0x9407;
int _levelNum; int _levelNum;
TableProperties _tprops; private TableProperties _tprops;
TableCell[] _cells; private TableCell[] _cells;
public TableRow(int startIdx, int endIdx, Table parent, int levelNum) public TableRow(int startIdx, int endIdx, Table parent, int levelNum)
{ {
@ -28,17 +27,26 @@ public class TableRow
_cells = new TableCell[_tprops.getItcMac()]; _cells = new TableCell[_tprops.getItcMac()];
int start = 0; int start = 0;
int cellIndex = 0; int end = 0;
for (int x = 0; x < numParagraphs(); x++)
for (int cellIndex = 0; cellIndex < _cells.length; cellIndex++)
{ {
Paragraph p = getParagraph(x); Paragraph p = getParagraph(start);
String s = p.text(); String s = p.text();
if ((levelNum == 1 && s.charAt(s.length()-1) == TABLE_CELL_MARK) || while (! ( (levelNum == 1 && s.charAt(s.length() - 1) == TABLE_CELL_MARK) ||
p.isEmbeddedCellMark() && p.getTableLevel() == levelNum) p.isEmbeddedCellMark() && p.getTableLevel() == levelNum))
{ {
_cells[cellIndex] = new TableCell(start, x+1, this, levelNum, _tprops.getRgtc()[cellIndex]); end++;
p = getParagraph(end);
s = p.text();
} }
_cells[cellIndex] = new TableCell(start, end, this, levelNum,
_tprops.getRgtc()[cellIndex],
_tprops.getRgdxaCenter()[cellIndex],
_tprops.getRgdxaCenter()[cellIndex+1]-_tprops.getRgdxaCenter()[cellIndex]);
end++;
start = end;
} }
} }
@ -97,4 +105,13 @@ public class TableRow
_papx.updateSprm(SPRM_FTABLEHEADER, (byte)(tableHeader ? 1 : 0)); _papx.updateSprm(SPRM_FTABLEHEADER, (byte)(tableHeader ? 1 : 0));
} }
public int numCells()
{
return _cells.length;
}
public TableCell getCell(int index)
{
return _cells[index];
}
} }