diff options
-rw-r--r-- | desktop/source/lib/init.cxx | 2 | ||||
-rw-r--r-- | include/vcl/errinf.hxx | 47 | ||||
-rw-r--r-- | svtools/source/misc/ehdl.cxx | 2 | ||||
-rw-r--r-- | test/source/bootstrapfixture.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/errinf.cxx | 46 |
5 files changed, 59 insertions, 40 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a419eb3ab84c..27af7dddca77 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3240,7 +3240,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char } if (eStage != SECOND_INIT) - ErrorHandler::RegisterDisplay(aBasicErrorFunc); + ErrorRegistry::RegisterDisplay(aBasicErrorFunc); SAL_INFO("lok", "LOK Initialized"); if (eStage == PRE_INIT) diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx index cc1118384118..6b7a4b84ec98 100644 --- a/include/vcl/errinf.hxx +++ b/include/vcl/errinf.hxx @@ -22,17 +22,33 @@ #ifndef INCLUDED_VCL_ERRINF_HXX #define INCLUDED_VCL_ERRINF_HXX -#include <limits.h> #include <rtl/ustring.hxx> #include <tools/errcode.hxx> #include <vcl/dllapi.h> #include <o3tl/typed_flags_set.hxx> + +#include <vector> #include <memory> +#include <limits.h> namespace vcl { class Window; } -class DynamicErrorInfo_Impl; +class ErrorHandler; +class ErrorContext; class ErrorStringFactory; +class DynamicErrorInfo; +class DynamicErrorInfo_Impl; +enum class DialogMask; + +namespace { + typedef void (* DisplayFnPtr)(); +} + +typedef DialogMask WindowDisplayErrorFunc( + vcl::Window *, DialogMask eMask, const OUString &rErr, const OUString &rAction); + +typedef void BasicDisplayErrorFunc( + const OUString &rErr, const OUString &rAction); enum class DialogMask { @@ -62,6 +78,30 @@ namespace o3tl template<> struct typed_flags<DialogMask> : is_typed_flags<DialogMask, 0xffff> {}; } +class VCL_DLLPUBLIC ErrorRegistry +{ + friend class ErrorHandler; + friend class ErrorContext; + friend class ErrorStringFactory; + friend class DynamicErrorInfo_Impl; + +public: + ErrorRegistry(); + + static void RegisterDisplay(BasicDisplayErrorFunc*); + static void RegisterDisplay(WindowDisplayErrorFunc*); + +private: + DisplayFnPtr pDsp; + bool bIsWindowDsp; + sal_uInt16 nNextError; + + std::vector<ErrorHandler*> errorHandlers; + std::vector<ErrorContext*> contexts; + + DynamicErrorInfo* ppDynErrInfo[ERRCODE_DYNAMIC_COUNT]; +}; + class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorInfo { private: @@ -158,9 +198,6 @@ public: static DialogMask HandleError ( sal_uInt32 lId, DialogMask nMask = DialogMask::MAX ); static bool GetErrorString( sal_uInt32 lId, OUString& rStr ); - static void RegisterDisplay( BasicDisplayErrorFunc* ); - static void RegisterDisplay( WindowDisplayErrorFunc* ); - protected: virtual bool CreateString(const ErrorInfo *, OUString &) const = 0; diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx index abf9af1dd6c6..850813183f78 100644 --- a/svtools/source/misc/ehdl.cxx +++ b/svtools/source/misc/ehdl.cxx @@ -145,7 +145,7 @@ SfxErrorHandler::SfxErrorHandler(sal_uInt16 nIdP, sal_uLong lStartP, sal_uLong l lStart(lStartP), lEnd(lEndP), nId(nIdP), pMgr(pMgrP), pFreeMgr( nullptr ) { - RegisterDisplay(&aWndFunc); + ErrorRegistry::RegisterDisplay(&aWndFunc); if( ! pMgr ) { pMgr = ResMgr::CreateResMgr("ofa", Application::GetSettings().GetUILanguageTag() ); diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx index 9cf167aa8d58..12657ab6a188 100644 --- a/test/source/bootstrapfixture.cxx +++ b/test/source/bootstrapfixture.cxx @@ -65,7 +65,7 @@ void test_init_impl(bool bAssertOnDialog, bool bNeedUCB, lang::XMultiServiceFactory * pSFactory) { if (bAssertOnDialog) - ErrorHandler::RegisterDisplay( aBasicErrorFunc ); + ErrorRegistry::RegisterDisplay( aBasicErrorFunc ); // Make GraphicConverter work, normally done in desktop::Desktop::Main() Application::SetFilterHdl( diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx index fbef60953241..b6ed18d616c1 100644 --- a/vcl/source/window/errinf.cxx +++ b/vcl/source/window/errinf.cxx @@ -27,25 +27,14 @@ #include <limits.h> class ErrorHandler; +class TheErrorRegistry: public rtl::Static<ErrorRegistry, TheErrorRegistry> {}; -namespace { - typedef void (* DisplayFnPtr)(); -} - -struct ErrorRegistry +void ErrorRegistry::RegisterDisplay(WindowDisplayErrorFunc *aDsp) { -public: - std::vector<ErrorHandler*> errorHandlers; - std::vector<ErrorContext*> contexts; - DisplayFnPtr pDsp; - bool bIsWindowDsp; - - DynamicErrorInfo* ppDynErrInfo[ERRCODE_DYNAMIC_COUNT]; - sal_uInt16 nNextError; - ErrorRegistry(); -}; - -struct TheErrorRegistry: public rtl::Static<ErrorRegistry, TheErrorRegistry> {}; + ErrorRegistry &rData = TheErrorRegistry::get(); + rData.bIsWindowDsp = true; + rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); +} class DynamicErrorInfo_Impl { @@ -71,6 +60,13 @@ ErrorRegistry::ErrorRegistry() rp = nullptr; } +void ErrorRegistry::RegisterDisplay(BasicDisplayErrorFunc *aDsp) +{ + ErrorRegistry &rData = TheErrorRegistry::get(); + rData.bIsWindowDsp = false; + rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); +} + void DynamicErrorInfo_Impl::RegisterError(DynamicErrorInfo *pDynErrInfo) { // Register dynamic identifier @@ -194,7 +190,7 @@ ErrorHandler::ErrorHandler() rData.errorHandlers.insert(rData.errorHandlers.begin(), this); if(!rData.pDsp) - RegisterDisplay(&aDspFunc); + ErrorRegistry::RegisterDisplay(&aDspFunc); } ErrorHandler::~ErrorHandler() @@ -209,20 +205,6 @@ vcl::Window* ErrorContext::GetParent() return pImpl ? pImpl->pWin : nullptr; } -void ErrorHandler::RegisterDisplay(WindowDisplayErrorFunc *aDsp) -{ - ErrorRegistry &rData = TheErrorRegistry::get(); - rData.bIsWindowDsp = true; - rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); -} - -void ErrorHandler::RegisterDisplay(BasicDisplayErrorFunc *aDsp) -{ - ErrorRegistry &rData = TheErrorRegistry::get(); - rData.bIsWindowDsp = false; - rData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); -} - bool ErrorHandler::GetErrorString(sal_uInt32 nErrCodeId, OUString& rErrStr) { OUString aErr; |