make Table elements constructors accepts char positions (as other constructors); fix SprmBuffer usage for PAPX
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
98c52813dd
commit
c8bb280df0
@ -41,7 +41,7 @@ public final class PAPX extends BytePropertyNode<PAPX> {
|
||||
|
||||
public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] papx, ParagraphHeight phe, byte[] dataStream)
|
||||
{
|
||||
super(fcStart, fcEnd, translator, new SprmBuffer(papx, 0));
|
||||
super(fcStart, fcEnd, translator, new SprmBuffer(papx, 2));
|
||||
_phe = phe;
|
||||
SprmBuffer buf = findHuge(new SprmBuffer(papx, 2), dataStream);
|
||||
if(buf != null)
|
||||
|
@ -84,11 +84,14 @@ public class Paragraph extends Range implements Cloneable {
|
||||
protected ParagraphProperties _props;
|
||||
protected SprmBuffer _papx;
|
||||
|
||||
protected Paragraph(int startIdxInclusive, int endIdxExclusive, Table parent)
|
||||
protected Paragraph( int startIdxInclusive, int endIdxExclusive,
|
||||
Table parent )
|
||||
{
|
||||
super(startIdxInclusive, endIdxExclusive, Range.TYPE_PARAGRAPH, parent);
|
||||
PAPX papx = _paragraphs.get(_parEnd - 1);
|
||||
_props = papx.getParagraphProperties(_doc.getStyleSheet());
|
||||
super( startIdxInclusive, endIdxExclusive, parent );
|
||||
|
||||
initAll();
|
||||
PAPX papx = _paragraphs.get( _parEnd - 1 );
|
||||
_props = papx.getParagraphProperties( _doc.getStyleSheet() );
|
||||
_papx = papx.getSprmBuf();
|
||||
_istd = papx.getIstd();
|
||||
}
|
||||
|
@ -186,6 +186,7 @@ public class Range { // TODO -instantiable superclass
|
||||
* @param parent
|
||||
* The parent Range this range belongs to.
|
||||
*/
|
||||
@Deprecated
|
||||
protected Range(int startIdx, int endIdx, int idxType, Range parent) {
|
||||
_doc = parent._doc;
|
||||
_sections = parent._sections;
|
||||
@ -194,37 +195,6 @@ public class Range { // TODO -instantiable superclass
|
||||
_text = parent._text;
|
||||
_parent = new WeakReference<Range>(parent);
|
||||
|
||||
switch (idxType) {
|
||||
case TYPE_PARAGRAPH:
|
||||
_parStart = parent._parStart + startIdx;
|
||||
_parEnd = parent._parStart + endIdx;
|
||||
_start = _paragraphs.get(_parStart).getStart();
|
||||
_end = _paragraphs.get(_parEnd - 1).getEnd();
|
||||
_parRangeFound = true;
|
||||
break;
|
||||
case TYPE_CHARACTER:
|
||||
_charStart = parent._charStart + startIdx;
|
||||
_charEnd = parent._charStart + endIdx;
|
||||
_start = _characters.get(_charStart - 1).getStart();
|
||||
_end = _characters.get(_charEnd).getEnd();
|
||||
_charRangeFound = true;
|
||||
break;
|
||||
case TYPE_SECTION:
|
||||
_sectionStart = parent._sectionStart + startIdx;
|
||||
_sectionEnd = parent._sectionStart + endIdx;
|
||||
_start = _sections.get(_sectionStart - 1).getStart();
|
||||
_end = _sections.get(_sectionEnd).getEnd();
|
||||
_sectionRangeFound = true;
|
||||
break;
|
||||
case TYPE_TEXT:
|
||||
_textStart = parent._textStart + startIdx;
|
||||
_textEnd = parent._textStart + endIdx;
|
||||
_start = _text.get(_textStart - 1).getStart();
|
||||
_end = _text.get(_textEnd).getEnd();
|
||||
_textRangeFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
sanityCheckStartEnd();
|
||||
}
|
||||
|
||||
@ -534,7 +504,7 @@ public class Range { // TODO -instantiable superclass
|
||||
byte[] withIndex = new byte[grpprl.length + LittleEndian.SHORT_SIZE];
|
||||
LittleEndian.putShort(withIndex, (short) styleIndex);
|
||||
System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length);
|
||||
SprmBuffer buf = new SprmBuffer(withIndex, 0);
|
||||
SprmBuffer buf = new SprmBuffer(withIndex, 2);
|
||||
|
||||
_doc.getParagraphTable().insert(_parStart, _start, buf);
|
||||
insertBefore(text, baseChp);
|
||||
@ -584,7 +554,7 @@ public class Range { // TODO -instantiable superclass
|
||||
byte[] withIndex = new byte[grpprl.length + LittleEndian.SHORT_SIZE];
|
||||
LittleEndian.putShort(withIndex, (short) styleIndex);
|
||||
System.arraycopy(grpprl, 0, withIndex, LittleEndian.SHORT_SIZE, grpprl.length);
|
||||
SprmBuffer buf = new SprmBuffer(withIndex, 0);
|
||||
SprmBuffer buf = new SprmBuffer(withIndex, 2);
|
||||
|
||||
_doc.getParagraphTable().insert(_parEnd, _end, buf);
|
||||
_parEnd++;
|
||||
@ -902,12 +872,12 @@ public class Range { // TODO -instantiable superclass
|
||||
}
|
||||
}
|
||||
|
||||
final Range overallrange = getDocument().getOverallRange();
|
||||
Range overallRange = _doc.getOverallRange();
|
||||
int limit = _paragraphs.size();
|
||||
for ( ; tableEndInclusive < limit - 1; tableEndInclusive++ )
|
||||
{
|
||||
Paragraph next = new Paragraph( _paragraphs.get( tableEndInclusive + 1 ),
|
||||
overallrange );
|
||||
Paragraph next = new Paragraph(
|
||||
_paragraphs.get( tableEndInclusive + 1 ), overallRange );
|
||||
if ( !next.isInTable() || next.getTableLevel() < tableLevel )
|
||||
break;
|
||||
}
|
||||
@ -923,8 +893,11 @@ public class Range { // TODO -instantiable superclass
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
"The table's end is negative, which isn't allowed!" );
|
||||
}
|
||||
return new Table( r._parStart, tableEndInclusive + 1, r._doc.getRange(),
|
||||
paragraph.getTableLevel() );
|
||||
|
||||
int endOffsetExclusive = _paragraphs.get( tableEndInclusive ).getEnd();
|
||||
|
||||
return new Table( paragraph.getStartOffset(), endOffsetExclusive,
|
||||
this, paragraph.getTableLevel() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ public final class Table extends Range
|
||||
Table( int startIdxInclusive, int endIdxExclusive, Range parent,
|
||||
int levelNum )
|
||||
{
|
||||
super( startIdxInclusive, endIdxExclusive, Range.TYPE_PARAGRAPH, parent );
|
||||
super( startIdxInclusive, endIdxExclusive, parent );
|
||||
_tableLevel = levelNum;
|
||||
initRows();
|
||||
}
|
||||
@ -58,11 +58,14 @@ public final class Table extends Range
|
||||
int numParagraphs = numParagraphs();
|
||||
while ( rowEnd < numParagraphs )
|
||||
{
|
||||
Paragraph p = getParagraph( rowEnd );
|
||||
Paragraph startRowP = getParagraph( rowStart );
|
||||
Paragraph endRowP = getParagraph( rowEnd );
|
||||
rowEnd++;
|
||||
if ( p.isTableRowEnd() && p.getTableLevel() == _tableLevel )
|
||||
if ( endRowP.isTableRowEnd()
|
||||
&& endRowP.getTableLevel() == _tableLevel )
|
||||
{
|
||||
_rows.add( new TableRow( rowStart, rowEnd, this, _tableLevel ) );
|
||||
_rows.add( new TableRow( startRowP.getStartOffset(), endRowP
|
||||
.getEndOffset(), this, _tableLevel ) );
|
||||
rowStart = rowEnd;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public final class TableCell
|
||||
TableRow parent, int levelNum, TableCellDescriptor tcd,
|
||||
int leftEdge, int width )
|
||||
{
|
||||
super( startIdxInclusive, endIdxExclusive, Range.TYPE_PARAGRAPH, parent );
|
||||
super( startIdxInclusive, endIdxExclusive, parent );
|
||||
_tcd = tcd;
|
||||
_leftEdge = leftEdge;
|
||||
_width = width;
|
||||
|
@ -66,7 +66,9 @@ public final class TableIterator
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Table(startIndex, endIndex, _range, _levelNum);
|
||||
return new Table( _range.getParagraph( startIndex ).getStartOffset(),
|
||||
_range.getParagraph( endIndex - 1 ).getEndOffset(), _range,
|
||||
_levelNum );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public final class TableRow extends Range
|
||||
super( startIdxInclusive, endIdxExclusive, parent );
|
||||
|
||||
Paragraph last = getParagraph( numParagraphs() - 1 );
|
||||
_tprops = TableSprmUncompressor.uncompressTAP( last._papx );
|
||||
_papx = last._papx;
|
||||
_tprops = TableSprmUncompressor.uncompressTAP( _papx );
|
||||
_levelNum = levelNum;
|
||||
initCells();
|
||||
}
|
||||
@ -146,9 +147,10 @@ public final class TableRow extends Range
|
||||
&& _tprops.getRgdxaCenter().length > cells.size() + 1 ? _tprops
|
||||
.getRgdxaCenter()[cells.size() + 1] : 0;
|
||||
|
||||
TableCell tableCell = new TableCell( lastCellStart, p + 1,
|
||||
this, _levelNum, tableCellDescriptor, leftEdge,
|
||||
rightEdge - leftEdge );
|
||||
TableCell tableCell = new TableCell( getParagraph(
|
||||
lastCellStart ).getStartOffset(), getParagraph( p )
|
||||
.getEndOffset(), this, _levelNum, tableCellDescriptor,
|
||||
leftEdge, rightEdge - leftEdge );
|
||||
cells.add( tableCell );
|
||||
lastCellStart = p + 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user