update credits
[LibreOffice.git] / include / tools / errinf.hxx
blob815447b7372fc104a55cfac75b710fc1f7f39e3d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 __RSC
22 #ifndef _EINF_HXX
23 #define _EINF_HXX
25 #include <limits.h>
26 #include <tools/rtti.hxx>
27 #include <tools/errcode.hxx>
28 #include <tools/string.hxx>
29 #include "tools/toolsdllapi.h"
31 class EDcr_Impl;
32 class ErrHdl_Impl;
33 class Window;
35 class ErrorInfo
37 private:
38 sal_uIntPtr lUserId;
40 public:
41 TYPEINFO();
43 ErrorInfo( sal_uIntPtr lArgUserId ) :
44 lUserId( lArgUserId ){}
45 virtual ~ErrorInfo(){}
47 sal_uIntPtr GetErrorCode() const { return lUserId; }
49 static ErrorInfo* GetErrorInfo(sal_uIntPtr);
52 class TOOLS_DLLPUBLIC DynamicErrorInfo : public ErrorInfo
54 friend class EDcr_Impl;
56 private:
57 EDcr_Impl* pImpl;
59 public:
60 TYPEINFO();
62 DynamicErrorInfo(sal_uIntPtr lUserId, sal_uInt16 nMask);
63 virtual ~DynamicErrorInfo();
65 operator sal_uIntPtr() const;
66 sal_uInt16 GetDialogMask() const;
69 class TOOLS_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo
71 private:
72 OUString aString;
74 public:
75 TYPEINFO();
77 StringErrorInfo( sal_uIntPtr lUserId,
78 const OUString& aStringP,
79 sal_uInt16 nFlags = 0);
80 const OUString& GetErrorString() const { return aString; }
83 class TOOLS_DLLPUBLIC TwoStringErrorInfo: public DynamicErrorInfo
85 private:
86 OUString aArg1;
87 OUString aArg2;
89 public:
90 TYPEINFO();
92 TwoStringErrorInfo(sal_uIntPtr nUserID, const OUString & rTheArg1,
93 const OUString & rTheArg2, sal_uInt16 nFlags = 0):
94 DynamicErrorInfo(nUserID, nFlags), aArg1(rTheArg1), aArg2(rTheArg2) {}
96 virtual ~TwoStringErrorInfo() {}
98 const OUString& GetArg1() const { return aArg1; }
99 const OUString& GetArg2() const { return aArg2; }
102 class TOOLS_DLLPUBLIC MessageInfo : public DynamicErrorInfo
104 public:
105 TYPEINFO();
107 MessageInfo(sal_uIntPtr UserId, sal_uInt16 nFlags = 0) :
108 DynamicErrorInfo(UserId, nFlags) {}
109 MessageInfo(sal_uIntPtr UserId, const OUString &rArg, sal_uInt16 nFlags = 0 ) :
110 DynamicErrorInfo(UserId, nFlags), aArg(rArg) {}
112 const OUString& GetMessageArg() const { return aArg; }
114 private:
115 OUString aArg;
118 class TOOLS_DLLPUBLIC ErrorContext
120 friend class ErrorHandler;
122 private:
123 ErrorContext* pNext;
124 Window* pWin;
126 public:
127 ErrorContext(Window *pWin=0);
128 virtual ~ErrorContext();
130 virtual sal_Bool GetString( sal_uIntPtr nErrId, OUString& rCtxStr ) = 0;
131 Window* GetParent() { return pWin; }
133 static ErrorContext* GetContext();
136 typedef sal_uInt16 WindowDisplayErrorFunc(
137 Window *, sal_uInt16 nMask, const OUString &rErr, const OUString &rAction);
139 typedef void BasicDisplayErrorFunc(
140 const OUString &rErr, const OUString &rAction);
142 class TOOLS_DLLPUBLIC ErrorHandler
144 friend class ErrHdl_Impl;
146 private:
147 ErrHdl_Impl* pImpl;
149 static sal_uInt16 HandleError_Impl( sal_uIntPtr lId,
150 sal_uInt16 nFlags,
151 sal_Bool bJustCreateString,
152 OUString & rError);
153 protected:
154 virtual sal_Bool CreateString( const ErrorInfo *,
155 OUString &, sal_uInt16& nMask ) const = 0;
157 public:
158 ErrorHandler();
159 virtual ~ErrorHandler();
161 static sal_uInt16 HandleError ( sal_uIntPtr lId, sal_uInt16 nMask = USHRT_MAX );
162 static sal_Bool GetErrorString( sal_uIntPtr lId, OUString& rStr );
164 static void RegisterDisplay( BasicDisplayErrorFunc* );
165 static void RegisterDisplay( WindowDisplayErrorFunc* );
168 class TOOLS_DLLPUBLIC SimpleErrorHandler : private ErrorHandler
170 protected:
171 virtual sal_Bool CreateString( const ErrorInfo*, OUString &,
172 sal_uInt16 &nMask ) const;
174 public:
175 SimpleErrorHandler();
178 #endif
179 #endif
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */