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)
protected ParagraphProperties _props;
protected SprmBuffer _papx;
- 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());
- _papx = papx.getSprmBuf();
- _istd = papx.getIstd();
- }
+ protected Paragraph( int startIdxInclusive, int endIdxExclusive,
+ Table parent )
+ {
+ super( startIdxInclusive, endIdxExclusive, parent );
+
+ initAll();
+ PAPX papx = _paragraphs.get( _parEnd - 1 );
+ _props = papx.getParagraphProperties( _doc.getStyleSheet() );
+ _papx = papx.getSprmBuf();
+ _istd = papx.getIstd();
+ }
protected Paragraph(PAPX papx, Range parent)
{
* @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;
_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();
}
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);
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++;
}
}
- 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;
}
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() );
}
/**
Table( int startIdxInclusive, int endIdxExclusive, Range parent,
int levelNum )
{
- super( startIdxInclusive, endIdxExclusive, Range.TYPE_PARAGRAPH, parent );
+ super( startIdxInclusive, endIdxExclusive, parent );
_tableLevel = levelNum;
initRows();
}
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;
}
}
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;
break;
}
}
- return new Table(startIndex, endIndex, _range, _levelNum);
+ return new Table( _range.getParagraph( startIndex ).getStartOffset(),
+ _range.getParagraph( endIndex - 1 ).getEndOffset(), _range,
+ _levelNum );
}
}
super( startIdxInclusive, endIdxExclusive, parent );
Paragraph last = getParagraph( numParagraphs() - 1 );
- _tprops = TableSprmUncompressor.uncompressTAP( last._papx );
+ _papx = last._papx;
+ _tprops = TableSprmUncompressor.uncompressTAP( _papx );
_levelNum = levelNum;
initCells();
}
&& _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;
}