int previous = range.getStartOffset();
for ( Structure structure : structures )
{
if ( structure.start != previous )
{
Range subrange = new Range( previous, structure.start, range )
{
@Override
public String toString()
{
return "BetweenStructuresSubrange " + super.toString();
}
};
processCharacters( wordDocument, currentTableLevel, subrange,
block );
}
if ( structure.structure instanceof Bookmark )
{
// other bookmarks with same boundaries
List<Bookmark> bookmarks = new LinkedList<Bookmark>();
for ( Bookmark bookmark : ( (HWPFDocument) wordDocument )
.getBookmarks()
.getBookmarksStartedBetween( structure.start,
structure.start + 1 ).values().iterator()
.next() )
{
if ( bookmark.getStart() == structure.start
&& bookmark.getEnd() == structure.end )
{
bookmarks.add( bookmark );
}
}
bookmarkStack.addAll( bookmarks );
try
{
int end = Math.min( range.getEndOffset(), structure.end );
Range subrange = new Range( structure.start, end, range )
{
@Override
public String toString()
{
return "BookmarksSubrange " + super.toString();
}
};
processBookmarks( wordDocument, block, subrange,
currentTableLevel, bookmarks );
}
finally
{
bookmarkStack.removeAll( bookmarks );
}
}
else if ( structure.structure instanceof Field )
{
Field field = (Field) structure.structure;
processField( (HWPFDocument) wordDocument, range,
currentTableLevel, field, block );
}
else if ( structure.structure instanceof DeadFieldBoundaries )
{
DeadFieldBoundaries boundaries = (DeadFieldBoundaries) structure.structure;
processDeadField( wordDocument, block, range,
currentTableLevel, boundaries.beginMark,
boundaries.separatorMark, boundaries.endMark );
}
else
{
throw new UnsupportedOperationException( "NYI: "
+ structure.structure.getClass() );
}
previous = Math.min( range.getEndOffset(), structure.end );
}
if ( previous != range.getStartOffset() )
{
if ( previous > range.getEndOffset() )
{
logger.log( POILogger.WARN, "Latest structure in ", range,
" ended at #" + previous, " after range boundaries [",
range.getStartOffset() + "; " + range.getEndOffset(),
")" );
return true;
}
if ( previous < range.getEndOffset() )
{
Range subrange = new Range( previous, range.getEndOffset(),
range )
{
@Override
public String toString()
{