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