diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-05 16:58:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-06 08:16:55 +0200 |
commit | e718817f0efc01c440271cc709c8e4eb28ff5c0d (patch) | |
tree | 651859a6a6bdfc7a5c1505ca8f05aa0259900b3c | |
parent | e4ffd9388968c717fe4c21222f322fe1c375c434 (diff) |
simplify EasyFile::close
since it only ever returns one value - 0.
And once we've simplified all of those call-sites, we can do the same
thing to EasyFile::createFileName
Change-Id: I18dda80eb12cc6cf1c9ab0d3801084557e661dcc
Reviewed-on: https://gerrit.libreoffice.org/38413
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sd/source/filter/html/htmlex.cxx | 75 |
1 files changed, 28 insertions, 47 deletions
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 81eeea393043..aef32f6bd961 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -139,8 +139,8 @@ public: ~EasyFile(); sal_uLong createStream( const OUString& rUrl, SvStream*& rpStr ); - sal_uLong createFileName( const OUString& rUrl, OUString& rFileName ); - sal_uLong close(); + void createFileName( const OUString& rUrl, OUString& rFileName ); + void close(); }; // Helper class for the embedding of text attributes into the html output @@ -1174,7 +1174,7 @@ bool HtmlExport::WriteHtml( const OUString& rFileName, bool bAddExtension, const OString aStr(OUStringToOString(rHtmlData, RTL_TEXTENCODING_UTF8)); pStr->WriteCharPtr( aStr.getStr() ); - nErr = aFile.close(); + aFile.close(); } if( nErr != 0 ) @@ -2918,8 +2918,7 @@ bool HtmlExport::CopyScript( const OUString& rPath, const OUString& rSource, con OString aStr(OUStringToOString(aScript, RTL_TEXTENCODING_UTF8)); pStr->WriteCharPtr( aStr.getStr() ); - - nErr = aFile.close(); + aFile.close(); } } @@ -3004,7 +3003,7 @@ bool HtmlExport::CreateImageNumberFile() if(nErr == 0) { pStr->WriteCharPtr( "1" ); - nErr = aFile.close(); + aFile.close(); } if (mpProgress) @@ -3130,33 +3129,27 @@ EasyFile::EasyFile() EasyFile::~EasyFile() { if( bOpen ) - (void)close(); + close(); } sal_uLong EasyFile::createStream( const OUString& rUrl, SvStream* &rpStr ) { - sal_uLong nErr = 0; - if(bOpen) - nErr = close(); + close(); OUString aFileName; + createFileName( rUrl, aFileName ); - if( nErr == 0 ) - nErr = createFileName( rUrl, aFileName ); - - if( nErr == 0 ) + sal_uLong nErr = 0; + pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, StreamMode::WRITE | StreamMode::TRUNC ); + if( pOStm ) { - pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, StreamMode::WRITE | StreamMode::TRUNC ); - if( pOStm ) - { - bOpen = true; - nErr = pOStm->GetError(); - } - else - { - nErr = ERRCODE_SFX_CANTCREATECONTENT; - } + bOpen = true; + nErr = pOStm->GetError(); + } + else + { + nErr = ERRCODE_SFX_CANTCREATECONTENT; } if( nErr != 0 ) @@ -3171,40 +3164,28 @@ sal_uLong EasyFile::createStream( const OUString& rUrl, SvStream* &rpStr ) return nErr; } -sal_uLong EasyFile::createFileName( const OUString& rURL, OUString& rFileName ) +void EasyFile::createFileName( const OUString& rURL, OUString& rFileName ) { - sal_uLong nErr = 0; - if( bOpen ) - nErr = close(); + close(); - if( nErr == 0 ) - { - INetURLObject aURL( rURL ); + INetURLObject aURL( rURL ); - if( aURL.GetProtocol() == INetProtocol::NotValid ) - { - OUString aURLStr; - osl::FileBase::getFileURLFromSystemPath( rURL, aURLStr ); - aURL = INetURLObject( aURLStr ); - } - DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - rFileName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + if( aURL.GetProtocol() == INetProtocol::NotValid ) + { + OUString aURLStr; + osl::FileBase::getFileURLFromSystemPath( rURL, aURLStr ); + aURL = INetURLObject( aURLStr ); } - - return nErr; + DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); + rFileName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); } -sal_uLong EasyFile::close() +void EasyFile::close() { - sal_uLong nErr = 0; - delete pOStm; pOStm = nullptr; - bOpen = false; - - return nErr; } // This class helps reporting errors during file i/o |