mirror of https://github.com/apache/poi.git
- Support for variant type VT_R8 added.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a5920f221
commit
e33d4f7cd1
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue