1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_ERRINF_HXX
21 #define INCLUDED_VCL_ERRINF_HXX
23 #include <rtl/ustring.hxx>
24 #include <comphelper/errcode.hxx>
25 #include <vcl/dllapi.h>
30 namespace weld
{ class Window
; }
34 enum class DialogMask
;
36 class UNLESS_MERGELIBS(VCL_DLLPUBLIC
) ErrorStringFactory
39 static bool CreateString(const ErrCodeMsg
&, OUString
&);
42 typedef void (* DisplayFnPtr
)();
44 typedef DialogMask
WindowDisplayErrorFunc(
45 weld::Window
*, DialogMask eMask
, const OUString
&rErr
, const OUString
&rAction
);
47 typedef void BasicDisplayErrorFunc(
48 const OUString
&rErr
, const OUString
&rAction
);
50 class VCL_DLLPUBLIC ErrorRegistry
52 friend class ErrorHandler
;
53 friend class ErrorContext
;
54 friend class ErrorStringFactory
;
59 static void RegisterDisplay(BasicDisplayErrorFunc
*);
60 static void RegisterDisplay(WindowDisplayErrorFunc
*);
62 static void SetLock(bool bLock
);
63 static bool GetLock();
73 std::vector
<ErrorHandler
*> errorHandlers
;
74 std::vector
<ErrorContext
*> contexts
;
77 class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorHandler
79 friend class ErrorStringFactory
;
83 virtual ~ErrorHandler();
87 If nFlags is not set, the DynamicErrorInfo flags or the
88 resource flags will be used. Thus the order is:
93 4. Default ButtonsOk, MessageError
95 @param nErrCodeId error id
96 @param pParent parent window the error dialog will be modal for. nullptr for unrecommended "pick default"
97 @param nFlags error flags.
99 @return what sort of dialog to use, with what buttons
101 static DialogMask
HandleError(const ErrCodeMsg
& nId
, weld::Window
* pParent
= nullptr, DialogMask nMask
= DialogMask::MAX
);
102 static bool GetErrorString(const ErrCodeMsg
& nId
, OUString
& rStr
);
105 virtual bool CreateString(const ErrCodeMsg
&, OUString
&) const = 0;
109 struct ImplErrorContext
;
111 class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorContext
113 friend class ErrorHandler
;
116 ErrorContext(weld::Window
*pWin
);
117 virtual ~ErrorContext();
119 virtual bool GetString(const ErrCodeMsg
& nErrId
, OUString
& rCtxStr
) = 0;
120 weld::Window
* GetParent();
122 static ErrorContext
* GetContext();
125 std::unique_ptr
<ImplErrorContext
> pImpl
;
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */