Branch libreoffice-5-0-4
[LibreOffice.git] / include / tools / errinf.hxx
blob4a9f07a69d62f0df1c1af61a5fb1f27009684cd3
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 INCLUDED_TOOLS_ERRINF_HXX
23 #define INCLUDED_TOOLS_ERRINF_HXX
25 #include <limits.h>
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; }
34 class EDcr_Impl;
35 class ErrHdl_Impl;
37 class ErrorInfo
39 private:
40 sal_uIntPtr lUserId;
42 public:
43 TYPEINFO();
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;
58 private:
59 EDcr_Impl* pImpl;
61 public:
62 TYPEINFO_OVERRIDE();
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
73 private:
74 OUString aString;
76 public:
77 TYPEINFO_OVERRIDE();
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
87 private:
88 OUString aArg1;
89 OUString aArg2;
91 public:
92 TYPEINFO_OVERRIDE();
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
106 public:
107 TYPEINFO_OVERRIDE();
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; }
116 private:
117 OUString aArg;
120 struct ErrorContextImpl;
121 class TOOLS_DLLPUBLIC ErrorContext
123 friend class ErrorHandler;
125 private:
126 ErrorContextImpl *pImpl;
128 public:
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;
148 private:
149 ErrHdl_Impl* pImpl;
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;
159 public:
160 ErrorHandler();
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* );
170 #endif
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */