[Libreoffice-commits] core.git: sd/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Jun 6 06:17:16 UTC 2017
sd/source/filter/html/htmlex.cxx | 75 ++++++++++++++-------------------------
1 file changed, 28 insertions(+), 47 deletions(-)
New commits:
commit e718817f0efc01c440271cc709c8e4eb28ff5c0d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jun 5 16:58:33 2017 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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
More information about the Libreoffice-commits
mailing list