diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-09 08:52:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-21 08:42:30 +0200 |
commit | 528632660b72b105345945c13c5b68060d94a91b (patch) | |
tree | 860508d482959abeb9175f0ce6b9e65954269f95 /linguistic | |
parent | aee66aa85e75f67135e5c6079a281e18402d261a (diff) |
convert ErrCode to strong typedef
would have preferred to re-use o3tl::strong_int, of which this
is a modified copy, but there are lots of convenience accessors
which are nice to define on the class.
Change-Id: I301b807aaf02fbced3bf75de1e1692cde6c0340a
Reviewed-on: https://gerrit.libreoffice.org/38497
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'linguistic')
-rw-r--r-- | linguistic/source/convdicxml.cxx | 2 | ||||
-rw-r--r-- | linguistic/source/convdicxml.hxx | 2 | ||||
-rw-r--r-- | linguistic/source/dicimp.cxx | 38 | ||||
-rw-r--r-- | linguistic/source/dicimp.hxx | 5 |
4 files changed, 24 insertions, 23 deletions
diff --git a/linguistic/source/convdicxml.cxx b/linguistic/source/convdicxml.cxx index 438b455afde3..e5ac95339348 100644 --- a/linguistic/source/convdicxml.cxx +++ b/linguistic/source/convdicxml.cxx @@ -295,7 +295,7 @@ bool ConvDicXMLExport::Export() } -sal_uInt32 ConvDicXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum /*eClass*/ ) +ErrCode ConvDicXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum /*eClass*/ ) { GetNamespaceMap_().Add( "tcd", XML_NAMESPACE_TCD_STRING, XML_NAMESPACE_TCD ); diff --git a/linguistic/source/convdicxml.hxx b/linguistic/source/convdicxml.hxx index 019dc03fdd06..8463d190a0e2 100644 --- a/linguistic/source/convdicxml.hxx +++ b/linguistic/source/convdicxml.hxx @@ -56,7 +56,7 @@ public: void ExportAutoStyles_() override {} void ExportMasterStyles_() override {} void ExportContent_() override; - sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) override; + ErrCode exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) override; bool Export(); }; diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx index 488c62bf454a..dd32758e2482 100644 --- a/linguistic/source/dicimp.cxx +++ b/linguistic/source/dicimp.cxx @@ -226,7 +226,7 @@ DictionaryNeo::~DictionaryNeo() { } -sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) +ErrCode DictionaryNeo::loadEntries(const OUString &rMainURL) { MutexGuard aGuard( GetLinguMutex() ); @@ -238,7 +238,7 @@ sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) bNeedEntries = false; if (rMainURL.isEmpty()) - return 0; + return ERRCODE_NONE; uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); @@ -254,7 +254,7 @@ sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) SAL_WARN( "linguistic", "failed to get input stream" ); } if (!xStream.is()) - return static_cast< sal_uLong >(-1); + return ErrCode(sal_uInt32(-1)); SvStreamPtr pStream = SvStreamPtr( utl::UcbStreamHelper::CreateStream( xStream ) ); @@ -262,8 +262,8 @@ sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) bool bNegativ; LanguageType nLang; nDicVersion = ReadDicVersion(pStream, nLang, bNegativ); - sal_uLong nErr = pStream->GetError(); - if (0 != nErr) + ErrCode nErr = pStream->GetError(); + if (nErr != ERRCODE_NONE) return nErr; nLanguage = nLang; @@ -286,12 +286,12 @@ sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) if (!pStream->IsEof()) { pStream->ReadUInt16( nLen ); - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; if ( nLen < BUFSIZE ) { pStream->ReadBytes(aWordBuf, nLen); - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; *(aWordBuf + nLen) = 0; } @@ -314,13 +314,13 @@ sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) pStream->ReadUInt16( nLen ); if (pStream->IsEof()) break; - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; if (nLen < BUFSIZE) { pStream->ReadBytes(aWordBuf, nLen); - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; } else @@ -367,12 +367,12 @@ static OString formatForSave(const uno::Reference< XDictionaryEntry > &xEntry, return aStr.makeStringAndClear(); } -sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) +ErrCode DictionaryNeo::saveEntries(const OUString &rURL) { MutexGuard aGuard( GetLinguMutex() ); if (rURL.isEmpty()) - return 0; + return ERRCODE_NONE; DBG_ASSERT(!INetURLObject( rURL ).HasError(), "lng : invalid URL"); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); @@ -388,7 +388,7 @@ sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) DBG_ASSERT( false, "failed to get input stream" ); } if (!xStream.is()) - return static_cast< sal_uLong >(-1); + return ErrCode(sal_uInt32(-1)); SvStreamPtr pStream = SvStreamPtr( utl::UcbStreamHelper::CreateStream( xStream ) ); @@ -396,8 +396,8 @@ sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) rtl_TextEncoding eEnc = RTL_TEXTENCODING_UTF8; pStream->WriteLine(OString(pVerOOo7)); - sal_uLong nErr = pStream->GetError(); - if (0 != nErr) + ErrCode nErr = pStream->GetError(); + if (nErr != ERRCODE_NONE) return nErr; /* XXX: the <none> case could be differentiated, is it absence or * undetermined or multiple? Earlier versions did not know about 'und' and @@ -410,22 +410,22 @@ sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) aLine.append(OUStringToOString(LanguageTag::convertToBcp47(nLanguage), eEnc)); pStream->WriteLine(aLine.makeStringAndClear()); } - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; if (eDicType == DictionaryType_POSITIVE) pStream->WriteLine(OString("type: positive")); else pStream->WriteLine(OString("type: negative")); - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; pStream->WriteLine(OString("---")); - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; for (Reference<XDictionaryEntry> & aEntrie : aEntries) { OString aOutStr = formatForSave(aEntrie, eEnc); pStream->WriteLine (aOutStr); - if (0 != (nErr = pStream->GetError())) + if (ERRCODE_NONE != (nErr = pStream->GetError())) return nErr; } @@ -444,7 +444,7 @@ sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) catch (const uno::Exception &) { DBG_ASSERT( false, "failed to write stream" ); - return static_cast< sal_uLong >(-1); + return ErrCode(sal_uInt32(-1)); } return nErr; diff --git a/linguistic/source/dicimp.hxx b/linguistic/source/dicimp.hxx index 6fef2c4f10b1..10beccdf7043 100644 --- a/linguistic/source/dicimp.hxx +++ b/linguistic/source/dicimp.hxx @@ -27,6 +27,7 @@ #include <cppuhelper/implbase.hxx> #include <comphelper/interfacecontainer2.hxx> #include <tools/solar.h> +#include <vcl/errcode.hxx> #include "defs.hxx" #include "linguistic/misc.hxx" @@ -62,8 +63,8 @@ class DictionaryNeo : void launchEvent(sal_Int16 nEvent, const css::uno::Reference< css::linguistic2::XDictionaryEntry >& xEntry); - sal_uLong loadEntries(const OUString &rMainURL); - sal_uLong saveEntries(const OUString &rMainURL); + ErrCode loadEntries(const OUString &rMainURL); + ErrCode saveEntries(const OUString &rMainURL); static int cmpDicEntry(const OUString &rWord1, const OUString &rWord2, bool bSimilarOnly = false); |