summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2009-06-12 19:36:52 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2009-06-12 19:36:52 +0000
commitc09770917fdef1019a8e11615f3e9cb68c23cb69 (patch)
tree230d93d820d12ac35805614843998690020076b5 /comphelper
parent4a3b7bff01e0e97e88f7718314208c4c7d262276 (diff)
CWS-TOOLING: integrate CWS mav54_P1
2009-06-12 16:28:38 +0200 mav r272930 : #i102701# adjust memory stream implementation
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/streaming/memorystream.cxx25
1 files changed, 19 insertions, 6 deletions
diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx
index 3afd9b555a84..9e209a01c581 100644
--- a/comphelper/source/streaming/memorystream.cxx
+++ b/comphelper/source/streaming/memorystream.cxx
@@ -35,15 +35,16 @@
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XSeekableInputStream.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase4.hxx>
#include <string.h>
#include <vector>
using ::rtl::OUString;
using ::cppu::OWeakObject;
-using ::cppu::WeakImplHelper3;
+using ::cppu::WeakImplHelper4;
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -52,7 +53,7 @@ using namespace ::osl;
namespace comphelper
{
-class UNOMemoryStream : public WeakImplHelper3 < XStream, XSeekableInputStream, XOutputStream >
+class UNOMemoryStream : public WeakImplHelper4 < XStream, XSeekableInputStream, XOutputStream, XTruncate >
{
public:
UNOMemoryStream();
@@ -79,6 +80,9 @@ public:
virtual void SAL_CALL flush() throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException);
virtual void SAL_CALL closeOutput() throw (NotConnectedException, BufferSizeExceededException, IOException, RuntimeException);
+ // XTruncate
+ virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
// XServiceInfo - static versions (used for component registration)
static ::rtl::OUString SAL_CALL getImplementationName_static();
static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
@@ -116,8 +120,7 @@ sal_Int32 SAL_CALL UNOMemoryStream::readBytes( Sequence< sal_Int8 >& aData, sal_
throw IOException();
nBytesToRead = std::min( nBytesToRead, available() );
- if( aData.getLength() < nBytesToRead )
- aData.realloc( nBytesToRead );
+ aData.realloc( nBytesToRead );
if( nBytesToRead )
{
@@ -157,9 +160,12 @@ void SAL_CALL UNOMemoryStream::closeInput() throw (NotConnectedException, IOExce
// XSeekable
void SAL_CALL UNOMemoryStream::seek( sal_Int64 location ) throw (IllegalArgumentException, IOException, RuntimeException)
{
- if( (location < 0) || (location > SAL_MAX_INT32) || (location > static_cast< sal_Int64 >( maData.size() )) )
+ if( (location < 0) || (location > SAL_MAX_INT32) )
throw IllegalArgumentException( OUString(RTL_CONSTASCII_USTRINGPARAM("this implementation does not support more than 2GB!")), Reference< XInterface >(static_cast<OWeakObject*>(this)), 0 );
+ if ( location > static_cast< sal_Int64 >( maData.size() ) )
+ maData.resize( static_cast< sal_Int32 >( location ) );
+
mnCursor = static_cast< sal_Int32 >( location );
}
@@ -206,6 +212,13 @@ void SAL_CALL UNOMemoryStream::closeOutput() throw (NotConnectedException, Buffe
mnCursor = 0;
}
+//XTruncate
+void SAL_CALL UNOMemoryStream::truncate() throw (IOException, RuntimeException)
+{
+ maData.resize( 0 );
+ mnCursor = 0;
+}
+
::rtl::OUString SAL_CALL UNOMemoryStream::getImplementationName_static()
{
static const OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.MemoryStream" ) );