summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-16 16:35:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-19 07:36:12 +0100
commite9c74a075c3c0809b993c017c11d1505bd244dc8 (patch)
tree88cf68873c9b60941ced2ae0fda040496cbe0e2d
parent9d75bfcfaef97b247b3b6cd346eb27e02ae7b010 (diff)
drop ErrCode::GetRest
it was always a broken API because it includes the code, the class, and only part of the subsystemarea. Change-Id: I6f88b54aed2feab02a6aeaa783d7c642054b8075 Reviewed-on: https://gerrit.libreoffice.org/51430 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/vcl/errcode.hxx24
-rw-r--r--svtools/source/misc/ehdl.cxx2
-rw-r--r--sw/inc/error.hrc4
-rw-r--r--uui/source/iahndl.cxx2
-rw-r--r--vcl/source/helper/errcode.cxx2
5 files changed, 22 insertions, 12 deletions
diff --git a/include/vcl/errcode.hxx b/include/vcl/errcode.hxx
index 8f1ba5ffc912..174c424f2871 100644
--- a/include/vcl/errcode.hxx
+++ b/include/vcl/errcode.hxx
@@ -64,11 +64,17 @@ enum class WarningFlag { Yes };
class SAL_WARN_UNUSED ErrCode final
{
public:
- explicit constexpr ErrCode(WarningFlag, ErrCodeArea nArea, ErrCodeClass nClass, sal_uInt16 nCode)
- : m_value(ERRCODE_WARNING_MASK | (sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | (sal_uInt32(nClass) << ERRCODE_CLASS_SHIFT) | nCode) {}
- explicit constexpr ErrCode(ErrCodeArea nArea, ErrCodeClass nClass, sal_uInt16 nCode)
- : m_value((sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | (sal_uInt32(nClass) << ERRCODE_CLASS_SHIFT) | nCode) {}
- explicit constexpr ErrCode(ErrCodeArea nArea, sal_uInt32 nClassAndCode)
+ explicit ErrCode(WarningFlag, ErrCodeArea nArea, ErrCodeClass nClass, sal_uInt16 nCode)
+ : m_value(ERRCODE_WARNING_MASK | (sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | (sal_uInt32(nClass) << ERRCODE_CLASS_SHIFT) | nCode)
+ {
+ assert(nCode <= 0xff && "code out of range");
+ }
+ explicit ErrCode(ErrCodeArea nArea, ErrCodeClass nClass, sal_uInt16 nCode)
+ : m_value((sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | (sal_uInt32(nClass) << ERRCODE_CLASS_SHIFT) | nCode)
+ {
+ assert(nCode <= 0xff && "code out of range");
+ }
+ explicit constexpr ErrCode(ErrCodeArea nArea, sal_uInt16 nClassAndCode)
: m_value((sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | nClassAndCode) {}
explicit constexpr ErrCode(sal_uInt32 nValue)
: m_value(nValue) {}
@@ -116,6 +122,10 @@ public:
return ErrCode(m_value & ~ERRCODE_DYNAMIC_MASK);
}
+ constexpr ErrCode StripWarningAndDynamic() const {
+ return ErrCode(m_value & ~(ERRCODE_DYNAMIC_MASK | ERRCODE_WARNING_MASK));
+ }
+
constexpr ErrCodeArea GetArea() const {
return static_cast<ErrCodeArea>((m_value >> ERRCODE_AREA_SHIFT) & 0x01fff);
}
@@ -124,8 +134,8 @@ public:
return static_cast<ErrCodeClass>((m_value >> ERRCODE_CLASS_SHIFT) & 0x1f);
}
- constexpr sal_uInt16 GetRest() const {
- return m_value & 0x7fff;
+ constexpr sal_uInt8 GetCode() const {
+ return static_cast<sal_uInt8>(m_value & 0xff);
}
OUString toHexString() const {
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
index 3ab4c7cedb9c..246b55ae4a24 100644
--- a/svtools/source/misc/ehdl.cxx
+++ b/svtools/source/misc/ehdl.cxx
@@ -221,7 +221,7 @@ bool SfxErrorHandler::GetErrorString(ErrCode lErrId, OUString &rStr) const
for (const ErrMsgCode* pItem = pIds; pItem->second; ++pItem)
{
- if (pItem->second.GetRest() == lErrId.GetRest())
+ if (pItem->second == lErrId.StripWarningAndDynamic())
{
rStr = rStr.replaceAll("$(ERROR)", Translate::get(pItem->first, aResLocale));
bRet = true;
diff --git a/sw/inc/error.hrc b/sw/inc/error.hrc
index 7f6b8d3f61c7..1e61b007cf98 100644
--- a/sw/inc/error.hrc
+++ b/sw/inc/error.hrc
@@ -24,8 +24,8 @@
#define NC_(Context, String) (Context "\004" u8##String)
-#define ERR_CODE( class, err ) ErrCode(ErrCodeArea::Sw, class, err.GetRest())
-#define WARN_CODE( class, err ) ErrCode(ErrCodeArea::Sw, class, err.GetRest())
+#define ERR_CODE( class, err ) ErrCode(ErrCodeArea::Sw, class, err.GetCode())
+#define WARN_CODE( class, err ) ErrCode(ErrCodeArea::Sw, class, err.GetCode())
const ErrMsgCode RID_SW_ERRHDL[] =
{
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 6dbe7df63e76..439c223d5e52 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -1286,7 +1286,7 @@ bool ErrorResource::getString(ErrCode nErrorCode, OUString &rString) const
{
for (const std::pair<const char*, ErrCode>* pStringArray = m_pStringArray; pStringArray->first != nullptr; ++pStringArray)
{
- if (nErrorCode.GetRest() == pStringArray->second.GetRest())
+ if (nErrorCode.StripWarningAndDynamic() == pStringArray->second)
{
rString = Translate::get(pStringArray->first, m_rResLocale);
return true;
diff --git a/vcl/source/helper/errcode.cxx b/vcl/source/helper/errcode.cxx
index bb8e4eaf09e9..d50bf522c7d8 100644
--- a/vcl/source/helper/errcode.cxx
+++ b/vcl/source/helper/errcode.cxx
@@ -138,7 +138,7 @@ VCL_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err)
os << "Compiler";
break;
}
- os << " Code:" << OUString::number(err.GetRest() & 0xff);
+ os << " Code:" << OUString::number(err.GetCode());
}
os << ")";
return os;