acoliver    02/05/18 08:57:43

  Modified:    src/scratchpad/src/org/apache/poi/generator
                        FieldIterator.java RecordUtil.java
  Log:
  fixes to handle new string type
  
  Revision  Changes    Path
  1.8       +11 -6     
jakarta-poi/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java
  
  Index: FieldIterator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FieldIterator.java        15 May 2002 00:56:18 -0000      1.7
  +++ FieldIterator.java        18 May 2002 15:57:43 -0000      1.8
  @@ -95,8 +95,10 @@
               result = "data[ 0x" + Integer.toHexString(offset) + " + offset ]";
           else if (javaType.equals("double"))
               result = "LittleEndian.getDouble(data, 0x" + 
Integer.toHexString(offset) + " + offset)";
  -        else if (javaType.equals("String"))
  -            result = "StringUtil.getFromUnicode(data, 0x" + 
Integer.toHexString(offset) + " + offset,"+ size + ")";
  +        else if (javaType.equals("String") && !type.equals("hbstring"))
  +            result = "StringUtil.getFromUnicode(data, 0x" + 
Integer.toHexString(offset) + " + offset,("+ size + "-1)/2)";
  +        else if (javaType.equals("String") && type.equals("hbstring"))
  +            result = "StringUtil.getFromUnicodeHigh(data, 0x" + 
Integer.toHexString(offset) + " + offset, ("+ size+"/2))";
   
           try
           {
  @@ -126,8 +128,11 @@
               result = "data[ " + (offset+4) + " + offset ] = " + javaFieldName + ";";
           else if (javaType.equals("double"))
               result = "LittleEndian.putDouble(data, " + (offset+4) + " + offset, " + 
javaFieldName + ");";
  -        else if (javaType.equals("ExcelString"))
  -            result = "StringUtil.putUncompressedUnicode("+ javaFieldName +", data, 
20 + offset);";
  +        else if (javaType.equals("String") && !type.equals("hbstring"))
  +            result = "StringUtil.putUncompressedUnicode("+ javaFieldName +", data, 
offset+4);";
  +        else if (javaType.equals("String") && type.equals("hbstring"))
  +            result = "StringUtil.putUncompressedUnicodeHigh("+ javaFieldName +", 
data, "+(offset+4)+" + offset);";
  +        
   
           try
           {
  @@ -152,12 +157,12 @@
           {
               String javaFieldName = RecordUtil.getFieldName(fieldNumber,fieldName,0);
               return result + javaFieldName + ".length * 2 + 2";
  -        }
  -        else
  +        } else 
           {
               return result + size;
           }
       }
  +    
   
   }
   
  
  
  
  1.11      +6 -0      
jakarta-poi/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java
  
  Index: RecordUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RecordUtil.java   15 May 2002 00:56:18 -0000      1.10
  +++ RecordUtil.java   18 May 2002 15:57:43 -0000      1.11
  @@ -137,6 +137,9 @@
               return pad(new StringBuffer("double"), padTo).toString();
           else if (type.equals("string"))
               return pad(new StringBuffer("String"), padTo).toString();
  +        else if (type.equals("hbstring"))
  +            return pad(new StringBuffer("String"), padTo).toString();
  +        
   
           return "short";   // if we don't know, default to short
       }
  @@ -153,6 +156,9 @@
               result = pad(new StringBuffer("short"), padTo);
           else if (type.equals("string"))
               result = pad(new StringBuffer("String"), padTo);
  +        else if (type.equals("hbstring"))
  +            result = pad(new StringBuffer("HighByteString"), padTo);
  +        
           else
               return "";
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to