From d8f189f40f992f4236d4790d8b64f14934ab6846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Budischewski?= Date: Fri, 8 Dec 2000 07:24:40 +0000 Subject: [PATCH] #81032# hyper are now also read/written. Note that e.g. scripts using hypers won't be able to read/write them in older versions. --- io/source/stm/odata.cxx | 34 +++++++++++++++++++++++++++++----- io/test/stm/datatest.cxx | 7 +++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/io/source/stm/odata.cxx b/io/source/stm/odata.cxx index 834ea08f12c7..b906cb3891cb 100644 --- a/io/source/stm/odata.cxx +++ b/io/source/stm/odata.cxx @@ -2,9 +2,9 @@ * * $RCSfile: odata.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:24:18 $ + * last change: $Author: jbu $ $Date: 2000-12-08 08:24:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -314,8 +314,22 @@ sal_Int32 ODataInputStream::readLong(void) throw (IOException, RuntimeException) sal_Int64 ODataInputStream::readHyper(void) throw (IOException, RuntimeException) { - throw WrongFormatException( ); - return 0; + Sequence aTmp(8); + if( 8 != readBytes( aTmp, 8 ) ) + { + throw UnexpectedEOFException( ); + } + + const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray(); + return + (((sal_Int64)pBytes[0]) << 56) + + (((sal_Int64)pBytes[1]) << 48) + + (((sal_Int64)pBytes[2]) << 40) + + (((sal_Int64)pBytes[3]) << 32) + + (((sal_Int64)pBytes[4]) << 24) + + (((sal_Int64)pBytes[5]) << 16) + + (((sal_Int64)pBytes[6]) << 8) + + pBytes[7]; } float ODataInputStream::readFloat(void) throw (IOException, RuntimeException) @@ -735,7 +749,17 @@ void ODataOutputStream::writeHyper(sal_Int64 Value) throw ( IOException, RuntimeException) { - throw WrongFormatException(); + Sequence aTmp( 8 ); + sal_Int8 * pBytes = aTmp.getArray(); + pBytes[0] = sal_Int8(Value >> 56); + pBytes[1] = sal_Int8(Value >> 48); + pBytes[2] = sal_Int8(Value >> 40); + pBytes[3] = sal_Int8(Value >> 32); + pBytes[4] = sal_Int8(Value >> 24); + pBytes[5] = sal_Int8(Value >> 16); + pBytes[6] = sal_Int8(Value >> 8); + pBytes[7] = sal_Int8(Value); + writeBytes( aTmp ); } diff --git a/io/test/stm/datatest.cxx b/io/test/stm/datatest.cxx index 1d627c69e320..0aed90948fba 100644 --- a/io/test/stm/datatest.cxx +++ b/io/test/stm/datatest.cxx @@ -2,9 +2,9 @@ * * $RCSfile: datatest.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:24:19 $ + * last change: $Author: jbu $ $Date: 2000-12-08 08:23:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -320,6 +320,9 @@ void ODataStreamTest::testSimple( const Reference < XDataInputStream > &rInput rOutput->writeDouble( (double) 42.42 ); ERROR_ASSERT( rInput->readDouble() == 42.42 , "double read/write mismatch" ); + rOutput->writeHyper( 0x123456789abcdef ); + ERROR_ASSERT( rInput->readHyper() == 0x123456789abcdef , "int64 read/write mismatch" ); + rOutput->writeUTF( L"Live long and prosper !" ); ERROR_ASSERT( rInput->readUTF() == L"Live long and prosper !" , "UTF read/write mismatch" );