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>
25 #include <comphelper/errcode.hxx>
26 #include <vcl/dllapi.h>
33 namespace weld
{ class Window
; }
37 enum class DialogMask
;
39 class VCL_DLLPUBLIC ErrorStringFactory
42 static bool CreateString(const ErrCodeMsg
&, OUString
&);
45 typedef void (* DisplayFnPtr
)();
47 typedef DialogMask
WindowDisplayErrorFunc(
48 weld::Window
*, DialogMask eMask
, const OUString
&rErr
, const OUString
&rAction
);
50 typedef void BasicDisplayErrorFunc(
51 const OUString
&rErr
, const OUString
&rAction
);
53 class VCL_DLLPUBLIC ErrorRegistry
55 friend class ErrorHandler
;
56 friend class ErrorContext
;
57 friend class ErrorStringFactory
;
62 static void RegisterDisplay(BasicDisplayErrorFunc
*);
63 static void RegisterDisplay(WindowDisplayErrorFunc
*);
65 static void SetLock(bool bLock
);
66 static bool GetLock();
76 std::vector
<ErrorHandler
*> errorHandlers
;
77 std::vector
<ErrorContext
*> contexts
;
80 class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorHandler
82 friend class ErrorStringFactory
;
86 virtual ~ErrorHandler();
90 If nFlags is not set, the DynamicErrorInfo flags or the
91 resource flags will be used. Thus the order is:
96 4. Default ButtonsOk, MessageError
98 @param nErrCodeId error id
99 @param pParent parent window the error dialog will be modal for. nullptr for unrecommended "pick default"
100 @param nFlags error flags.
102 @return what sort of dialog to use, with what buttons
104 static DialogMask
HandleError(const ErrCodeMsg
& nId
, weld::Window
* pParent
= nullptr, DialogMask nMask
= DialogMask::MAX
);
105 static bool GetErrorString(const ErrCodeMsg
& nId
, OUString
& rStr
);
108 virtual bool CreateString(const ErrCodeMsg
&, OUString
&) const = 0;
112 struct ImplErrorContext
;
114 class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorContext
116 friend class ErrorHandler
;
119 ErrorContext(weld::Window
*pWin
);
120 virtual ~ErrorContext();
122 virtual bool GetString(const ErrCodeMsg
& nErrId
, OUString
& rCtxStr
) = 0;
123 weld::Window
* GetParent();
125 static ErrorContext
* GetContext();
128 std::unique_ptr
<ImplErrorContext
> pImpl
;
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */