Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifndef __RSC
21 : :
22 : : #ifndef _EINF_HXX
23 : : #define _EINF_HXX
24 : :
25 : : #include <limits.h>
26 : : #include <tools/rtti.hxx>
27 : : #include <tools/errcode.hxx>
28 : : #include <tools/string.hxx>
29 : : #include "tools/toolsdllapi.h"
30 : :
31 : : class EDcr_Impl;
32 : : class ErrHdl_Impl;
33 : : class Window;
34 : :
35 : : class ErrorInfo
36 : : {
37 : : private:
38 : : sal_uIntPtr lUserId;
39 : :
40 : : public:
41 : : TYPEINFO();
42 : :
43 : : ErrorInfo( sal_uIntPtr lArgUserId ) :
44 : : lUserId( lArgUserId ){}
45 [ # # ]: 0 : virtual ~ErrorInfo(){}
46 : :
47 : 0 : sal_uIntPtr GetErrorCode() const { return lUserId; }
48 : :
49 : : static ErrorInfo* GetErrorInfo(sal_uIntPtr);
50 : : };
51 : :
52 : : class TOOLS_DLLPUBLIC DynamicErrorInfo : public ErrorInfo
53 : : {
54 : : friend class EDcr_Impl;
55 : :
56 : : private:
57 : : EDcr_Impl* pImpl;
58 : :
59 : : public:
60 : : TYPEINFO();
61 : :
62 : : DynamicErrorInfo(sal_uIntPtr lUserId, sal_uInt16 nMask);
63 : : virtual ~DynamicErrorInfo();
64 : :
65 : : operator sal_uIntPtr() const;
66 : : sal_uInt16 GetDialogMask() const;
67 : : };
68 : :
69 : : class TOOLS_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo
70 : : {
71 : : private:
72 : : String aString;
73 : :
74 : : public:
75 : : TYPEINFO();
76 : :
77 : : StringErrorInfo( sal_uIntPtr lUserId,
78 : : const String& aStringP,
79 : : sal_uInt16 nFlags = 0);
80 : 0 : const String& GetErrorString() const { return aString; }
81 : : };
82 : :
83 : : class TOOLS_DLLPUBLIC TwoStringErrorInfo: public DynamicErrorInfo
84 : : {
85 : : private:
86 : : String aArg1;
87 : : String aArg2;
88 : :
89 : : public:
90 : : TYPEINFO();
91 : :
92 : 0 : TwoStringErrorInfo(sal_uIntPtr nUserID, const String & rTheArg1,
93 : : const String & rTheArg2, sal_uInt16 nFlags = 0):
94 [ # # ][ # # ]: 0 : DynamicErrorInfo(nUserID, nFlags), aArg1(rTheArg1), aArg2(rTheArg2) {}
95 [ # # ][ # # ]: 0 : virtual ~TwoStringErrorInfo() {}
[ # # ]
96 : :
97 : 0 : String GetArg1() const { return aArg1; }
98 : 0 : String GetArg2() const { return aArg2; }
99 : : };
100 : :
101 : : class TOOLS_DLLPUBLIC MessageInfo : public DynamicErrorInfo
102 : : {
103 : : public:
104 : : TYPEINFO();
105 : : MessageInfo(sal_uIntPtr UserId, sal_uInt16 nFlags = 0) :
106 : : DynamicErrorInfo(UserId, nFlags){}
107 : 0 : MessageInfo(sal_uIntPtr UserId, const String &rArg,
108 : : sal_uInt16 nFlags = 0 ) :
109 [ # # ]: 0 : DynamicErrorInfo(UserId, nFlags), aArg(rArg) {}
110 : 0 : const String& GetMessageArg() const { return aArg; }
111 : :
112 : : private:
113 : : String aArg;
114 : : };
115 : :
116 : : class TOOLS_DLLPUBLIC ErrorContext
117 : : {
118 : : friend class ErrorHandler;
119 : :
120 : : private:
121 : : ErrorContext* pNext;
122 : : Window* pWin;
123 : :
124 : : public:
125 : : ErrorContext(Window *pWin=0);
126 : : virtual ~ErrorContext();
127 : :
128 : : virtual sal_Bool GetString( sal_uIntPtr nErrId, String& rCtxStr ) = 0;
129 : : Window* GetParent() { return pWin; }
130 : :
131 : : static ErrorContext* GetContext();
132 : : };
133 : :
134 : : typedef sal_uInt16 WindowDisplayErrorFunc(
135 : : Window *, sal_uInt16 nMask, const String &rErr, const String &rAction);
136 : :
137 : : typedef void BasicDisplayErrorFunc(
138 : : const String &rErr, const String &rAction);
139 : :
140 : : class TOOLS_DLLPUBLIC ErrorHandler
141 : : {
142 : : friend class ErrHdl_Impl;
143 : :
144 : : private:
145 : : ErrHdl_Impl* pImpl;
146 : :
147 : : static sal_uInt16 HandleError_Impl( sal_uIntPtr lId,
148 : : sal_uInt16 nFlags,
149 : : sal_Bool bJustCreateString,
150 : : String & rError);
151 : : protected:
152 : : virtual sal_Bool CreateString( const ErrorInfo *,
153 : : String &, sal_uInt16& nMask ) const = 0;
154 : :
155 : : public:
156 : : ErrorHandler();
157 : : virtual ~ErrorHandler();
158 : :
159 : : static sal_uInt16 HandleError ( sal_uIntPtr lId, sal_uInt16 nMask = USHRT_MAX );
160 : : static sal_Bool GetErrorString( sal_uIntPtr lId, String& rStr );
161 : :
162 : : static void RegisterDisplay( BasicDisplayErrorFunc* );
163 : : static void RegisterDisplay( WindowDisplayErrorFunc* );
164 : : };
165 : :
166 : : class TOOLS_DLLPUBLIC SimpleErrorHandler : private ErrorHandler
167 : : {
168 : : protected:
169 : : virtual sal_Bool CreateString( const ErrorInfo*, String &,
170 : : sal_uInt16 &nMask ) const;
171 : :
172 : : public:
173 : : SimpleErrorHandler();
174 : : };
175 : :
176 : : #endif
177 : : #endif
178 : :
179 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|