summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-04-24 02:13:30 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2017-04-27 08:23:46 +0200
commit7df07fabe481f2bcf8b780d05739b3406b0adf39 (patch)
tree73c5a9c2467e5a5eed728e2837ebf55e5cb69741 /vcl
parent5302c78163934b58ac6ee0506b211f2ce5352fd6 (diff)
vcl: rearrange order of functions in errinf.cxx
Change-Id: Ifbde0423e228151e1572e81a443f63355c9bc760 Reviewed-on: https://gerrit.libreoffice.org/36858 Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com> Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/errinf.cxx269
1 files changed, 134 insertions, 135 deletions
diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx
index 00091c52de39..4703e82325ae 100644
--- a/vcl/source/window/errinf.cxx
+++ b/vcl/source/window/errinf.cxx
@@ -29,27 +29,21 @@
class ErrorHandler;
class TheErrorRegistry: public rtl::Static<ErrorRegistry, TheErrorRegistry> {};
-void ErrorRegistry::RegisterDisplay(WindowDisplayErrorFunc *aDsp)
+class ErrorStringFactory
{
- ErrorRegistry &rData = TheErrorRegistry::get();
- rData.bIsWindowDsp = true;
- rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
-}
+public:
+ static bool CreateString(const ErrorInfo*, OUString&);
+};
-class DynamicErrorInfo_Impl
+bool ErrorStringFactory::CreateString(const ErrorInfo* pInfo, OUString& rStr)
{
-private:
- friend class DynamicErrorInfo;
- friend class ErrorInfo;
-
- ErrCode nErrId;
- DialogMask nMask;
-
- void RegisterError(DynamicErrorInfo *);
- static void UnRegisterError(DynamicErrorInfo const *);
- static ErrorInfo* GetDynamicErrorInfo(sal_uInt32 nId);
-
-};
+ for(const ErrorHandler *pHdlr : TheErrorRegistry::get().errorHandlers)
+ {
+ if(pHdlr->CreateString(pInfo, rStr))
+ return true;
+ }
+ return false;
+}
ErrorRegistry::ErrorRegistry()
: pDsp(nullptr)
@@ -67,90 +61,13 @@ void ErrorRegistry::RegisterDisplay(BasicDisplayErrorFunc *aDsp)
rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
}
-void DynamicErrorInfo_Impl::RegisterError(DynamicErrorInfo *pDynErrInfo)
-{
- // Register dynamic identifier
- ErrorRegistry& rData = TheErrorRegistry::get();
- nErrId = (((sal_uInt32)rData.nNextError + 1) << ERRCODE_DYNAMIC_SHIFT) +
- pDynErrInfo->GetErrorCode();
-
- if(rData.ppDynErrInfo[rData.nNextError])
- delete rData.ppDynErrInfo[rData.nNextError];
-
- rData.ppDynErrInfo[rData.nNextError] = pDynErrInfo;
-
- if(++rData.nNextError>=ERRCODE_DYNAMIC_COUNT)
- rData.nNextError=0;
-}
-
-void DynamicErrorInfo_Impl::UnRegisterError(DynamicErrorInfo const *pDynErrInfo)
-{
- DynamicErrorInfo **ppDynErrInfo = TheErrorRegistry::get().ppDynErrInfo;
- sal_uInt32 nIdx = (((sal_uInt32)(*pDynErrInfo) & ERRCODE_DYNAMIC_MASK) >> ERRCODE_DYNAMIC_SHIFT) - 1;
- DBG_ASSERT(ppDynErrInfo[nIdx] == pDynErrInfo, "ErrHdl: Error not found");
-
- if(ppDynErrInfo[nIdx]==pDynErrInfo)
- ppDynErrInfo[nIdx]=nullptr;
-}
-
-ErrorInfo::~ErrorInfo()
-{
-}
-
-ErrorInfo *ErrorInfo::GetErrorInfo(sal_uInt32 nId)
-{
- if(nId & ERRCODE_DYNAMIC_MASK)
- return DynamicErrorInfo_Impl::GetDynamicErrorInfo(nId);
- else
- return new ErrorInfo(nId);
-}
-
-DynamicErrorInfo::operator sal_uInt32() const
-{
- return pImpl->nErrId;
-}
-
-DynamicErrorInfo::DynamicErrorInfo(sal_uInt32 nArgUserId, DialogMask nMask)
-: ErrorInfo(nArgUserId),
- pImpl(new DynamicErrorInfo_Impl)
-{
- pImpl->RegisterError(this);
- pImpl->nMask=nMask;
-}
-
-DynamicErrorInfo::~DynamicErrorInfo()
-{
- DynamicErrorInfo_Impl::UnRegisterError(this);
-}
-
-ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uInt32 nId)
-{
- sal_uInt32 nIdx = ((nId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
- DynamicErrorInfo* pDynErrInfo = TheErrorRegistry::get().ppDynErrInfo[nIdx];
-
- if(pDynErrInfo && (sal_uInt32)(*pDynErrInfo)==nId)
- return pDynErrInfo;
- else
- return new ErrorInfo(nId & ~ERRCODE_DYNAMIC_MASK);
-}
-
-DialogMask DynamicErrorInfo::GetDialogMask() const
-{
- return pImpl->nMask;
-}
-
-StringErrorInfo::StringErrorInfo(
- sal_uInt32 nUserId, const OUString& aStringP, DialogMask nMask)
-: DynamicErrorInfo(nUserId, nMask), aString(aStringP)
+void ErrorRegistry::RegisterDisplay(WindowDisplayErrorFunc *aDsp)
{
+ ErrorRegistry &rData = TheErrorRegistry::get();
+ rData.bIsWindowDsp = true;
+ rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
}
-class ErrorStringFactory
-{
-public:
- static bool CreateString(const ErrorInfo*, OUString&);
-};
-
static void aDspFunc(const OUString &rErr, const OUString &rAction)
{
OStringBuffer aErr("Action: ");
@@ -160,30 +77,6 @@ static void aDspFunc(const OUString &rErr, const OUString &rAction)
OSL_FAIL(aErr.getStr());
}
-struct ErrorContextImpl
-{
- vcl::Window *pWin; // FIXME: should be VclPtr for strong lifecycle
-};
-
-ErrorContext::ErrorContext(vcl::Window *pWinP)
- : pImpl( new ErrorContextImpl )
-{
- pImpl->pWin = pWinP;
- TheErrorRegistry::get().contexts.insert(TheErrorRegistry::get().contexts.begin(), this);
-}
-
-ErrorContext::~ErrorContext()
-{
- auto &rContexts = TheErrorRegistry::get().contexts;
- rContexts.erase( ::std::remove(rContexts.begin(), rContexts.end(), this), rContexts.end());
-}
-
-ErrorContext *ErrorContext::GetContext()
-{
- return TheErrorRegistry::get().contexts.empty() ? nullptr : TheErrorRegistry::get().contexts.front();
-}
-
-
ErrorHandler::ErrorHandler()
{
ErrorRegistry &rData = TheErrorRegistry::get();
@@ -200,11 +93,6 @@ ErrorHandler::~ErrorHandler()
rErrorHandlers.end());
}
-vcl::Window* ErrorContext::GetParent()
-{
- return pImpl ? pImpl->pWin : nullptr;
-}
-
bool ErrorHandler::GetErrorString(sal_uInt32 nErrCodeId, OUString& rErrStr)
{
OUString aErr;
@@ -320,14 +208,125 @@ DialogMask ErrorHandler::HandleError(sal_uInt32 nErrCodeId, DialogMask nFlags)
return DialogMask::NONE;
}
-bool ErrorStringFactory::CreateString(const ErrorInfo* pInfo, OUString& rStr)
+struct ErrorContextImpl
+{
+ vcl::Window *pWin; // FIXME: should be VclPtr for strong lifecycle
+};
+
+ErrorContext::ErrorContext(vcl::Window *pWinP)
+ : pImpl( new ErrorContextImpl )
+{
+ pImpl->pWin = pWinP;
+ TheErrorRegistry::get().contexts.insert(TheErrorRegistry::get().contexts.begin(), this);
+}
+
+ErrorContext::~ErrorContext()
+{
+ auto &rContexts = TheErrorRegistry::get().contexts;
+ rContexts.erase( ::std::remove(rContexts.begin(), rContexts.end(), this), rContexts.end());
+}
+
+ErrorContext *ErrorContext::GetContext()
+{
+ return TheErrorRegistry::get().contexts.empty() ? nullptr : TheErrorRegistry::get().contexts.front();
+}
+
+vcl::Window* ErrorContext::GetParent()
+{
+ return pImpl ? pImpl->pWin : nullptr;
+}
+
+class DynamicErrorInfo_Impl
+{
+ friend class DynamicErrorInfo;
+ friend class ErrorInfo;
+
+private:
+ void RegisterError(DynamicErrorInfo *);
+ static void UnRegisterError(DynamicErrorInfo const *);
+ static ErrorInfo* GetDynamicErrorInfo(sal_uInt32 nId);
+
+ ErrCode nErrId;
+ DialogMask nMask;
+
+};
+
+void DynamicErrorInfo_Impl::RegisterError(DynamicErrorInfo *pDynErrInfo)
+{
+ // Register dynamic identifier
+ ErrorRegistry& rData = TheErrorRegistry::get();
+ nErrId = (((sal_uInt32)rData.nNextError + 1) << ERRCODE_DYNAMIC_SHIFT) +
+ pDynErrInfo->GetErrorCode();
+
+ if(rData.ppDynErrInfo[rData.nNextError])
+ delete rData.ppDynErrInfo[rData.nNextError];
+
+ rData.ppDynErrInfo[rData.nNextError] = pDynErrInfo;
+
+ if(++rData.nNextError>=ERRCODE_DYNAMIC_COUNT)
+ rData.nNextError=0;
+}
+
+void DynamicErrorInfo_Impl::UnRegisterError(DynamicErrorInfo const *pDynErrInfo)
+{
+ DynamicErrorInfo **ppDynErrInfo = TheErrorRegistry::get().ppDynErrInfo;
+ sal_uInt32 nIdx = (((sal_uInt32)(*pDynErrInfo) & ERRCODE_DYNAMIC_MASK) >> ERRCODE_DYNAMIC_SHIFT) - 1;
+ DBG_ASSERT(ppDynErrInfo[nIdx] == pDynErrInfo, "ErrHdl: Error not found");
+
+ if(ppDynErrInfo[nIdx]==pDynErrInfo)
+ ppDynErrInfo[nIdx]=nullptr;
+}
+
+ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uInt32 nId)
+{
+ sal_uInt32 nIdx = ((nId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
+ DynamicErrorInfo* pDynErrInfo = TheErrorRegistry::get().ppDynErrInfo[nIdx];
+
+ if(pDynErrInfo && (sal_uInt32)(*pDynErrInfo)==nId)
+ return pDynErrInfo;
+ else
+ return new ErrorInfo(nId & ~ERRCODE_DYNAMIC_MASK);
+}
+
+ErrorInfo *ErrorInfo::GetErrorInfo(sal_uInt32 nId)
+{
+ if(nId & ERRCODE_DYNAMIC_MASK)
+ return DynamicErrorInfo_Impl::GetDynamicErrorInfo(nId);
+ else
+ return new ErrorInfo(nId);
+}
+
+ErrorInfo::~ErrorInfo()
+{
+}
+
+DynamicErrorInfo::DynamicErrorInfo(sal_uInt32 nArgUserId, DialogMask nMask)
+: ErrorInfo(nArgUserId),
+ pImpl(new DynamicErrorInfo_Impl)
+{
+ pImpl->RegisterError(this);
+ pImpl->nMask=nMask;
+}
+
+DynamicErrorInfo::~DynamicErrorInfo()
+{
+ DynamicErrorInfo_Impl::UnRegisterError(this);
+}
+
+DynamicErrorInfo::operator sal_uInt32() const
+{
+ return pImpl->nErrId;
+}
+
+DialogMask DynamicErrorInfo::GetDialogMask() const
+{
+ return pImpl->nMask;
+}
+
+StringErrorInfo::StringErrorInfo(
+ sal_uInt32 nUserId, const OUString& aStringP, DialogMask nMask)
+: DynamicErrorInfo(nUserId, nMask), aString(aStringP)
{
- for(const ErrorHandler *pHdlr : TheErrorRegistry::get().errorHandlers)
- {
- if(pHdlr->CreateString(pInfo, rStr))
- return true;
- }
- return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */