[Libreoffice-commits] core.git: chart2/qa connectivity/source extensions/source filter/source forms/source sc/source sd/source sw/source tools/source unotools/source vcl/source
Michael Stahl
mstahl at redhat.com
Fri Apr 11 14:15:32 PDT 2014
chart2/qa/extras/chart2export.cxx | 4 +---
connectivity/source/drivers/flat/ETable.cxx | 4 +---
extensions/source/plugin/base/context.cxx | 6 ++----
filter/source/graphicfilter/icgm/cgm.cxx | 3 +--
filter/source/graphicfilter/ios2met/ios2met.cxx | 15 +++++----------
filter/source/graphicfilter/ipict/ipict.cxx | 10 +++++-----
forms/source/component/ImageControl.cxx | 3 +--
sc/source/ui/docshell/impex.cxx | 7 +++----
sd/source/filter/eppt/epptso.cxx | 4 +---
sw/source/filter/ww8/wrtw8esh.cxx | 7 +------
tools/source/zcodec/zcodec.cxx | 7 ++-----
unotools/source/ucbhelper/xtempfile.cxx | 10 ++--------
vcl/source/gdi/dibtools.cxx | 6 +-----
vcl/source/gdi/svgdata.cxx | 4 +---
14 files changed, 27 insertions(+), 63 deletions(-)
New commits:
commit e98e738a82885b6e7fb643bf407e504fe095803e
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Apr 11 20:00:14 2014 +0200
replace some SvStream seeking with calls to remainingSize()
Change-Id: I2905e98425b9991d6138ab0adc15083d313ca445
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index fa1c90c..b0cda22 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -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)
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
index e156b1d..c58376a 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -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 :
diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx
index f795dc2..91214b7 100644
--- a/extensions/source/plugin/base/context.cxx
+++ b/extensions/source/plugin/base/context.cxx
@@ -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 );
diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx
index cc3205c..0b1882f 100644
--- a/filter/source/graphicfilter/icgm/cgm.cxx
+++ b/filter/source/graphicfilter/icgm/cgm.cxx
@@ -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
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index e0acde9..2fcfdea 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -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;
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index 0292f0a..4338672 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -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;
diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx
index 26979a5..cfafdbb 100644
--- a/forms/source/component/ImageControl.cxx
+++ b/forms/source/component/ImageControl.cxx
@@ -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);
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index e048ffe..773bec5 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -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();
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 05267f5..52524e1 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -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 )
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 9fd00e4..dfac4b3 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -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 ];
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index ab50640..ed6d8e4 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -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?
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 4d4f4fa..f09b94e 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -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;
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index e46b7d3..e67a7cb 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -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);
diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/svgdata.cxx
index 4080f5d..b844c50 100644
--- a/vcl/source/gdi/svgdata.cxx
+++ b/vcl/source/gdi/svgdata.cxx
@@ -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())
More information about the Libreoffice-commits
mailing list