|
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 Implementation header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SVGDECODER_H |
|
20 #define SVGDECODER_H |
|
21 |
|
22 #include <stdio.h> |
|
23 #include <e32std.h> |
|
24 #include <string.h> |
|
25 #include <e32base.h> |
|
26 #include <f32file.h> |
|
27 #include <s32file.h> |
|
28 |
|
29 #include "SVGPaintCssValueImpl.h" |
|
30 #include "SVGPathElementImpl.h" |
|
31 #include "GfxGeneralPath.h" |
|
32 #include "SVGSvgElementImpl.h" |
|
33 #include "SVGImageElementImpl.h" |
|
34 #include "SVGDocumentImpl.h" |
|
35 #include "SVGErrorImpl.h" |
|
36 |
|
37 enum TGfxEncodedSegType |
|
38 { |
|
39 EGfxEncodedSegMoveTo, |
|
40 EGfxEncodedSegLineTo, |
|
41 EGfxEncodedSegQuadTo, |
|
42 EGfxEncodedSegCubicTo, |
|
43 EGfxEncodedSegClose |
|
44 }; |
|
45 |
|
46 |
|
47 class CSvgDecoder : public CBase |
|
48 { |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Two phase constructor |
|
53 * |
|
54 * @since 1.0 |
|
55 * @param None |
|
56 * @return An isntance of this class |
|
57 */ |
|
58 static CSvgDecoder* NewL(const TDesC& aFileName); |
|
59 |
|
60 /** |
|
61 * Two phase constructor |
|
62 * |
|
63 * @since 1.0 |
|
64 * @param None |
|
65 * @return An isntance of this class |
|
66 */ |
|
67 static CSvgDecoder* NewL(const TDesC8& aByteData); |
|
68 |
|
69 /** |
|
70 * Reads a Descriptor's data |
|
71 * |
|
72 * @since 1.0 |
|
73 * @param |
|
74 * @return the created descriptor |
|
75 */ |
|
76 TDesC& DecodeTDesCLC(); |
|
77 |
|
78 /** |
|
79 * Reads a Descriptor's data. Used only for image element with |
|
80 * Embedde image. |
|
81 * @since 1.0 |
|
82 * @param |
|
83 * @return the created descriptor |
|
84 */ |
|
85 TDesC& DecodeImageEmbeddedTDesCLC(); |
|
86 |
|
87 /** |
|
88 * start of the decoder |
|
89 * |
|
90 * @since 1.0 |
|
91 * @param |
|
92 * @return the root element |
|
93 */ |
|
94 CSvgElementImpl* StartDecodingL(CSvgDocumentImpl *aDocument, CSvgErrorImpl& aError); |
|
95 |
|
96 |
|
97 /** |
|
98 * Read Data of a particular attribute |
|
99 * |
|
100 * @since 1.0 |
|
101 * @param Attribute Id |
|
102 * @return A value that indicates success/failure |
|
103 */ |
|
104 TInt DecodeAttributeL(const TUint16 aName); |
|
105 |
|
106 |
|
107 /** |
|
108 * Read Data of a presentation attribute |
|
109 * |
|
110 * @since 1.0 |
|
111 * @param Attribute Id |
|
112 * @return A value that indicates success/failure |
|
113 */ |
|
114 TBool DecodePresentationAttributeL(const TUint16 aName); |
|
115 |
|
116 /** |
|
117 * Read Data of a SVGT attribute |
|
118 * |
|
119 * @since 1.0 |
|
120 * @param Attribute Id |
|
121 * @return A value that indicates success/failure |
|
122 */ |
|
123 TBool DecodeSVGTAttributeL(const TUint16 aName); |
|
124 |
|
125 /** |
|
126 * Read Data of a SVGT attribute |
|
127 * |
|
128 * @since 1.0 |
|
129 * @param Attribute Id |
|
130 * @return A value that indicates success/failure |
|
131 */ |
|
132 TBool DecodeAnimationAttributeL(const TUint16 aName); |
|
133 |
|
134 |
|
135 /** |
|
136 * Read Data of a SVGT attribute |
|
137 * |
|
138 * @since 1.0 |
|
139 * @param Attribute Id |
|
140 * @return A value that indicates success/failure |
|
141 */ |
|
142 TBool DecodeSvgElementAttributeL(const TUint16 aName); |
|
143 |
|
144 /** |
|
145 * Read Data of a SVGT attribute |
|
146 * |
|
147 * @since 1.0 |
|
148 * @param Attribute Id |
|
149 * @return A value that indicates success/failure |
|
150 */ |
|
151 TBool DecodeLangSpaceAttributeL(const TUint16 aName); |
|
152 |
|
153 /** |
|
154 * Read Data of an attribute |
|
155 * |
|
156 * @since 1.0 |
|
157 * @param Attribute Id |
|
158 * @return A value that indicates success/failure |
|
159 */ |
|
160 TBool DecodeTransformAttributeL(const TUint16 aName); |
|
161 |
|
162 /** |
|
163 * Read Data of an attribute |
|
164 * |
|
165 * @since 1.0 |
|
166 * @param Attribute Id |
|
167 * @return A value that indicates success/failure |
|
168 */ |
|
169 TBool DecodeTestAttributeL(const TUint16 aName); |
|
170 |
|
171 /** |
|
172 * Read Data of an attribute |
|
173 * |
|
174 * @since 1.0 |
|
175 * @param Attribute Id |
|
176 * @return A value that indicates success/failure |
|
177 */ |
|
178 TBool DecodeIdAndXmlAttributeL(const TUint16 aName); |
|
179 |
|
180 /** |
|
181 * Read Data of an attribute |
|
182 * |
|
183 * @since 1.0 |
|
184 * @param Attribute Id |
|
185 * @return A value that indicates success/failure |
|
186 */ |
|
187 TBool DecodeUriRefAttributeL(const TUint16 aName); |
|
188 |
|
189 |
|
190 |
|
191 /** |
|
192 * Decode attributes for Discard element |
|
193 * |
|
194 * @since 1.2 |
|
195 * @param Attribute Id |
|
196 * @return A value that indicates success/failure |
|
197 */ |
|
198 TBool DecodeDiscardAttributeL (const TUint16& aName); |
|
199 |
|
200 |
|
201 /** |
|
202 * Read Data of an attribute |
|
203 * |
|
204 * @since 1.0 |
|
205 * @param Attribute Id |
|
206 * @return A value that indicates success/failure |
|
207 */ |
|
208 |
|
209 void SetPaintValueL (CCssValue*& aValue); |
|
210 |
|
211 /** |
|
212 * Read Data of an attribute |
|
213 * |
|
214 * @since 1.0 |
|
215 * @param Attribute Id |
|
216 * @return A value that indicates success/failure |
|
217 */ |
|
218 TBool DecodeColorCssValueL(const TUint16 aName); |
|
219 |
|
220 /** |
|
221 * Read Data of an attribute |
|
222 * |
|
223 * @since 1.0 |
|
224 * @param Attribute Id |
|
225 * @return A value that indicates success/failure |
|
226 */ |
|
227 TBool DecodeFloatCssValueL(const TUint16 aName); |
|
228 |
|
229 /** |
|
230 * Read Data of an attribute |
|
231 * |
|
232 * @since 1.0 |
|
233 * @param Attribute Id |
|
234 * @return A value that indicates success/failure |
|
235 */ |
|
236 TBool DecodeIntCssValueL(const TUint16 aName); |
|
237 |
|
238 /** |
|
239 * Read Data of an attribute |
|
240 * |
|
241 * @since 1.0 |
|
242 * @param Attribute Id |
|
243 * @return A value that indicates success/failure |
|
244 */ |
|
245 TBool DecodeStringCssValueL(const TUint16 aName); |
|
246 |
|
247 /** |
|
248 * Read a Des attribute value |
|
249 * |
|
250 * @since 1.0 |
|
251 * @param Attribute Id |
|
252 * @return A value that indicates success/failure |
|
253 */ |
|
254 TBool DecodeAttributeDesL(const TUint16 aName); |
|
255 |
|
256 /** |
|
257 * Read a path attribute value |
|
258 * |
|
259 * @since 1.0 |
|
260 * @param Attribute Id |
|
261 * @return A value that indicates success/failure |
|
262 */ |
|
263 TBool DecodeAttributePathL(const TUint16 aName); |
|
264 |
|
265 void DecodeAnimationPathL(CGfxGeneralPath*& aPath); |
|
266 |
|
267 /** |
|
268 * Read a float attribute value |
|
269 * |
|
270 * @since 1.0 |
|
271 * @param Attribute Id |
|
272 * @return A value that indicates success/failure |
|
273 */ |
|
274 TBool DecodeAttributeFloatL(const TUint16 aName); |
|
275 |
|
276 /** |
|
277 * Read a Int attribute value |
|
278 * |
|
279 * @since 1.0 |
|
280 * @param Attribute Id |
|
281 * @return A value that indicates success/failure |
|
282 */ |
|
283 TBool DecodeAttributeIntL(const TUint16 aName); |
|
284 |
|
285 // checks whether required attributes are present. |
|
286 void CheckRequiredAttributesL(const TUint8 aName); |
|
287 |
|
288 |
|
289 /** |
|
290 * Destructor |
|
291 * |
|
292 * @since 1.0 |
|
293 * @param None |
|
294 * @return None |
|
295 */ |
|
296 ~CSvgDecoder(); |
|
297 |
|
298 void RemoveFalseSwitchCases(); |
|
299 void RemoveFalseElements(); |
|
300 TBool VerifyReqExReqFtrSysL( CSvgElementImpl* aElement ); |
|
301 |
|
302 /** |
|
303 * Find out the system language for the client environment based on |
|
304 * SVG source hint |
|
305 * |
|
306 * @since 1.0 |
|
307 * @param aValue - A string buffer that contains the System Language hint |
|
308 * @return None |
|
309 */ |
|
310 void SystemLanguage( TPtr aValue ); |
|
311 |
|
312 private: |
|
313 |
|
314 // Default constructor |
|
315 CSvgDecoder(); |
|
316 |
|
317 /** |
|
318 * Part of two phase construction |
|
319 * |
|
320 * @since 1.0 |
|
321 * @param None |
|
322 * @return None |
|
323 */ |
|
324 void ConstructL(const TDesC& aFileName); |
|
325 |
|
326 // to read from a descriptor |
|
327 void ConstructL(const TDesC8& aByteData); |
|
328 |
|
329 /** |
|
330 * Removes references of element. Usually called before the element is |
|
331 * deleted. |
|
332 * |
|
333 * @since s60 3.2 |
|
334 * @param aElement Pointer of element that is about to be deleted. |
|
335 * @return none |
|
336 */ |
|
337 void RemoveInternalReferences( CSvgElementImpl* aElement ); |
|
338 |
|
339 private: // Data |
|
340 |
|
341 //All the functions in the class RReadStream that are used for reading data can Leave. |
|
342 RReadStream iStream; |
|
343 RFileReadStream iFStream; |
|
344 RDesReadStream iDStream; |
|
345 RFs iFs; |
|
346 |
|
347 CSvgElementImpl*iRootElement; // SVG Element |
|
348 CSvgElementImpl*iCurrentElement; // Latest discovered element |
|
349 CSvgElementImpl*iCurrentParentElement; // Parent element for the current depth |
|
350 CSvgDocumentImpl* iDocument; // The document object to which this SVG source is processed |
|
351 |
|
352 // Various attributes that hold document "depth" information |
|
353 TInt iIgnoreDepth; |
|
354 TBool iIsSvgElement; |
|
355 |
|
356 // Various booleans that indicate success/failure or true/false for various attributes |
|
357 TBool iIsAnimElement; |
|
358 |
|
359 CSvgErrorImpl* iSvgError; |
|
360 |
|
361 /* Added to support forward references in USE, Animation and Animate elements*/ |
|
362 RPointerArray<CSvgElementImpl>* iUseElementArray; |
|
363 RPointerArray<CSvgElementImpl>* iAnimationElementArray; |
|
364 RPointerArray<CSvgElementImpl>* iAnimRefElementArray; |
|
365 |
|
366 //array to keep track of switch elements |
|
367 //so we can go back at the end of parsing and remove the elements |
|
368 //that dont evaluate to true from memory |
|
369 RPointerArray<CSvgElementImpl>* iSwitchElementArray; |
|
370 RPointerArray<CSvgElementImpl>* iReqFetAttSysArray; |
|
371 |
|
372 //variable to tell if the encoder was encoding fixed points or floats |
|
373 TBool iIsFixPt; |
|
374 TBool iIsRGB; |
|
375 |
|
376 RPointerArray<CSvgImageElementImpl> iImageElements; |
|
377 // Embedded Images Need to be kept track cause loadimage is not called on them |
|
378 // iImageElements has only images that have uri |
|
379 // Document needs to be set with the total images so that it can perform a |
|
380 // callback to the client and indicate that all image loading is complete |
|
381 TInt iEmbeddedImagesCount; |
|
382 }; |
|
383 |
|
384 |
|
385 |
|
386 #endif |