[Libreoffice-commits] core.git: desktop/source include/vcl svtools/source test/source vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Thu Apr 27 06:12:57 UTC 2017


 desktop/source/lib/init.cxx      |    2 -
 include/vcl/errinf.hxx           |   47 ++++++++++++++++++++++++++++++++++-----
 svtools/source/misc/ehdl.cxx     |    2 -
 test/source/bootstrapfixture.cxx |    2 -
 vcl/source/window/errinf.cxx     |   46 +++++++++++---------------------------
 5 files changed, 59 insertions(+), 40 deletions(-)

New commits:
commit 201f05f9bf66d0467b1137f3712108a96c159698
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sun Apr 23 22:01:46 2017 +1000

    vcl: move RegisterDisplay() from ErrorHandler to ErrorRegistry
    
    It is the error registry that should register the display, not
    the error handler. Move this function to the class that is
    responsible for it.
    
    Change-Id: I95ca1662b907a7f38a42a39ec729b35fd530bb79
    Reviewed-on: https://gerrit.libreoffice.org/36853
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>

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;


More information about the Libreoffice-commits mailing list