Hi all.

We're on POI 3.1, and are getting the following exception when getting the text pieces for some Word documents:

java.lang.StringIndexOutOfBoundsException: String index out of range: -22528
        at 
java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:881)
        at java.lang.StringBuffer.substring(StringBuffer.java:416)
        at org.apache.poi.hwpf.usermodel.Range.text(Range.java:270)
        at 
org.apache.poi.hwpf.model.PicturesTable.getAllPictures(PicturesTable.java:196)

This appears to be coming from here:

  public String text()
  {
    initText();

    StringBuffer sb = new StringBuffer();

    for (int x = _textStart; x < _textEnd; x++)
    {
      TextPiece piece = (TextPiece)_text.get(x);
      int start = _start > piece.getStart() ? _start - piece.getStart() : 0;
      int end = _end <= piece.getEnd() ? _end - piece.getStart() : 
piece.getEnd() - piece.getStart();

      if(piece.usesUnicode()) // convert the byte pointers to char pointers
      {
        start/=2;
        end/=2;
      }
      sb.append(piece.getStringBuffer().substring(start, end));
    }
    return sb.toString();
  }

A breakpoint at the call to substring shows the following values:

  _start = 7468
  _end = 7680
  piece.getStart() = 52736
  _end - piece.getStart() = -45056

I notice that trunk is significantly different in this area... so I'm wondering how safe it would be to pull just the changes in this area into 3.1, or whether it is a practical impossibility due to being part of a much larger changeset.

We can't upgrade to 3.2 as updating caused about half a dozen of our own unit tests to fail.

Daniel



--
Daniel Noll                            Forensic and eDiscovery Software
Senior Developer                              The world's most advanced
Nuix                                                email data analysis
http://nuix.com/                                and eDiscovery software

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to