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 INCLUDED_TOOLS_ERRINF_HXX
23 : #define INCLUDED_TOOLS_ERRINF_HXX
24 :
25 : #include <limits.h>
26 : #include <rtl/ustring.hxx>
27 : #include <tools/rtti.hxx>
28 : #include <tools/errcode.hxx>
29 : #include <tools/toolsdllapi.h>
30 :
31 : // FIXME: horrible legacy dependency on VCL from tools.
32 : namespace vcl { class Window; }
33 :
34 : class EDcr_Impl;
35 : class ErrHdl_Impl;
36 :
37 : class ErrorInfo
38 : {
39 : private:
40 : sal_uIntPtr lUserId;
41 :
42 : public:
43 : TYPEINFO();
44 :
45 2 : ErrorInfo( sal_uIntPtr lArgUserId ) :
46 2 : lUserId( lArgUserId ){}
47 0 : virtual ~ErrorInfo(){}
48 :
49 2 : sal_uIntPtr GetErrorCode() const { return lUserId; }
50 :
51 : static ErrorInfo* GetErrorInfo(sal_uIntPtr);
52 : };
53 :
54 : class TOOLS_DLLPUBLIC DynamicErrorInfo : public ErrorInfo
55 : {
56 : friend class EDcr_Impl;
57 :
58 : private:
59 : EDcr_Impl* pImpl;
60 :
61 : public:
62 : TYPEINFO_OVERRIDE();
63 :
64 : DynamicErrorInfo(sal_uIntPtr lUserId, sal_uInt16 nMask);
65 : virtual ~DynamicErrorInfo();
66 :
67 : operator sal_uIntPtr() const;
68 : sal_uInt16 GetDialogMask() const;
69 : };
70 :
71 0 : class TOOLS_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo
72 : {
73 : private:
74 : OUString aString;
75 :
76 : public:
77 : TYPEINFO_OVERRIDE();
78 :
79 : StringErrorInfo( sal_uIntPtr lUserId,
80 : const OUString& aStringP,
81 : sal_uInt16 nFlags = 0);
82 0 : const OUString& GetErrorString() const { return aString; }
83 : };
84 :
85 : class TOOLS_DLLPUBLIC TwoStringErrorInfo: public DynamicErrorInfo
86 : {
87 : private:
88 : OUString aArg1;
89 : OUString aArg2;
90 :
91 : public:
92 : TYPEINFO_OVERRIDE();
93 :
94 1 : TwoStringErrorInfo(sal_uIntPtr nUserID, const OUString & rTheArg1,
95 : const OUString & rTheArg2, sal_uInt16 nFlags = 0):
96 1 : DynamicErrorInfo(nUserID, nFlags), aArg1(rTheArg1), aArg2(rTheArg2) {}
97 :
98 0 : virtual ~TwoStringErrorInfo() {}
99 :
100 0 : const OUString& GetArg1() const { return aArg1; }
101 0 : const OUString& GetArg2() const { return aArg2; }
102 : };
103 :
104 0 : class TOOLS_DLLPUBLIC MessageInfo : public DynamicErrorInfo
105 : {
106 : public:
107 : TYPEINFO_OVERRIDE();
108 :
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) {}
113 :
114 0 : const OUString& GetMessageArg() const { return aArg; }
115 :
116 : private:
117 : OUString aArg;
118 : };
119 :
120 : struct ErrorContextImpl;
121 : class TOOLS_DLLPUBLIC ErrorContext
122 : {
123 : friend class ErrorHandler;
124 :
125 : private:
126 : ErrorContextImpl *pImpl;
127 :
128 : public:
129 : ErrorContext(vcl::Window *pWin=0);
130 : virtual ~ErrorContext();
131 :
132 : virtual bool GetString( sal_uIntPtr nErrId, OUString& rCtxStr ) = 0;
133 : vcl::Window* GetParent();
134 :
135 : static ErrorContext* GetContext();
136 : };
137 :
138 : typedef sal_uInt16 WindowDisplayErrorFunc(
139 : vcl::Window *, sal_uInt16 nMask, const OUString &rErr, const OUString &rAction);
140 :
141 : typedef void BasicDisplayErrorFunc(
142 : const OUString &rErr, const OUString &rAction);
143 :
144 : class TOOLS_DLLPUBLIC ErrorHandler
145 : {
146 : friend class ErrHdl_Impl;
147 :
148 : private:
149 : ErrHdl_Impl* pImpl;
150 :
151 : static sal_uInt16 HandleError_Impl( sal_uIntPtr lId,
152 : sal_uInt16 nFlags,
153 : bool bJustCreateString,
154 : OUString & rError);
155 : protected:
156 : virtual bool CreateString( const ErrorInfo *,
157 : OUString &, sal_uInt16& nMask ) const = 0;
158 :
159 : public:
160 : ErrorHandler();
161 : virtual ~ErrorHandler();
162 :
163 : static sal_uInt16 HandleError ( sal_uIntPtr lId, sal_uInt16 nMask = USHRT_MAX );
164 : static bool GetErrorString( sal_uIntPtr lId, OUString& rStr );
165 :
166 : static void RegisterDisplay( BasicDisplayErrorFunc* );
167 : static void RegisterDisplay( WindowDisplayErrorFunc* );
168 : };
169 :
170 : #endif
171 : #endif
172 :
173 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|