summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2018-10-11 18:49:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-15 07:56:42 +0200
commit9ec8bf8f22fe74884185492ef2576ce79b41e4f1 (patch)
tree0b162c71c51a55125a2ce6055632d4f96180f431 /filter
parenta84e3df74eecc8778e3d5be5dd80ad4ddb511edf (diff)
add SvStream::TellEnd
and simplify callsites to use it instead of the current "seek to end, find pos, seek back to original pos" pattern Change-Id: Ib5828868f73c341891efc759af8bd4695ae2f33c Reviewed-on: https://gerrit.libreoffice.org/61738 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/flash/swfwriter.cxx3
-rw-r--r--filter/source/flash/swfwriter1.cxx8
-rw-r--r--filter/source/flash/swfwriter2.cxx3
-rw-r--r--filter/source/graphicfilter/eps/eps.cxx3
-rw-r--r--filter/source/msfilter/escherex.cxx9
-rw-r--r--filter/source/msfilter/msdffimp.cxx6
-rw-r--r--filter/source/svg/svgfilter.cxx5
7 files changed, 12 insertions, 25 deletions
diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx
index 6e6ea996b82f..fc751f772728 100644
--- a/filter/source/flash/swfwriter.cxx
+++ b/filter/source/flash/swfwriter.cxx
@@ -98,8 +98,7 @@ static void ImplCopySvStreamToXOutputStream( SvStream& rIn, Reference< XOutputSt
{
sal_uInt32 nBufferSize = 64*1024;
- rIn.Seek( STREAM_SEEK_TO_END );
- sal_uInt32 nSize = rIn.Tell();
+ sal_uInt32 nSize = rIn.TellEnd();
rIn.Seek( STREAM_SEEK_TO_BEGIN );
Sequence< sal_Int8 > aBuffer( std::min( nBufferSize, nSize ) );
diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx
index 77af4c859fa6..03042a9c86a2 100644
--- a/filter/source/flash/swfwriter1.cxx
+++ b/filter/source/flash/swfwriter1.cxx
@@ -773,7 +773,7 @@ sal_uInt16 Writer::defineBitmap( const BitmapEx &bmpSource, sal_Int32 nJPEGQuali
aFilter.GetExportFormatNumberForShortName( JPG_SHORTNAME ), &aFilterData ) == ERRCODE_NONE )
{
pJpgData = static_cast<const sal_uInt8*>(aDstStm.GetData());
- nJpgDataLength = aDstStm.Seek( STREAM_SEEK_TO_END );
+ nJpgDataLength = aDstStm.TellEnd();
}
// AS: Ok, now go ahead and use whichever is smaller. If JPEG is smaller, then
@@ -998,12 +998,10 @@ void Writer::Impl_writeJPEG(sal_uInt16 nBitmapId, const sal_uInt8* pJpgData, sal
}
}
- EncodingTableStream.Seek( STREAM_SEEK_TO_END );
- sal_uInt32 nEncodingTableSize = EncodingTableStream.Tell();
+ sal_uInt32 nEncodingTableSize = EncodingTableStream.TellEnd();
EncodingTableStream.Seek( STREAM_SEEK_TO_BEGIN );
- ImageBitsStream.Seek( STREAM_SEEK_TO_END );
- sal_uInt32 nImageBitsSize = ImageBitsStream.Tell();
+ sal_uInt32 nImageBitsSize = ImageBitsStream.TellEnd();
ImageBitsStream.Seek( STREAM_SEEK_TO_BEGIN );
// AS: If we need alpha support, use TAG_DEFINEBITSJPEG3.
diff --git a/filter/source/flash/swfwriter2.cxx b/filter/source/flash/swfwriter2.cxx
index 2b7a4bbee717..325cddde4c99 100644
--- a/filter/source/flash/swfwriter2.cxx
+++ b/filter/source/flash/swfwriter2.cxx
@@ -129,8 +129,7 @@ Tag::Tag( sal_uInt8 nTagId )
void Tag::write( SvStream &out )
{
- Seek( STREAM_SEEK_TO_END );
- sal_uInt32 nSz = Tell();
+ sal_uInt32 nSz = TellEnd();
Seek( STREAM_SEEK_TO_BEGIN );
if( mnTagId != 0xff )
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index f3ef15a9d06c..f20e899c0cc6 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -356,8 +356,7 @@ bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Filter
if ( nErrCode == ERRCODE_NONE )
{
- rTargetStream.Seek( STREAM_SEEK_TO_END );
- nPSPosition = rTargetStream.Tell();
+ nPSPosition = rTargetStream.TellEnd();
rTargetStream.Seek( nStreamPosition + 20 );
rTargetStream.WriteUInt32( nPSPosition - 30 ); // size of tiff gfx
rTargetStream.Seek( nPSPosition );
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 8eea3a8585ea..53f66cea476b 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4226,8 +4226,7 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, GraphicObjec
if ( nErrCode == ERRCODE_NONE )
{
p_EscherBlibEntry->meBlibType = ( eGraphicType == GraphicType::Bitmap ) ? PNG : EMF;
- aStream.Seek( STREAM_SEEK_TO_END );
- p_EscherBlibEntry->mnSize = aStream.Tell();
+ p_EscherBlibEntry->mnSize = aStream.TellEnd();
pGraphicAry = static_cast<sal_uInt8 const *>(aStream.GetData());
}
}
@@ -4293,8 +4292,7 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, GraphicObjec
SvMemoryStream aDestStrm;
aZCodec.Write( aDestStrm, pGraphicAry, p_EscherBlibEntry->mnSize );
aZCodec.EndCompression();
- aDestStrm.Seek( STREAM_SEEK_TO_END );
- p_EscherBlibEntry->mnSize = aDestStrm.Tell();
+ p_EscherBlibEntry->mnSize = aDestStrm.TellEnd();
pGraphicAry = static_cast<sal_uInt8 const *>(aDestStrm.GetData());
if ( p_EscherBlibEntry->mnSize && pGraphicAry )
{
@@ -4961,8 +4959,7 @@ void EscherEx::InsertAtCurrentPos( sal_uInt32 nBytes )
if ( offset > nCurPos )
offset += nBytes;
}
- mpOutStrm->Seek( STREAM_SEEK_TO_END );
- nSource = mpOutStrm->Tell();
+ nSource = mpOutStrm->TellEnd();
nToCopy = nSource - nCurPos; // increase the size of the tream by nBytes
std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ 0x40000 ]); // 256KB Buffer
while ( nToCopy )
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index b3a54e3c28fa..ef8ab1e9e7d7 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5915,8 +5915,7 @@ void SvxMSDffManager::GetCtrlData(sal_uInt32 nOffsDggL)
bool bOk;
GetDrawingGroupContainerData( rStCtrl, nLength );
- rStCtrl.Seek( STREAM_SEEK_TO_END );
- sal_uInt32 nMaxStrPos = rStCtrl.Tell();
+ sal_uInt32 nMaxStrPos = rStCtrl.TellEnd();
nPos += nLength;
sal_uInt16 nDrawingContainerId = 1;
@@ -6531,8 +6530,7 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool
{
if ( bZCodecCompression )
{
- xOut->Seek(STREAM_SEEK_TO_END);
- pDbgOut->WriteBytes(xOut->GetData(), xOut->Tell());
+ pDbgOut->WriteBytes(xOut->GetData(), xOut->TellEnd());
xOut->Seek(STREAM_SEEK_TO_BEGIN);
}
else
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 835e6e69bfd5..07aef15edba3 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -582,10 +582,7 @@ private:
return;
}
- const sal_uLong nStreamPos(aStream->Tell());
- aStream->Seek(STREAM_SEEK_TO_END);
- const sal_uLong nStreamLen(aStream->Tell() - nStreamPos);
- aStream->Seek(nStreamPos);
+ const sal_uLong nStreamLen(aStream->remainingSize());
if(aStream->GetError())
{