vcl/source/gdi/impgraph.cxx | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
New commits: commit 02a2110209c28e9d10e3527c87a3767e2276dfce Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 20 22:29:04 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Apr 20 22:30:25 2020 +0200 ImpGraphic: clean-up and simplify swapOut() Change-Id: I3e578c3172fcea341a218798843cd750971a5af1 diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 2a5780fc137c..04f576c76737 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1321,45 +1321,50 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) bool ImpGraphic::swapOut() { - bool bRet = false; + bool bResult = false; if (!isSwappedOut()) { - ::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()) { - std::unique_ptr<SvStream> xOStm; + std::unique_ptr<SvStream> xOutputStream; + 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) { - xOStm->SetVersion( SOFFICE_FILEFORMAT_50 ); - xOStm->SetCompressMode( SvStreamCompressFlags::NATIVE ); + xOutputStream->SetVersion(SOFFICE_FILEFORMAT_50); + xOutputStream->SetCompressMode(SvStreamCompressFlags::NATIVE); - bRet = swapOutToStream(xOStm.get()); - if( bRet ) + bResult = swapOutToStream(xOutputStream.get()); + + if (bResult) { - mpSwapFile = std::make_unique<ImpSwapFile>(aTmpURL, getOriginURL()); + mpSwapFile = std::make_unique<ImpSwapFile>(aTempFileURL, getOriginURL()); } 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits