svx/source/xml/xmlgrhlp.cxx |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 4973de104da87e522fe1f485984c081bc0be1b36
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Sep 18 12:07:40 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Sep 19 09:30:06 2022 +0200

    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.gran...@collabora.co.uk>

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;

Reply via email to