You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Przemyslaw Kleszczewski <PK...@infovidematrix.pl> on 2006/12/05 13:57:28 UTC

[improvement]

Hello 
I've worked with POI library and discowered that hwpf module for word documents dosn't work for some kind of documents. I had some exceptions connectiong with out of bound and index was less then zero.

java.lang.StringIndexOutOfBoundsException: String index out of range: -768
	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:886)
	at java.lang.StringBuffer.substring(StringBuffer.java:417)
	at org.apache.poi.hwpf.usermodel.Range.text(Range.java:261)


_____________________________________________________________
java.lang.StringIndexOutOfBoundsException: String index out of range: -768
	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:886)
	at java.lang.StringBuffer.substring(StringBuffer.java:417)
	at org.apache.poi.hwpf.usermodel.Range.text(Range.java:261)
_____________________________________________________________
java.lang.NegativeArraySizeException
	at org.apache.poi.hwpf.model.StyleDescription.<init>(StyleDescription.java:123)
	at org.apache.poi.hwpf.model.StyleSheet.<init>(StyleSheet.java:107)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:174)
	at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:102)
_____________________________________________________________


After a search I discovered that adreses was to long for type short witch was used in whole hwpf package. As i've discowered word has adreses in type unsigned short and that's why this errors occured because type was owerflowed and as a result we had some less zero
walues. I've changed in this module functions getShort(...) and putShort(...) to getUShort() and putUShort(...) from package and made some changes, where nessesary according to type (from short to int). This semsed to solve this practicular problem. Some documends whitch were couldn't parsed with elier version were parsed now quite good. I would like to submit this improvment. I could send some
code but it is not made on version from repository but from stable version prom .zip. Besides it should be done more cerfoul. But as i
compiled it seems to work fine. Please respond what should I do?? Should I send you what I've done and You make this improvment into official version or should I get version from repository make this improvment and commited it???

Przemyslaw Kleszczewski

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/