klute 2005/04/13 09:33:22
Modified: src/java/org/apache/poi/hpsf TypeWriter.java
VariantSupport.java
src/testcases/org/apache/poi/hpsf/basic TestWrite.java
Log:
- Support for variant type VT_R8 added.
Revision Changes Path
1.5 +18 -4 jakarta-poi/src/java/org/apache/poi/hpsf/TypeWriter.java
Index: TypeWriter.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/TypeWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TypeWriter.java 9 Apr 2004 13:05:16 -0000 1.4
+++ TypeWriter.java 13 Apr 2005 16:33:22 -0000 1.5
@@ -169,8 +169,22 @@
-
-
-
+ /**
+ * <p>Writes a double value value to an output stream.</p>
+ *
+ * @param out The stream to write to.
+ * @param n The value to write.
+ * @exception IOException if an I/O error occurs
+ * @return The number of bytes written to the output stream.
+ */
+ public static int writeToStream(final OutputStream out, final double n)
+ throws IOException
+ {
+ final int l = LittleEndian.DOUBLE_SIZE;
+ final byte[] buffer = new byte[l];
+ LittleEndian.putDouble(buffer, 0, n);
+ out.write(buffer, 0, l);
+ return l;
+ }
}
1.13 +16 -1
jakarta-poi/src/java/org/apache/poi/hpsf/VariantSupport.java
Index: VariantSupport.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/VariantSupport.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- VariantSupport.java 13 Feb 2005 18:35:09 -0000 1.12
+++ VariantSupport.java 13 Apr 2005 16:33:22 -0000 1.13
@@ -169,6 +169,15 @@
value = new Long(LittleEndian.getUInt(src, o1));
break;
}
+ case Variant.VT_R8:
+ {
+ /*
+ * Read an eight-byte double value. In Java it is
represented as
+ * a Double object.
+ */
+ value = new Double(LittleEndian.getDouble(src, o1));
+ break;
+ }
case Variant.VT_FILETIME:
{
/*
@@ -394,6 +403,12 @@
((Long) value).intValue());
break;
}
+ case Variant.VT_R8:
+ {
+ length += TypeWriter.writeToStream(out,
+ ((Double) value).doubleValue());
+ break;
+ }
case Variant.VT_FILETIME:
{
long filetime = Util.dateToFileTime((Date) value);
1.21 +2 -1
jakarta-poi/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
Index: TestWrite.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- TestWrite.java 12 Oct 2004 05:49:01 -0000 1.20
+++ TestWrite.java 13 Apr 2005 16:33:22 -0000 1.21
@@ -411,6 +411,7 @@
check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4, 5, 6, 7},
codepage);
check(Variant.VT_I2, new Integer(27), codepage);
check(Variant.VT_I4, new Long(28), codepage);
+ check(Variant.VT_R8, new Double(29.0), codepage);
check(Variant.VT_FILETIME, new Date(), codepage);
check(Variant.VT_LPSTR,
---------------------------------------------------------------------
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/