summaryrefslogtreecommitdiff
path: root/oox/source/helper
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2008-09-30 13:51:36 +0000
committerVladimir Glazounov <vg@openoffice.org>2008-09-30 13:51:36 +0000
commit07cabd8e634679ff59db4d72eacdfb514feb3cd1 (patch)
tree41b064504b537ff35a017aad8373870ae2cc1738 /oox/source/helper
parenta53f44d8fba07d9f7a79ac594a85b1059f1ae4a6 (diff)
CWS-TOOLING: integrate CWS dr63
Diffstat (limited to 'oox/source/helper')
-rw-r--r--oox/source/helper/binaryinputstream.cxx124
-rw-r--r--oox/source/helper/binaryoutputstream.cxx107
-rw-r--r--oox/source/helper/binarystreambase.cxx87
-rw-r--r--oox/source/helper/containerhelper.cxx17
-rw-r--r--oox/source/helper/makefile.mk4
-rw-r--r--oox/source/helper/recordinputstream.cxx62
6 files changed, 274 insertions, 127 deletions
diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx
index 72485b117009..4675372b497b 100644
--- a/oox/source/helper/binaryinputstream.cxx
+++ b/oox/source/helper/binaryinputstream.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: binaryinputstream.cxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.22.2 $
*
* This file is part of OpenOffice.org.
*
@@ -29,77 +29,149 @@
************************************************************************/
#include "oox/helper/binaryinputstream.hxx"
-#include <com/sun/star/io/XInputStream.hpp>
#include <osl/diagnose.h>
#include <string.h>
+using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::io::XInputStream;
+using ::com::sun::star::io::XSeekable;
namespace oox {
+const sal_Int32 INPUTSTREAM_BUFFERSIZE = 0x8000;
+
+// ============================================================================
+
+void BinaryInputStream::readAtom( void* opMem, sal_uInt8 nSize )
+{
+ readMemory( opMem, nSize );
+}
+
// ============================================================================
-BinaryInputStream::BinaryInputStream( const Reference< XInputStream >& rxInStrm, bool bAutoClose ) :
- BinaryStreamBase( rxInStrm ),
+BinaryXInputStream::BinaryXInputStream( const Reference< XInputStream >& rxInStrm, bool bAutoClose ) :
+ BinaryXSeekableStream( Reference< XSeekable >( rxInStrm, UNO_QUERY ) ),
+ maBuffer( INPUTSTREAM_BUFFERSIZE ),
mxInStrm( rxInStrm ),
mbAutoClose( bAutoClose )
{
+ mbEof = !mxInStrm.is();
}
-BinaryInputStream::~BinaryInputStream()
+BinaryXInputStream::~BinaryXInputStream()
{
if( mbAutoClose )
close();
}
-void BinaryInputStream::skip( sal_Int32 nBytes )
+sal_Int32 BinaryXInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes )
{
- try
+ sal_Int32 nRet = 0;
+ if( !mbEof && (nBytes > 0) ) try
{
- OSL_ENSURE( mxInStrm.is(), "BinaryInputStream::skip - invalid call" );
- mxInStrm->skipBytes( nBytes );
+ OSL_ENSURE( mxInStrm.is(), "BinaryXInputStream::readData - invalid call" );
+ nRet = mxInStrm->readBytes( orData, nBytes );
+ mbEof = nRet != nBytes;
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryInputStream::skip - exception caught" );
+ mbEof = true;
}
+ return nRet;
}
-sal_Int32 BinaryInputStream::read( Sequence< sal_Int8 >& orBuffer, sal_Int32 nBytes )
+sal_Int32 BinaryXInputStream::readMemory( void* opMem, sal_Int32 nBytes )
{
sal_Int32 nRet = 0;
- try
- {
- OSL_ENSURE( mxInStrm.is(), "BinaryInputStream::read - invalid call" );
- nRet = mxInStrm->readBytes( orBuffer, nBytes );
- }
- catch( Exception& )
+ if( !mbEof && (nBytes > 0) )
{
- OSL_ENSURE( false, "BinaryInputStream::read - stream read error" );
+ sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, INPUTSTREAM_BUFFERSIZE );
+ sal_uInt8* opnMem = reinterpret_cast< sal_uInt8* >( opMem );
+ while( !mbEof && (nBytes > 0) )
+ {
+ sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize );
+ sal_Int32 nBytesRead = readData( maBuffer, nReadSize );
+ if( nBytesRead > 0 )
+ memcpy( opnMem, maBuffer.getConstArray(), static_cast< size_t >( nBytesRead ) );
+ opnMem += nBytesRead;
+ nBytes -= nBytesRead;
+ nRet += nBytesRead;
+ }
}
return nRet;
}
-sal_Int32 BinaryInputStream::read( void* opBuffer, sal_Int32 nBytes )
+void BinaryXInputStream::skip( sal_Int32 nBytes )
{
- sal_Int32 nRet = read( maBuffer, nBytes );
- if( nRet > 0 )
- memcpy( opBuffer, maBuffer.getConstArray(), static_cast< size_t >( nRet ) );
- return nRet;
+ if( !mbEof ) try
+ {
+ OSL_ENSURE( mxInStrm.is(), "BinaryXInputStream::skip - invalid call" );
+ mxInStrm->skipBytes( nBytes );
+ }
+ catch( Exception& )
+ {
+ mbEof = true;
+ }
}
-void BinaryInputStream::close()
+void BinaryXInputStream::close()
{
if( mxInStrm.is() ) try
{
mxInStrm->closeInput();
+ mxInStrm.clear();
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryInputStream::close - closing input stream failed" );
+ OSL_ENSURE( false, "BinaryXInputStream::close - closing input stream failed" );
+ }
+}
+
+// ============================================================================
+
+SequenceInputStream::SequenceInputStream( StreamDataSequence& rData ) :
+ SequenceSeekableStream( rData )
+{
+}
+
+sal_Int32 SequenceInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes )
+{
+ sal_Int32 nReadBytes = 0;
+ if( !mbEof )
+ {
+ nReadBytes = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mrData.getLength() - mnPos );
+ orData.realloc( nReadBytes );
+ if( nReadBytes > 0 )
+ memcpy( orData.getArray(), mrData.getConstArray() + mnPos, static_cast< size_t >( nReadBytes ) );
+ mnPos += nReadBytes;
+ mbEof = nReadBytes < nBytes;
+ }
+ return nReadBytes;
+}
+
+sal_Int32 SequenceInputStream::readMemory( void* opMem, sal_Int32 nBytes )
+{
+ sal_Int32 nReadBytes = 0;
+ if( !mbEof )
+ {
+ nReadBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos );
+ if( nReadBytes > 0 )
+ memcpy( opMem, mrData.getConstArray() + mnPos, static_cast< size_t >( nReadBytes ) );
+ mnPos += nReadBytes;
+ mbEof = nReadBytes < nBytes;
+ }
+ return nReadBytes;
+}
+
+void SequenceInputStream::skip( sal_Int32 nBytes )
+{
+ if( !mbEof )
+ {
+ sal_Int32 nSkipBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos );
+ mnPos += nSkipBytes;
+ mbEof = nSkipBytes < nBytes;
}
}
diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx
index 946f50d97d48..c61b005029ba 100644
--- a/oox/source/helper/binaryoutputstream.cxx
+++ b/oox/source/helper/binaryoutputstream.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: binaryoutputstream.cxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.22.2 $
*
* This file is part of OpenOffice.org.
*
@@ -30,75 +30,94 @@
#include "oox/helper/binaryoutputstream.hxx"
#include <osl/diagnose.h>
-#include <com/sun/star/io/XOutputStream.hpp>
#include "oox/helper/binaryinputstream.hxx"
#include <string.h>
+using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::io::XOutputStream;
+using ::com::sun::star::io::XSeekable;
namespace oox {
+const sal_Int32 OUTPUTSTREAM_BUFFERSIZE = 0x8000;
+
+// ============================================================================
+
+void BinaryOutputStream::copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes )
+{
+ if( nBytes > 0 )
+ {
+ sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, OUTPUTSTREAM_BUFFERSIZE );
+ StreamDataSequence aBuffer( nBufferSize );
+ while( nBytes > 0 )
+ {
+ sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize );
+ sal_Int32 nBytesRead = rInStrm.readData( aBuffer, nReadSize );
+ writeData( aBuffer );
+ if( nReadSize == nBytesRead )
+ nBytes -= nReadSize;
+ else
+ nBytes = 0;
+ }
+ }
+}
+
+void BinaryOutputStream::writeAtom( const void* pMem, sal_uInt8 nSize )
+{
+ writeMemory( pMem, nSize );
+}
+
// ============================================================================
-BinaryOutputStream::BinaryOutputStream( const Reference< XOutputStream >& rxOutStrm, bool bAutoClose ) :
- BinaryStreamBase( rxOutStrm ),
+BinaryXOutputStream::BinaryXOutputStream( const Reference< XOutputStream >& rxOutStrm, bool bAutoClose ) :
+ BinaryXSeekableStream( Reference< XSeekable >( rxOutStrm, UNO_QUERY ) ),
+ maBuffer( OUTPUTSTREAM_BUFFERSIZE ),
mxOutStrm( rxOutStrm ),
mbAutoClose( bAutoClose )
{
+ mbEof = !mxOutStrm.is();
}
-BinaryOutputStream::~BinaryOutputStream()
+BinaryXOutputStream::~BinaryXOutputStream()
{
if( mbAutoClose )
close();
}
-void BinaryOutputStream::write( const Sequence< sal_Int8 >& rBuffer )
+void BinaryXOutputStream::writeData( const StreamDataSequence& rData )
{
try
{
- OSL_ENSURE( mxOutStrm.is(), "BinaryOutputStream::write - invalid call" );
- mxOutStrm->writeBytes( rBuffer );
+ OSL_ENSURE( mxOutStrm.is(), "BinaryXOutputStream::writeData - invalid call" );
+ mxOutStrm->writeBytes( rData );
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryOutputStream::write - stream read error" );
+ OSL_ENSURE( false, "BinaryXOutputStream::writeData - stream read error" );
}
}
-void BinaryOutputStream::write( const void* pBuffer, sal_Int32 nBytes )
+void BinaryXOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes )
{
if( nBytes > 0 )
{
- maBuffer.realloc( nBytes );
- memcpy( maBuffer.getArray(), pBuffer, static_cast< size_t >( nBytes ) );
- write( maBuffer );
- }
-}
-
-void BinaryOutputStream::copy( BinaryInputStream& rInStrm, sal_Int64 nBytes )
-{
- if( rInStrm.is() && (nBytes > 0) )
- {
- sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, 0x8000 );
- Sequence< sal_Int8 > aBuffer( nBufferSize );
+ sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, OUTPUTSTREAM_BUFFERSIZE );
+ const sal_uInt8* pnMem = reinterpret_cast< const sal_uInt8* >( pMem );
while( nBytes > 0 )
{
- sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize );
- sal_Int32 nBytesRead = rInStrm.read( aBuffer, nReadSize );
- write( aBuffer );
- if( nReadSize == nBytesRead )
- nBytes -= nReadSize;
- else
- nBytes = 0;
+ sal_Int32 nWriteSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize );
+ maBuffer.realloc( nWriteSize );
+ memcpy( maBuffer.getArray(), pnMem, static_cast< size_t >( nWriteSize ) );
+ writeData( maBuffer );
+ pnMem += nWriteSize;
+ nBytes -= nWriteSize;
}
}
}
-void BinaryOutputStream::close()
+void BinaryXOutputStream::close()
{
if( mxOutStrm.is() ) try
{
@@ -107,7 +126,31 @@ void BinaryOutputStream::close()
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryOutputStream::close - closing output stream failed" );
+ OSL_ENSURE( false, "BinaryXOutputStream::close - closing output stream failed" );
+ }
+}
+
+// ============================================================================
+
+SequenceOutputStream::SequenceOutputStream( StreamDataSequence& rData ) :
+ SequenceSeekableStream( rData )
+{
+}
+
+void SequenceOutputStream::writeData( const StreamDataSequence& rData )
+{
+ if( rData.hasElements() )
+ writeMemory( rData.getConstArray(), rData.getLength() );
+}
+
+void SequenceOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes )
+{
+ if( nBytes > 0 )
+ {
+ if( mrData.getLength() - mnPos < nBytes )
+ mrData.realloc( mnPos + nBytes );
+ memcpy( mrData.getArray() + mnPos, pMem, static_cast< size_t >( nBytes ) );
+ mnPos += nBytes;
}
}
diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx
index 0497e8274591..238baded3434 100644
--- a/oox/source/helper/binarystreambase.cxx
+++ b/oox/source/helper/binarystreambase.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: binarystreambase.cxx,v $
- * $Revision: 1.3 $
+ * $Revision: 1.3.22.2 $
*
* This file is part of OpenOffice.org.
*
@@ -31,7 +31,9 @@
#include "oox/helper/binarystreambase.hxx"
#include <osl/diagnose.h>
+using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Exception;
+using ::com::sun::star::io::XSeekable;
namespace oox {
@@ -41,46 +43,105 @@ BinaryStreamBase::~BinaryStreamBase()
{
}
+bool BinaryStreamBase::isSeekable() const
+{
+ return false;
+}
+
sal_Int64 BinaryStreamBase::getLength() const
{
- try
+ return -1;
+}
+
+sal_Int64 BinaryStreamBase::tell() const
+{
+ return -1;
+}
+
+void BinaryStreamBase::seek( sal_Int64 )
+{
+}
+
+sal_Int64 BinaryStreamBase::getRemaining() const
+{
+ return isSeekable() ? ::std::max< sal_Int64 >( getLength() - tell(), 0 ) : -1;
+}
+
+// ============================================================================
+
+BinaryXSeekableStream::BinaryXSeekableStream( const Reference< XSeekable >& rxSeekable ) :
+ mxSeekable( rxSeekable )
+{
+}
+
+bool BinaryXSeekableStream::isSeekable() const
+{
+ return mxSeekable.is();
+}
+
+sal_Int64 BinaryXSeekableStream::getLength() const
+{
+ if( mxSeekable.is() ) try
{
- return mxSeekable.is() ? mxSeekable->getLength() : -1;
+ return mxSeekable->getLength();
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryStreamBase::getLength - exception caught" );
+ OSL_ENSURE( false, "BinaryXSeekableStream::getLength - exception caught" );
}
return -1;
}
-sal_Int64 BinaryStreamBase::tell() const
+sal_Int64 BinaryXSeekableStream::tell() const
{
- try
+ if( mxSeekable.is() ) try
{
- return mxSeekable.is() ? mxSeekable->getPosition() : -1;
+ return mxSeekable->getPosition();
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryStreamBase::tell - exception caught" );
+ OSL_ENSURE( false, "BinaryXSeekableStream::tell - exception caught" );
}
return -1;
}
-void BinaryStreamBase::seek( sal_Int64 nPos )
+void BinaryXSeekableStream::seek( sal_Int64 nPos )
{
- try
+ if( mxSeekable.is() ) try
{
- if( mxSeekable.is() )
- mxSeekable->seek( nPos );
+ mbEof = false;
+ mxSeekable->seek( nPos );
}
catch( Exception& )
{
- OSL_ENSURE( false, "BinaryStreamBase::seek - exception caught" );
+ mbEof = true;
}
}
// ============================================================================
+bool SequenceSeekableStream::isSeekable() const
+{
+ return true;
+}
+
+sal_Int64 SequenceSeekableStream::getLength() const
+{
+ return mrData.getLength();
+}
+
+sal_Int64 SequenceSeekableStream::tell() const
+{
+ return mnPos;
+}
+
+void SequenceSeekableStream::seek( sal_Int64 nPos )
+{
+ mnPos = getLimitedValue< sal_Int32, sal_Int64 >( nPos, 0, mrData.getLength() );
+ mbEof = mnPos < nPos;
+}
+
+// ============================================================================
+
} // namespace oox
diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx
index 9d4327e12d31..e09fe77bcc2f 100644
--- a/oox/source/helper/containerhelper.cxx
+++ b/oox/source/helper/containerhelper.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: containerhelper.cxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.6.1 $
*
* This file is part of OpenOffice.org.
*
@@ -33,7 +33,6 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
-#include <comphelper/processfactory.hxx>
#include "oox/helper/helper.hxx"
using ::rtl::OUString;
@@ -52,13 +51,12 @@ namespace oox {
// ============================================================================
-Reference< XIndexContainer > ContainerHelper::createIndexContainer()
+Reference< XIndexContainer > ContainerHelper::createIndexContainer( const Reference< XMultiServiceFactory >& rxFactory )
{
Reference< XIndexContainer > xContainer;
- try
+ if( rxFactory.is() ) try
{
- Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
- xContainer.set( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.IndexedPropertyValues" ) ), UNO_QUERY_THROW );
+ xContainer.set( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.IndexedPropertyValues" ) ), UNO_QUERY_THROW );
}
catch( Exception& )
{
@@ -85,13 +83,12 @@ bool ContainerHelper::insertByIndex(
return bRet;
}
-Reference< XNameContainer > ContainerHelper::createNameContainer()
+Reference< XNameContainer > ContainerHelper::createNameContainer( const Reference< XMultiServiceFactory >& rxFactory )
{
Reference< XNameContainer > xContainer;
- try
+ if( rxFactory.is() ) try
{
- Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
- xContainer.set( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.NamedPropertyValues" ) ), UNO_QUERY_THROW );
+ xContainer.set( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.NamedPropertyValues" ) ), UNO_QUERY_THROW );
}
catch( Exception& )
{
diff --git a/oox/source/helper/makefile.mk b/oox/source/helper/makefile.mk
index 900c3c8d4605..d584c14d2c07 100644
--- a/oox/source/helper/makefile.mk
+++ b/oox/source/helper/makefile.mk
@@ -1,14 +1,14 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
+#
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.3 $
+# $Revision: 1.3.22.1 $
#
# This file is part of OpenOffice.org.
#
diff --git a/oox/source/helper/recordinputstream.cxx b/oox/source/helper/recordinputstream.cxx
index 8ab942e4898d..4b2ad21fc5c2 100644
--- a/oox/source/helper/recordinputstream.cxx
+++ b/oox/source/helper/recordinputstream.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: recordinputstream.cxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.22.1 $
*
* This file is part of OpenOffice.org.
*
@@ -38,62 +38,36 @@ namespace oox {
// ============================================================================
-RecordInputStream::RecordInputStream( const RecordDataSequence& rData ) :
- maData( rData ),
- mnRecSize( rData.getLength() ),
- mnRecPos( 0 ),
- mbValid( true )
+RecordInputStream::RecordInputStream( StreamDataSequence& rData ) :
+ SequenceInputStream( rData )
{
}
-sal_Int32 RecordInputStream::read( void* opData, sal_Int32 nBytes )
-{
- sal_Int32 nReadSize = ::std::min( nBytes, getRecLeft() );
- OSL_ENSURE( !mbValid || (nReadSize == nBytes), "RecordInputStream::read - buffer overflow" );
- mbValid = nReadSize == nBytes;
- if( mbValid && opData && (nReadSize > 0) )
- memcpy( opData, maData.getConstArray() + mnRecPos, nReadSize );
- mnRecPos += nReadSize;
- return nReadSize;
-}
-
OUString RecordInputStream::readString( bool b32BitLen )
{
OUString aString;
- sal_Int32 nCharCount = b32BitLen ? readValue< sal_Int32 >() : readValue< sal_Int16 >();
- // string length -1 is often used to indicate a missing string
- OSL_ENSURE( !mbValid || (nCharCount >= -1), "RecordInputStream::readString - invalid string length" );
- if( mbValid && (nCharCount >= 0) )
+ if( !isEof() )
{
- ::std::vector< sal_Unicode > aBuffer;
- aBuffer.reserve( getLimitedValue< size_t, sal_Int32 >( nCharCount + 1, 0, 0xFFFF ) );
- for( sal_Int32 nCharIdx = 0; mbValid && (nCharIdx < nCharCount); ++nCharIdx )
+ sal_Int32 nCharCount = b32BitLen ? readValue< sal_Int32 >() : readValue< sal_Int16 >();
+ // string length -1 is often used to indicate a missing string
+ OSL_ENSURE( !isEof() && (nCharCount >= -1), "RecordInputStream::readString - invalid string length" );
+ if( !isEof() && (nCharCount > 0) )
{
- sal_uInt16 nChar;
- readValue( nChar );
- aBuffer.push_back( static_cast< sal_Unicode >( nChar ) );
+ ::std::vector< sal_Unicode > aBuffer;
+ aBuffer.reserve( getLimitedValue< size_t, sal_Int32 >( nCharCount + 1, 0, 0xFFFF ) );
+ for( sal_Int32 nCharIdx = 0; !isEof() && (nCharIdx < nCharCount); ++nCharIdx )
+ {
+ sal_uInt16 nChar;
+ readValue( nChar );
+ aBuffer.push_back( static_cast< sal_Unicode >( nChar ) );
+ }
+ aBuffer.push_back( 0 );
+ aString = OUString( &aBuffer.front() );
}
- aBuffer.push_back( 0 );
- aString = OUString( &aBuffer.front() );
}
return aString;
}
-void RecordInputStream::seek( sal_Int32 nRecPos )
-{
- mnRecPos = getLimitedValue< sal_Int32, sal_Int32 >( nRecPos, 0, mnRecSize );
- OSL_ENSURE( !mbValid || (nRecPos == mnRecPos), "RecordInputStream::seek - invalid position" );
- mbValid = nRecPos == mnRecPos;
-}
-
-void RecordInputStream::skip( sal_Int32 nBytes )
-{
- sal_Int32 nSkipSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, getRecLeft() );
- OSL_ENSURE( !mbValid || (nSkipSize == nBytes), "RecordInputStream::skip - buffer overflow" );
- mbValid = nSkipSize == nBytes;
- mnRecPos += nSkipSize;
-}
-
// ============================================================================
} // namespace oox