diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-04-20 22:29:04 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-04-27 06:56:22 +0200 |
commit | 25983404aa710990194ca8afa89f91bee879a6be (patch) | |
tree | 257bd646b69fd5f3917a7148f508172f10a20150 /vcl/source | |
parent | ab5fbd39b76be8cc8015d303c1677c198776390a (diff) |
ImpGraphic: clean-up and simplify swapOut()
Change-Id: I3e578c3172fcea341a218798843cd750971a5af1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92944
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 9eb42fec39e8..610d98b9528c 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1328,44 +1328,46 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) bool ImpGraphic::swapOut() { - - if( isSwappedOut() ) + if (isSwappedOut()) return false; - ::utl::TempFile aTempFile; - const INetURLObject aTmpURL( aTempFile.GetURL() ); + utl::TempFile aTempFile; + const INetURLObject aTempFileURL(aTempFile.GetURL()); + OUString sTempFileURLString = aTempFileURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); - if( aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ).isEmpty() ) + if (sTempFileURLString.isEmpty()) return false; + std::unique_ptr<SvStream> xOutputStream; - std::unique_ptr<SvStream> xOStm; try { - xOStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE ); + xOutputStream = utl::UcbStreamHelper::CreateStream(sTempFileURLString, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE); } - catch( const css::uno::Exception& ) + catch (const css::uno::Exception&) { } - if( !xOStm ) + + if (!xOutputStream) return false; + xOutputStream->SetVersion(SOFFICE_FILEFORMAT_50); + xOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE); - xOStm->SetVersion( SOFFICE_FILEFORMAT_50 ); - xOStm->SetCompressMode( SvStreamCompressFlags::NATIVE ); + bool bResult = swapOutToStream(xOutputStream.get()); - bool bRet = swapOutToStream( xOStm.get() ); - if( bRet ) + if (bResult) { - mpSwapFile.reset(new ImpSwapFile(aTmpURL, getOriginURL()), o3tl::default_delete<ImpSwapFile>()); + mpSwapFile.reset(new ImpSwapFile(aTempFileURL, getOriginURL()), o3tl::default_delete<ImpSwapFile>()); } else { - xOStm.reset(); - utl::UCBContentHelper::Kill(aTmpURL.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + xOutputStream.reset(); + utl::UCBContentHelper::Kill(sTempFileURLString); } - if (bRet) + if (bResult) vcl::graphic::Manager::get().swappedOut(this); - return bRet; + + return bResult; } bool ImpGraphic::swapOutToStream(SvStream* xOStm) |