diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-06 16:34:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-06 21:39:41 +0200 |
commit | f76a7bcc65343a4aa51d24b13c998bf04031d89f (patch) | |
tree | d272dfda5e78e62ed619de64a981b864efeaf73c /svtools | |
parent | 08e09136a60e176703c08aff8a7a8e8a12d3f9b1 (diff) |
return unique_ptr from :svt::GraphicAccess::getImageStream
Change-Id: Ie63259ce826101e553c1cb03a85e7c0ba5f0f9f5
Reviewed-on: https://gerrit.libreoffice.org/78719
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/misc/imageresourceaccess.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx index b8a27dd7a802..829ffdb5feb5 100644 --- a/svtools/source/misc/imageresourceaccess.cxx +++ b/svtools/source/misc/imageresourceaccess.cxx @@ -111,9 +111,9 @@ bool isSupportedURL(OUString const & rURL) || rURL.startsWith("vnd.sun.star.extension://"); } -SvStream* getImageStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL) +std::unique_ptr<SvStream> getImageStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL) { - SvStream* pReturn = nullptr; + std::unique_ptr<SvMemoryStream> pMemBuffer; try { @@ -128,10 +128,10 @@ SvStream* getImageStream(uno::Reference<uno::XComponentContext> const & rxContex OSL_ENSURE(xGraphic.is(), "GraphicAccess::getImageStream: the provider did not give us a graphic object!"); if (!xGraphic.is()) - return pReturn; + return pMemBuffer; // copy the graphic to an in-memory buffer - SvMemoryStream* pMemBuffer = new SvMemoryStream; + pMemBuffer.reset(new SvMemoryStream); uno::Reference<io::XStream> xBufferAccess = new StreamSupplier( new OSeekableInputStreamWrapper(*pMemBuffer), new OSeekableOutputStreamWrapper(*pMemBuffer)); @@ -144,19 +144,19 @@ SvStream* getImageStream(uno::Reference<uno::XComponentContext> const & rxContex xProvider->storeGraphic(xGraphic, aMediaProperties); pMemBuffer->Seek(0); - pReturn = pMemBuffer; } catch (const uno::Exception&) { OSL_FAIL("GraphicAccess::getImageStream: caught an exception!"); + pMemBuffer.reset(); } - return pReturn; + return pMemBuffer; } uno::Reference<io::XInputStream> getImageXStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL) { - return new OSeekableInputStreamWrapper(getImageStream(rxContext, rImageResourceURL), true); // take ownership + return new OSeekableInputStreamWrapper(getImageStream(rxContext, rImageResourceURL).release(), true); // take ownership } } // namespace GraphicAccess |