|
1 /* |
|
2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: SVG Engine source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "SVGErrorImpl.h" |
|
20 |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // Two-phase constructor |
|
24 // --------------------------------------------------------------------------- |
|
25 CSvgErrorImpl* CSvgErrorImpl::NewL() |
|
26 { |
|
27 CSvgErrorImpl* self = NewLC(); |
|
28 CleanupStack::Pop(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Two-phase constructor |
|
34 // --------------------------------------------------------------------------- |
|
35 CSvgErrorImpl* CSvgErrorImpl::NewLC() |
|
36 { |
|
37 CSvgErrorImpl* self = new ( ELeave ) CSvgErrorImpl(); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Destructor |
|
45 // --------------------------------------------------------------------------- |
|
46 CSvgErrorImpl::~CSvgErrorImpl() |
|
47 { |
|
48 if(iDescription) |
|
49 { |
|
50 delete iDescription; |
|
51 iDescription = NULL; |
|
52 } |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // return Etrue if an error is indicated by this object. |
|
57 // --------------------------------------------------------------------------- |
|
58 TBool CSvgErrorImpl::HasError() |
|
59 { |
|
60 return iErrorCode != ESvgNoError; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // return Etrue if the error indicated by this object is only a warning. |
|
65 // --------------------------------------------------------------------------- |
|
66 TBool CSvgErrorImpl::IsWarning() |
|
67 { |
|
68 return iIsWarning; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Set the state that the error indicated by this object is only a warning. |
|
73 // --------------------------------------------------------------------------- |
|
74 void CSvgErrorImpl::SetIsWarning( TBool aBool ) |
|
75 { |
|
76 iIsWarning = aBool; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Get the error code. |
|
81 // --------------------------------------------------------------------------- |
|
82 TSvgErrorCode CSvgErrorImpl::ErrorCode() |
|
83 { |
|
84 return iErrorCode; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // Set the error code. |
|
89 // --------------------------------------------------------------------------- |
|
90 void CSvgErrorImpl::SetErrorCode( TSvgErrorCode aErrorCode ) |
|
91 { |
|
92 iErrorCode = aErrorCode; |
|
93 } |
|
94 // --------------------------------------------------------------------------- |
|
95 // Get the error description. |
|
96 // --------------------------------------------------------------------------- |
|
97 TDesC& CSvgErrorImpl::Description() |
|
98 { |
|
99 return *iDescription; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Set the given string as the description |
|
104 // --------------------------------------------------------------------------- |
|
105 void CSvgErrorImpl::SetDescription( const TDesC& aDescription ) |
|
106 { |
|
107 delete iDescription; |
|
108 iDescription = NULL; |
|
109 TRAPD( error, iDescription = aDescription.AllocL() ); |
|
110 if ( error != KErrNone ) |
|
111 { |
|
112 // ignore trap error |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // Set the given strings as the description |
|
118 // --------------------------------------------------------------------------- |
|
119 void CSvgErrorImpl::SetDescription( const TDesC& aText1, const TDesC& aText2 ) |
|
120 { |
|
121 delete iDescription; |
|
122 iDescription = NULL; |
|
123 TRAPD( error, iDescription = HBufC::NewL( aText1.Length() + aText2.Length() ) ); |
|
124 if ( error == KErrNone ) |
|
125 { |
|
126 iDescription->Des().Append( aText1 ); |
|
127 iDescription->Des().Append( aText2 ); |
|
128 } |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // Append the given string to the description |
|
133 // --------------------------------------------------------------------------- |
|
134 void CSvgErrorImpl::AppendDescription( const TDesC& aDescription ) |
|
135 { |
|
136 iDescription = iDescription->ReAlloc( iDescription->Length() + aDescription.Length() ); |
|
137 iDescription->Des().Append( aDescription ); |
|
138 } |
|
139 |
|
140 TInt CSvgErrorImpl::SystemErrorCode() |
|
141 { |
|
142 return iSystemErrorCode; |
|
143 } |
|
144 |
|
145 void CSvgErrorImpl::SetSystemErrorCode( TInt aErrorCode ) |
|
146 { |
|
147 iSystemErrorCode = aErrorCode; |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // Second phase of construction |
|
152 // --------------------------------------------------------------------------- |
|
153 void CSvgErrorImpl::ConstructL() |
|
154 { |
|
155 iDescription = HBufC::NewL( 1 ); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // Constructor |
|
160 // --------------------------------------------------------------------------- |
|
161 CSvgErrorImpl::CSvgErrorImpl() |
|
162 { |
|
163 SetIsWarning( ETrue ); |
|
164 SetErrorCode( ESvgNoError ); |
|
165 SetSystemErrorCode( KErrNone ); |
|
166 } |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |