xref: /aoo41x/main/tools/source/ref/errinf.cxx (revision 89b56da7)
1*89b56da7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*89b56da7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*89b56da7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*89b56da7SAndrew Rist  * distributed with this work for additional information
6*89b56da7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*89b56da7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*89b56da7SAndrew Rist  * "License"); you may not use this file except in compliance
9*89b56da7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*89b56da7SAndrew Rist  *
11*89b56da7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*89b56da7SAndrew Rist  *
13*89b56da7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*89b56da7SAndrew Rist  * software distributed under the License is distributed on an
15*89b56da7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*89b56da7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*89b56da7SAndrew Rist  * specific language governing permissions and limitations
18*89b56da7SAndrew Rist  * under the License.
19*89b56da7SAndrew Rist  *
20*89b56da7SAndrew Rist  *************************************************************/
21*89b56da7SAndrew Rist 
22*89b56da7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_tools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <limits.h>
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <tools/errinf.hxx>
31cdf0e10cSrcweir #include <tools/string.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class ErrorHandler;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir typedef void (* DisplayFnPtr)();
38cdf0e10cSrcweir 
39cdf0e10cSrcweir }
40cdf0e10cSrcweir 
41cdf0e10cSrcweir struct EDcrData
42cdf0e10cSrcweir {
43cdf0e10cSrcweir   public:
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     ErrorHandler               *pFirstHdl;
46cdf0e10cSrcweir     ErrorContext               *pFirstCtx;
47cdf0e10cSrcweir     DisplayFnPtr               pDsp;
48cdf0e10cSrcweir     sal_Bool                       bIsWindowDsp;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     DynamicErrorInfo            *ppDcr[ERRCODE_DYNAMIC_COUNT];
52cdf0e10cSrcweir     sal_uInt16                      nNextDcr;
53cdf0e10cSrcweir                                 EDcrData();
54cdf0e10cSrcweir 
55cdf0e10cSrcweir static  EDcrData                *GetData();
56cdf0e10cSrcweir 
57cdf0e10cSrcweir };
58cdf0e10cSrcweir 
59cdf0e10cSrcweir class EDcr_Impl
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     sal_uIntPtr                       lErrId;
62cdf0e10cSrcweir     sal_uInt16                      nMask;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     void                        RegisterEDcr(DynamicErrorInfo *);
65cdf0e10cSrcweir     void                        UnRegisterEDcr(DynamicErrorInfo *);
66cdf0e10cSrcweir     static ErrorInfo           *GetDynamicErrorInfo(sal_uIntPtr lId);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir friend class DynamicErrorInfo;
69cdf0e10cSrcweir friend class ErrorInfo;
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
EDcrData()73cdf0e10cSrcweir EDcrData::EDcrData()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	for(sal_uInt16 n=0;n<ERRCODE_DYNAMIC_COUNT;n++)
76cdf0e10cSrcweir 		ppDcr[n]=0;
77cdf0e10cSrcweir 	nNextDcr=0;
78cdf0e10cSrcweir 	pFirstHdl=0;
79cdf0e10cSrcweir 	pDsp=0;
80cdf0e10cSrcweir 	pFirstCtx=0;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
GetData()84cdf0e10cSrcweir EDcrData *EDcrData::GetData()
85cdf0e10cSrcweir {
86cdf0e10cSrcweir #ifdef BOOTSTRAP
87cdf0e10cSrcweir 	return 0x0;
88cdf0e10cSrcweir #else
89cdf0e10cSrcweir     EDcrData **ppDat=(EDcrData **)GetAppData(SHL_ERR);
90cdf0e10cSrcweir     if(!*ppDat)
91cdf0e10cSrcweir     {
92cdf0e10cSrcweir         return (*ppDat=new EDcrData);
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir     else
95cdf0e10cSrcweir         return *ppDat;
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
RegisterEDcr(DynamicErrorInfo * pDcr)99cdf0e10cSrcweir void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     //Vergibt eine dynamische Id
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     EDcrData* pData=EDcrData::GetData();
104cdf0e10cSrcweir     lErrId= (((sal_uIntPtr)pData->nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) +
105cdf0e10cSrcweir         pDcr->GetErrorCode();
106cdf0e10cSrcweir     DynamicErrorInfo **ppDcr=pData->ppDcr;
107cdf0e10cSrcweir     sal_uInt16 nNext=pData->nNextDcr;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     // bei einem Ringbuffer koennen wir uns das ASSERT wohl sparen!
110cdf0e10cSrcweir 	// DBG_ASSERT(ppDcr[nNext]==0,"ErrHdl: Alle Errors belegt");
111cdf0e10cSrcweir     if(ppDcr[nNext])
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         delete ppDcr[nNext];
114cdf0e10cSrcweir     }
115cdf0e10cSrcweir     ppDcr[nNext]=pDcr;
116cdf0e10cSrcweir     if(++pData->nNextDcr>=ERRCODE_DYNAMIC_COUNT)
117cdf0e10cSrcweir         pData->nNextDcr=0;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
UnRegisterEDcr(DynamicErrorInfo * pDcr)121cdf0e10cSrcweir void EDcr_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     EDcrData* pData=EDcrData::GetData();
125cdf0e10cSrcweir     DynamicErrorInfo **ppDcr=pData->ppDcr;
126cdf0e10cSrcweir     sal_uIntPtr lIdx=(
127cdf0e10cSrcweir         ((sal_uIntPtr)(*pDcr) & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
128cdf0e10cSrcweir     DBG_ASSERT(ppDcr[lIdx]==pDcr,"ErrHdl: Error nicht gefunden");
129cdf0e10cSrcweir     if(ppDcr[lIdx]==pDcr)
130cdf0e10cSrcweir         ppDcr[lIdx]=0;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir TYPEINIT0(ErrorInfo);
134cdf0e10cSrcweir TYPEINIT1(DynamicErrorInfo, ErrorInfo);
135cdf0e10cSrcweir TYPEINIT1(StandardErrorInfo, DynamicErrorInfo);
136cdf0e10cSrcweir TYPEINIT1(StringErrorInfo, DynamicErrorInfo);
137cdf0e10cSrcweir TYPEINIT1(TwoStringErrorInfo, DynamicErrorInfo);
138cdf0e10cSrcweir TYPEINIT1(MessageInfo, DynamicErrorInfo);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
GetErrorInfo(sal_uIntPtr lId)141cdf0e10cSrcweir ErrorInfo *ErrorInfo::GetErrorInfo(sal_uIntPtr lId)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     if(lId & ERRCODE_DYNAMIC_MASK)
144cdf0e10cSrcweir         return EDcr_Impl::GetDynamicErrorInfo(lId);
145cdf0e10cSrcweir     else
146cdf0e10cSrcweir         return new ErrorInfo(lId);
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
operator sal_uIntPtr() const149cdf0e10cSrcweir DynamicErrorInfo::operator sal_uIntPtr() const
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     return pImpl->lErrId;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
DynamicErrorInfo(sal_uIntPtr lArgUserId,sal_uInt16 nMask)154cdf0e10cSrcweir DynamicErrorInfo::DynamicErrorInfo(sal_uIntPtr lArgUserId, sal_uInt16 nMask)
155cdf0e10cSrcweir : ErrorInfo(lArgUserId)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     pImpl=new EDcr_Impl;
158cdf0e10cSrcweir     pImpl->RegisterEDcr(this);
159cdf0e10cSrcweir     pImpl->nMask=nMask;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
~DynamicErrorInfo()162cdf0e10cSrcweir DynamicErrorInfo::~DynamicErrorInfo()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     pImpl->UnRegisterEDcr(this);
165cdf0e10cSrcweir     delete pImpl;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
GetDynamicErrorInfo(sal_uIntPtr lId)168cdf0e10cSrcweir ErrorInfo* EDcr_Impl::GetDynamicErrorInfo(sal_uIntPtr lId)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     sal_uIntPtr lIdx=((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1;
171cdf0e10cSrcweir     DynamicErrorInfo* pDcr=EDcrData::GetData()->ppDcr[lIdx];
172cdf0e10cSrcweir     if(pDcr && (sal_uIntPtr)(*pDcr)==lId)
173cdf0e10cSrcweir         return pDcr;
174cdf0e10cSrcweir     else
175cdf0e10cSrcweir         return new ErrorInfo(lId & ~ERRCODE_DYNAMIC_MASK);
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
GetDialogMask() const179cdf0e10cSrcweir sal_uInt16 DynamicErrorInfo::GetDialogMask() const
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     return pImpl->nMask;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
StandardErrorInfo(sal_uIntPtr UserId,sal_uIntPtr lArgExtId,sal_uInt16 nFlags)185cdf0e10cSrcweir StandardErrorInfo::StandardErrorInfo(
186cdf0e10cSrcweir 	sal_uIntPtr UserId, sal_uIntPtr lArgExtId, sal_uInt16 nFlags)
187cdf0e10cSrcweir : DynamicErrorInfo(UserId, nFlags), lExtId(lArgExtId)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
StringErrorInfo(sal_uIntPtr UserId,const String & aStringP,sal_uInt16 nFlags)192cdf0e10cSrcweir StringErrorInfo::StringErrorInfo(
193cdf0e10cSrcweir 	sal_uIntPtr UserId, const String& aStringP,  sal_uInt16 nFlags)
194cdf0e10cSrcweir : DynamicErrorInfo(UserId, nFlags), aString(aStringP)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir class ErrHdl_Impl
200cdf0e10cSrcweir {
201cdf0e10cSrcweir   public:
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     ErrorHandler        *pNext;
204cdf0e10cSrcweir     static sal_Bool         CreateString(const ErrorHandler *pStart,
205cdf0e10cSrcweir                                      const ErrorInfo*, String&, sal_uInt16&);
206cdf0e10cSrcweir };
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
aDspFunc(const String & rErr,const String & rAction)209cdf0e10cSrcweir static void aDspFunc(const String &rErr, const String &rAction)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     ByteString aErr("Aktion: ");
212cdf0e10cSrcweir     aErr+= ByteString( rAction, RTL_TEXTENCODING_ASCII_US );
213cdf0e10cSrcweir     aErr+=" Fehler: ";
214cdf0e10cSrcweir     aErr+= ByteString( rErr, RTL_TEXTENCODING_ASCII_US );
215cdf0e10cSrcweir     DBG_ERROR(aErr.GetBuffer());
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 
ErrorContext(Window * pWinP)219cdf0e10cSrcweir ErrorContext::ErrorContext(Window *pWinP)
220cdf0e10cSrcweir {
221cdf0e10cSrcweir     EDcrData *pData=EDcrData::GetData();
222cdf0e10cSrcweir     ErrorContext *&pHdl=pData->pFirstCtx;
223cdf0e10cSrcweir     pWin=pWinP;
224cdf0e10cSrcweir     pNext=pHdl;
225cdf0e10cSrcweir     pHdl=this;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
~ErrorContext()228cdf0e10cSrcweir ErrorContext::~ErrorContext()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     ErrorContext **ppCtx=&(EDcrData::GetData()->pFirstCtx);
231cdf0e10cSrcweir     while(*ppCtx && *ppCtx!=this)
232cdf0e10cSrcweir         ppCtx=&((*ppCtx)->pNext);
233cdf0e10cSrcweir     if(*ppCtx)
234cdf0e10cSrcweir         *ppCtx=(*ppCtx)->pNext;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
GetContext()237cdf0e10cSrcweir ErrorContext *ErrorContext::GetContext()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     return EDcrData::GetData()->pFirstCtx;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
ErrorHandler()242cdf0e10cSrcweir ErrorHandler::ErrorHandler()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     pImpl=new ErrHdl_Impl;
245cdf0e10cSrcweir     EDcrData *pData=EDcrData::GetData();
246cdf0e10cSrcweir     ErrorHandler *&pHdl=pData->pFirstHdl;
247cdf0e10cSrcweir     pImpl->pNext=pHdl;
248cdf0e10cSrcweir     pHdl=this;
249cdf0e10cSrcweir     if(!pData->pDsp)
250cdf0e10cSrcweir         RegisterDisplay(&aDspFunc);
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
~ErrorHandler()253cdf0e10cSrcweir ErrorHandler::~ErrorHandler()
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     ErrorHandler **ppHdl=&(EDcrData::GetData()->pFirstHdl);
256cdf0e10cSrcweir     while(*ppHdl && *ppHdl!=this)
257cdf0e10cSrcweir         ppHdl=&((*ppHdl)->pImpl->pNext);
258cdf0e10cSrcweir     if(*ppHdl)
259cdf0e10cSrcweir         *ppHdl=(*ppHdl)->pImpl->pNext;
260cdf0e10cSrcweir 	delete pImpl;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
RegisterDisplay(WindowDisplayErrorFunc * aDsp)263cdf0e10cSrcweir void ErrorHandler::RegisterDisplay(WindowDisplayErrorFunc *aDsp)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir     EDcrData *pData=EDcrData::GetData();
266cdf0e10cSrcweir     pData->bIsWindowDsp=sal_True;
267cdf0e10cSrcweir     pData->pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
RegisterDisplay(BasicDisplayErrorFunc * aDsp)270cdf0e10cSrcweir void ErrorHandler::RegisterDisplay(BasicDisplayErrorFunc *aDsp)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir     EDcrData *pData=EDcrData::GetData();
273cdf0e10cSrcweir     pData->bIsWindowDsp=sal_False;
274cdf0e10cSrcweir     pData->pDsp = reinterpret_cast< DisplayFnPtr >(aDsp);
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
HandleError_Impl(sal_uIntPtr lId,sal_uInt16 nFlags,sal_Bool bJustCreateString,String & rError)277cdf0e10cSrcweir sal_uInt16 ErrorHandler::HandleError_Impl(
278cdf0e10cSrcweir     sal_uIntPtr lId, sal_uInt16 nFlags, sal_Bool bJustCreateString, String & rError)
279cdf0e10cSrcweir {
280cdf0e10cSrcweir 
281cdf0e10cSrcweir /*  [Beschreibung]
282cdf0e10cSrcweir 	Handelt einen Fehler ab. lId ist die FehlerId, nFlags sind die
283cdf0e10cSrcweir 	ErrorFlags. Werden nFlags nicht abgegeben, so werden die in
284cdf0e10cSrcweir 	der DynamicErrorInfo angegebenen Flags bzw. die aus der Resource
285cdf0e10cSrcweir 	verwendet.
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 	Also:
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	1. nFlags,
290cdf0e10cSrcweir 	2. Resource Flags
291cdf0e10cSrcweir 	3. Dynamic Flags
292cdf0e10cSrcweir 	4. Default ERRCODE_BUTTON_OK, ERRCODE_MSG_ERROR
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	*/
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     String aErr;
298cdf0e10cSrcweir     String aAction;
299cdf0e10cSrcweir     if(!lId || lId == ERRCODE_ABORT)
300cdf0e10cSrcweir         return 0;
301cdf0e10cSrcweir     EDcrData *pData=EDcrData::GetData();
302cdf0e10cSrcweir     ErrorInfo *pInfo=ErrorInfo::GetErrorInfo(lId);
303cdf0e10cSrcweir     ErrorContext *pCtx=ErrorContext::GetContext();
304cdf0e10cSrcweir     if(pCtx)
305cdf0e10cSrcweir         pCtx->GetString(pInfo->GetErrorCode(), aAction);
306cdf0e10cSrcweir     Window *pParent=0;
307cdf0e10cSrcweir     //Nimm den Parent aus dem Konext
308cdf0e10cSrcweir     for(;pCtx;pCtx=pCtx->pNext)
309cdf0e10cSrcweir         if(pCtx->GetParent())
310cdf0e10cSrcweir         {
311cdf0e10cSrcweir             pParent=pCtx->GetParent();
312cdf0e10cSrcweir             break;
313cdf0e10cSrcweir         }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     sal_Bool bWarning = ((lId & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
316cdf0e10cSrcweir 	sal_uInt16 nErrFlags = ERRCODE_BUTTON_DEF_OK | ERRCODE_BUTTON_OK;
317cdf0e10cSrcweir     if (bWarning)
318cdf0e10cSrcweir         nErrFlags |= ERRCODE_MSG_WARNING;
319cdf0e10cSrcweir     else
320cdf0e10cSrcweir 		nErrFlags |= ERRCODE_MSG_ERROR;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir     DynamicErrorInfo* pDynPtr=PTR_CAST(DynamicErrorInfo,pInfo);
323cdf0e10cSrcweir     if(pDynPtr)
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir 		sal_uInt16 nDynFlags = pDynPtr->GetDialogMask();
326cdf0e10cSrcweir         if( nDynFlags )
327cdf0e10cSrcweir 			nErrFlags = nDynFlags;
328cdf0e10cSrcweir     }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     if(ErrHdl_Impl::CreateString(pData->pFirstHdl,pInfo,aErr,nErrFlags))
331cdf0e10cSrcweir     {
332cdf0e10cSrcweir 	if (bJustCreateString)
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 	    rError = aErr;
335cdf0e10cSrcweir 	    return 1;
336cdf0e10cSrcweir 	}
337cdf0e10cSrcweir 	else
338cdf0e10cSrcweir 	{
339cdf0e10cSrcweir 	    if(!pData->pDsp)
340cdf0e10cSrcweir 	    {
341cdf0e10cSrcweir 		ByteString aStr("Action: ");
342cdf0e10cSrcweir 		aStr += ByteString( aAction, RTL_TEXTENCODING_ASCII_US );
343cdf0e10cSrcweir 		aStr += ByteString("\nFehler: ");
344cdf0e10cSrcweir 		aStr += ByteString( aErr, RTL_TEXTENCODING_ASCII_US );
345cdf0e10cSrcweir 		DBG_ERROR( aStr.GetBuffer() );
346cdf0e10cSrcweir 	    }
347cdf0e10cSrcweir 	    else
348cdf0e10cSrcweir 	    {
349cdf0e10cSrcweir 		delete pInfo;
350cdf0e10cSrcweir 		if(!pData->bIsWindowDsp)
351cdf0e10cSrcweir 		{
352cdf0e10cSrcweir 		    (*(BasicDisplayErrorFunc*)pData->pDsp)(aErr,aAction);
353cdf0e10cSrcweir 		    return 0;
354cdf0e10cSrcweir 		}
355cdf0e10cSrcweir 		else
356cdf0e10cSrcweir 		{
357cdf0e10cSrcweir 		    if( nFlags != USHRT_MAX )
358cdf0e10cSrcweir 			nErrFlags = nFlags;
359cdf0e10cSrcweir 		    return (*(WindowDisplayErrorFunc*)pData->pDsp)(
360cdf0e10cSrcweir 			pParent, nErrFlags, aErr, aAction);
361cdf0e10cSrcweir 		}
362cdf0e10cSrcweir 	    }
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir     }
365cdf0e10cSrcweir     DBG_ERROR("Error nicht behandelt");
366cdf0e10cSrcweir     // Error 1 ist General Error im Sfx
367cdf0e10cSrcweir     if(pInfo->GetErrorCode()!=1) {
368cdf0e10cSrcweir         HandleError_Impl(1, USHRT_MAX, bJustCreateString, rError);
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir     else {
371cdf0e10cSrcweir         DBG_ERROR("Error 1 nicht gehandeled");
372cdf0e10cSrcweir     }
373cdf0e10cSrcweir     delete pInfo;
374cdf0e10cSrcweir     return 0;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir // static
GetErrorString(sal_uIntPtr lId,String & rStr)378cdf0e10cSrcweir sal_Bool ErrorHandler::GetErrorString(sal_uIntPtr lId, String& rStr)
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     return (sal_Bool)HandleError_Impl( lId, USHRT_MAX, sal_True, rStr );
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
HandleError(sal_uIntPtr lId,sal_uInt16 nFlags)383cdf0e10cSrcweir sal_uInt16 ErrorHandler::HandleError(sal_uIntPtr lId, sal_uInt16 nFlags)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 
386cdf0e10cSrcweir /*  [Beschreibung]
387cdf0e10cSrcweir 	Handelt einen Fehler ab. lId ist die FehlerId, nFlags sind die
388cdf0e10cSrcweir 	ErrorFlags. Werden nFlags nicht abgegeben, so werden die in
389cdf0e10cSrcweir 	der DynamicErrorInfo angegebenen Flags bzw. die aus der Resource
390cdf0e10cSrcweir 	verwendet.
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	Also:
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	1. nFlags,
395cdf0e10cSrcweir 	2. Resource Flags
396cdf0e10cSrcweir 	3. Dynamic Flags
397cdf0e10cSrcweir 	4. Default ERRCODE_BUTTON_OK, ERRCODE_MSG_ERROR
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 	*/
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     String aDummy;
403cdf0e10cSrcweir     return HandleError_Impl( lId, nFlags, sal_False, aDummy );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
ForwCreateString(const ErrorInfo * pInfo,String & rStr,sal_uInt16 & rFlags) const406cdf0e10cSrcweir sal_Bool ErrorHandler::ForwCreateString(const ErrorInfo* pInfo, String& rStr, sal_uInt16 &rFlags) const
407cdf0e10cSrcweir {
408cdf0e10cSrcweir     return ErrHdl_Impl::CreateString(this->pImpl->pNext, pInfo, rStr, rFlags);
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
CreateString(const ErrorHandler * pStart,const ErrorInfo * pInfo,String & pStr,sal_uInt16 & rFlags)411cdf0e10cSrcweir sal_Bool ErrHdl_Impl::CreateString( const ErrorHandler *pStart,
412cdf0e10cSrcweir                                 const ErrorInfo* pInfo, String& pStr,
413cdf0e10cSrcweir 							   sal_uInt16 &rFlags)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir     for(const ErrorHandler *pHdl=pStart;pHdl;pHdl=pHdl->pImpl->pNext)
416cdf0e10cSrcweir     {
417cdf0e10cSrcweir         if(pHdl->CreateString( pInfo, pStr, rFlags))
418cdf0e10cSrcweir             return sal_True;
419cdf0e10cSrcweir     }
420cdf0e10cSrcweir     return sal_False;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir 
CreateString(const ErrorInfo * pInfo,String & rStr,sal_uInt16 &) const423cdf0e10cSrcweir sal_Bool SimpleErrorHandler::CreateString(
424cdf0e10cSrcweir     const ErrorInfo *pInfo, String &rStr, sal_uInt16 &) const
425cdf0e10cSrcweir {
426cdf0e10cSrcweir 	sal_uIntPtr nId = pInfo->GetErrorCode();
427cdf0e10cSrcweir 	ByteString aStr;
428cdf0e10cSrcweir     aStr="Id ";
429cdf0e10cSrcweir     aStr+=ByteString::CreateFromInt32(nId);
430cdf0e10cSrcweir     aStr+=" only handled by SimpleErrorHandler";
431cdf0e10cSrcweir 	aStr+="\nErrorCode: ";
432cdf0e10cSrcweir 	aStr+=ByteString::CreateFromInt32(nId & ((1L <<  ERRCODE_CLASS_SHIFT)  - 1 ));
433cdf0e10cSrcweir 	aStr+="\nErrorClass: ";
434cdf0e10cSrcweir 	aStr+=ByteString::CreateFromInt32((nId & ERRCODE_CLASS_MASK) >> ERRCODE_CLASS_SHIFT);
435cdf0e10cSrcweir 	aStr+="\nErrorArea: ";
436cdf0e10cSrcweir 	aStr+=ByteString::CreateFromInt32((nId & ERRCODE_ERROR_MASK &
437cdf0e10cSrcweir 			~((1 << ERRCODE_AREA_SHIFT ) -1 ) ) >> ERRCODE_AREA_SHIFT);
438cdf0e10cSrcweir     DynamicErrorInfo *pDyn=PTR_CAST(DynamicErrorInfo,pInfo);
439cdf0e10cSrcweir     if(pDyn)
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir 		aStr+="\nDId ";
442cdf0e10cSrcweir 		aStr+=ByteString::CreateFromInt32((sal_uIntPtr)*pDyn);
443cdf0e10cSrcweir 	}
444cdf0e10cSrcweir     StandardErrorInfo *pStd=PTR_CAST(StandardErrorInfo,pInfo);
445cdf0e10cSrcweir     if(pStd)
446cdf0e10cSrcweir     {
447cdf0e10cSrcweir 		aStr+="\nXId ";
448cdf0e10cSrcweir 		aStr+=ByteString::CreateFromInt32(pStd->GetExtendedErrorCode());
449cdf0e10cSrcweir 	}
450cdf0e10cSrcweir 	rStr = String( aStr, RTL_TEXTENCODING_ASCII_US );
451cdf0e10cSrcweir     return sal_True;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
SimpleErrorHandler()454cdf0e10cSrcweir SimpleErrorHandler::SimpleErrorHandler()
455cdf0e10cSrcweir  : ErrorHandler()
456cdf0e10cSrcweir {
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459