From 3b85b72d643e26fd9fda5eeb05f774b3c37917fd Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Fri, 14 Apr 2017 15:29:06 +1000 Subject: errinf.hxx moved out of tools and into vcl module ErrorInfo has a hard depency on VCL, yet is in the tools package. It is more appropriate to have it reside in the VCL module. Change-Id: Ica54a46c3a7f86cf0331ed7245234bea69c05650 Reviewed-on: https://gerrit.libreoffice.org/36839 Reviewed-by: Chris Sherlock Tested-by: Chris Sherlock --- accessibility/inc/pch/precompiled_acc.hxx | 2 +- basctl/inc/pch/precompiled_basctl.hxx | 2 +- basic/source/basmgr/basmgr.cxx | 2 +- basic/source/classes/sb.cxx | 2 +- basic/source/uno/namecont.cxx | 2 +- chart2/inc/pch/precompiled_chartcontroller.hxx | 2 +- connectivity/inc/pch/precompiled_dbase.hxx | 2 +- connectivity/inc/pch/precompiled_file.hxx | 2 +- cppcanvas/inc/pch/precompiled_cppcanvas.hxx | 2 +- cui/inc/pch/precompiled_cui.hxx | 2 +- cui/source/dialogs/cuigaldlg.cxx | 2 +- dbaccess/inc/pch/precompiled_dba.hxx | 2 +- dbaccess/inc/pch/precompiled_dbmm.hxx | 2 +- dbaccess/source/filter/xml/xmlfilter.cxx | 2 +- desktop/inc/pch/precompiled_sofficeapp.hxx | 2 +- desktop/source/lib/init.cxx | 2 +- editeng/source/misc/splwrap.cxx | 2 +- forms/inc/pch/precompiled_frm.hxx | 2 +- fpicker/source/office/RemoteFilesDialog.hxx | 2 +- framework/inc/pch/precompiled_fwe.hxx | 2 +- framework/inc/pch/precompiled_fwi.hxx | 2 +- framework/inc/pch/precompiled_fwk.hxx | 2 +- framework/inc/pch/precompiled_fwl.hxx | 2 +- framework/source/interaction/quietinteraction.cxx | 2 +- framework/source/services/desktop.cxx | 2 +- include/basic/basmgr.hxx | 2 +- include/svtools/ehdl.hxx | 2 +- include/tools/errinf.hxx | 177 ----------- include/vcl/errinf.hxx | 176 +++++++++++ oox/inc/pch/precompiled_oox.hxx | 2 +- reportdesign/inc/pch/precompiled_rpt.hxx | 2 +- reportdesign/inc/pch/precompiled_rptui.hxx | 2 +- reportdesign/source/filter/xml/xmlfilter.cxx | 2 +- sc/inc/pch/precompiled_sc.hxx | 2 +- sc/inc/pch/precompiled_scfilt.hxx | 2 +- sc/source/filter/xml/xmlwrap.cxx | 2 +- sc/source/ui/docshell/dbdocimp.cxx | 2 +- sc/source/ui/docshell/docsh.cxx | 2 +- sc/source/ui/docshell/docsh8.cxx | 2 +- sc/source/ui/view/tabvwshb.cxx | 2 +- sd/inc/pch/precompiled_sdui.hxx | 2 +- sd/inc/sdgrffilter.hxx | 2 +- sd/source/filter/grf/sdgrffilter.cxx | 2 +- sd/source/filter/html/sdhtmlfilter.cxx | 2 +- sd/source/filter/xml/sdxmlwrp.cxx | 2 +- sd/source/ui/app/sdmod1.cxx | 2 +- slideshow/inc/pch/precompiled_slideshow.hxx | 2 +- sot/inc/pch/precompiled_sot.hxx | 2 +- svx/source/dialog/imapdlg.cxx | 2 +- sw/inc/pch/precompiled_msword.hxx | 2 +- sw/inc/pch/precompiled_swui.hxx | 2 +- sw/inc/pch/precompiled_vbaswobj.hxx | 2 +- sw/source/core/frmedt/fetab.cxx | 2 +- sw/source/filter/html/swhtml.cxx | 2 +- sw/source/filter/xml/swxml.cxx | 2 +- sw/source/filter/xml/wrtxml.cxx | 2 +- sw/source/uibase/dbui/dbmgr.cxx | 2 +- sw/source/uibase/dochdl/gloshdl.cxx | 2 +- sw/source/uibase/misc/glosdoc.cxx | 2 +- sw/source/uibase/shells/textsh.cxx | 2 +- sw/source/uibase/uiview/srcview.cxx | 2 +- sw/source/uibase/uiview/view2.cxx | 2 +- test/source/bootstrapfixture.cxx | 2 +- tools/Library_tl.mk | 1 - tools/source/ref/errinf.cxx | 350 ---------------------- unotools/inc/pch/precompiled_utl.hxx | 2 +- uui/source/iahndl-authentication.cxx | 2 +- uui/source/iahndl-errorhandler.cxx | 2 +- uui/source/iahndl.cxx | 2 +- vbahelper/inc/pch/precompiled_msforms.hxx | 2 +- vcl/Library_vcl.mk | 1 + vcl/source/window/errinf.cxx | 350 ++++++++++++++++++++++ xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx | 2 +- 73 files changed, 594 insertions(+), 595 deletions(-) delete mode 100644 include/tools/errinf.hxx create mode 100644 include/vcl/errinf.hxx delete mode 100644 tools/source/ref/errinf.cxx create mode 100644 vcl/source/window/errinf.cxx diff --git a/accessibility/inc/pch/precompiled_acc.hxx b/accessibility/inc/pch/precompiled_acc.hxx index deb737656f1f..a6a92876ada5 100644 --- a/accessibility/inc/pch/precompiled_acc.hxx +++ b/accessibility/inc/pch/precompiled_acc.hxx @@ -308,7 +308,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/basctl/inc/pch/precompiled_basctl.hxx b/basctl/inc/pch/precompiled_basctl.hxx index f51bd722a4f4..802637ccf100 100644 --- a/basctl/inc/pch/precompiled_basctl.hxx +++ b/basctl/inc/pch/precompiled_basctl.hxx @@ -534,7 +534,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index dc09a8ba8908..97b5125f5367 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include #include #include #include diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 4f55047944b4..ac8bf7f56d87 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index a2bb84a8bcd2..3e5af6eed373 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx index 80a8c3b6cfa8..307469471f21 100644 --- a/chart2/inc/pch/precompiled_chartcontroller.hxx +++ b/chart2/inc/pch/precompiled_chartcontroller.hxx @@ -486,7 +486,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/connectivity/inc/pch/precompiled_dbase.hxx b/connectivity/inc/pch/precompiled_dbase.hxx index b1913e0770d6..abc2e6592240 100644 --- a/connectivity/inc/pch/precompiled_dbase.hxx +++ b/connectivity/inc/pch/precompiled_dbase.hxx @@ -184,7 +184,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/connectivity/inc/pch/precompiled_file.hxx b/connectivity/inc/pch/precompiled_file.hxx index 27c9e522fd38..bcbee91e5301 100644 --- a/connectivity/inc/pch/precompiled_file.hxx +++ b/connectivity/inc/pch/precompiled_file.hxx @@ -166,7 +166,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx index d78d9e0ed0da..d1f4b7ba9cc6 100644 --- a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx +++ b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx @@ -187,7 +187,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index e3f729574910..ee57ed708cb2 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -447,7 +447,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index 4836affd4156..fd6bd4b6b59b 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/dbaccess/inc/pch/precompiled_dba.hxx b/dbaccess/inc/pch/precompiled_dba.hxx index 9b6a07eb3a1b..157f1eef9530 100644 --- a/dbaccess/inc/pch/precompiled_dba.hxx +++ b/dbaccess/inc/pch/precompiled_dba.hxx @@ -269,7 +269,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dbaccess/inc/pch/precompiled_dbmm.hxx b/dbaccess/inc/pch/precompiled_dbmm.hxx index 6415c84daf91..cf33574c33d1 100644 --- a/dbaccess/inc/pch/precompiled_dbmm.hxx +++ b/dbaccess/inc/pch/precompiled_dbmm.hxx @@ -195,7 +195,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 0ff1a3d2fefe..d84704722eee 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -19,7 +19,7 @@ #include -#include +#include #include #include #include diff --git a/desktop/inc/pch/precompiled_sofficeapp.hxx b/desktop/inc/pch/precompiled_sofficeapp.hxx index 057b8d98cd3e..95a52227dd26 100644 --- a/desktop/inc/pch/precompiled_sofficeapp.hxx +++ b/desktop/inc/pch/precompiled_sofficeapp.hxx @@ -238,7 +238,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 8e5e89d0dbad..8f350cd61d46 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/editeng/source/misc/splwrap.cxx b/editeng/source/misc/splwrap.cxx index 7c7169a9a53f..56024f280610 100644 --- a/editeng/source/misc/splwrap.cxx +++ b/editeng/source/misc/splwrap.cxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/forms/inc/pch/precompiled_frm.hxx b/forms/inc/pch/precompiled_frm.hxx index fbd0675dede4..2b8955ae8f16 100644 --- a/forms/inc/pch/precompiled_frm.hxx +++ b/forms/inc/pch/precompiled_frm.hxx @@ -250,7 +250,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx index ab8b8131bf6b..08907f95ce29 100644 --- a/fpicker/source/office/RemoteFilesDialog.hxx +++ b/fpicker/source/office/RemoteFilesDialog.hxx @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/framework/inc/pch/precompiled_fwe.hxx b/framework/inc/pch/precompiled_fwe.hxx index 7db2f996160c..a87d4036c208 100644 --- a/framework/inc/pch/precompiled_fwe.hxx +++ b/framework/inc/pch/precompiled_fwe.hxx @@ -209,7 +209,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/inc/pch/precompiled_fwi.hxx b/framework/inc/pch/precompiled_fwi.hxx index d907b87357d4..df8b9eb8fc01 100644 --- a/framework/inc/pch/precompiled_fwi.hxx +++ b/framework/inc/pch/precompiled_fwi.hxx @@ -150,7 +150,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx index 9ba34417bab8..971763caef8b 100644 --- a/framework/inc/pch/precompiled_fwk.hxx +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -335,7 +335,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/inc/pch/precompiled_fwl.hxx b/framework/inc/pch/precompiled_fwl.hxx index b753e93bd239..3529522da173 100644 --- a/framework/inc/pch/precompiled_fwl.hxx +++ b/framework/inc/pch/precompiled_fwl.hxx @@ -317,7 +317,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/source/interaction/quietinteraction.cxx b/framework/source/interaction/quietinteraction.cxx index f59c2d1d33aa..0d2a7fb2f78d 100644 --- a/framework/source/interaction/quietinteraction.cxx +++ b/framework/source/interaction/quietinteraction.cxx @@ -30,7 +30,7 @@ #include -#include +#include namespace framework{ diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 7463dfc940c1..477f166d3b41 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -67,7 +67,7 @@ #include #include -#include +#include #include #include diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx index 13ad654ff3ed..db074cb54d86 100644 --- a/include/basic/basmgr.hxx +++ b/include/basic/basmgr.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_BASIC_BASMGR_HXX #define INCLUDED_BASIC_BASMGR_HXX -#include +#include #include #include #include diff --git a/include/svtools/ehdl.hxx b/include/svtools/ehdl.hxx index bb8e83b7677f..183121851e9c 100644 --- a/include/svtools/ehdl.hxx +++ b/include/svtools/ehdl.hxx @@ -25,7 +25,7 @@ #include #include -#include +#include namespace vcl { class Window; } class ResMgr; diff --git a/include/tools/errinf.hxx b/include/tools/errinf.hxx deleted file mode 100644 index 0cd64efa33f2..000000000000 --- a/include/tools/errinf.hxx +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef __RSC - -#ifndef INCLUDED_TOOLS_ERRINF_HXX -#define INCLUDED_TOOLS_ERRINF_HXX - -#include -#include -#include -#include -#include -#include - -// FIXME: horrible legacy dependency on VCL from tools. -namespace vcl { class Window; } - -class DynamicErrorInfo_Impl; -class ErrorHandler_Impl; - -enum class ErrorHandlerFlags -{ - NONE = 0x0000, - ButtonsOk = 0x0001, - ButtonsCancel = 0x0002, - ButtonsRetry = 0x0004, - ButtonsOkCancel = 0x0003, - ButtonsNo = 0x0008, - ButtonsYes = 0x0010, - ButtonsYesNo = 0x0018, - ButtonsYesNoCancel = 0x001a, - - ButtonDefaultsOk = 0x0100, - ButtonDefaultsCancel = 0x0200, - ButtonDefaultsYes = 0x0300, - ButtonDefaultsNo = 0x0400, - - MessageError = 0x1000, - MessageWarning = 0x2000, - MessageInfo = 0x3000, - - MAX = USHRT_MAX, -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - -class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ErrorInfo -{ -private: - sal_uIntPtr lUserId; - -public: - - ErrorInfo( sal_uIntPtr lArgUserId ) : - lUserId( lArgUserId ){} - virtual ~ErrorInfo(); - - sal_uIntPtr GetErrorCode() const { return lUserId; } - - static ErrorInfo* GetErrorInfo(sal_uIntPtr); -}; - -class SAL_WARN_UNUSED TOOLS_DLLPUBLIC DynamicErrorInfo : public ErrorInfo -{ - friend class DynamicErrorInfo_Impl; - -private: - std::unique_ptr pImpl; - -public: - - DynamicErrorInfo(sal_uIntPtr lUserId, ErrorHandlerFlags nMask); - virtual ~DynamicErrorInfo() override; - - operator sal_uIntPtr() const; - ErrorHandlerFlags GetDialogMask() const; -}; - -class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo -{ -private: - OUString aString; - -public: - - StringErrorInfo( sal_uIntPtr lUserId, - const OUString& aStringP, - ErrorHandlerFlags nMask = ErrorHandlerFlags::NONE); - const OUString& GetErrorString() const { return aString; } -}; - -class SAL_WARN_UNUSED TOOLS_DLLPUBLIC TwoStringErrorInfo: public DynamicErrorInfo -{ -private: - OUString aArg1; - OUString aArg2; - -public: - - TwoStringErrorInfo(sal_uIntPtr nUserID, const OUString & rTheArg1, - const OUString & rTheArg2, ErrorHandlerFlags nMask): - DynamicErrorInfo(nUserID, nMask), aArg1(rTheArg1), aArg2(rTheArg2) {} - - const OUString& GetArg1() const { return aArg1; } - const OUString& GetArg2() const { return aArg2; } -}; - -struct ErrorContextImpl; -class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ErrorContext -{ - friend class ErrorHandler; - -private: - std::unique_ptr pImpl; - -public: - ErrorContext(vcl::Window *pWin); - virtual ~ErrorContext(); - - virtual bool GetString( sal_uIntPtr nErrId, OUString& rCtxStr ) = 0; - vcl::Window* GetParent(); - - static ErrorContext* GetContext(); -}; - -typedef ErrorHandlerFlags WindowDisplayErrorFunc( - vcl::Window *, ErrorHandlerFlags nMask, const OUString &rErr, const OUString &rAction); - -typedef void BasicDisplayErrorFunc( - const OUString &rErr, const OUString &rAction); - -class SAL_WARN_UNUSED TOOLS_DLLPUBLIC ErrorHandler -{ - friend class ErrorHandler_Impl; - -private: - static ErrorHandlerFlags HandleError_Impl( sal_uIntPtr lId, - ErrorHandlerFlags nFlags, - bool bJustCreateString, - OUString & rError); -protected: - virtual bool CreateString(const ErrorInfo *, OUString &) const = 0; - -public: - ErrorHandler(); - virtual ~ErrorHandler(); - - static ErrorHandlerFlags HandleError ( sal_uIntPtr lId, ErrorHandlerFlags nMask = ErrorHandlerFlags::MAX ); - static bool GetErrorString( sal_uIntPtr lId, OUString& rStr ); - - static void RegisterDisplay( BasicDisplayErrorFunc* ); - static void RegisterDisplay( WindowDisplayErrorFunc* ); -}; - -#endif -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx new file mode 100644 index 000000000000..68e5f08e0840 --- /dev/null +++ b/include/vcl/errinf.hxx @@ -0,0 +1,176 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef __RSC + +#ifndef INCLUDED_VCL_ERRINF_HXX +#define INCLUDED_VCL_ERRINF_HXX + +#include +#include +#include +#include +#include +#include + +namespace vcl { class Window; } + +class DynamicErrorInfo_Impl; +class ErrorHandler_Impl; + +enum class ErrorHandlerFlags +{ + NONE = 0x0000, + ButtonsOk = 0x0001, + ButtonsCancel = 0x0002, + ButtonsRetry = 0x0004, + ButtonsOkCancel = 0x0003, + ButtonsNo = 0x0008, + ButtonsYes = 0x0010, + ButtonsYesNo = 0x0018, + ButtonsYesNoCancel = 0x001a, + + ButtonDefaultsOk = 0x0100, + ButtonDefaultsCancel = 0x0200, + ButtonDefaultsYes = 0x0300, + ButtonDefaultsNo = 0x0400, + + MessageError = 0x1000, + MessageWarning = 0x2000, + MessageInfo = 0x3000, + + MAX = USHRT_MAX, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorInfo +{ +private: + sal_uIntPtr lUserId; + +public: + + ErrorInfo( sal_uIntPtr lArgUserId ) : + lUserId( lArgUserId ){} + virtual ~ErrorInfo(); + + sal_uIntPtr GetErrorCode() const { return lUserId; } + + static ErrorInfo* GetErrorInfo(sal_uIntPtr); +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC DynamicErrorInfo : public ErrorInfo +{ + friend class DynamicErrorInfo_Impl; + +private: + std::unique_ptr pImpl; + +public: + + DynamicErrorInfo(sal_uIntPtr lUserId, ErrorHandlerFlags nMask); + virtual ~DynamicErrorInfo() override; + + operator sal_uIntPtr() const; + ErrorHandlerFlags GetDialogMask() const; +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo +{ +private: + OUString aString; + +public: + + StringErrorInfo( sal_uIntPtr lUserId, + const OUString& aStringP, + ErrorHandlerFlags nMask = ErrorHandlerFlags::NONE); + const OUString& GetErrorString() const { return aString; } +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC TwoStringErrorInfo: public DynamicErrorInfo +{ +private: + OUString aArg1; + OUString aArg2; + +public: + + TwoStringErrorInfo(sal_uIntPtr nUserID, const OUString & rTheArg1, + const OUString & rTheArg2, ErrorHandlerFlags nMask): + DynamicErrorInfo(nUserID, nMask), aArg1(rTheArg1), aArg2(rTheArg2) {} + + const OUString& GetArg1() const { return aArg1; } + const OUString& GetArg2() const { return aArg2; } +}; + +struct ErrorContextImpl; +class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorContext +{ + friend class ErrorHandler; + +private: + std::unique_ptr pImpl; + +public: + ErrorContext(vcl::Window *pWin); + virtual ~ErrorContext(); + + virtual bool GetString( sal_uIntPtr nErrId, OUString& rCtxStr ) = 0; + vcl::Window* GetParent(); + + static ErrorContext* GetContext(); +}; + +typedef ErrorHandlerFlags WindowDisplayErrorFunc( + vcl::Window *, ErrorHandlerFlags nMask, const OUString &rErr, const OUString &rAction); + +typedef void BasicDisplayErrorFunc( + const OUString &rErr, const OUString &rAction); + +class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorHandler +{ + friend class ErrorHandler_Impl; + +private: + static ErrorHandlerFlags HandleError_Impl( sal_uIntPtr lId, + ErrorHandlerFlags nFlags, + bool bJustCreateString, + OUString & rError); +protected: + virtual bool CreateString(const ErrorInfo *, OUString &) const = 0; + +public: + ErrorHandler(); + virtual ~ErrorHandler(); + + static ErrorHandlerFlags HandleError ( sal_uIntPtr lId, ErrorHandlerFlags nMask = ErrorHandlerFlags::MAX ); + static bool GetErrorString( sal_uIntPtr lId, OUString& rStr ); + + static void RegisterDisplay( BasicDisplayErrorFunc* ); + static void RegisterDisplay( WindowDisplayErrorFunc* ); +}; + +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/pch/precompiled_oox.hxx b/oox/inc/pch/precompiled_oox.hxx index 5949c9f9ec18..fc5b43d7cbc8 100644 --- a/oox/inc/pch/precompiled_oox.hxx +++ b/oox/inc/pch/precompiled_oox.hxx @@ -188,7 +188,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/reportdesign/inc/pch/precompiled_rpt.hxx b/reportdesign/inc/pch/precompiled_rpt.hxx index 3be45770a7b0..9919e30508f5 100644 --- a/reportdesign/inc/pch/precompiled_rpt.hxx +++ b/reportdesign/inc/pch/precompiled_rpt.hxx @@ -308,7 +308,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx b/reportdesign/inc/pch/precompiled_rptui.hxx index b5021b26cebf..9a64847835ab 100644 --- a/reportdesign/inc/pch/precompiled_rptui.hxx +++ b/reportdesign/inc/pch/precompiled_rptui.hxx @@ -515,7 +515,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx index 3f513db3de59..2017a2ae8466 100644 --- a/reportdesign/source/filter/xml/xmlfilter.cxx +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -29,7 +29,7 @@ #include "xmlfilter.hxx" #include "xmlGroup.hxx" #include "xmlReport.hxx" -#include +#include #include "xmlHelper.hxx" #include #include diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index 7770a480f558..8b3fb3ce1780 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -553,7 +553,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sc/inc/pch/precompiled_scfilt.hxx b/sc/inc/pch/precompiled_scfilt.hxx index 9048a2cca156..b67942852e14 100644 --- a/sc/inc/pch/precompiled_scfilt.hxx +++ b/sc/inc/pch/precompiled_scfilt.hxx @@ -283,7 +283,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index abe9593f521d..5805a6e0498c 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include #include #include #include diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index c4310abf8b84..69ffd28bc62e 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include #include #include #include diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 3497ade75ec0..bfb3edd65290 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -20,7 +20,7 @@ #include "docsh.hxx" #include "scitems.hxx" -#include +#include #include #include #include diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 28a1be9b246e..586f48e3967a 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -19,7 +19,7 @@ #include -#include +#include #include #include #include diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index fa0f91a0b61c..a1b196d6e0dc 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx index 66e2a70b3755..92fbc46c0855 100644 --- a/sd/inc/pch/precompiled_sdui.hxx +++ b/sd/inc/pch/precompiled_sdui.hxx @@ -488,7 +488,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sd/inc/sdgrffilter.hxx b/sd/inc/sdgrffilter.hxx index c725173c5dfa..fdd2bc04f6cd 100644 --- a/sd/inc/sdgrffilter.hxx +++ b/sd/inc/sdgrffilter.hxx @@ -22,7 +22,7 @@ #include -#include +#include #include "sdfilter.hxx" // SdCGMFilter diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx index c1941ec2be74..8a22c88e46bb 100644 --- a/sd/source/filter/grf/sdgrffilter.cxx +++ b/sd/source/filter/grf/sdgrffilter.cxx @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/sd/source/filter/html/sdhtmlfilter.cxx b/sd/source/filter/html/sdhtmlfilter.cxx index ac59c38f6a59..67782dbae73d 100644 --- a/sd/source/filter/html/sdhtmlfilter.cxx +++ b/sd/source/filter/html/sdhtmlfilter.cxx @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx index 02a0dbeb3f5d..4f12e3702ed2 100644 --- a/sd/source/filter/xml/sdxmlwrp.cxx +++ b/sd/source/filter/xml/sdxmlwrp.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include #include #include #include diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx index 98f129f7d934..f90d50d5824d 100644 --- a/sd/source/ui/app/sdmod1.cxx +++ b/sd/source/ui/app/sdmod1.cxx @@ -24,7 +24,7 @@ #include "framework/FrameworkHelper.hxx" #include -#include +#include #include #include #include diff --git a/slideshow/inc/pch/precompiled_slideshow.hxx b/slideshow/inc/pch/precompiled_slideshow.hxx index e4884ee250ba..c281f02ed9f4 100644 --- a/slideshow/inc/pch/precompiled_slideshow.hxx +++ b/slideshow/inc/pch/precompiled_slideshow.hxx @@ -233,7 +233,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sot/inc/pch/precompiled_sot.hxx b/sot/inc/pch/precompiled_sot.hxx index 9c446888395e..6d693ba3901c 100644 --- a/sot/inc/pch/precompiled_sot.hxx +++ b/sot/inc/pch/precompiled_sot.hxx @@ -64,7 +64,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx index dcd1e5242e95..94fbd4454a7f 100644 --- a/svx/source/dialog/imapdlg.cxx +++ b/svx/source/dialog/imapdlg.cxx @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx index bb4ba923e5ba..4fd868e00650 100644 --- a/sw/inc/pch/precompiled_msword.hxx +++ b/sw/inc/pch/precompiled_msword.hxx @@ -636,7 +636,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/inc/pch/precompiled_swui.hxx b/sw/inc/pch/precompiled_swui.hxx index 2d586e6944b8..41e348d5e594 100644 --- a/sw/inc/pch/precompiled_swui.hxx +++ b/sw/inc/pch/precompiled_swui.hxx @@ -567,7 +567,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index f8965404cbc6..7fbd51c7b477 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -365,7 +365,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 6bcae1c5d65d..cafafbbaeac2 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 9624e4ab9108..d77eee22f65f 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -32,7 +32,7 @@ #endif #include -#include +#include #include #include #include diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index d899db80c4e8..a61948552c06 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 3086a86b05f2..7e3658adacb1 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 52f9e023c440..1012e1896598 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index 2d5d3718ecb5..75c0c9eea027 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index 13e50027b2e3..42a7d5b0bddd 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -23,7 +23,7 @@ #include -#include +#include #include #include #include diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 4ea1a236a19a..4647ca0edcd7 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 550ae169e88a..6c1629bb9205 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 63dd947d3da3..4d3a3e56335e 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx index c97c0ceed535..9cf167aa8d58 100644 --- a/test/source/bootstrapfixture.cxx +++ b/test/source/bootstrapfixture.cxx @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk index e774ffc18f0a..04231aaed139 100644 --- a/tools/Library_tl.mk +++ b/tools/Library_tl.mk @@ -73,7 +73,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\ tools/source/rc/rc \ tools/source/rc/resary \ tools/source/rc/resmgr \ - tools/source/ref/errinf \ tools/source/ref/globname \ tools/source/ref/pstm \ tools/source/ref/ref \ diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx deleted file mode 100644 index ab304e961461..000000000000 --- a/tools/source/ref/errinf.cxx +++ /dev/null @@ -1,350 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include -#include -#include -#include -#include - -class ErrorHandler; - -namespace { - typedef void (* DisplayFnPtr)(); -} - -struct ErrorRegistry -{ -public: - std::vector errorHandlers; - std::vector contexts; - DisplayFnPtr pDsp; - bool bIsWindowDsp; - - DynamicErrorInfo* ppDynErrInfo[ERRCODE_DYNAMIC_COUNT]; - sal_uInt16 nNextDcr; - ErrorRegistry(); -}; - -struct TheErrorRegistry: public rtl::Static {}; - -class DynamicErrorInfo_Impl -{ - ErrCode lErrId; - ErrorHandlerFlags nMask; - - void RegisterEDcr(DynamicErrorInfo *); - static void UnRegisterEDcr(DynamicErrorInfo const *); - static ErrorInfo* GetDynamicErrorInfo(sal_uIntPtr lId); - -friend class DynamicErrorInfo; -friend class ErrorInfo; -}; - -ErrorRegistry::ErrorRegistry() - : pDsp(nullptr) - , bIsWindowDsp(false) - , nNextDcr(0) -{ - for(DynamicErrorInfo*& rp : ppDynErrInfo) - rp = nullptr; -} - -void DynamicErrorInfo_Impl::RegisterEDcr(DynamicErrorInfo *pDynErrInfo) -{ - // Register dynamic identifier - ErrorRegistry& rData = TheErrorRegistry::get(); - lErrId = (((sal_uIntPtr)rData.nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) + - pDynErrInfo->GetErrorCode(); - - if(rData.ppDynErrInfo[rData.nNextDcr]) - { - delete rData.ppDynErrInfo[rData.nNextDcr]; - } - rData.ppDynErrInfo[rData.nNextDcr] = pDynErrInfo; - if(++rData.nNextDcr>=ERRCODE_DYNAMIC_COUNT) - rData.nNextDcr=0; -} - -void DynamicErrorInfo_Impl::UnRegisterEDcr(DynamicErrorInfo const *pDynErrInfo) -{ - DynamicErrorInfo **ppDynErrInfo = TheErrorRegistry::get().ppDynErrInfo; - sal_uIntPtr lIdx = (((sal_uIntPtr)(*pDynErrInfo) & ERRCODE_DYNAMIC_MASK) >> ERRCODE_DYNAMIC_SHIFT) - 1; - DBG_ASSERT(ppDynErrInfo[lIdx]==pDynErrInfo,"ErrHdl: Error not found"); - if(ppDynErrInfo[lIdx]==pDynErrInfo) - ppDynErrInfo[lIdx]=nullptr; -} - -ErrorInfo::~ErrorInfo() -{ -} - - -ErrorInfo *ErrorInfo::GetErrorInfo(sal_uIntPtr lId) -{ - if(lId & ERRCODE_DYNAMIC_MASK) - return DynamicErrorInfo_Impl::GetDynamicErrorInfo(lId); - else - return new ErrorInfo(lId); -} - -DynamicErrorInfo::operator sal_uIntPtr() const -{ - return pImpl->lErrId; -} - -DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr lArgUserId, ErrorHandlerFlags nMask) -: ErrorInfo(lArgUserId), - pImpl(new DynamicErrorInfo_Impl) -{ - pImpl->RegisterEDcr(this); - pImpl->nMask=nMask; -} - -DynamicErrorInfo::~DynamicErrorInfo() -{ - DynamicErrorInfo_Impl::UnRegisterEDcr(this); -} - -ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uIntPtr lId) -{ - sal_uIntPtr lIdx = ((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1; - DynamicErrorInfo* pDynErrInfo = TheErrorRegistry::get().ppDynErrInfo[lIdx]; - if(pDynErrInfo && (sal_uIntPtr)(*pDynErrInfo)==lId) - return pDynErrInfo; - else - return new ErrorInfo(lId & ~ERRCODE_DYNAMIC_MASK); -} - -ErrorHandlerFlags DynamicErrorInfo::GetDialogMask() const -{ - return pImpl->nMask; -} - -StringErrorInfo::StringErrorInfo( - sal_uIntPtr UserId, const OUString& aStringP, ErrorHandlerFlags nMask) -: DynamicErrorInfo(UserId, nMask), aString(aStringP) -{ -} - -class ErrorHandler_Impl -{ -public: - static bool CreateString(const ErrorInfo*, OUString&); -}; - -static void aDspFunc(const OUString &rErr, const OUString &rAction) -{ - OStringBuffer aErr("Action: "); - aErr.append(OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US)); - aErr.append(" Error: "); - aErr.append(OUStringToOString(rErr, RTL_TEXTENCODING_ASCII_US)); - OSL_FAIL(aErr.getStr()); -} - -// FIXME: this is a horrible reverse dependency on VCL -struct ErrorContextImpl -{ - vcl::Window *pWin; // 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(); - rData.errorHandlers.insert(rData.errorHandlers.begin(), this); - if(!rData.pDsp) - RegisterDisplay(&aDspFunc); -} - -ErrorHandler::~ErrorHandler() -{ - auto &rErrorHandlers = TheErrorRegistry::get().errorHandlers; - rErrorHandlers.erase( ::std::remove(rErrorHandlers.begin(), rErrorHandlers.end(), this), rErrorHandlers.end()); -} - -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); -} - -/** Handles an error. - - If nFlags is not set, the DynamicErrorInfo flags or the - resource flags will be used. - Thus: - - 1. nFlags, - 2. Resource Flags - 3. Dynamic Flags - 4. Default ButtonsOk, MessageError - - @param nErrCodeId error id - @param nFlags error flags. - @param bJustCreateString ??? - @param rError ??? - - @return ??? -*/ -ErrorHandlerFlags ErrorHandler::HandleError_Impl( - sal_uIntPtr nErrCodeId, ErrorHandlerFlags nFlags, bool bJustCreateString, OUString & rError) -{ - OUString aErr; - OUString aAction; - if(!nErrCodeId || nErrCodeId == ERRCODE_ABORT) - return ErrorHandlerFlags::NONE; - ErrorRegistry &rData = TheErrorRegistry::get(); - vcl::Window *pParent = nullptr; - ErrorInfo *pInfo = ErrorInfo::GetErrorInfo(nErrCodeId); - if (!rData.contexts.empty()) - { - rData.contexts.front()->GetString(pInfo->GetErrorCode(), aAction); - // Remove parent from context - for(ErrorContext *pCtx : rData.contexts) - if(pCtx->GetParent()) - { - pParent=pCtx->GetParent(); - break; - } - } - - bool bWarning = ((nErrCodeId & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK); - ErrorHandlerFlags nErrFlags = ErrorHandlerFlags::ButtonDefaultsOk | ErrorHandlerFlags::ButtonsOk; - if (bWarning) - nErrFlags |= ErrorHandlerFlags::MessageWarning; - else - nErrFlags |= ErrorHandlerFlags::MessageError; - - DynamicErrorInfo* pDynPtr=dynamic_cast(pInfo); - if(pDynPtr) - { - ErrorHandlerFlags nDynFlags = pDynPtr->GetDialogMask(); - if( nDynFlags != ErrorHandlerFlags::NONE ) - nErrFlags = nDynFlags; - } - - if(ErrorHandler_Impl::CreateString(pInfo,aErr)) - { - if (bJustCreateString) - { - rError = aErr; - return ErrorHandlerFlags::ButtonsOk; - } - else - { - if(!rData.pDsp) - { - OStringBuffer aStr("Action: "); - aStr.append(OUStringToOString(aAction, RTL_TEXTENCODING_ASCII_US)); - aStr.append("\nFehler: "); - aStr.append(OUStringToOString(aErr, RTL_TEXTENCODING_ASCII_US)); - OSL_FAIL(aStr.getStr()); - } - else - { - delete pInfo; - if(!rData.bIsWindowDsp) - { - (*reinterpret_cast(rData.pDsp))(aErr,aAction); - return ErrorHandlerFlags::NONE; - } - else - { - if (nFlags != ErrorHandlerFlags::MAX) - nErrFlags = nFlags; - return (*reinterpret_cast(rData.pDsp))( - pParent, nErrFlags, aErr, aAction); - } - } - } - } - OSL_FAIL("Error not handled"); - // Error 1 is General Error in the Sfx - if(pInfo->GetErrorCode()!=1) - { - HandleError_Impl(1, ErrorHandlerFlags::MAX, bJustCreateString, rError); - } - else - { - OSL_FAIL("Error 1 not handled"); - } - delete pInfo; - return ErrorHandlerFlags::NONE; -} - -// static -bool ErrorHandler::GetErrorString(sal_uIntPtr lId, OUString& rStr) -{ - return HandleError_Impl( lId, ErrorHandlerFlags::MAX, true, rStr ) != ErrorHandlerFlags::NONE; -} - -/** Handles an error. - - @see ErrorHandler::HandleError_Impl -*/ -ErrorHandlerFlags ErrorHandler::HandleError(sal_uIntPtr lId, ErrorHandlerFlags nFlags) -{ - OUString aDummy; - return HandleError_Impl( lId, nFlags, false, aDummy ); -} - -bool ErrorHandler_Impl::CreateString(const ErrorInfo* pInfo, OUString& rStr) -{ - for(const ErrorHandler *pHdl : TheErrorRegistry::get().errorHandlers) - { - if(pHdl->CreateString(pInfo, rStr)) - return true; - } - return false; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/inc/pch/precompiled_utl.hxx b/unotools/inc/pch/precompiled_utl.hxx index 97ed1b6d5777..7d191ccf7912 100644 --- a/unotools/inc/pch/precompiled_utl.hxx +++ b/unotools/inc/pch/precompiled_utl.hxx @@ -130,7 +130,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 3370030d81c5..11b1062dbc08 100644 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/uui/source/iahndl-errorhandler.cxx b/uui/source/iahndl-errorhandler.cxx index a549cc2a4e7b..d9a3d2ab8c6c 100644 --- a/uui/source/iahndl-errorhandler.cxx +++ b/uui/source/iahndl-errorhandler.cxx @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index f8a1efd0af3e..c1049894d200 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -62,7 +62,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/vbahelper/inc/pch/precompiled_msforms.hxx b/vbahelper/inc/pch/precompiled_msforms.hxx index b8596a418a1b..068c9a33adc4 100644 --- a/vbahelper/inc/pch/precompiled_msforms.hxx +++ b/vbahelper/inc/pch/precompiled_msforms.hxx @@ -314,7 +314,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 9fefd4e25de5..a0113a2e85d4 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -131,6 +131,7 @@ $(eval $(call gb_Library_use_externals,vcl,\ endif $(eval $(call gb_Library_add_exception_objects,vcl,\ + vcl/source/window/errinf \ vcl/source/window/settings \ vcl/source/window/paint \ vcl/source/window/abstdlg \ diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx new file mode 100644 index 000000000000..cfe44da63c2f --- /dev/null +++ b/vcl/source/window/errinf.cxx @@ -0,0 +1,350 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include + +class ErrorHandler; + +namespace { + typedef void (* DisplayFnPtr)(); +} + +struct ErrorRegistry +{ +public: + std::vector errorHandlers; + std::vector contexts; + DisplayFnPtr pDsp; + bool bIsWindowDsp; + + DynamicErrorInfo* ppDynErrInfo[ERRCODE_DYNAMIC_COUNT]; + sal_uInt16 nNextDcr; + ErrorRegistry(); +}; + +struct TheErrorRegistry: public rtl::Static {}; + +class DynamicErrorInfo_Impl +{ + ErrCode lErrId; + ErrorHandlerFlags nMask; + + void RegisterEDcr(DynamicErrorInfo *); + static void UnRegisterEDcr(DynamicErrorInfo const *); + static ErrorInfo* GetDynamicErrorInfo(sal_uIntPtr lId); + +friend class DynamicErrorInfo; +friend class ErrorInfo; +}; + +ErrorRegistry::ErrorRegistry() + : pDsp(nullptr) + , bIsWindowDsp(false) + , nNextDcr(0) +{ + for(DynamicErrorInfo*& rp : ppDynErrInfo) + rp = nullptr; +} + +void DynamicErrorInfo_Impl::RegisterEDcr(DynamicErrorInfo *pDynErrInfo) +{ + // Register dynamic identifier + ErrorRegistry& rData = TheErrorRegistry::get(); + lErrId = (((sal_uIntPtr)rData.nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) + + pDynErrInfo->GetErrorCode(); + + if(rData.ppDynErrInfo[rData.nNextDcr]) + { + delete rData.ppDynErrInfo[rData.nNextDcr]; + } + rData.ppDynErrInfo[rData.nNextDcr] = pDynErrInfo; + if(++rData.nNextDcr>=ERRCODE_DYNAMIC_COUNT) + rData.nNextDcr=0; +} + +void DynamicErrorInfo_Impl::UnRegisterEDcr(DynamicErrorInfo const *pDynErrInfo) +{ + DynamicErrorInfo **ppDynErrInfo = TheErrorRegistry::get().ppDynErrInfo; + sal_uIntPtr lIdx = (((sal_uIntPtr)(*pDynErrInfo) & ERRCODE_DYNAMIC_MASK) >> ERRCODE_DYNAMIC_SHIFT) - 1; + DBG_ASSERT(ppDynErrInfo[lIdx]==pDynErrInfo, "ErrHdl: Error not found"); + if(ppDynErrInfo[lIdx]==pDynErrInfo) + ppDynErrInfo[lIdx]=nullptr; +} + +ErrorInfo::~ErrorInfo() +{ +} + + +ErrorInfo *ErrorInfo::GetErrorInfo(sal_uIntPtr lId) +{ + if(lId & ERRCODE_DYNAMIC_MASK) + return DynamicErrorInfo_Impl::GetDynamicErrorInfo(lId); + else + return new ErrorInfo(lId); +} + +DynamicErrorInfo::operator sal_uIntPtr() const +{ + return pImpl->lErrId; +} + +DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr lArgUserId, ErrorHandlerFlags nMask) +: ErrorInfo(lArgUserId), + pImpl(new DynamicErrorInfo_Impl) +{ + pImpl->RegisterEDcr(this); + pImpl->nMask=nMask; +} + +DynamicErrorInfo::~DynamicErrorInfo() +{ + DynamicErrorInfo_Impl::UnRegisterEDcr(this); +} + +ErrorInfo* DynamicErrorInfo_Impl::GetDynamicErrorInfo(sal_uIntPtr lId) +{ + sal_uIntPtr lIdx = ((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1; + DynamicErrorInfo* pDynErrInfo = TheErrorRegistry::get().ppDynErrInfo[lIdx]; + if(pDynErrInfo && (sal_uIntPtr)(*pDynErrInfo)==lId) + return pDynErrInfo; + else + return new ErrorInfo(lId & ~ERRCODE_DYNAMIC_MASK); +} + +ErrorHandlerFlags DynamicErrorInfo::GetDialogMask() const +{ + return pImpl->nMask; +} + +StringErrorInfo::StringErrorInfo( + sal_uIntPtr UserId, const OUString& aStringP, ErrorHandlerFlags nMask) +: DynamicErrorInfo(UserId, nMask), aString(aStringP) +{ +} + +class ErrorHandler_Impl +{ +public: + static bool CreateString(const ErrorInfo*, OUString&); +}; + +static void aDspFunc(const OUString &rErr, const OUString &rAction) +{ + OStringBuffer aErr("Action: "); + aErr.append(OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US)); + aErr.append(" Error: "); + aErr.append(OUStringToOString(rErr, RTL_TEXTENCODING_ASCII_US)); + OSL_FAIL(aErr.getStr()); +} + +// FIXME: this is a horrible reverse dependency on VCL +struct ErrorContextImpl +{ + vcl::Window *pWin; // 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(); + rData.errorHandlers.insert(rData.errorHandlers.begin(), this); + if(!rData.pDsp) + RegisterDisplay(&aDspFunc); +} + +ErrorHandler::~ErrorHandler() +{ + auto &rErrorHandlers = TheErrorRegistry::get().errorHandlers; + rErrorHandlers.erase( ::std::remove(rErrorHandlers.begin(), rErrorHandlers.end(), this), rErrorHandlers.end()); +} + +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); +} + +/** Handles an error. + + If nFlags is not set, the DynamicErrorInfo flags or the + resource flags will be used. + Thus: + + 1. nFlags, + 2. Resource Flags + 3. Dynamic Flags + 4. Default ButtonsOk, MessageError + + @param nErrCodeId error id + @param nFlags error flags. + @param bJustCreateString ??? + @param rError ??? + + @return ??? +*/ +ErrorHandlerFlags ErrorHandler::HandleError_Impl( + sal_uIntPtr nErrCodeId, ErrorHandlerFlags nFlags, bool bJustCreateString, OUString & rError) +{ + OUString aErr; + OUString aAction; + if(!nErrCodeId || nErrCodeId == ERRCODE_ABORT) + return ErrorHandlerFlags::NONE; + ErrorRegistry &rData = TheErrorRegistry::get(); + vcl::Window *pParent = nullptr; + ErrorInfo *pInfo = ErrorInfo::GetErrorInfo(nErrCodeId); + if (!rData.contexts.empty()) + { + rData.contexts.front()->GetString(pInfo->GetErrorCode(), aAction); + // Remove parent from context + for(ErrorContext *pCtx : rData.contexts) + if(pCtx->GetParent()) + { + pParent=pCtx->GetParent(); + break; + } + } + + bool bWarning = ((nErrCodeId & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK); + ErrorHandlerFlags nErrFlags = ErrorHandlerFlags::ButtonDefaultsOk | ErrorHandlerFlags::ButtonsOk; + if (bWarning) + nErrFlags |= ErrorHandlerFlags::MessageWarning; + else + nErrFlags |= ErrorHandlerFlags::MessageError; + + DynamicErrorInfo* pDynPtr=dynamic_cast(pInfo); + if(pDynPtr) + { + ErrorHandlerFlags nDynFlags = pDynPtr->GetDialogMask(); + if( nDynFlags != ErrorHandlerFlags::NONE ) + nErrFlags = nDynFlags; + } + + if(ErrorHandler_Impl::CreateString(pInfo,aErr)) + { + if (bJustCreateString) + { + rError = aErr; + return ErrorHandlerFlags::ButtonsOk; + } + else + { + if(!rData.pDsp) + { + OStringBuffer aStr("Action: "); + aStr.append(OUStringToOString(aAction, RTL_TEXTENCODING_ASCII_US)); + aStr.append("\nFehler: "); + aStr.append(OUStringToOString(aErr, RTL_TEXTENCODING_ASCII_US)); + OSL_FAIL(aStr.getStr()); + } + else + { + delete pInfo; + if(!rData.bIsWindowDsp) + { + (*reinterpret_cast(rData.pDsp))(aErr,aAction); + return ErrorHandlerFlags::NONE; + } + else + { + if (nFlags != ErrorHandlerFlags::MAX) + nErrFlags = nFlags; + return (*reinterpret_cast(rData.pDsp))( + pParent, nErrFlags, aErr, aAction); + } + } + } + } + OSL_FAIL("Error not handled"); + // Error 1 is General Error in the Sfx + if(pInfo->GetErrorCode()!=1) + { + HandleError_Impl(1, ErrorHandlerFlags::MAX, bJustCreateString, rError); + } + else + { + OSL_FAIL("Error 1 not handled"); + } + delete pInfo; + return ErrorHandlerFlags::NONE; +} + +// static +bool ErrorHandler::GetErrorString(sal_uIntPtr lId, OUString& rStr) +{ + return HandleError_Impl( lId, ErrorHandlerFlags::MAX, true, rStr ) != ErrorHandlerFlags::NONE; +} + +/** Handles an error. + + @see ErrorHandler::HandleError_Impl +*/ +ErrorHandlerFlags ErrorHandler::HandleError(sal_uIntPtr lId, ErrorHandlerFlags nFlags) +{ + OUString aDummy; + return HandleError_Impl( lId, nFlags, false, aDummy ); +} + +bool ErrorHandler_Impl::CreateString(const ErrorInfo* pInfo, OUString& rStr) +{ + for(const ErrorHandler *pHdl : TheErrorRegistry::get().errorHandlers) + { + if(pHdl->CreateString(pInfo, rStr)) + return true; + } + return false; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx b/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx index 4e82ff05954c..18ecadddb2d1 100644 --- a/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx +++ b/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx @@ -268,7 +268,7 @@ #include #include #include -#include +#include #include #include #include -- cgit