Author: nick
Date: Mon Nov 12 04:47:34 2007
New Revision: 594097

URL: http://svn.apache.org/viewvc?rev=594097&view=rev
Log:
Support getting and setting as int, as well as short (bug #43648)

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=594097&r1=594096&r2=594097&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Mon Nov 12 04:47:34 
2007
@@ -36,7 +36,8 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.0.2-FINAL" date="2007-??-??">
-            <action dev="POI-DEVELOPERS" type="add">43751 - [PATCH] - Fix for 
handling rotated text in HSSFSheet.autoSizeColumn</action>
+            <action dev="POI-DEVELOPERS" type="fix">43648 - Fix for IntPtg and 
short vs int</action>
+            <action dev="POI-DEVELOPERS" type="fix">43751 - [PATCH] - Fix for 
handling rotated text in HSSFSheet.autoSizeColumn</action>
             <action dev="POI-DEVELOPERS" type="add">Include an Excel text 
extractor, and put all existing text extractors under a common 
superclass</action>
             <action dev="POI-DEVELOPERS" type="add">Improvements to the LZW 
compression engine used by HDGF</action>
             <action dev="POI-DEVELOPERS" type="add">HSSFPicture.resize() - a 
handy method to reset a picture to its original width and height</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=594097&r1=594096&r2=594097&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Nov 12 04:47:34 
2007
@@ -33,6 +33,8 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.0.2-FINAL" date="2007-??-??">
+            <action dev="POI-DEVELOPERS" type="fix">43648 - Fix for IntPtg and 
short vs int</action>
+            <action dev="POI-DEVELOPERS" type="fix">43751 - [PATCH] - Fix for 
handling rotated text in HSSFSheet.autoSizeColumn</action>
             <action dev="POI-DEVELOPERS" type="add">Include an Excel text 
extractor, and put all existing text extractors under a common 
superclass</action>
             <action dev="POI-DEVELOPERS" type="add">Improvements to the LZW 
compression engine used by HDGF</action>
             <action dev="POI-DEVELOPERS" type="add">HSSFPicture.resize() - a 
handy method to reset a picture to its original width and height</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java?rev=594097&r1=594096&r2=594097&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java Mon Nov 
12 04:47:34 2007
@@ -29,8 +29,8 @@
 import org.apache.poi.hssf.record.RecordInputStream;
 
 /**
- * Integer (short intger)
- * Stores a (java) short value in a formula
+ * Integer (unsigned short intger)
+ * Stores an unsigned short value (java int) in a formula
  * @author  Andrew C. Oliver (acoliver at apache dot org)
  * @author Jason Height (jheight at chariot dot net dot au)
  */
@@ -57,13 +57,45 @@
         setValue(Short.parseShort(formulaToken));
     }
 
+    /**
+     * Sets the wrapped value.
+     * Normally you should call with a positive int.
+     */
     public void setValue(short value)
     {
         field_1_value = value;
     }
 
+    /**
+     * Sets the unsigned value.
+     * (Handles conversion to the internal short value) 
+     */
+    public void setValue(int value)
+    {
+       if(value > Short.MAX_VALUE) {
+               // Need to wrap
+               value -= (Short.MAX_VALUE+1)*2;
+       }
+       field_1_value = (short)value;
+    }
+
+    /**
+     * Returns the value as a short, which may have
+     *  been wrapped into negative numbers
+     */
     public short getValue()
     {
+        return field_1_value;
+    }
+
+    /**
+     * Returns the value as an unsigned positive int.
+     */
+    public int getValueAsInt()
+    {
+       if(field_1_value < 0) {
+               return (Short.MAX_VALUE + 1)*2 + field_1_value;
+       }
         return field_1_value;
     }
 



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

Reply via email to