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/rtti.hxx>
28 #include <tools/errcode.hxx>
29 #include <tools/toolsdllapi.h>
31 // FIXME: horrible legacy dependency on VCL from tools.
32 namespace vcl
{ class Window
; }
45 ErrorInfo( sal_uIntPtr lArgUserId
) :
46 lUserId( lArgUserId
){}
47 virtual ~ErrorInfo(){}
49 sal_uIntPtr
GetErrorCode() const { return lUserId
; }
51 static ErrorInfo
* GetErrorInfo(sal_uIntPtr
);
54 class TOOLS_DLLPUBLIC DynamicErrorInfo
: public ErrorInfo
56 friend class EDcr_Impl
;
64 DynamicErrorInfo(sal_uIntPtr lUserId
, sal_uInt16 nMask
);
65 virtual ~DynamicErrorInfo();
67 operator sal_uIntPtr() const;
68 sal_uInt16
GetDialogMask() const;
71 class TOOLS_DLLPUBLIC StringErrorInfo
: public DynamicErrorInfo
79 StringErrorInfo( sal_uIntPtr lUserId
,
80 const OUString
& aStringP
,
81 sal_uInt16 nFlags
= 0);
82 const OUString
& GetErrorString() const { return aString
; }
85 class TOOLS_DLLPUBLIC TwoStringErrorInfo
: public DynamicErrorInfo
94 TwoStringErrorInfo(sal_uIntPtr nUserID
, const OUString
& rTheArg1
,
95 const OUString
& rTheArg2
, sal_uInt16 nFlags
= 0):
96 DynamicErrorInfo(nUserID
, nFlags
), aArg1(rTheArg1
), aArg2(rTheArg2
) {}
98 virtual ~TwoStringErrorInfo() {}
100 const OUString
& GetArg1() const { return aArg1
; }
101 const OUString
& GetArg2() const { return aArg2
; }
104 class TOOLS_DLLPUBLIC MessageInfo
: public DynamicErrorInfo
109 MessageInfo(sal_uIntPtr UserId
, sal_uInt16 nFlags
= 0) :
110 DynamicErrorInfo(UserId
, nFlags
) {}
111 MessageInfo(sal_uIntPtr UserId
, const OUString
&rArg
, sal_uInt16 nFlags
= 0 ) :
112 DynamicErrorInfo(UserId
, nFlags
), aArg(rArg
) {}
114 const OUString
& GetMessageArg() const { return aArg
; }
120 struct ErrorContextImpl
;
121 class TOOLS_DLLPUBLIC ErrorContext
123 friend class ErrorHandler
;
126 ErrorContextImpl
*pImpl
;
129 ErrorContext(vcl::Window
*pWin
=0);
130 virtual ~ErrorContext();
132 virtual bool GetString( sal_uIntPtr nErrId
, OUString
& rCtxStr
) = 0;
133 vcl::Window
* GetParent();
135 static ErrorContext
* GetContext();
138 typedef sal_uInt16
WindowDisplayErrorFunc(
139 vcl::Window
*, sal_uInt16 nMask
, const OUString
&rErr
, const OUString
&rAction
);
141 typedef void BasicDisplayErrorFunc(
142 const OUString
&rErr
, const OUString
&rAction
);
144 class TOOLS_DLLPUBLIC ErrorHandler
146 friend class ErrHdl_Impl
;
151 static sal_uInt16
HandleError_Impl( sal_uIntPtr lId
,
153 bool bJustCreateString
,
156 virtual bool CreateString( const ErrorInfo
*,
157 OUString
&, sal_uInt16
& nMask
) const = 0;
161 virtual ~ErrorHandler();
163 static sal_uInt16
HandleError ( sal_uIntPtr lId
, sal_uInt16 nMask
= USHRT_MAX
);
164 static bool GetErrorString( sal_uIntPtr lId
, OUString
& rStr
);
166 static void RegisterDisplay( BasicDisplayErrorFunc
* );
167 static void RegisterDisplay( WindowDisplayErrorFunc
* );
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */