diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-09-18 12:07:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-19 09:30:06 +0200 |
commit | 4973de104da87e522fe1f485984c081bc0be1b36 (patch) | |
tree | 4eebb1d15d51997f95c4090381ac0b2e636b7883 | |
parent | OSL_ENSURE->assert where we would crash if not true (diff) | |
download | core-4973de104da87e522fe1f485984c081bc0be1b36.tar.gz core-4973de104da87e522fe1f485984c081bc0be1b36.zip |
simplify usage of TempFile in Graphic(In/Out)putStream
TempFile already handles the stream. And not touching the URL
means we stay on the fast path for temp files.
Change-Id: Icdfcb96b002c489dee51c03b69127c21be5c85ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140113
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | svx/source/xml/xmlgrhlp.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index bafcca9f55a0..e2e452d51ae9 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -114,7 +114,7 @@ GraphicInputStream::GraphicInputStream(GraphicObject const & aGraphicObject, con if (aGraphicObject.GetType() == GraphicType::NONE) return; - std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream(maTempFile.GetURL(), StreamMode::WRITE | StreamMode::TRUNC); + SvStream* pStream = maTempFile.GetStream(StreamMode::READWRITE); if (!pStream) return; @@ -168,7 +168,7 @@ GraphicInputStream::GraphicInputStream(GraphicObject const & aGraphicObject, con if (bRet) { pStream->Seek( 0 ); - mxStreamWrapper = new ::utl::OInputStreamWrapper(std::move(pStream)); + mxStreamWrapper = new ::utl::OInputStreamWrapper(*pStream); } } @@ -225,7 +225,7 @@ private: private: std::unique_ptr<::utl::TempFile> mpTmp; - std::unique_ptr<SvStream> mpOStm; + SvStream* mpOStm; Reference< XOutputStream > mxStmWrapper; std::unique_ptr<GraphicObject> mxGrfObj; bool mbClosed; @@ -249,7 +249,7 @@ SvXMLGraphicOutputStream::SvXMLGraphicOutputStream() { mpTmp->EnableKillingFile(); - mpOStm = ::utl::UcbStreamHelper::CreateStream( mpTmp->GetURL(), StreamMode::WRITE | StreamMode::TRUNC ); + mpOStm = mpTmp->GetStream( StreamMode::READWRITE ); if( mpOStm ) mxStmWrapper = new ::utl::OOutputStreamWrapper( *mpOStm ); @@ -258,7 +258,6 @@ SvXMLGraphicOutputStream::SvXMLGraphicOutputStream() SvXMLGraphicOutputStream::~SvXMLGraphicOutputStream() { mpTmp.reset(); - mpOStm.reset(); } void SAL_CALL SvXMLGraphicOutputStream::writeBytes( const Sequence< sal_Int8 >& rData ) @@ -347,7 +346,7 @@ Graphic SvXMLGraphicOutputStream::GetGraphic() if (aGraphic.GetType() != GraphicType::NONE) { - mpOStm.reset(); + mpOStm = nullptr; mpTmp.reset(); } return aGraphic; |