Bug 39595

Summary: java.lang.IndexOutOfBoundsException: Index: 7, Size: 7
Product: POI Reporter: Xianing Zhu <Xianing.Zhu>
Component: HWPFAssignee: POI Developers List <dev>
Status: RESOLVED LATER    
Severity: major    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Xianing Zhu 2006-05-16 22:43:08 UTC
InputStream data = .....
HWPFDocument doc = new HWPFDocument(data)
StyleSheet styleSheet = doc.getStyleSheet();
Range r = doc.getRange();
int lenParagraph = r.numParagraphs();

Range.numParagraphs() throw: java.lang.IndexOutOfBoundsException: Index: 7, 
Size: 7

The problem was cased in CHPBinTable and PAPBinTable method: adjustForDelete
(..)
      chpx = (CHPX)_textRuns.get(endIndex);
      chpx.setEnd((chpx.getEnd() - endMark) + offset);
 The start did not be ajusted. When start is less than offset, it causes 
java.lang.IndexOutOfBoundsException.
Comment 1 Nick Burch 2011-02-25 17:02:14 UTC
I believe this has been solved by HWPF updates in the intervening time. Please re-open if the bug still remains for you with a recent svn nightly build / poi 3.8 beta 1 (when released)