poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1178111 - /poi/trunk/src/java/org/apache/poi/hpsf/VariantSupport.java
Date Sun, 02 Oct 2011 00:55:57 GMT
Author: sergey
Date: Sun Oct  2 00:55:56 2011
New Revision: 1178111

URL: http://svn.apache.org/viewvc?rev=1178111&view=rev
Log:
correctly add padding to 16-bit integers

Modified:
    poi/trunk/src/java/org/apache/poi/hpsf/VariantSupport.java

Modified: poi/trunk/src/java/org/apache/poi/hpsf/VariantSupport.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/VariantSupport.java?rev=1178111&r1=1178110&r2=1178111&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/VariantSupport.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/VariantSupport.java Sun Oct  2 00:55:56 2011
@@ -477,11 +477,12 @@ public class VariantSupport extends Vari
             case Variant.VT_BOOL:
             {
                 int trueOrFalse;
-                if (((Boolean) value).booleanValue())
-                    trueOrFalse = 1;
+                if ( ( (Boolean) value ).booleanValue() )
+                    trueOrFalse = 0xFFFF;
                 else
-                    trueOrFalse = 0;
-                length = TypeWriter.writeUIntToStream(out, trueOrFalse);
+                    trueOrFalse = 0x0000;
+                TypeWriter.writeUShortToStream( out, trueOrFalse );
+                length += 2;
                 break;
             }
             case Variant.VT_LPSTR:
@@ -534,7 +535,13 @@ public class VariantSupport extends Vari
             case Variant.VT_I2:
             {
                 TypeWriter.writeToStream(out, ((Integer) value).shortValue());
-                length = LittleEndianConsts.SHORT_SIZE;
+                // length = LittleEndianConsts.SHORT_SIZE;
+                TypeWriter.writeToStream( out, (short) 0x0000 );
+                /*
+                 * MUST be a 16-bit signed integer, followed by zero padding to 4
+                 * bytes -- http://msdn.microsoft.com/en-us/library/dd942532(v=PROT.13).aspx
+                 */
+                length = LittleEndianConsts.INT_SIZE;
                 break;
             }
             case Variant.VT_I4:



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


Mime
View raw message