You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by sa...@apache.org on 2004/03/23 06:51:52 UTC

cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model Ffn.java FontTable.java PAPFormattedDiskPage.java PropertyNode.java TextPiece.java TextPieceTable.java

sackley     2004/03/22 21:51:52

  Modified:    src/scratchpad/src/org/apache/poi/hwpf/model Ffn.java
                        FontTable.java PAPFormattedDiskPage.java
                        PropertyNode.java TextPiece.java
                        TextPieceTable.java
  Log:
  Applied patches from Piers and my latest changes
  
  Revision  Changes    Path
  1.3       +5 -5      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java
  
  Index: Ffn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Ffn.java	10 Mar 2004 04:18:53 -0000	1.2
  +++ Ffn.java	23 Mar 2004 05:51:52 -0000	1.3
  @@ -108,7 +108,7 @@
       offset += _fontSig.length;
   
       offsetTmp = offset - offsetTmp;
  -    _xszFfnLength = this.getSize() - offsetTmp;
  +    _xszFfnLength = (this.getSize() - offsetTmp)/2;
       _xszFfn = new char[_xszFfnLength];
   
       for(int i = 0; i < _xszFfnLength; i++)
  @@ -206,13 +206,13 @@
   
       for(int i = 0; i < _xszFfn.length; i++)
       {
  -      buf[offset] = (byte)_xszFfn[i];
  -        offset += LittleEndian.BYTE_SIZE;
  +      LittleEndian.putShort(buf, offset, (short)_xszFfn[i]);
  +      offset += LittleEndian.SHORT_SIZE;
       }
   
  -      return buf;
  +    return buf;
   
  -    }
  +  }
   
       public boolean equals(Object o)
       {
  
  
  
  1.3       +1 -1      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
  
  Index: FontTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FontTable.java	10 Mar 2004 04:18:53 -0000	1.2
  +++ FontTable.java	23 Mar 2004 05:51:52 -0000	1.3
  @@ -159,7 +159,7 @@
   
   	  for(int i = 0; i < _fontNames.length; i++)
   	  {
  -		tableStream.write(_fontNames[i].toByteArray());
  +		  tableStream.write(_fontNames[i].toByteArray());
   	  }
   
     }
  
  
  
  1.4       +3 -3      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java
  
  Index: PAPFormattedDiskPage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PAPFormattedDiskPage.java	12 Mar 2004 12:34:32 -0000	1.3
  +++ PAPFormattedDiskPage.java	23 Mar 2004 05:51:52 -0000	1.4
  @@ -272,15 +272,15 @@
               int maxHugeGrpprlSize = LittleEndian.getUShort(_dataStream,
                   hugeGrpprlOffset);
   
  -            if (maxHugeGrpprlSize < grpprl.length)
  +            if (maxHugeGrpprlSize < grpprl.length-2) // grpprl.length-2 because we don't store the istd
                 throw new UnsupportedOperationException(
                     "This Paragraph's dataStream storage is too small.");
             }
   
             // store grpprl at hugeGrpprlOffset
             System.arraycopy(grpprl, 2, _dataStream, hugeGrpprlOffset + 2,
  -                           grpprl.length);
  -          LittleEndian.putUShort(_dataStream, hugeGrpprlOffset, grpprl.length);
  +                           grpprl.length - 2); // grpprl.length-2 because we don't store the istd
  +          LittleEndian.putUShort(_dataStream, hugeGrpprlOffset, grpprl.length - 2);
   
             // grpprl = grpprl containing only a sprmPHugePapx2
             int istd = LittleEndian.getUShort(grpprl, 0);
  
  
  
  1.2       +23 -0     jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
  
  Index: PropertyNode.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyNode.java	2 Mar 2004 06:22:01 -0000	1.1
  +++ PropertyNode.java	23 Mar 2004 05:51:52 -0000	1.2
  @@ -110,6 +110,29 @@
       _cpEnd = end;
     }
   
  +  /**
  +   * Adjust for a deletion that can span multiple PropertyNodes.
  +   * @param start
  +   * @param length
  +   */
  +  public void adjustForDelete(int start, int length)
  +  {
  +    int end = start + length;
  +
  +    if (_cpEnd > start)
  +    {
  +      if (_cpStart < end)
  +      {
  +        _cpEnd = end >= _cpEnd ? start : _cpEnd - length;
  +        _cpStart = Math.min(start, _cpStart);
  +      }
  +      else
  +      {
  +        _cpEnd -= length;
  +        _cpStart -= length;
  +      }
  +    }
  +  }
   
     protected boolean limitsAreEqual(Object o)
     {
  
  
  
  1.3       +31 -57    jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
  
  Index: TextPiece.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TextPiece.java	4 Mar 2004 04:31:16 -0000	1.2
  +++ TextPiece.java	23 Mar 2004 05:51:52 -0000	1.3
  @@ -1,56 +1,19 @@
   /* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache POI" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache POI", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  +   Copyright 2002-2004   Apache Software Foundation
  +
  +   Licensed under the Apache License, Version 2.0 (the "License");
  +   you may not use this file except in compliance with the License.
  +   You may obtain a copy of the License at
  +
  +       http://www.apache.org/licenses/LICENSE-2.0
  +
  +   Unless required by applicable law or agreed to in writing, software
  +   distributed under the License is distributed on an "AS IS" BASIS,
  +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  +   See the License for the specific language governing permissions and
  +   limitations under the License.
  +==================================================================== */
  +
   
   package org.apache.poi.hwpf.model;
   
  @@ -65,7 +28,7 @@
   public class TextPiece extends PropertyNode implements Comparable
   {
     private boolean _usesUnicode;
  -  private int _length;
  +
     private PieceDescriptor _pd;
   
     /**
  @@ -77,10 +40,11 @@
     public TextPiece(int start, int end, byte[] text, PieceDescriptor pd)
       throws UnsupportedEncodingException
     {
  -      super(start, end, new StringBuffer(new String(text, pd.isUnicode() ? "UTF-16LE" : "Cp1252")));
  -      _usesUnicode = pd.isUnicode();
  -      _length = end - start;
  -      _pd = pd;
  +     /** start - end is length on file. This is double the expected when its
  +     * unicode.*/
  +    super(start, end, new StringBuffer(new String(text, pd.isUnicode() ? "UTF-16LE" : "Cp1252")));
  +    _usesUnicode = pd.isUnicode();
  +    _pd = pd;
     }
     /**
      * @return If this text piece uses unicode
  @@ -121,6 +85,16 @@
        int denominator = _usesUnicode ? 2 : 1;
   
        return ((StringBuffer)_buf).substring(start/denominator, end/denominator);
  +   }
  +
  +   public void adjustForDelete(int start, int length)
  +   {
  +
  +   }
  +
  +   public int characterLength()
  +   {
  +     return (getEnd() - getStart()) / (_usesUnicode ? 2 : 1);
      }
   
      public boolean equals(Object o)
  
  
  
  1.2       +2 -0      jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
  
  Index: TextPieceTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextPieceTable.java	2 Mar 2004 06:22:01 -0000	1.1
  +++ TextPieceTable.java	23 Mar 2004 05:51:52 -0000	1.2
  @@ -204,6 +204,8 @@
       int size = _textPieces.size();
   
       TextPiece tp = (TextPiece)_textPieces.get(listIndex);
  +
  +    //The text piece stores the length on file.
       length = length * (tp.usesUnicode() ? 2 : 1);
       tp.setEnd(tp.getEnd() + length);
       for (int x = listIndex + 1; x < size; x++)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org