aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/poi/hpsf/TypeWriter.java20
-rw-r--r--src/java/org/apache/poi/hpsf/VariantSupport.java15
-rw-r--r--src/testcases/org/apache/poi/hpsf/basic/TestWrite.java1
3 files changed, 33 insertions, 3 deletions
diff --git a/src/java/org/apache/poi/hpsf/TypeWriter.java b/src/java/org/apache/poi/hpsf/TypeWriter.java
index 3f0f488002..c88e98d07b 100644
--- a/src/java/org/apache/poi/hpsf/TypeWriter.java
+++ b/src/java/org/apache/poi/hpsf/TypeWriter.java
@@ -169,8 +169,22 @@ public class TypeWriter
-
-
-
+ /**
+ * <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;
+ }
}
diff --git a/src/java/org/apache/poi/hpsf/VariantSupport.java b/src/java/org/apache/poi/hpsf/VariantSupport.java
index 081e7f4dd4..b9ab14ffca 100644
--- a/src/java/org/apache/poi/hpsf/VariantSupport.java
+++ b/src/java/org/apache/poi/hpsf/VariantSupport.java
@@ -169,6 +169,15 @@ public class VariantSupport extends Variant
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 @@ public class VariantSupport extends Variant
((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);
diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
index bec47c737f..3fa12d83f6 100644
--- a/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
+++ b/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
@@ -411,6 +411,7 @@ public class TestWrite extends TestCase
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,