replace some SvStream seeking with calls to remainingSize()
Change-Id: I2905e98425b9991d6138ab0adc15083d313ca445
This commit is contained in:
@@ -167,9 +167,7 @@ xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rF
|
|||||||
uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY);
|
uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY);
|
||||||
CPPUNIT_ASSERT(xInputStream.is());
|
CPPUNIT_ASSERT(xInputStream.is());
|
||||||
boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
|
boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
|
||||||
pStream->Seek(STREAM_SEEK_TO_END);
|
sal_uInt64 const nSize = pStream->remainingSize();
|
||||||
sal_Size nSize = pStream->Tell();
|
|
||||||
pStream->Seek(0);
|
|
||||||
OStringBuffer aDocument(nSize);
|
OStringBuffer aDocument(nSize);
|
||||||
char ch;
|
char ch;
|
||||||
for (sal_Size i = 0; i < nSize; ++i)
|
for (sal_Size i = 0; i < nSize; ++i)
|
||||||
|
@@ -455,9 +455,7 @@ void OFlatTable::construct()
|
|||||||
|
|
||||||
if(m_pFileStream)
|
if(m_pFileStream)
|
||||||
{
|
{
|
||||||
m_pFileStream->Seek(STREAM_SEEK_TO_END);
|
sal_uInt64 const nSize = m_pFileStream->remainingSize();
|
||||||
sal_Size nSize = m_pFileStream->Tell();
|
|
||||||
m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
|
|
||||||
|
|
||||||
// Buffersize is dependent on the file-size
|
// Buffersize is dependent on the file-size
|
||||||
m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
|
m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
|
||||||
|
@@ -209,10 +209,8 @@ void XPluginContext_Impl::postURL(const Reference< ::com::sun::star::plugin::XPl
|
|||||||
SvFileStream aStream( aFileName, STREAM_READ );
|
SvFileStream aStream( aFileName, STREAM_READ );
|
||||||
if( aStream.IsOpen() )
|
if( aStream.IsOpen() )
|
||||||
{
|
{
|
||||||
int nBytes = 0;
|
sal_Int64 const nBytes = aStream.remainingSize();
|
||||||
aStream.Seek( STREAM_SEEK_TO_END );
|
aBuf = Sequence<sal_Int8>( nBytes );
|
||||||
aBuf = Sequence<sal_Int8>( nBytes = aStream.Tell() );
|
|
||||||
aStream.Seek( STREAM_SEEK_TO_BEGIN );
|
|
||||||
aStream.Read( aBuf.getArray(), nBytes );
|
aStream.Read( aBuf.getArray(), nBytes );
|
||||||
aStream.Close();
|
aStream.Close();
|
||||||
osl::FileBase::getFileURLFromSystemPath( aFileName, aFileName );
|
osl::FileBase::getFileURLFromSystemPath( aFileName, aFileName );
|
||||||
|
@@ -719,8 +719,7 @@ ImportCGM( OUString& rFileName, uno::Reference< frame::XModel > & rXModel, sal_u
|
|||||||
if ( pIn )
|
if ( pIn )
|
||||||
{
|
{
|
||||||
pIn->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
|
pIn->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
|
||||||
pIn->Seek( STREAM_SEEK_TO_END );
|
sal_uInt64 const nInSize = pIn->remainingSize();
|
||||||
sal_uInt32 nInSize = pIn->Tell();
|
|
||||||
pIn->Seek( 0 );
|
pIn->Seek( 0 );
|
||||||
|
|
||||||
#ifdef CGM_EXPORT_IMPRESS
|
#ifdef CGM_EXPORT_IMPRESS
|
||||||
|
@@ -2521,7 +2521,7 @@ void OS2METReader::ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaF
|
|||||||
{
|
{
|
||||||
sal_uInt16 nFieldSize;
|
sal_uInt16 nFieldSize;
|
||||||
sal_uInt16 nFieldType;
|
sal_uInt16 nFieldType;
|
||||||
sal_uLong nPos, nStartPos, nEndPos, nPercent, nLastPercent;
|
sal_uLong nPercent, nLastPercent;
|
||||||
sal_uInt8 nMagicByte;
|
sal_uInt8 nMagicByte;
|
||||||
|
|
||||||
ErrorCode=0;
|
ErrorCode=0;
|
||||||
@@ -2586,20 +2586,15 @@ void OS2METReader::ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaF
|
|||||||
|
|
||||||
pOS2MET->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
|
pOS2MET->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
|
||||||
|
|
||||||
nStartPos=pOS2MET->Tell();
|
sal_uInt64 const nStartPos = pOS2MET->Tell();
|
||||||
nEndPos=pOS2MET->Seek(STREAM_SEEK_TO_END); pOS2MET->Seek(nStartPos);
|
sal_uInt64 const nRemaining = pOS2MET->remainingSize();
|
||||||
Callback(0); nLastPercent=0;
|
Callback(0); nLastPercent=0;
|
||||||
|
|
||||||
nPos=pOS2MET->Tell();
|
sal_uInt64 nPos = pOS2MET->Tell();
|
||||||
if ( nStartPos == nEndPos )
|
|
||||||
{
|
|
||||||
nEndPos = 100;
|
|
||||||
nStartPos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
nPercent=(nPos-nStartPos)*100/(nEndPos-nStartPos);
|
nPercent = (nPos-nStartPos)*100 / nRemaining;
|
||||||
if (nLastPercent+4<=nPercent) {
|
if (nLastPercent+4<=nPercent) {
|
||||||
if (Callback((sal_uInt16)nPercent)==sal_True) break;
|
if (Callback((sal_uInt16)nPercent)==sal_True) break;
|
||||||
nLastPercent=nPercent;
|
nLastPercent=nPercent;
|
||||||
|
@@ -1780,7 +1780,7 @@ void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile )
|
|||||||
{
|
{
|
||||||
sal_uInt16 nOpcode;
|
sal_uInt16 nOpcode;
|
||||||
sal_uInt8 nOneByteOpcode;
|
sal_uInt8 nOneByteOpcode;
|
||||||
sal_uLong nSize, nPos, nStartPos, nEndPos, nPercent, nLastPercent;
|
sal_uLong nSize, nPercent, nLastPercent;
|
||||||
|
|
||||||
pPict = &rStreamPict;
|
pPict = &rStreamPict;
|
||||||
nOrigPos = pPict->Tell();
|
nOrigPos = pPict->Tell();
|
||||||
@@ -1806,8 +1806,8 @@ void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile )
|
|||||||
|
|
||||||
pPict->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
|
pPict->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
|
||||||
|
|
||||||
nStartPos=pPict->Tell();
|
sal_uInt64 const nStartPos=pPict->Tell();
|
||||||
nEndPos=pPict->Seek(STREAM_SEEK_TO_END); pPict->Seek(nStartPos);
|
sal_uInt64 const nRemaining = pPict->remainingSize();
|
||||||
Callback(0); nLastPercent=0;
|
Callback(0); nLastPercent=0;
|
||||||
|
|
||||||
ReadHeader();
|
ReadHeader();
|
||||||
@@ -1815,11 +1815,11 @@ void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile )
|
|||||||
aPenPosition=Point(-aBoundingRect.Left(),-aBoundingRect.Top());
|
aPenPosition=Point(-aBoundingRect.Left(),-aBoundingRect.Top());
|
||||||
aTextPosition=aPenPosition;
|
aTextPosition=aPenPosition;
|
||||||
|
|
||||||
nPos=pPict->Tell();
|
sal_uInt64 nPos=pPict->Tell();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
nPercent=(nPos-nStartPos)*100/(nEndPos-nStartPos);
|
nPercent = (nPos-nStartPos) * 100 / nRemaining;
|
||||||
if (nLastPercent+4<=nPercent) {
|
if (nLastPercent+4<=nPercent) {
|
||||||
if (Callback((sal_uInt16)nPercent)==sal_True) break;
|
if (Callback((sal_uInt16)nPercent)==sal_True) break;
|
||||||
nLastPercent=nPercent;
|
nLastPercent=nPercent;
|
||||||
|
@@ -426,8 +426,7 @@ sal_Bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL,
|
|||||||
if ( !bSetNull )
|
if ( !bSetNull )
|
||||||
{
|
{
|
||||||
// get the size of the stream
|
// get the size of the stream
|
||||||
pImageStream->Seek(STREAM_SEEK_TO_END);
|
sal_uInt64 const nSize = pImageStream->remainingSize();
|
||||||
sal_Int32 nSize = (sal_Int32)pImageStream->Tell();
|
|
||||||
if (pImageStream->GetBufferSize() < 8192)
|
if (pImageStream->GetBufferSize() < 8192)
|
||||||
pImageStream->SetBufferSize(8192);
|
pImageStream->SetBufferSize(8192);
|
||||||
pImageStream->Seek(STREAM_SEEK_TO_BEGIN);
|
pImageStream->Seek(STREAM_SEEK_TO_BEGIN);
|
||||||
|
@@ -1267,11 +1267,10 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
|
|||||||
if (!pExtOptions)
|
if (!pExtOptions)
|
||||||
return Text2Doc( rStrm );
|
return Text2Doc( rStrm );
|
||||||
|
|
||||||
sal_uLong nOldPos = rStrm.Tell();
|
sal_uInt64 const nOldPos = rStrm.Tell();
|
||||||
rStrm.Seek( STREAM_SEEK_TO_END );
|
sal_uInt64 const nRemaining = rStrm.remainingSize();
|
||||||
boost::scoped_ptr<ScProgress> xProgress( new ScProgress( pDocSh,
|
boost::scoped_ptr<ScProgress> xProgress( new ScProgress( pDocSh,
|
||||||
ScGlobal::GetRscString( STR_LOAD_DOC ), rStrm.Tell() - nOldPos ));
|
ScGlobal::GetRscString( STR_LOAD_DOC ), nRemaining ));
|
||||||
rStrm.Seek( nOldPos );
|
|
||||||
rStrm.StartReadingUnicodeText( rStrm.GetStreamCharSet() );
|
rStrm.StartReadingUnicodeText( rStrm.GetStreamCharSet() );
|
||||||
|
|
||||||
SCCOL nStartCol = aRange.aStart.Col();
|
SCCOL nStartCol = aRange.aStart.Col();
|
||||||
|
@@ -2506,9 +2506,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
|
|||||||
SvStorageStreamRef xCompObj = xTemp->OpenSotStream(
|
SvStorageStreamRef xCompObj = xTemp->OpenSotStream(
|
||||||
OUString( "\1CompObj" ),
|
OUString( "\1CompObj" ),
|
||||||
STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYALL );
|
STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYALL );
|
||||||
xCompObj->Seek( STREAM_SEEK_TO_END );
|
sal_uInt32 const nStreamLen = xCompObj->remainingSize();
|
||||||
sal_uInt32 nStreamLen = xCompObj->Tell();
|
|
||||||
xCompObj->Seek( 0 );
|
|
||||||
sal_Int16 nVersion, nByteOrder;
|
sal_Int16 nVersion, nByteOrder;
|
||||||
sal_Int32 nWinVersion, nVal, nStringLen;
|
sal_Int32 nWinVersion, nVal, nStringLen;
|
||||||
xCompObj->ReadInt16( nVersion )
|
xCompObj->ReadInt16( nVersion )
|
||||||
|
@@ -273,12 +273,7 @@ void SwBasicEscherEx::WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFm
|
|||||||
rStrm .WriteUInt32( sal_uInt32( 2 ) )
|
rStrm .WriteUInt32( sal_uInt32( 2 ) )
|
||||||
.WriteUInt32( mnFlags );
|
.WriteUInt32( mnFlags );
|
||||||
tmpStrm.Seek( STREAM_SEEK_TO_BEGIN );
|
tmpStrm.Seek( STREAM_SEEK_TO_BEGIN );
|
||||||
sal_uInt32 nStrmPos = tmpStrm.Tell();
|
sal_uInt32 const nLen = tmpStrm.remainingSize();
|
||||||
tmpStrm.Seek( STREAM_SEEK_TO_END );
|
|
||||||
sal_uInt32 nStrmSize = tmpStrm.Tell();
|
|
||||||
tmpStrm.Seek( nStrmPos );
|
|
||||||
sal_uInt32 nLen;
|
|
||||||
nLen = nStrmSize - nStrmPos;
|
|
||||||
if(nLen >0)
|
if(nLen >0)
|
||||||
{
|
{
|
||||||
sal_uInt8* pBuffer = new sal_uInt8[ nLen ];
|
sal_uInt8* pBuffer = new sal_uInt8[ nLen ];
|
||||||
|
@@ -284,11 +284,8 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize
|
|||||||
{
|
{
|
||||||
nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize;
|
nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize;
|
||||||
|
|
||||||
sal_uIntPtr nStreamPos = rIStm.Tell();
|
sal_uInt64 const nRemaining = rIStm.remainingSize();
|
||||||
rIStm.Seek( STREAM_SEEK_TO_END );
|
if (nRemaining < nInToRead)
|
||||||
sal_uIntPtr nMaxPos = rIStm.Tell();
|
|
||||||
rIStm.Seek( nStreamPos );
|
|
||||||
if ( ( nMaxPos - nStreamPos ) < nInToRead )
|
|
||||||
{
|
{
|
||||||
rIStm.SetError( ERRCODE_IO_PENDING );
|
rIStm.SetError( ERRCODE_IO_PENDING );
|
||||||
err= int(!Z_STREAM_END); // TODO What is appropriate code for this?
|
err= int(!Z_STREAM_END); // TODO What is appropriate code for this?
|
||||||
|
@@ -227,14 +227,8 @@ throw ( css::io::NotConnectedException, css::io::IOException, css::uno::RuntimeE
|
|||||||
|
|
||||||
checkConnected();
|
checkConnected();
|
||||||
|
|
||||||
sal_uInt32 nPos = mpStream->Tell();
|
sal_uInt32 const nAvailable =
|
||||||
checkError();
|
static_cast<sal_uInt32>(mpStream->remainingSize());
|
||||||
|
|
||||||
mpStream->Seek(STREAM_SEEK_TO_END);
|
|
||||||
checkError();
|
|
||||||
|
|
||||||
sal_Int32 nAvailable = (sal_Int32)mpStream->Tell() - nPos;
|
|
||||||
mpStream->Seek(nPos);
|
|
||||||
checkError();
|
checkError();
|
||||||
|
|
||||||
return nAvailable;
|
return nAvailable;
|
||||||
|
@@ -427,11 +427,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r
|
|||||||
{
|
{
|
||||||
if(!rHeader.nSizeImage)
|
if(!rHeader.nSizeImage)
|
||||||
{
|
{
|
||||||
const sal_uLong nOldPos(rIStm.Tell());
|
rHeader.nSizeImage = rIStm.remainingSize();
|
||||||
|
|
||||||
rIStm.Seek(STREAM_SEEK_TO_END);
|
|
||||||
rHeader.nSizeImage = rIStm.Tell() - nOldPos;
|
|
||||||
rIStm.Seek(nOldPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(rHeader.nSizeImage);
|
sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(rHeader.nSizeImage);
|
||||||
|
@@ -173,12 +173,10 @@ SvgData::SvgData(const OUString& rPath):
|
|||||||
SvFileStream rIStm(rPath, STREAM_STD_READ);
|
SvFileStream rIStm(rPath, STREAM_STD_READ);
|
||||||
if(rIStm.GetError())
|
if(rIStm.GetError())
|
||||||
return;
|
return;
|
||||||
const sal_uInt32 nStmPos(rIStm.Tell());
|
const sal_uInt32 nStmLen(rIStm.remainingSize());
|
||||||
const sal_uInt32 nStmLen(rIStm.Seek(STREAM_SEEK_TO_END) - nStmPos);
|
|
||||||
if(nStmLen)
|
if(nStmLen)
|
||||||
{
|
{
|
||||||
SvgDataArray aNewData(new sal_uInt8[nStmLen]);
|
SvgDataArray aNewData(new sal_uInt8[nStmLen]);
|
||||||
rIStm.Seek(nStmPos);
|
|
||||||
rIStm.Read(aNewData.get(), nStmLen);
|
rIStm.Read(aNewData.get(), nStmLen);
|
||||||
|
|
||||||
if(!rIStm.GetError())
|
if(!rIStm.GetError())
|
||||||
|
Reference in New Issue
Block a user