|
1 /* |
|
2 * Copyright (c) 2005 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 __INC_CSVGDISCARDELEMENTIMPL__ |
|
20 #define __INC_CSVGDISCARDELEMENTIMPL__ |
|
21 |
|
22 // INCLUDES |
|
23 #include "SVGElementImpl.h" |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class CSvgDocumentImpl; |
|
27 class CSvgEngineImpl; |
|
28 |
|
29 |
|
30 /** |
|
31 * The Discard element allows content authors to specifiy the time at which particular |
|
32 * elements are to be discarded, therefore reducing the CPU and memory resources. |
|
33 * |
|
34 * The class does not export any function to other non SVG compoents. |
|
35 * |
|
36 * @lib SVGEngine.lib |
|
37 * @since 1.2 |
|
38 */ |
|
39 class CSvgDiscardElementImpl : public CSvgElementImpl |
|
40 { |
|
41 public: // Constructor/deconstructor |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 */ |
|
46 static CSvgDiscardElementImpl*NewL( const TUint8 aElemID, |
|
47 CSvgDocumentImpl* aDoc ); |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CSvgDiscardElementImpl*NewLC( const TUint8 aElemID, |
|
53 CSvgDocumentImpl* aDoc ); |
|
54 |
|
55 /** |
|
56 * Destructor. |
|
57 */ |
|
58 virtual ~CSvgDiscardElementImpl(); |
|
59 |
|
60 public: // From CSvgElementImpl |
|
61 |
|
62 |
|
63 /** |
|
64 * ReceiveEventL: This function will be called whenever the registered |
|
65 * event was happened. |
|
66 * |
|
67 * The call flow is like: |
|
68 * |
|
69 * _______ |
|
70 * | UI |------------------ |
|
71 * ------- | |
|
72 * v |
|
73 * ________ ________ ______________ |
|
74 * | Timer|-------------> |Engine|-------------->|EventHandler|-------- |
|
75 * -------- ProcessEvenL -------- ProcessEventL -------------- ReceiveEventL |
|
76 * |
|
77 * |
|
78 * _____________ ________________ |
|
79 * --->|ElementImpl| --------------> |DiscardElement| |
|
80 * ------------- ReceiveEventL ---------------- |
|
81 * |
|
82 * @since Series 60 3.1 SVGTiny 1.2 |
|
83 * @param aEvent |
|
84 * @return ETrue if redraw is needed. |
|
85 * |
|
86 */ |
|
87 TBool ReceiveEventL( MSvgEvent* aEvent ); |
|
88 |
|
89 /** |
|
90 * Clone the discard element |
|
91 * |
|
92 * @since 1.0 |
|
93 * @param MXmlElement* new parent element |
|
94 * @return MXmlElement* |
|
95 */ |
|
96 MXmlElement* CloneL( MXmlElement* aParentElement); |
|
97 |
|
98 |
|
99 /** |
|
100 * SetAttributeL: Attribute can only be xlink:href or begin |
|
101 * If it is xlink::href, it refers to the element that is to be discard. |
|
102 * |
|
103 * @since Series 60 3.1 SVGTiny 1.2 |
|
104 * @param aName Name of the attribute |
|
105 * aValue conent of the attribute |
|
106 * @return KErrNone if no error. |
|
107 */ |
|
108 TInt SetAttributeL( const TDesC& aName, const TDesC& aValue ); |
|
109 |
|
110 public: |
|
111 // Setter |
|
112 /** |
|
113 * Setter function for iTargetId |
|
114 * |
|
115 * @since Series 60 3.1 SVGTiny 1.2 |
|
116 * @param TDesC& Descriptor of the target element. |
|
117 * @return void |
|
118 */ |
|
119 void SetTargetId(const TDesC& aTargetId); |
|
120 |
|
121 /** |
|
122 * Setter function for iSyncValueDefined |
|
123 * |
|
124 * @since Series 60 3.1 SVGTiny 1.2 |
|
125 * @param TBool flag if Sync type of begine time is defined. |
|
126 * @return void |
|
127 */ |
|
128 void SetSyncValueDefined(TBool aSyncValueDefined); |
|
129 |
|
130 /** |
|
131 * Setter function for iEventValueDefined |
|
132 * |
|
133 * @since Series 60 3.1 SVGTiny 1.2 |
|
134 * @param TBool flag if event type of begin time is defined. |
|
135 * @return void |
|
136 */ |
|
137 void SetEventValueDefined(TBool aEventValueDefined); |
|
138 |
|
139 /** |
|
140 * Setter function for iHrefValueDefined |
|
141 * |
|
142 * @since Series 60 3.1 SVGTiny 1.2 |
|
143 * @param TBool flag if xlink:href is defined. |
|
144 * @return void |
|
145 */ |
|
146 void SetHrefValueDefined(TBool aHrefValueDefined); |
|
147 |
|
148 /** |
|
149 * Setter function for iBeginSyncElementId |
|
150 * |
|
151 * @since Series 60 3.1 SVGTiny 1.2 |
|
152 * @param TDesC& Descriptor of the referenced target element |
|
153 * @return void |
|
154 */ |
|
155 void SetBeginSyncElementId(const TDesC& aBeginSyncElementId); |
|
156 |
|
157 /** |
|
158 * Setter function for iAbsoluteBeginTime |
|
159 * |
|
160 * @since Series 60 3.1 SVGTiny 1.2 |
|
161 * @param TInt the value of Absolute begin time |
|
162 * @return void |
|
163 */ |
|
164 void SetAbsoluteBeginTime(TInt aAbsoluteBeginTime); |
|
165 |
|
166 /** |
|
167 * Setter function for iRefBeginTime |
|
168 * |
|
169 * @since Series 60 3.1 SVGTiny 1.2 |
|
170 * @param TInt the value of reference begin time |
|
171 * @return void |
|
172 */ |
|
173 void SetRefBeginTime(TInt aRefBeginTime); |
|
174 |
|
175 /** |
|
176 * Setter function for iKeyValue |
|
177 * |
|
178 * @since Series 60 3.1 SVGTiny 1.2 |
|
179 * @param TInt the value of key code from user |
|
180 * @return void |
|
181 */ |
|
182 void SetKeyValue(TInt aKeyValue); |
|
183 |
|
184 /** |
|
185 * Setter function for iBeginReferenceEvent |
|
186 * |
|
187 * @since Series 60 3.1 SVGTiny 1.2 |
|
188 * @param TSvgEvent the SVG event generated either by Timer |
|
189 * or UI. |
|
190 * @return void |
|
191 */ |
|
192 void SetBeginReferenceEvent(TSvgEvent aBeginReferenceEvent); |
|
193 |
|
194 // Getter |
|
195 |
|
196 /** |
|
197 * Getter function for iTargetId |
|
198 * |
|
199 * Target element to be removed. The id may be identified at |
|
200 * parsing stage after SetAttributeL. But if the xlink:href |
|
201 * does not specified, the value of TargetId could be NULL and |
|
202 * Target element will be parent. Or, if the specified target id |
|
203 * is not valid, then the discard element will remove itself. |
|
204 * |
|
205 * @since Series 60 3.1 SVGTiny 1.2 |
|
206 * @param none |
|
207 * @return TDesC& TargetId the target element's id |
|
208 */ |
|
209 const TDesC& TargetId(); |
|
210 |
|
211 /** |
|
212 * Getter function for iBeginSyncElementId |
|
213 * |
|
214 * @since Series 60 3.1 SVGTiny 1.2 |
|
215 * @param none |
|
216 * @return TDesC& iBeginSyncElementId the reference element's id |
|
217 */ |
|
218 const TDesC& BeginSyncElementId(); |
|
219 |
|
220 /** |
|
221 * Getter function for iAbsoluteBeginTime |
|
222 * |
|
223 * @since Series 60 3.1 SVGTiny 1.2 |
|
224 * @param none |
|
225 * @return TInt iAbsoluteBeginTime |
|
226 */ |
|
227 TInt AbsoluteBeginTime(); |
|
228 |
|
229 /** |
|
230 * Getter function for iSyncValueDefined |
|
231 * |
|
232 * @since Series 60 3.1 SVGTiny 1.2 |
|
233 * @param none |
|
234 * @return TBool iSyncValueDefined |
|
235 */ |
|
236 TBool IsSyncValueDefined(); |
|
237 |
|
238 /** |
|
239 * Getter function for iEventValueDefined |
|
240 * |
|
241 * @since Series 60 3.1 SVGTiny 1.2 |
|
242 * @param none |
|
243 * @return TBool iEventValueDefined |
|
244 */ |
|
245 TBool IsEventValueDefined(); |
|
246 |
|
247 /** |
|
248 * Getter function for iHrefValueDefined |
|
249 * |
|
250 * @since Series 60 3.1 SVGTiny 1.2 |
|
251 * @param none |
|
252 * @return TBool iHrefValueDefined |
|
253 */ |
|
254 TBool IsHrefValueDefined(); |
|
255 |
|
256 /** |
|
257 * Getter function for iRefBeginTime |
|
258 * |
|
259 * @since Series 60 3.1 SVGTiny 1.2 |
|
260 * @param none |
|
261 * @return TInt iRefBeginTime |
|
262 */ |
|
263 TInt RefBeginTime(); |
|
264 |
|
265 /** |
|
266 * Getter function for iKeyValue |
|
267 * |
|
268 * @since Series 60 3.1 SVGTiny 1.2 |
|
269 * @param none |
|
270 * @return TInt iKeyValue |
|
271 */ |
|
272 TInt KeyValue(); |
|
273 |
|
274 /** |
|
275 * Getter function for iBeginReferenceEvent |
|
276 * |
|
277 * @since Series 60 3.1 SVGTiny 1.2 |
|
278 * @param none |
|
279 * @return TSvgEvent iBeginReferenceEvent |
|
280 */ |
|
281 TSvgEvent BeginReferenceEvent(); |
|
282 |
|
283 void Print( TBool aIsEncodeOn ); |
|
284 |
|
285 protected: // From CSvgElementImpl |
|
286 |
|
287 /** |
|
288 * Copy content to an element |
|
289 * |
|
290 * @since 1.0 |
|
291 * @param CSvgDiscardElementImpl new element |
|
292 * @return none |
|
293 */ |
|
294 void CopyL( CSvgDiscardElementImpl* aDestElement ); |
|
295 |
|
296 private: |
|
297 |
|
298 /** |
|
299 * C++ default constructor. |
|
300 */ |
|
301 CSvgDiscardElementImpl( CSvgDocumentImpl* aDoc ); |
|
302 |
|
303 /** |
|
304 * Symbian 2nd phase constructor |
|
305 * |
|
306 * Mainly initialize the element and subscribe events to be listen. |
|
307 * |
|
308 * @since Series 60 3.1 SVGTiny 1.2 |
|
309 * @param |
|
310 * @return |
|
311 */ |
|
312 void ConstructL( const TUint8 aElemID ); |
|
313 |
|
314 |
|
315 private: //New Functions |
|
316 |
|
317 /** |
|
318 * Find the target element to be remmoved. |
|
319 * |
|
320 * If no target was found, the discard element is ignored and |
|
321 * will be removed later to save memory. |
|
322 * |
|
323 * @since Series 60 3.1 SVGTiny 1.2 |
|
324 * @param none |
|
325 * @return ETrue if target is found. |
|
326 */ |
|
327 TBool FindTargetElementL(); |
|
328 |
|
329 /** |
|
330 * Check to see if the target element is animation element |
|
331 * |
|
332 * @since Series 60 3.1 SVGTiny 1.2 |
|
333 * @param CSvgElementImpl* Target element |
|
334 * @return ETrue if the target element is animation element. |
|
335 */ |
|
336 //TBool IsAnimationElement(CSvgElementImpl* aElement); |
|
337 |
|
338 /** |
|
339 * Check to see if the target element contains any animation element |
|
340 * |
|
341 * @since Series 60 3.1 SVGTiny 1.2 |
|
342 * @param CSvgElementImpl* Target element |
|
343 * @return ETrue if the target element contains at least one |
|
344 * animation element. |
|
345 */ |
|
346 //TBool HasAnimationElements(CSvgElementImpl* aElement); |
|
347 |
|
348 /** |
|
349 * Remove target element |
|
350 * |
|
351 * @since Series 60 3.1 SVGTiny 1.2 |
|
352 * @param none |
|
353 * @return void |
|
354 */ |
|
355 void RemoveTargetElement(); |
|
356 |
|
357 |
|
358 |
|
359 private: |
|
360 |
|
361 // Target element to be removed. |
|
362 CSvgElementImpl* iTargetElement; |
|
363 |
|
364 // Time to be removed |
|
365 TInt32 iAbsoluteBeginTime; |
|
366 |
|
367 // Flag if the element needs to be removed. |
|
368 TBool iRemoveMyself; |
|
369 |
|
370 // Used in xlink:xhref to identify element to be removed. |
|
371 HBufC* iTargetId; |
|
372 |
|
373 // Flag to identify xlink:xhref is used |
|
374 TBool iHrefValueDefined; |
|
375 |
|
376 // Used in Syncbased begin time to identify element to be removed. |
|
377 TBuf<30> iBeginSyncElementId; |
|
378 |
|
379 // Used in Syncbased begin time to identify the event |
|
380 TSvgEvent iBeginReferenceEvent; |
|
381 |
|
382 // Flag to identity Sync-base begin time is used |
|
383 TBool iSyncValueDefined; |
|
384 |
|
385 // Flag to identity event-based begin time is used |
|
386 TBool iEventValueDefined; |
|
387 |
|
388 // Time to be used in Sync-based and event-based begin time |
|
389 TInt32 iRefBeginTime; |
|
390 |
|
391 // The element that is been referenced in sync-based and event-based |
|
392 CSvgElementImpl* iRefTargetElement; |
|
393 |
|
394 // Flag to identify referenced begin time is used |
|
395 TBool iRefBeginTimeSet; |
|
396 |
|
397 // Accesskey's scancode |
|
398 TInt iKeyValue; |
|
399 }; |
|
400 |
|
401 #endif // __INC_CSVGDISCARDELEMENTIMPL__ |