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 .
22 #ifndef INCLUDED_TOOLS_ERRINF_HXX
23 #define INCLUDED_TOOLS_ERRINF_HXX
26 #include <rtl/ustring.hxx>
27 #include <tools/errcode.hxx>
28 #include <tools/toolsdllapi.h>
31 // FIXME: horrible legacy dependency on VCL from tools.
32 namespace vcl
{ class Window
; }
34 class DynamicErrorInfo_Impl
;
35 class ErrorHandler_Impl
;
37 class TOOLS_DLLPUBLIC ErrorInfo
44 ErrorInfo( sal_uIntPtr lArgUserId
) :
45 lUserId( lArgUserId
){}
48 sal_uIntPtr
GetErrorCode() const { return lUserId
; }
50 static ErrorInfo
* GetErrorInfo(sal_uIntPtr
);
53 class TOOLS_DLLPUBLIC DynamicErrorInfo
: public ErrorInfo
55 friend class DynamicErrorInfo_Impl
;
58 std::unique_ptr
<DynamicErrorInfo_Impl
> pImpl
;
62 DynamicErrorInfo(sal_uIntPtr lUserId
, sal_uInt16 nMask
);
63 virtual ~DynamicErrorInfo() override
;
65 operator sal_uIntPtr() const;
66 sal_uInt16
GetDialogMask() const;
69 class TOOLS_DLLPUBLIC StringErrorInfo
: public DynamicErrorInfo
76 StringErrorInfo( sal_uIntPtr lUserId
,
77 const OUString
& aStringP
,
78 sal_uInt16 nMask
= 0);
79 const OUString
& GetErrorString() const { return aString
; }
82 class TOOLS_DLLPUBLIC TwoStringErrorInfo
: public DynamicErrorInfo
90 TwoStringErrorInfo(sal_uIntPtr nUserID
, const OUString
& rTheArg1
,
91 const OUString
& rTheArg2
, sal_uInt16 nMask
):
92 DynamicErrorInfo(nUserID
, nMask
), aArg1(rTheArg1
), aArg2(rTheArg2
) {}
94 virtual ~TwoStringErrorInfo() override
{}
96 const OUString
& GetArg1() const { return aArg1
; }
97 const OUString
& GetArg2() const { return aArg2
; }
100 struct ErrorContextImpl
;
101 class TOOLS_DLLPUBLIC ErrorContext
103 friend class ErrorHandler
;
106 std::unique_ptr
<ErrorContextImpl
> pImpl
;
109 ErrorContext(vcl::Window
*pWin
);
110 virtual ~ErrorContext();
112 virtual bool GetString( sal_uIntPtr nErrId
, OUString
& rCtxStr
) = 0;
113 vcl::Window
* GetParent();
115 static ErrorContext
* GetContext();
118 typedef sal_uInt16
WindowDisplayErrorFunc(
119 vcl::Window
*, sal_uInt16 nMask
, const OUString
&rErr
, const OUString
&rAction
);
121 typedef void BasicDisplayErrorFunc(
122 const OUString
&rErr
, const OUString
&rAction
);
124 class TOOLS_DLLPUBLIC ErrorHandler
126 friend class ErrorHandler_Impl
;
129 static sal_uInt16
HandleError_Impl( sal_uIntPtr lId
,
131 bool bJustCreateString
,
134 virtual bool CreateString( const ErrorInfo
*,
135 OUString
&, sal_uInt16
& nMask
) const = 0;
139 virtual ~ErrorHandler();
141 static sal_uInt16
HandleError ( sal_uIntPtr lId
, sal_uInt16 nMask
= USHRT_MAX
);
142 static bool GetErrorString( sal_uIntPtr lId
, OUString
& rStr
);
144 static void RegisterDisplay( BasicDisplayErrorFunc
* );
145 static void RegisterDisplay( WindowDisplayErrorFunc
* );
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */