klute       2005/01/28 09:23:00

  Modified:    src/scratchpad/src/org/apache/poi/hwpf/model ListLevel.java
  Log:
  Bug 33263 fixed: Patch provided by Der-Johng Sun <[EMAIL PROTECTED]>.
  
  Revision  Changes    Path
  1.4       +19 -9     
jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
  
  Index: ListLevel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ListLevel.java    24 Aug 2004 12:53:59 -0000      1.3
  +++ ListLevel.java    28 Jan 2005 17:23:00 -0000      1.4
  @@ -49,7 +49,7 @@
     private short _reserved;
     private byte[] _grpprlPapx;
     private byte[] _grpprlChpx;
  -  private char[] _numberText;
  +  private char[] _numberText=null;
   
     public ListLevel(int startAt, int numberFormatCode, int alignment,
                      byte[] numberProperties, byte[] entryProperties,
  @@ -111,13 +111,18 @@
       System.arraycopy(buf, offset, _grpprlChpx, 0, _cbGrpprlChpx);
       offset += _cbGrpprlChpx;
   
  -    int numberTextLength = LittleEndian.getShort(buf, offset);
  -    _numberText = new char[numberTextLength];
  -    offset += LittleEndian.SHORT_SIZE;
  -    for (int x = 0; x < numberTextLength; x++)
  -    {
  -      _numberText[x] = (char)LittleEndian.getShort(buf, offset);
  -      offset += LittleEndian.SHORT_SIZE;
  +    int numberTextLength = LittleEndian.getShort(buf, offset); 
  +    /* sometimes numberTextLength<0 */
  +    /* by derjohng */
  +    if (numberTextLength>0)
  +    {
  +        _numberText = new char[numberTextLength];
  +        offset += LittleEndian.SHORT_SIZE;
  +        for (int x = 0; x < numberTextLength; x++)
  +        {
  +          _numberText[x] = (char)LittleEndian.getShort(buf, offset);
  +          offset += LittleEndian.SHORT_SIZE;
  +        }
       }
   
     }
  @@ -230,7 +235,12 @@
     }
     public int getSizeInBytes()
     {
  -    return 28 + _cbGrpprlChpx + _cbGrpprlPapx + (_numberText.length * 
LittleEndian.SHORT_SIZE) + 2;
  +      if (_numberText!=null)
  +      {
  +            return 28 + _cbGrpprlChpx + _cbGrpprlPapx + (_numberText.length 
* LittleEndian.SHORT_SIZE) + 2;
  +      } else {
  +          return 28 + _cbGrpprlChpx + _cbGrpprlPapx  + 2;
  +      }
     }
   
   }
  
  
  

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

Reply via email to