|
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 source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <utf.h> |
|
20 #include <s32mem.h> |
|
21 |
|
22 #include "SVGContentHandler.h" |
|
23 #include "Svgdecoder.h" |
|
24 |
|
25 #include "SVGDocumentImpl.h" |
|
26 #include "SVGEngineImpl.h" |
|
27 #include "SVGSvgElementImpl.h" |
|
28 #include "SVGLineElementImpl.h" |
|
29 #include "SVGRectElementImpl.h" |
|
30 #include "SVGCircleElementImpl.h" |
|
31 #include "SVGEllipseElementImpl.h" |
|
32 #include "SVGPolylineElementImpl.h" |
|
33 #include "SVGGElementImpl.h" |
|
34 #include "SVGPathElementImpl.h" |
|
35 #include "SVGMpathElementImpl.h" |
|
36 #include "SVGSchemaData.h" |
|
37 #include "SVGTextElementImpl.h" |
|
38 #include "SVGImageElementImpl.h" |
|
39 #include "SVGUseElementImpl.h" |
|
40 #include "SVGAElementImpl.h" |
|
41 #include "SVGStyleElementImpl.h" |
|
42 #include "SVGForeignObjectElementImpl.h" |
|
43 #include "SVGSetElementImpl.h" |
|
44 #include "SVGAnimateTransformElementImpl.h" |
|
45 #include "SVGAnimateElementImpl.h" |
|
46 #include "SVGAnimateMotionElementImpl.h" |
|
47 #include "SVGAnimationElementImpl.h" |
|
48 #include "SVGMetadataElementImpl.h" |
|
49 #include "SVGDescElementImpl.h" |
|
50 #include "SVGDefsElementImpl.h" |
|
51 #include "SVGTitleElementImpl.h" |
|
52 #include "SVGFontElementImpl.h" |
|
53 #include "SVGFontFaceElementImpl.h" |
|
54 #include "SVGGlyphElementImpl.h" |
|
55 #include "SVGMissingGlyphElementImpl.h" |
|
56 #include "SvgHkernelementimpl.h" |
|
57 |
|
58 #include "SVGLinearGradientElementImpl.h" |
|
59 #include "SVGRadialGradientElementImpl.h" |
|
60 #include "SvgStopElementImpl.h" |
|
61 #include "SVGDiscardElementImpl.h" |
|
62 #include "SVGScriptElementImpl.h" |
|
63 |
|
64 #include "SVGAudioElementImpl.h" |
|
65 |
|
66 //#ifdef RD_SVGT_MEDIAANIMATION_SUPPORT |
|
67 #include "SVGMediaAnimationElementImpl.h" |
|
68 //#endif |
|
69 #include "SVGTextAreaElementImpl.h" |
|
70 #include "SVGSolidColorElementImpl.h" |
|
71 |
|
72 #include "SVGFloatCssValueImpl.h" |
|
73 |
|
74 #include "SVGEventHandler.h" |
|
75 #include "SVGErrorImpl.h" |
|
76 #include "SVGFontHashMap.h" |
|
77 #include "SVGTimeContainer.h" |
|
78 #include <ezgzip.h> |
|
79 |
|
80 #include <caf/caf.h> |
|
81 #include <bautils.h> |
|
82 |
|
83 // ========================================================================== |
|
84 // Need method description |
|
85 // ========================================================================== |
|
86 CSvgDocumentImpl* CSvgDocumentImpl::NewL( CSvgBitmapFontProvider* aSvgBitmapFontProvider, const TBool aHasParent, |
|
87 const TSvgSyncBehaviour aSyncBehavDefault, |
|
88 const TInt32 aSyncTolDefault ) |
|
89 { |
|
90 CSvgDocumentImpl* self = new ( ELeave ) CSvgDocumentImpl(aSvgBitmapFontProvider, |
|
91 aHasParent, aSyncBehavDefault, aSyncTolDefault ); |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL(); |
|
94 CleanupStack::Pop(); |
|
95 |
|
96 return self; |
|
97 } |
|
98 |
|
99 // ========================================================================== |
|
100 // Need method description |
|
101 // ========================================================================== |
|
102 CSvgDocumentImpl* CSvgDocumentImpl::NewLC( CSvgBitmapFontProvider* aSvgBitmapFontProvider, const TBool aHasParent, |
|
103 const TSvgSyncBehaviour aSyncBehavDefault, |
|
104 const TInt32 aSyncTolDefault ) |
|
105 { |
|
106 CSvgDocumentImpl* self = new ( ELeave ) CSvgDocumentImpl(aSvgBitmapFontProvider, |
|
107 aHasParent, aSyncBehavDefault, aSyncTolDefault ); |
|
108 CleanupStack::PushL( self ); |
|
109 self->ConstructL(); |
|
110 |
|
111 return self; |
|
112 } |
|
113 |
|
114 // ========================================================================== |
|
115 // Need method description |
|
116 // ========================================================================== |
|
117 void CSvgDocumentImpl::ConstructL() |
|
118 { |
|
119 iSchemaData = CSvgSchemaData::NewL(); |
|
120 |
|
121 |
|
122 iEventHandler = CSvgEventHandler::NewL(); |
|
123 |
|
124 // create CSvgErrorImpl object |
|
125 // iSvgError = CSvgErrorImpl::NewL(); |
|
126 iIsInteractive = EFalse; |
|
127 iHasGroupOpacity = EFalse; |
|
128 |
|
129 |
|
130 // iImageHashMap = CSvgImageHashMap::NewL(); |
|
131 iFontHashMap = CSvgFontHashMap::NewL(); |
|
132 |
|
133 iMemoryManager = CSvgMemoryManager::NewL(); |
|
134 |
|
135 iTimeForJSR226 = 0; |
|
136 // Create the time container used for Runtime Sync |
|
137 iTimeContainer = CSvgTimeContainer::NewL( this, iHasParent ); |
|
138 |
|
139 // Add to the time container |
|
140 iTimeContainer->AddTimedEntityL( this ); |
|
141 |
|
142 //set media state to ready as default for document |
|
143 iTimeContainer->TimedEntityReady( this ); |
|
144 } |
|
145 |
|
146 // ========================================================================== |
|
147 // Need method description |
|
148 // ========================================================================== |
|
149 CSvgDocumentImpl::CSvgDocumentImpl( CSvgBitmapFontProvider* aSvgBitmapFontProvider, const TBool aHasParent, |
|
150 const TSvgSyncBehaviour aSyncBehavDefault, |
|
151 const TInt32 aSyncTolDefault ) : |
|
152 iInitSortList( ETrue ), |
|
153 iReqExReqFtrSysLTested( EFalse ), |
|
154 iFinishedParsing( EFalse ), |
|
155 iFontHashMap( NULL ), |
|
156 iEngine(NULL), |
|
157 iMultipleRendering( EFalse ), |
|
158 iHasGradientElement( EFalse ), |
|
159 iIsThumbNailMode( EFalse ), |
|
160 iIsDRMProtected( EFalse ), |
|
161 iHasParent( aHasParent ), |
|
162 iSyncBehaviorDefault( |
|
163 aSyncBehavDefault ), |
|
164 iSyncToleranceDefault( |
|
165 aSyncTolDefault), |
|
166 iSvgBitmapFontProvider(aSvgBitmapFontProvider) |
|
167 |
|
168 |
|
169 |
|
170 { |
|
171 SetDRMMode( ETrue ); |
|
172 SetDRMRights( ETrue ); |
|
173 } |
|
174 |
|
175 // ========================================================================== |
|
176 // Need method description |
|
177 // ========================================================================== |
|
178 CSvgDocumentImpl::~CSvgDocumentImpl() |
|
179 { |
|
180 if ( iTimeContainer ) |
|
181 { |
|
182 // Stop timer and reset time |
|
183 iTimeContainer->UserStop(); |
|
184 iTimeContainer->UserResetTime(); |
|
185 } |
|
186 |
|
187 if (iPerfText) |
|
188 { |
|
189 delete iPerfText; |
|
190 iPerfText = NULL; |
|
191 } |
|
192 |
|
193 if( iSchemaData ) |
|
194 { |
|
195 delete iSchemaData; |
|
196 iSchemaData = NULL; |
|
197 } |
|
198 |
|
199 if( iEventHandler ) |
|
200 { |
|
201 delete iEventHandler; |
|
202 iEventHandler = NULL ; |
|
203 } |
|
204 |
|
205 // if( iSvgError ) |
|
206 // { |
|
207 // delete iSvgError; |
|
208 // iSvgError = NULL; |
|
209 // } |
|
210 |
|
211 if( iRootElement ) |
|
212 { |
|
213 delete iRootElement; |
|
214 iRootElement = NULL; |
|
215 } |
|
216 |
|
217 /* if ( iImageHashMap ) |
|
218 { |
|
219 //probably should check to verify that the image ptrs |
|
220 //in this have had their images deleted somehow to be safe |
|
221 delete iImageHashMap; |
|
222 iImageHashMap = NULL; |
|
223 } */ |
|
224 |
|
225 if ( iFontHashMap ) |
|
226 { |
|
227 delete iFontHashMap; |
|
228 iFontHashMap = NULL; |
|
229 } |
|
230 iSvgMouseListeners.Close(); |
|
231 |
|
232 iSvgAnimations.Close(); |
|
233 |
|
234 if ( iXmlHandler ) |
|
235 { |
|
236 delete iXmlHandler; |
|
237 } |
|
238 |
|
239 if ( iError ) |
|
240 { |
|
241 delete iError; |
|
242 } |
|
243 |
|
244 if ( iMemoryManager ) |
|
245 { |
|
246 delete iMemoryManager; |
|
247 } |
|
248 |
|
249 delete iTimeContainer; |
|
250 } |
|
251 |
|
252 // ========================================================================== |
|
253 // Need method description |
|
254 // ========================================================================== |
|
255 void CSvgDocumentImpl::SetEngine( CSvgEngineImpl* aEngine ) |
|
256 { |
|
257 iEngine = aEngine; |
|
258 // Propogate this to all child documentsas well |
|
259 // Only animation elements currently possess a new document |
|
260 // Locate all the active animation elements |
|
261 RPointerArray<CSvgElementImpl> lAnimationEleList; |
|
262 |
|
263 FindAllElements( |
|
264 (CSvgElementImpl* )RootElement(), |
|
265 KSvgMediaAnimationElement, lAnimationEleList ); |
|
266 // Set the engine on the child documents associated with the animation elements as well |
|
267 TInt lAnimationEleCnt = lAnimationEleList.Count(); |
|
268 for ( TInt lCurAnimationEle = 0; lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ ) |
|
269 { |
|
270 CSvgMediaAnimationElementImpl* lAnimationElement = |
|
271 (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ]; |
|
272 CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument(); |
|
273 if ( lChildDoc ) |
|
274 { |
|
275 lChildDoc->SetEngine( aEngine ); |
|
276 } |
|
277 } |
|
278 lAnimationEleList.Close(); |
|
279 } |
|
280 |
|
281 // ========================================================================== |
|
282 // Need method description |
|
283 // ========================================================================== |
|
284 CSvgEngineImpl* CSvgDocumentImpl::Engine() |
|
285 { |
|
286 return iEngine; |
|
287 } |
|
288 |
|
289 //*********************************************************************** |
|
290 // From MXmlDocument |
|
291 // |
|
292 |
|
293 // ========================================================================== |
|
294 // Need method description |
|
295 // ========================================================================== |
|
296 MXmlElement* CSvgDocumentImpl::CreateElementL( const TDesC& aTagName ) |
|
297 { |
|
298 |
|
299 TInt position = iSchemaData->GetSVGElementId(aTagName); |
|
300 |
|
301 if ( position == KErrNotFound ) |
|
302 { |
|
303 return NULL; |
|
304 } |
|
305 |
|
306 return CreateElementL( position ); |
|
307 |
|
308 } |
|
309 |
|
310 // ========================================================================== |
|
311 // Need method description |
|
312 // ========================================================================== |
|
313 MXmlElement* CSvgDocumentImpl::CreateElementL(const TUint8 aTagName ) |
|
314 { |
|
315 |
|
316 TInt position = (TInt) aTagName; |
|
317 |
|
318 //##4 this uses the rearrangement of elements, all these elements are same as g element |
|
319 // same constructor |
|
320 // |
|
321 // =====> creating fake G elements to take the place of others... |
|
322 // |
|
323 //need to remove G elements as place holders that is a bad idea |
|
324 |
|
325 if( position >= KSvgAltglyphElement && position <= KSvgViewElement ) |
|
326 { |
|
327 return ( MXmlElement * ) CSvgGElementImpl::NewL( (TUint8) position, this ); |
|
328 } |
|
329 |
|
330 switch ( position ) |
|
331 { |
|
332 |
|
333 case KSvgPathElement: |
|
334 // path |
|
335 return ( MXmlElement * ) CSvgPathElementImpl::NewL( (TUint8) position, this ); |
|
336 |
|
337 case KSvgStopElement: |
|
338 // stop |
|
339 return ( MXmlElement * ) CSvgStopElementImpl::NewL((TUint8) position,this); |
|
340 |
|
341 case KSvgLinearGradientElement: |
|
342 // linearGradient |
|
343 return ( MXmlElement * ) CSvgLinearGradientElementImpl::NewL((TUint8) position,this); |
|
344 |
|
345 case KSvgRectElement: |
|
346 // rect |
|
347 return ( MXmlElement * ) CSvgRectElementImpl::NewL( (TUint8) position, this ); |
|
348 |
|
349 case KSvgPolygonElement: |
|
350 // polygon |
|
351 return ( MXmlElement * ) CSvgPolylineElementImpl::NewL( (TUint8) position, this ); |
|
352 |
|
353 case KSvgSvgElement: |
|
354 // svg |
|
355 return ( MXmlElement * ) CSvgSvgElementImpl::NewL( (TUint8) position, this ); |
|
356 |
|
357 case KSvgRadialGradientElement: |
|
358 // radialGradient |
|
359 return ( MXmlElement * ) CSvgRadialGradientElementImpl::NewL((TUint8) position,this); |
|
360 |
|
361 case KSvgCircleElement: |
|
362 // circle |
|
363 return ( MXmlElement * ) CSvgCircleElementImpl::NewL( (TUint8) position, this ); |
|
364 |
|
365 case KSvgLineElement: |
|
366 // line |
|
367 return ( MXmlElement * ) CSvgLineElementImpl::NewL( (TUint8) position,this ); |
|
368 |
|
369 case KSvgPolylineElement: |
|
370 // polyline |
|
371 return ( MXmlElement * ) CSvgPolylineElementImpl::NewL( (TUint8) position, this ); |
|
372 |
|
373 case KSvgEllipseElement: |
|
374 // ellipse |
|
375 return ( MXmlElement * ) CSvgEllipseElementImpl::NewL( (TUint8) position, this ); |
|
376 |
|
377 case KSvgDefsElement: |
|
378 // defs |
|
379 return ( MXmlElement * ) CSvgDefsElementImpl::NewL((TUint8) position, this); |
|
380 |
|
381 case KSvgForeignObjectElement: |
|
382 // foreignObject |
|
383 return ( MXmlElement * ) CSvgForeignObjectElementImpl::NewL((TUint8) position, this); |
|
384 |
|
385 case KSvgStyleElement: |
|
386 // style |
|
387 return ( MXmlElement * ) CSvgStyleElementImpl::NewL( (TUint8) position, this ); |
|
388 |
|
389 case KSvgUseElement: |
|
390 // use |
|
391 return ( MXmlElement * ) CSvgUseElementImpl::NewL( (TUint8) position, this ); |
|
392 |
|
393 case KSvgImageElement: |
|
394 // image |
|
395 return ( MXmlElement * ) CSvgImageElementImpl::NewL( (TUint8) position, this ); |
|
396 |
|
397 case KSvgAnimateColorElement: |
|
398 // animateColor |
|
399 case KSvgAnimateElement: |
|
400 { |
|
401 // animate |
|
402 CSvgAnimateElementImpl* lAnimateElement = CSvgAnimateElementImpl::NewL( (TUint8) position, this ); |
|
403 iSvgAnimations.Append(lAnimateElement); |
|
404 return ( MXmlElement * ) lAnimateElement; |
|
405 } |
|
406 |
|
407 case KSvgSetElement: |
|
408 // set |
|
409 return ( MXmlElement * ) CSvgSetElementImpl::NewL( (TUint8) position, this ); |
|
410 |
|
411 case KSvgMpathElement: |
|
412 // mPath |
|
413 return ( MXmlElement * ) CSvgMpathElementImpl::NewL( (TUint8) position, this ); |
|
414 |
|
415 case KSvgDiscardElement: |
|
416 // discard |
|
417 return ( MXmlElement * ) CSvgDiscardElementImpl::NewL( (TUint8) position, this ); |
|
418 |
|
419 /* case KSvgAnimationElement: |
|
420 { |
|
421 // animation |
|
422 CSvgAnimationElementImpl* lAnimationElementImpl = CSvgAnimationElementImpl::NewL( (TUint8) position, this ); |
|
423 iSvgAnimations.Append( lAnimationElementImpl ); |
|
424 return ( MXmlElement * ) lAnimationElementImpl; |
|
425 } |
|
426 */ |
|
427 case KSvgScriptElement: |
|
428 { |
|
429 // script |
|
430 return ( MXmlElement * ) CSvgScriptElementImpl::NewL((TUint8) position,this); |
|
431 } |
|
432 |
|
433 case KSvgSolidColorElement: |
|
434 // solidColor |
|
435 return ( MXmlElement * ) CSvgSolidColorElementImpl::NewL((TUint8) position,this); |
|
436 |
|
437 case KSvgMetadataElement: |
|
438 // metaData |
|
439 return ( MXmlElement * ) CSvgMetadataElementImpl::NewL((TUint8) position, this); |
|
440 |
|
441 case KSvgDescElement: |
|
442 // desc |
|
443 return ( MXmlElement * ) CSvgDescElementImpl::NewL((TUint8) position, this); |
|
444 |
|
445 case KSvgTitleElement: |
|
446 // title |
|
447 return ( MXmlElement * ) CSvgTitleElementImpl::NewL((TUint8) position, this); |
|
448 |
|
449 case KSvgTextElement: |
|
450 // text |
|
451 //add in the boolean thing here.... |
|
452 return ( MXmlElement * ) CSvgTextElementImpl::NewL( (TUint8) position, this ); |
|
453 |
|
454 case KSvgTextAreaElement: |
|
455 { |
|
456 // textArea |
|
457 return ( MXmlElement * ) CSvgTextAreaElementImpl::NewL((TUint8) position,this); |
|
458 } |
|
459 |
|
460 case KSvgAnimateMotionElement: |
|
461 { |
|
462 // animateMotion |
|
463 CSvgAnimateMotionElementImpl* lAnimateMotionElement = CSvgAnimateMotionElementImpl::NewL( (TUint8) position, this ); |
|
464 iSvgAnimations.Append(lAnimateMotionElement); |
|
465 return ( MXmlElement * ) lAnimateMotionElement; |
|
466 } |
|
467 |
|
468 case KSvgAnimateTransformElement: |
|
469 { |
|
470 // animateTransform |
|
471 CSvgAnimateTransformElementImpl* lAnimateTransformElement = CSvgAnimateTransformElementImpl::NewL( (TUint8) position, this ); |
|
472 iSvgAnimations.Append(lAnimateTransformElement); |
|
473 return ( MXmlElement * ) lAnimateTransformElement; |
|
474 } |
|
475 |
|
476 case KSvgGlyphElement: |
|
477 // glyph |
|
478 #ifdef SVG_FONTS_INCLUDE |
|
479 return ( MXmlElement * ) CSvgGlyphElementImpl::NewL( (TUint8) position, this ); |
|
480 #else |
|
481 return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" ),(TUint8) position, this ); |
|
482 #endif |
|
483 case KSvgFontElement: |
|
484 // font |
|
485 #ifdef SVG_FONTS_INCLUDE |
|
486 return ( MXmlElement * ) CSvgFontElementImpl::NewL( (TUint8) position, this ); |
|
487 #else |
|
488 return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" ),(TUint8) position, this ); |
|
489 #endif |
|
490 |
|
491 case KSvgAElement: |
|
492 // a |
|
493 return ( MXmlElement * ) CSvgAElementImpl::NewL( (TUint8) position, this ); |
|
494 |
|
495 case KSvgFontfaceElement: |
|
496 // font-face |
|
497 #ifdef SVG_FONTS_INCLUDE |
|
498 return ( MXmlElement * ) CSvgFontFaceElementImpl::NewL( (TUint8) position, this ); |
|
499 #else |
|
500 return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" )(TUint8) position, this ); |
|
501 #endif |
|
502 |
|
503 case KSvgMissingglyphElement: |
|
504 // missing-glyph |
|
505 #ifdef SVG_FONTS_INCLUDE |
|
506 return ( MXmlElement * ) CSvgMissingGlyphElementImpl::NewL( (TUint8) position, this ); |
|
507 #else |
|
508 return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" )(TUint8) position, this ); |
|
509 #endif |
|
510 |
|
511 case KSvgHkernElement: |
|
512 // hkern |
|
513 #ifdef SVG_FONTS_INCLUDE |
|
514 return ( MXmlElement * ) CSvgHkernElementImpl::NewL( (TUint8) position, this ); |
|
515 #else |
|
516 return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" )(TUint8) position, this ); |
|
517 #endif |
|
518 |
|
519 case KSvgAudioElement: |
|
520 { |
|
521 CSvgAudioElementImpl* lAudioElement = CSvgAudioElementImpl::NewL( (TUint8) position, this ); |
|
522 iSvgAnimations.Append(lAudioElement); |
|
523 return ( MXmlElement * ) lAudioElement; |
|
524 } |
|
525 //#ifdef RD_SVGT_MEDIAANIMATION_SUPPORT |
|
526 case KSvgMediaAnimationElement: |
|
527 { |
|
528 CSvgMediaAnimationElementImpl* lMediaAnimationElement = CSvgMediaAnimationElementImpl::NewL( (TUint8) position, this ); |
|
529 iSvgAnimations.Append(lMediaAnimationElement); |
|
530 return ( MXmlElement * ) lMediaAnimationElement; |
|
531 } |
|
532 //#endif |
|
533 |
|
534 } // for switch |
|
535 |
|
536 return NULL; |
|
537 } |
|
538 |
|
539 // ========================================================================== |
|
540 // Need method description |
|
541 // ========================================================================== |
|
542 TInt CSvgDocumentImpl::CreateAttribute( const TDesC& /* aName */ ) |
|
543 { |
|
544 return KErrNone; |
|
545 } |
|
546 |
|
547 // ========================================================================== |
|
548 // Need method description |
|
549 // ========================================================================== |
|
550 MXmlElement* CSvgDocumentImpl::GetElementById( const TDesC& aElementId ) |
|
551 { |
|
552 if(iRootElement) |
|
553 { |
|
554 const TDesC* myId = iRootElement->Id(); |
|
555 |
|
556 if (myId) |
|
557 { |
|
558 if (myId->Length() > 0) |
|
559 { |
|
560 if ( *myId == aElementId ) |
|
561 { |
|
562 return iRootElement; |
|
563 } |
|
564 } |
|
565 } |
|
566 |
|
567 MXmlElement* element = SearchElementById( iRootElement, aElementId ); |
|
568 |
|
569 return element; |
|
570 } |
|
571 else |
|
572 { |
|
573 return NULL; |
|
574 } |
|
575 } |
|
576 |
|
577 // ========================================================================== |
|
578 // Need method description |
|
579 // ========================================================================== |
|
580 TInt CSvgDocumentImpl::GetNumberOfIds(MXmlElement* aElement) |
|
581 { |
|
582 TInt count = 0; |
|
583 |
|
584 CSvgElementImpl* child = ( CSvgElementImpl* ) aElement->FirstChild(); |
|
585 while ( child != NULL ) |
|
586 { |
|
587 const TDesC* lPtr = child->Id(); |
|
588 |
|
589 if (lPtr) |
|
590 { |
|
591 count++; |
|
592 } |
|
593 // search children |
|
594 TInt inside_count = GetNumberOfIds( child ); |
|
595 if ( inside_count > 0 ) |
|
596 { |
|
597 count = count + inside_count; |
|
598 } |
|
599 // search siblings |
|
600 |
|
601 child = ( CSvgElementImpl * ) child->NextSibling(); |
|
602 } |
|
603 |
|
604 return count; |
|
605 } |
|
606 |
|
607 // ========================================================================== |
|
608 // Need method description |
|
609 // ========================================================================== |
|
610 TDesC* CSvgDocumentImpl::GetId(TInt index) |
|
611 { |
|
612 TDesC* id = NULL; |
|
613 RPointerArray<TDesC> ids; |
|
614 |
|
615 FindAllIds( (CSvgElementImpl*)RootElement(), ids ); |
|
616 |
|
617 if (index < ids.Count()) |
|
618 { |
|
619 id = ids[index]; |
|
620 } |
|
621 |
|
622 ids.Close(); |
|
623 |
|
624 return id; |
|
625 } |
|
626 |
|
627 // ========================================================================== |
|
628 // // Return all elements of the given type |
|
629 // ========================================================================== |
|
630 void CSvgDocumentImpl::FindAllIds( CSvgElementImpl* aStartElement, RPointerArray<TDesC>& aList ) |
|
631 { |
|
632 if ( aStartElement == NULL ) |
|
633 return; |
|
634 |
|
635 CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild(); |
|
636 while ( child != NULL ) |
|
637 { |
|
638 // add to list if child is found |
|
639 const TDesC* myId = child->Id(); |
|
640 |
|
641 if ( myId ) |
|
642 aList.Append( myId ); |
|
643 |
|
644 // find in grandchildren |
|
645 FindAllIds( child, aList ); |
|
646 child = (CSvgElementImpl*)child->NextSibling(); |
|
647 } |
|
648 } |
|
649 |
|
650 |
|
651 //*********************************************************************** |
|
652 // From MSvgDocument |
|
653 // |
|
654 |
|
655 |
|
656 |
|
657 // |
|
658 // ========================================================================== |
|
659 // Need method description |
|
660 // ========================================================================== |
|
661 TDesC& CSvgDocumentImpl::GetUrl() |
|
662 { |
|
663 return iUri; |
|
664 } |
|
665 |
|
666 // ========================================================================== |
|
667 // // Returns the value of the current focus index. |
|
668 // ========================================================================== |
|
669 |
|
670 TInt32 CSvgDocumentImpl::GetCurFocusIndex() |
|
671 { |
|
672 return iCurObjIdx; |
|
673 } |
|
674 |
|
675 |
|
676 // ========================================================================== |
|
677 // // Increment the focus index by one value |
|
678 // ========================================================================== |
|
679 |
|
680 TInt32 CSvgDocumentImpl::IncCurFocusIndex() |
|
681 { |
|
682 return ++iCurObjIdx; |
|
683 } |
|
684 |
|
685 // ========================================================================== |
|
686 // // Decrement the focus index by one value |
|
687 // ========================================================================== |
|
688 TInt32 CSvgDocumentImpl::DecCurFocusIndex() |
|
689 { |
|
690 return --iCurObjIdx; |
|
691 } |
|
692 |
|
693 // ========================================================================== |
|
694 // // Sets the focus index to the given value |
|
695 // ========================================================================== |
|
696 void CSvgDocumentImpl::SetCurFocusIndex(TInt32 aVal) |
|
697 { |
|
698 iCurObjIdx = aVal; |
|
699 } |
|
700 |
|
701 // ========================================================================== |
|
702 // // Returns the current focus object |
|
703 // ========================================================================== |
|
704 CSvgElementImpl* CSvgDocumentImpl::GetCurFocusObject() |
|
705 { |
|
706 return iCurrentFocusObject; |
|
707 } |
|
708 |
|
709 // ========================================================================== |
|
710 // // Sets the current focus element to the element specified |
|
711 // ========================================================================== |
|
712 void CSvgDocumentImpl::SetCurFocusObject(CSvgElementImpl* aElement) |
|
713 { |
|
714 iCurrentFocusObject = aElement; |
|
715 } |
|
716 |
|
717 // |
|
718 // ========================================================================== |
|
719 // Need method description |
|
720 // ========================================================================== |
|
721 EXPORT_C MXmlElement* CSvgDocumentImpl::RootElement() |
|
722 { |
|
723 return iRootElement; |
|
724 } |
|
725 |
|
726 //*********************************************************************** |
|
727 // |
|
728 // |
|
729 |
|
730 // ========================================================================== |
|
731 // Need method description |
|
732 // ========================================================================== |
|
733 MXmlElement* CSvgDocumentImpl::SearchElementById( MXmlElement* aElement, |
|
734 const TDesC& aElementId ) |
|
735 { |
|
736 CSvgElementImpl* child = ( CSvgElementImpl* ) aElement->FirstChild(); |
|
737 while ( child != NULL ) |
|
738 { |
|
739 const TDesC* lPtr = child->Id(); |
|
740 |
|
741 if (lPtr) |
|
742 { |
|
743 if ( *lPtr == aElementId ) |
|
744 { |
|
745 return child; |
|
746 } |
|
747 } |
|
748 // search children |
|
749 MXmlElement* childrenMatch = SearchElementById( child, aElementId ); |
|
750 if ( childrenMatch != NULL ) |
|
751 { |
|
752 return childrenMatch; |
|
753 } |
|
754 // search siblings |
|
755 |
|
756 child = ( CSvgElementImpl * ) child->NextSibling(); |
|
757 |
|
758 } |
|
759 return NULL; |
|
760 } |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 // ========================================================================== |
|
766 // Need method description |
|
767 // ========================================================================== |
|
768 MXmlElement* CSvgDocumentImpl::AppendChildL( MXmlElement* aNewChild ) |
|
769 { |
|
770 |
|
771 if ( aNewChild && ((CXmlElementImpl*)aNewChild)->ElemID() == KSvgSvgElement ) |
|
772 |
|
773 { |
|
774 // Set new node as the root element, if it is |
|
775 if ( iRootElement ) |
|
776 { |
|
777 return NULL; |
|
778 } |
|
779 iRootElement = (CSvgElementImpl *) aNewChild; |
|
780 |
|
781 // Set the new node's next sibling |
|
782 aNewChild->SetNextSibling( NULL ); |
|
783 } |
|
784 else |
|
785 { |
|
786 return NULL; |
|
787 } |
|
788 |
|
789 return aNewChild; |
|
790 } |
|
791 |
|
792 |
|
793 // ========================================================================== |
|
794 // Need method description |
|
795 // ========================================================================== |
|
796 CSvgSchemaData* CSvgDocumentImpl::SchemaData() |
|
797 { |
|
798 return iSchemaData; |
|
799 } |
|
800 |
|
801 |
|
802 // ========================================================================== |
|
803 // Need method description |
|
804 // ========================================================================== |
|
805 void CSvgDocumentImpl::SetUri( const TDesC& aUri ) |
|
806 { |
|
807 iUri.Zero(); |
|
808 iUri.Copy(aUri); |
|
809 } |
|
810 |
|
811 // ========================================================================== |
|
812 // Need method description |
|
813 // ========================================================================== |
|
814 void CSvgDocumentImpl::GetUri( TDes& aUri ) |
|
815 { |
|
816 aUri.Zero(); |
|
817 aUri.Copy(iUri); |
|
818 } |
|
819 |
|
820 // ========================================================================== |
|
821 // Register an element for receiving events using the event mask |
|
822 // ========================================================================== |
|
823 void CSvgDocumentImpl::AddToEventReceiverListL( MSvgEventReceiver* aElement, |
|
824 TUint8 aEventMask) |
|
825 { |
|
826 if (iEventHandler != NULL) |
|
827 iEventHandler->AddToEventReceiverListL( aElement, aEventMask ); |
|
828 } |
|
829 |
|
830 // ========================================================================== |
|
831 // Register an element for receiving events and events using the event mask |
|
832 // ========================================================================== |
|
833 void CSvgDocumentImpl::AddToEventReceiverListL( MSvgEventReceiver* aElement, |
|
834 TSvgEvent aEvent, |
|
835 TUint8 aEventMask) |
|
836 { |
|
837 if (iEventHandler != NULL) |
|
838 iEventHandler->AddToEventReceiverListL( aElement,aEvent,aEventMask ); |
|
839 } |
|
840 |
|
841 // ========================================================================== |
|
842 // Unregister an element for receiving events using the event mask |
|
843 // ========================================================================== |
|
844 void CSvgDocumentImpl::RemoveFromEventReceiverList( MSvgEventReceiver* aElement ) |
|
845 { |
|
846 if (iEventHandler != NULL) |
|
847 iEventHandler->RemoveFromEventReceiverList( aElement ); |
|
848 } |
|
849 |
|
850 // ========================================================================== |
|
851 // Provide event handler the event timing information for the |
|
852 // completion of event. |
|
853 // ========================================================================== |
|
854 void CSvgDocumentImpl::AddEventBeginTime(MSvgEventReceiver* aElement, TUint32 aTime, MSvgEventReceiver* aTargetElement ) |
|
855 { |
|
856 if (iEventHandler != NULL) |
|
857 iEventHandler->AddEventBeginTime( aElement, aTime, aTargetElement ); |
|
858 } |
|
859 |
|
860 // ========================================================================== |
|
861 // Sort the events in a time scale according to their absolute start |
|
862 // and finish times |
|
863 // ========================================================================== |
|
864 void CSvgDocumentImpl::SortEventList() |
|
865 { |
|
866 if (iEventHandler != NULL) |
|
867 iEventHandler->SortEventList(); |
|
868 } |
|
869 |
|
870 // |
|
871 // ========================================================================== |
|
872 // Returns an element that is registered for the given event mask and |
|
873 // is the first one starting from the given index (either up or down the |
|
874 // list based on the aNext parameter) |
|
875 // ========================================================================== |
|
876 CSvgElementImpl* CSvgDocumentImpl::GetEventReceiverElement(TInt32 aIndex, TBool aNext, TUint8 aEventMask, TInt32& aNewIndex) |
|
877 { |
|
878 if (iEventHandler != NULL) |
|
879 { |
|
880 return (CSvgElementImpl*)iEventHandler->GetEventReceiver(aIndex, aNext, aEventMask, aNewIndex); |
|
881 } |
|
882 else |
|
883 return NULL; |
|
884 |
|
885 } |
|
886 |
|
887 // ========================================================================== |
|
888 // Is Animation file |
|
889 // ========================================================================== |
|
890 TBool CSvgDocumentImpl::IsAnimationFile() |
|
891 { |
|
892 if( (iEventHandler != NULL) && iEventHandler->Count() ) |
|
893 return ETrue; |
|
894 else |
|
895 return EFalse; |
|
896 } |
|
897 |
|
898 // ========================================================================== |
|
899 // IsValidSubEventMask |
|
900 // ========================================================================== |
|
901 TBool CSvgDocumentImpl::IsValidSubEventMask(TUint16 aSubEventMask) |
|
902 { |
|
903 if(iEventHandler) |
|
904 { |
|
905 return(iEventHandler->IsValidSubEventMask(aSubEventMask)); |
|
906 } |
|
907 else |
|
908 { |
|
909 return EFalse; |
|
910 } |
|
911 } |
|
912 // ========================================================================== |
|
913 // Set DRM Mode |
|
914 // ========================================================================== |
|
915 |
|
916 void CSvgDocumentImpl::SetDRMMode(TBool aEnable) |
|
917 { |
|
918 iDrmEnable = aEnable; |
|
919 } |
|
920 // ========================================================================== |
|
921 // Set DRM Mode |
|
922 // ========================================================================== |
|
923 void CSvgDocumentImpl::Reset(MSvgEvent *aEvent) |
|
924 { |
|
925 if ( iAnimationResetNeeded && iEventHandler != NULL ) |
|
926 { |
|
927 iEventHandler->Reset( aEvent ); |
|
928 iAnimationResetNeeded = EFalse; |
|
929 } |
|
930 } |
|
931 // ========================================================================== |
|
932 // Set DRM Mode |
|
933 // ========================================================================== |
|
934 TBool CSvgDocumentImpl::SvgElementPresent(CSvgElementImpl* aElement) |
|
935 { |
|
936 if(iRootElement == NULL) return EFalse; |
|
937 if ( ( ( CSvgElementImpl * ) iRootElement ) == aElement ) |
|
938 { |
|
939 return ETrue; |
|
940 } |
|
941 |
|
942 return SearchByPointer(iRootElement, aElement); |
|
943 |
|
944 } |
|
945 // ========================================================================== |
|
946 // Set DRM Mode |
|
947 // ========================================================================== |
|
948 TBool CSvgDocumentImpl::SearchByPointer(CSvgElementImpl* aParent, CSvgElementImpl* aElement) |
|
949 { |
|
950 CSvgElementImpl* child = ( CSvgElementImpl* ) aParent->FirstChild(); |
|
951 while ( child != NULL ) |
|
952 { |
|
953 |
|
954 if ( child == aElement ) |
|
955 { |
|
956 return ETrue; |
|
957 } |
|
958 // search children |
|
959 TBool result = SearchByPointer( child, aElement ); |
|
960 if (result) |
|
961 { |
|
962 return ETrue; |
|
963 } |
|
964 // search siblings |
|
965 child = ( CSvgElementImpl * ) child->NextSibling(); |
|
966 } |
|
967 return EFalse; |
|
968 } |
|
969 // ========================================================================== |
|
970 // Set DRM Mode |
|
971 // ========================================================================== |
|
972 void CSvgDocumentImpl::SetFocusElement(CXmlElementImpl* aElement ) |
|
973 { |
|
974 iCurrentFocusObject = (CSvgElementImpl*)aElement; |
|
975 } |
|
976 // ========================================================================== |
|
977 // Set DRM Mode |
|
978 // ========================================================================== |
|
979 CXmlElementImpl* CSvgDocumentImpl::GetFocusElement() |
|
980 { |
|
981 return (CXmlElementImpl*) iCurrentFocusObject; |
|
982 } |
|
983 |
|
984 // ========================================================================== |
|
985 // Need method description |
|
986 // ========================================================================== |
|
987 void CSvgDocumentImpl::ReInitialize() |
|
988 { |
|
989 if(iMultipleRendering) |
|
990 { |
|
991 if (iEventHandler != NULL) |
|
992 iEventHandler->ReInitialize(); |
|
993 } |
|
994 else |
|
995 { |
|
996 iMultipleRendering= ETrue; |
|
997 } |
|
998 } |
|
999 |
|
1000 // ========================================================================== |
|
1001 // Need method description |
|
1002 // ========================================================================== |
|
1003 void CSvgDocumentImpl::Load( const TDesC& aFileName, CSvgErrorImpl& aError ) |
|
1004 { |
|
1005 aError.SetErrorCode( ESvgNoError ); |
|
1006 |
|
1007 RFs session; |
|
1008 OpenSession( session, aError ); |
|
1009 if ( aError.HasError() ) |
|
1010 return; |
|
1011 |
|
1012 RFile fileHandle; |
|
1013 TInt openError = fileHandle.Open( session, aFileName, EFileRead ); |
|
1014 if ( openError != KErrNone ) |
|
1015 { |
|
1016 PrepareError( aError, ESvgUnknown, openError, |
|
1017 _L( "Fail to open file for reading: " ), aFileName ); |
|
1018 session.Close(); |
|
1019 return; |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 Load( fileHandle, aError ); |
|
1024 session.Close(); |
|
1025 } |
|
1026 } |
|
1027 |
|
1028 // ========================================================================== |
|
1029 // Need method description |
|
1030 // ========================================================================== |
|
1031 void CSvgDocumentImpl::Load( const TDesC8& aByteData, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements ) |
|
1032 { |
|
1033 aError.SetErrorCode( ESvgNoError ); |
|
1034 |
|
1035 //------------------------------------------------------------------- |
|
1036 // Byte array is gzipped and/or drm: |
|
1037 // Write buffer to file: |
|
1038 // a) GZip only has filename function to unzip |
|
1039 // b) Drm only has file-handle to decrypt |
|
1040 //------------------------------------------------------------------- |
|
1041 if ( IsGzipContent( aByteData ) || |
|
1042 ( iDrmEnable && IsDRMContent( aByteData ) ) ) |
|
1043 { |
|
1044 RFs session; |
|
1045 OpenSession( session, aError ); |
|
1046 if ( aError.HasError() ) |
|
1047 return; |
|
1048 |
|
1049 // Write byte-array to temp file |
|
1050 TFileName zippedTempFilename; |
|
1051 if ( WriteToTempFile( session, aByteData, zippedTempFilename, aError ) != KErrNone ) |
|
1052 { |
|
1053 session.Close(); |
|
1054 return; |
|
1055 } |
|
1056 Load( zippedTempFilename, aError ); |
|
1057 session.Delete( zippedTempFilename ); |
|
1058 session.Close(); |
|
1059 } |
|
1060 //------------------------------------------------------------------- |
|
1061 // byte-array is neither gzipped nor DRM encrypted |
|
1062 //------------------------------------------------------------------- |
|
1063 else |
|
1064 { |
|
1065 iIsDRMProtected = EFalse; |
|
1066 iEventHandler->Reset(); |
|
1067 TRAPD(error,ProcessSvgContentL( aByteData, aError, aRemoveFalseSwitchElements )); |
|
1068 if ( error != KErrNone ) |
|
1069 { |
|
1070 PrepareError( aError, ESvgNoMemory, error, |
|
1071 _L( "Out of Memory: " ), |
|
1072 _L( "Instantiating Parser" ) ); |
|
1073 } |
|
1074 |
|
1075 iInitialDrawFlag = ETrue; |
|
1076 iFinishedParsing = ETrue; |
|
1077 |
|
1078 } |
|
1079 } |
|
1080 |
|
1081 // ========================================================================== |
|
1082 // Need method description |
|
1083 // ========================================================================== |
|
1084 void CSvgDocumentImpl::Load( RFile& aFileHandle, CSvgErrorImpl& aError ) |
|
1085 { |
|
1086 aError.SetErrorCode( ESvgNoError ); |
|
1087 |
|
1088 RFs session; |
|
1089 OpenSession( session, aError ); |
|
1090 if ( !aError.HasError() ) |
|
1091 { |
|
1092 Load( session, aFileHandle, aError ); |
|
1093 session.Close(); |
|
1094 } |
|
1095 } |
|
1096 // ----------------------------------------------------------------------------- |
|
1097 // CSvgDocumentImpl::ParentTimeContainerTick |
|
1098 // From MSvgTimedEntityInterface |
|
1099 // ----------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CSvgDocumentImpl::ParentTimeContainerTick( |
|
1102 TSvgTick aTick ) // Current tick information |
|
1103 { |
|
1104 TBool lDoRedraw = ETrue; |
|
1105 if ( iHasParent ) |
|
1106 { |
|
1107 // Do not redraw in child document to avoid |
|
1108 // double redraws. |
|
1109 lDoRedraw = EFalse; |
|
1110 } |
|
1111 // Create timer event and propogate to engine |
|
1112 TSvgTimerEvent lTimerEvent( aTick.iParentTcTick ); |
|
1113 // Send to engine to process the timer event |
|
1114 TRAPD( lProcEvtErr, Engine()->ProcessEventL( |
|
1115 this, &lTimerEvent, lDoRedraw ) ); |
|
1116 if ( lProcEvtErr != KErrNone ) |
|
1117 { |
|
1118 // Error Processing |
|
1119 } |
|
1120 } |
|
1121 |
|
1122 // ----------------------------------------------------------------------------- |
|
1123 // CSvgDocumentImpl::GetEntitySyncBehavior |
|
1124 // From MSvgTimedEntityInterface |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 // |
|
1127 TSvgSyncBehaviour CSvgDocumentImpl::GetEntitySyncBehavior() |
|
1128 { |
|
1129 // Document is locked with the parent tc timeline |
|
1130 return ESvgSyncLocked; |
|
1131 } |
|
1132 |
|
1133 |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // CSvgDocumentImpl::GetEntityCurrentTime |
|
1136 // From MSvgTimedEntityInterface |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // |
|
1139 void CSvgDocumentImpl::GetEntityCurrentTime( TUint32& |
|
1140 /* aEntityCurTime */) // Current Entity Time in msecs. |
|
1141 { |
|
1142 } |
|
1143 |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // CSvgDocumentImpl::GetCnfSyncMasterStatus |
|
1146 // From MSvgTimedEntityInterface |
|
1147 // ----------------------------------------------------------------------------- |
|
1148 // |
|
1149 void CSvgDocumentImpl::GetCnfSyncMasterStatus( |
|
1150 TBool& aIsSyncMaster ) // Indicates whether the element is configured as |
|
1151 // Sync Master. |
|
1152 { |
|
1153 // Document can never be a sync master |
|
1154 aIsSyncMaster = EFalse; |
|
1155 } |
|
1156 |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // CSvgDocumentImpl::GetCurSyncMasterStatus |
|
1159 // From MSvgTimedEntityInterface |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 void CSvgDocumentImpl::GetCurSyncMasterStatus( |
|
1162 TBool& aIsSyncMaster ) // Indicates whether the element is currrently |
|
1163 // Sync Master. |
|
1164 { |
|
1165 // Document can never be a sync master |
|
1166 aIsSyncMaster = EFalse; |
|
1167 } |
|
1168 |
|
1169 |
|
1170 // ----------------------------------------------------------------------------- |
|
1171 // CSvgDocumentImpl::SetCurSyncMasterStatus |
|
1172 // From MSvgTimedEntityInterface |
|
1173 // ----------------------------------------------------------------------------- |
|
1174 void CSvgDocumentImpl::SetCurSyncMasterStatus( |
|
1175 TBool /*aSyncMasterStatus */) // Indicates whether the element is |
|
1176 // currrently Sync Master. |
|
1177 { |
|
1178 // Document sync master status is always false as it can never be |
|
1179 // a sync master |
|
1180 } |
|
1181 |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // CSvgDocumentImpl::CanGenerateTick |
|
1184 // From MSvgTimedEntityInterface |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 TBool CSvgDocumentImpl::CanGenerateTick() |
|
1187 { |
|
1188 // Document cannot generate tick, as it is not a inherently timed element |
|
1189 return EFalse; |
|
1190 } |
|
1191 |
|
1192 // ----------------------------------------------------------------------------- |
|
1193 // CSvgDocumentImpl::CanUseParentTick |
|
1194 // From MSvgTimedEntityInterface |
|
1195 // ----------------------------------------------------------------------------- |
|
1196 TBool CSvgDocumentImpl::CanUseParentTick() |
|
1197 { |
|
1198 // Return True as document can always use parent tick to |
|
1199 // advance itself |
|
1200 return ( ETrue ); |
|
1201 } |
|
1202 |
|
1203 // ----------------------------------------------------------------------------- |
|
1204 // CSvgDocumentImpl::ResyncTimedEntity |
|
1205 // From MSvgTimedEntityInterface |
|
1206 // ----------------------------------------------------------------------------- |
|
1207 void CSvgDocumentImpl::ResyncTimedEntity( |
|
1208 TUint32 /*aSynctime*/ ) // Time for resync in msecs. |
|
1209 { |
|
1210 } |
|
1211 |
|
1212 |
|
1213 |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // CSvgDocumentImpl::PauseTimedEntity |
|
1216 // From MSvgTimedEntityInterface |
|
1217 // ----------------------------------------------------------------------------- |
|
1218 void CSvgDocumentImpl::PauseTimedEntity() |
|
1219 { |
|
1220 |
|
1221 } |
|
1222 |
|
1223 // ----------------------------------------------------------------------------- |
|
1224 // CSvgDocumentImpl::ResumeTimedEntity |
|
1225 // From MSvgTimedEntityInterface |
|
1226 // ----------------------------------------------------------------------------- |
|
1227 void CSvgDocumentImpl::ResumeTimedEntity() |
|
1228 { |
|
1229 |
|
1230 } |
|
1231 |
|
1232 // ----------------------------------------------------------------------------- |
|
1233 // CSvgDocumentImpl::StopTimedEntity |
|
1234 // From MSvgTimedEntityInterface |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 void CSvgDocumentImpl::StopTimedEntity() |
|
1237 { |
|
1238 iEventHandler->ResetTimes(); |
|
1239 } |
|
1240 |
|
1241 |
|
1242 //From MSvgTimedEntityInterface |
|
1243 TSvgObjectType CSvgDocumentImpl::ObjectType() |
|
1244 { |
|
1245 return ESvgDocumentElement; |
|
1246 } |
|
1247 |
|
1248 |
|
1249 //returns the child time container of the element |
|
1250 //used in timecontainer |
|
1251 CSvgTimeContainer* CSvgDocumentImpl::GetChildTimeContainer() |
|
1252 { |
|
1253 return NULL; |
|
1254 } |
|
1255 |
|
1256 |
|
1257 //if node has a child |
|
1258 // visit the child call postorder on that |
|
1259 //add current node |
|
1260 //if there are siblings |
|
1261 // visit all siblings |
|
1262 void CSvgDocumentImpl::ParsePostOrderMediaElements( CSvgElementImpl* aRoot, |
|
1263 RPointerArray<CSvgElementImpl>& aPostOrderList) |
|
1264 { |
|
1265 if ( !aRoot ) |
|
1266 { |
|
1267 return; |
|
1268 } |
|
1269 |
|
1270 CSvgElementImpl* lNodePtr = ( CSvgElementImpl* )aRoot->FirstChild(); |
|
1271 while ( lNodePtr != NULL ) |
|
1272 { |
|
1273 ParsePostOrderMediaElements( lNodePtr, aPostOrderList ); |
|
1274 lNodePtr = (CSvgElementImpl* )(lNodePtr->NextSibling() ); |
|
1275 } |
|
1276 |
|
1277 // Add only media elements, currently animation and audio |
|
1278 if ( aRoot->ElemID() == KSvgMediaAnimationElement || |
|
1279 aRoot->ElemID() == KSvgAudioElement ) |
|
1280 { |
|
1281 aPostOrderList.Append( aRoot ); |
|
1282 } |
|
1283 } |
|
1284 |
|
1285 // ========================================================================== |
|
1286 // Need method description |
|
1287 // ========================================================================== |
|
1288 void CSvgDocumentImpl::Load( RFs& aSession, RFile& aFileHandle, CSvgErrorImpl& aError ) |
|
1289 { |
|
1290 iEventHandler->Reset(); |
|
1291 |
|
1292 RFile ungzippedFile; |
|
1293 RFile* fileHandle = &aFileHandle; |
|
1294 TFileName tempFilename; |
|
1295 TBool needToDeleteTempFile = EFalse; |
|
1296 iIsDRMProtected = EFalse; |
|
1297 |
|
1298 //************************************************ |
|
1299 // Check for gzip format: write to temp file |
|
1300 //************************************************ |
|
1301 // Ignore Gzip content due to platform security: uncompressed file must be created |
|
1302 if ( IsGzipContent( aFileHandle ) ) |
|
1303 { |
|
1304 //************************************************ |
|
1305 // Ungzipped content may be DRM or txt-svg or binary-svg |
|
1306 //************************************************ |
|
1307 needToDeleteTempFile = ETrue; |
|
1308 if ( !ProcessGZipContent( aSession, aFileHandle, tempFilename, aError ) ) |
|
1309 return; |
|
1310 |
|
1311 // Open ungzipped file |
|
1312 TInt openError = ungzippedFile.Open( aSession, tempFilename, EFileRead ); |
|
1313 if ( openError != KErrNone ) |
|
1314 { |
|
1315 // couldn't open temp file for writing |
|
1316 PrepareError( aError, ESvgUnknown, openError, |
|
1317 _L( "Loading GZipped SVG File failed: " ), |
|
1318 _L( "Error Opening Temp File for Reading." ) ); |
|
1319 |
|
1320 // Delete uncompress temp file if needed |
|
1321 if ( needToDeleteTempFile ) |
|
1322 aSession.Delete( tempFilename ); |
|
1323 return; |
|
1324 } |
|
1325 fileHandle = &ungzippedFile; |
|
1326 } |
|
1327 |
|
1328 HBufC8* svgByteArray = NULL; |
|
1329 //************************************************ |
|
1330 // Decrypt DRM |
|
1331 //************************************************ |
|
1332 if ( iDrmEnable && IsDRMContent( *fileHandle ) ) |
|
1333 { |
|
1334 TRAPD( drmError, svgByteArray = ProcessDRMContentL( *fileHandle, aError ) ); |
|
1335 if ( drmError != KErrNone ) |
|
1336 { |
|
1337 PrepareError( aError, ESvgNoMemory, drmError, |
|
1338 _L( "Out of Memory: " ), |
|
1339 _L( "Instantiating DRM Decoder" ) ); |
|
1340 return; |
|
1341 } |
|
1342 // drm failed, error should already be set |
|
1343 else if ( svgByteArray == NULL ) |
|
1344 { |
|
1345 return; |
|
1346 } |
|
1347 |
|
1348 if ( needToDeleteTempFile && ( drmError || svgByteArray == NULL ) ) |
|
1349 { |
|
1350 aSession.Delete( tempFilename ); |
|
1351 } |
|
1352 iIsDRMProtected = ETrue; |
|
1353 } |
|
1354 // Read Non encrypted data |
|
1355 else |
|
1356 { |
|
1357 //************************************************ |
|
1358 // Read plain file: txt-svg or binary-svg |
|
1359 //************************************************ |
|
1360 TInt fileLength = 0; |
|
1361 fileHandle->Size( fileLength ); |
|
1362 TRAPD( error, svgByteArray = HBufC8::NewL( fileLength ) ); |
|
1363 if ( error != NULL ) |
|
1364 { |
|
1365 PrepareError( aError, ESvgNoMemory, error, |
|
1366 _L( "Out of Memory" ), |
|
1367 _L( "Allocating byte-array for data" ) ); |
|
1368 if ( needToDeleteTempFile ) |
|
1369 { |
|
1370 aSession.Delete( tempFilename ); |
|
1371 } |
|
1372 return; |
|
1373 } |
|
1374 TInt pos = 0; |
|
1375 fileHandle->Seek( ESeekStart, pos ); |
|
1376 TPtr8 des = svgByteArray->Des(); |
|
1377 TInt readError = fileHandle->Read( des ); |
|
1378 if ( readError != KErrNone ) |
|
1379 { |
|
1380 PrepareError( aError, ESvgUnknown, readError, |
|
1381 _L( "Reading SVG File Failed." ), _L( "" ) ); |
|
1382 delete svgByteArray; |
|
1383 if ( needToDeleteTempFile ) |
|
1384 { |
|
1385 aSession.Delete( tempFilename ); |
|
1386 } |
|
1387 return; |
|
1388 } |
|
1389 } |
|
1390 |
|
1391 //************************************************ |
|
1392 // Parser binary or plain svg content |
|
1393 //************************************************ |
|
1394 TRAPD( svgError, ProcessSvgContentL( *svgByteArray, aError ) ); |
|
1395 if ( svgError != KErrNone || ( aError.HasError() && !aError.IsWarning() ) ) |
|
1396 { |
|
1397 delete svgByteArray; |
|
1398 if ( !aError.HasError() ) |
|
1399 { |
|
1400 PrepareError( aError, ESvgNoMemory, svgError, |
|
1401 _L( "Out of Memory: " ), |
|
1402 _L( "Instantiating SVG ContentHandler/Decoder" ) ); |
|
1403 } |
|
1404 if ( needToDeleteTempFile ) |
|
1405 aSession.Delete( tempFilename ); |
|
1406 return; |
|
1407 } |
|
1408 |
|
1409 iInitialDrawFlag = ETrue; |
|
1410 iFinishedParsing = ETrue; |
|
1411 |
|
1412 delete svgByteArray; |
|
1413 |
|
1414 |
|
1415 // Delete uncompress temp file if needed |
|
1416 if ( needToDeleteTempFile ) |
|
1417 { |
|
1418 // Close only when file handle is for temp file |
|
1419 fileHandle->Close(); |
|
1420 aSession.Delete( tempFilename ); |
|
1421 } |
|
1422 |
|
1423 // Prepare engine to draw document |
|
1424 LoadingCompleted(); |
|
1425 } |
|
1426 |
|
1427 // ========================================================================== |
|
1428 // Need method description |
|
1429 // Leaves only when allocating memory fails |
|
1430 // Reports other errors |
|
1431 // ========================================================================== |
|
1432 void CSvgDocumentImpl::ProcessSvgContentL( const TDesC8& aByteArray, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements ) |
|
1433 { |
|
1434 //************************************************ |
|
1435 // Determine binary or xml svg file |
|
1436 //************************************************ |
|
1437 if ( IsBinarySvg( aByteArray ) ) |
|
1438 { |
|
1439 TInt error = KErrNone; |
|
1440 CSvgDecoder* decoder = CSvgDecoder::NewL( aByteArray ); |
|
1441 |
|
1442 TRAP( error, iRootElement = decoder->StartDecodingL( this, aError ) ); |
|
1443 if ( error != KErrNone || iRootElement == NULL && !aError.HasError() ) |
|
1444 { |
|
1445 if ( error != KErrNone ) |
|
1446 { |
|
1447 PrepareError( aError, ESvgbFileNotValid, error, |
|
1448 _L( "Invalid binary file." ), _L( "" ) ); |
|
1449 } |
|
1450 } |
|
1451 delete decoder; |
|
1452 } |
|
1453 else |
|
1454 { |
|
1455 iXmlHandler = CSvgContentHandler::NewL( aRemoveFalseSwitchElements ); |
|
1456 iRootElement = iXmlHandler->ParseByteData( this, aByteArray, aError ); |
|
1457 delete iXmlHandler; |
|
1458 iXmlHandler = NULL; |
|
1459 } |
|
1460 } |
|
1461 |
|
1462 // ========================================================================== |
|
1463 // JSR226 only!! |
|
1464 // Allows filling of document from JSR side with 16 bit string instead of 8 |
|
1465 // |
|
1466 // ========================================================================== |
|
1467 void CSvgDocumentImpl::Load16BitString( const TDesC16& aSvgString, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements ) |
|
1468 { |
|
1469 aError.SetErrorCode( ESvgNoError ); |
|
1470 |
|
1471 iIsDRMProtected = EFalse; |
|
1472 |
|
1473 if (iEventHandler) |
|
1474 iEventHandler->Reset(); |
|
1475 TRAPD(error,Process16BitSvgContentL( aSvgString, aError, aRemoveFalseSwitchElements )); |
|
1476 if ( error != KErrNone ) |
|
1477 { |
|
1478 PrepareError( aError, ESvgNoMemory, error, |
|
1479 _L( "Out of Memory: " ), |
|
1480 _L( "Instantiating Parser" ) ); |
|
1481 } |
|
1482 |
|
1483 iInitialDrawFlag = ETrue; |
|
1484 iFinishedParsing = ETrue; |
|
1485 } |
|
1486 |
|
1487 void CSvgDocumentImpl::Process16BitSvgContentL( const TDesC16& aSvgString, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements ) |
|
1488 { |
|
1489 iXmlHandler = CSvgContentHandler::NewL( aRemoveFalseSwitchElements ); |
|
1490 iRootElement = iXmlHandler->Parse16BitData( this, aSvgString, aError ); |
|
1491 delete iXmlHandler; |
|
1492 iXmlHandler = NULL; |
|
1493 } |
|
1494 // END OF JSR226 ONLY |
|
1495 // ========================================================================== |
|
1496 |
|
1497 // ========================================================================== |
|
1498 void CSvgDocumentImpl::CancelParsing() |
|
1499 { |
|
1500 // Check if there is animation element in the parent svg |
|
1501 RPointerArray<CSvgElementImpl> lAnimationEleList; |
|
1502 FindAllElements((CSvgElementImpl* )RootElement(), |
|
1503 KSvgMediaAnimationElement, lAnimationEleList ); |
|
1504 TInt lAnimationEleCnt = lAnimationEleList.Count(); |
|
1505 for ( TInt lCurAnimationEle = 0; |
|
1506 lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ ) |
|
1507 { |
|
1508 CSvgMediaAnimationElementImpl* lAnimationElement = |
|
1509 (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ]; |
|
1510 CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument(); |
|
1511 if ( lChildDoc ) |
|
1512 { |
|
1513 lChildDoc->CancelParsing(); // Cancel parsing on child svg |
|
1514 } |
|
1515 } |
|
1516 lAnimationEleList.Close(); |
|
1517 if ( iXmlHandler ) |
|
1518 { |
|
1519 iXmlHandler->CancelParsing(); |
|
1520 } |
|
1521 } |
|
1522 |
|
1523 // ========================================================================== |
|
1524 TBool CSvgDocumentImpl::IsParsing() |
|
1525 { |
|
1526 // xml handler is set to NULL after parsing |
|
1527 return iXmlHandler != NULL; |
|
1528 } |
|
1529 |
|
1530 //*************************************************************************** |
|
1531 // The function isGroupOpacity checks to see if there is a valid opacity |
|
1532 // attribute. |
|
1533 //*************************************************************************** |
|
1534 |
|
1535 TBool CSvgDocumentImpl::isGroupOpacity( CSvgElementImpl* aElement ) |
|
1536 { |
|
1537 TBool lReturnValue = EFalse; |
|
1538 CCssValue* lCssValue = NULL; |
|
1539 |
|
1540 aElement->FindProperty( KCSS_ATTR_GROUP_OPACITY, lCssValue, aElement ); |
|
1541 if ( lCssValue ) |
|
1542 { |
|
1543 if ( ((CFloatCssValueImpl*)lCssValue)->Value() != KFloatFixOne ) |
|
1544 { |
|
1545 // valid opacity value |
|
1546 lReturnValue = ETrue; |
|
1547 } |
|
1548 } |
|
1549 |
|
1550 return lReturnValue; |
|
1551 } |
|
1552 |
|
1553 |
|
1554 // ========================================================================== |
|
1555 // Pre-condition: content is DRM |
|
1556 // The content of a DRM may be svg-text or svg-bin |
|
1557 // Leaves only for memory allocation failure |
|
1558 // ========================================================================== |
|
1559 HBufC8* CSvgDocumentImpl::ProcessDRMContentL( RFile& aFileHandle, CSvgErrorImpl& aError ) |
|
1560 { |
|
1561 // Open File Content and Data |
|
1562 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( |
|
1563 aFileHandle ); |
|
1564 // Note: very important to use EView and NOT EPlay |
|
1565 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EView ); |
|
1566 |
|
1567 // Read Length of Content |
|
1568 TInt length = 0; |
|
1569 TRAPD( sizeError, data->DataSizeL( length ) ); |
|
1570 // Cannot get length of data |
|
1571 if ( sizeError != KErrNone ) |
|
1572 { |
|
1573 ProcessDRMError( sizeError, aError ); |
|
1574 CleanupStack::PopAndDestroy( 2 ); |
|
1575 return NULL; |
|
1576 } |
|
1577 |
|
1578 // Allocate Memory for Content: no leavable command after this |
|
1579 // so, pushing onto cleanup stack not needed |
|
1580 HBufC8* buffer = HBufC8::NewL( length ); |
|
1581 |
|
1582 TPtr8 des = buffer->Des(); |
|
1583 TInt readError = data->Read( des ); |
|
1584 |
|
1585 // Check for read error |
|
1586 if ( readError != KErrNone ) |
|
1587 { |
|
1588 ProcessDRMError( readError, aError ); |
|
1589 CleanupStack::PopAndDestroy( 2 ); |
|
1590 delete buffer; |
|
1591 return NULL; |
|
1592 } |
|
1593 // Only consume rights when not in thumb nail mode |
|
1594 else if ( !iIsThumbNailMode ) |
|
1595 { |
|
1596 // Do not consume drm rights if iDrmRightsConsumptionEnabled is EFalse |
|
1597 if(iDrmRightsConsumptionEnabled) |
|
1598 { |
|
1599 TInt intentError = data->ExecuteIntent( ContentAccess::EView ); |
|
1600 if ( intentError != KErrNone ) |
|
1601 { |
|
1602 ProcessDRMError( readError, aError ); |
|
1603 aError.SetIsWarning( ETrue ); |
|
1604 } |
|
1605 } |
|
1606 } |
|
1607 CleanupStack::PopAndDestroy( 2 ); |
|
1608 return buffer; |
|
1609 } |
|
1610 |
|
1611 // ========================================================================== |
|
1612 // Un-gzip to a temp file and return the name of temp file |
|
1613 // ========================================================================== |
|
1614 TBool CSvgDocumentImpl::ProcessGZipContent( RFs& aSession, |
|
1615 RFile& aGZipFileHandle, |
|
1616 TFileName& aUnzippedFileName , |
|
1617 CSvgErrorImpl& aError ) |
|
1618 { |
|
1619 // Write data to temp file: gzip does not have function to read RFile |
|
1620 TFileName gzipFilename; |
|
1621 if ( WriteToTempFile( aSession, aGZipFileHandle, gzipFilename, aError ) != KErrNone ) |
|
1622 return EFalse; |
|
1623 |
|
1624 TBool result = ProcessGZipContent( aSession, gzipFilename, aUnzippedFileName, aError ); |
|
1625 |
|
1626 // Delete temp gzipped file |
|
1627 aSession.Delete( gzipFilename ); |
|
1628 |
|
1629 return result; |
|
1630 } |
|
1631 |
|
1632 // ========================================================================== |
|
1633 // Uncompress to a temporary file |
|
1634 // ========================================================================== |
|
1635 TBool CSvgDocumentImpl::ProcessGZipContent( RFs& aSession, |
|
1636 TFileName& aZippedFileName, |
|
1637 TFileName& aUnzippedFileName , |
|
1638 CSvgErrorImpl& aError ) |
|
1639 { |
|
1640 // Create ungzipped temp file |
|
1641 TFileName path; |
|
1642 GetProcessPrivatePath( aSession, path ); |
|
1643 RFile gzipOutputFile; |
|
1644 TInt replaceError = gzipOutputFile.Temp( aSession, path, aUnzippedFileName, EFileWrite ); |
|
1645 if ( replaceError != KErrNone ) |
|
1646 { |
|
1647 // couldn't open temp file for writing |
|
1648 PrepareError( aError, ESvgUnknown, replaceError, |
|
1649 _L( "Failed to create file or unGZip: " ), aUnzippedFileName ); |
|
1650 return EFalse; |
|
1651 } |
|
1652 |
|
1653 // okay so far, uncompressing |
|
1654 CEZGZipToFile* uncompressor = NULL; |
|
1655 TRAPD( uncompressorError, |
|
1656 uncompressor = CEZGZipToFile::NewL( aSession, aZippedFileName, gzipOutputFile ) ) |
|
1657 if ( uncompressorError != KErrNone ) |
|
1658 { |
|
1659 PrepareError( aError, ESvgUnknown, uncompressorError, |
|
1660 _L( "Out of memory: " ), |
|
1661 _L( "Instantiating GZip decompressor" ) ); |
|
1662 gzipOutputFile.Close(); |
|
1663 aSession.Delete( aUnzippedFileName ); |
|
1664 |
|
1665 return EFalse; |
|
1666 } |
|
1667 |
|
1668 // Decompress file |
|
1669 TBool done = EFalse; |
|
1670 while ( !done ) |
|
1671 { |
|
1672 TRAPD( inflateError, done = !uncompressor->InflateL() ); |
|
1673 if ( inflateError != KErrNone ) |
|
1674 { |
|
1675 PrepareError( aError, ESvgUnknown, inflateError, |
|
1676 _L( "Uncompressing GZip file failed." ), _L( "" ) ); |
|
1677 delete uncompressor; |
|
1678 gzipOutputFile.Close(); |
|
1679 aSession.Delete( aUnzippedFileName ); |
|
1680 |
|
1681 return EFalse; |
|
1682 } |
|
1683 } |
|
1684 |
|
1685 gzipOutputFile.Close(); |
|
1686 delete uncompressor; |
|
1687 |
|
1688 return ETrue; |
|
1689 } |
|
1690 |
|
1691 // ========================================================================== |
|
1692 // Error codes taken from caf/content.h |
|
1693 // ========================================================================== |
|
1694 void CSvgDocumentImpl::ProcessDRMError( TInt errorCode, CSvgErrorImpl& aError ) |
|
1695 { |
|
1696 if ( errorCode == KErrNone ) |
|
1697 return; |
|
1698 |
|
1699 if ( errorCode == KErrNotFound ) |
|
1700 { |
|
1701 aError.SetDescription( _L( "Content Not Found" ) ); |
|
1702 } |
|
1703 else if ( errorCode == KErrCAPendingRights ) |
|
1704 { |
|
1705 aError.SetDescription( _L( "Rights Have Not Arrived" ) ); |
|
1706 } |
|
1707 else if ( errorCode == KErrCANoPermission ) |
|
1708 { |
|
1709 aError.SetDescription( _L( "No Permission to Play Content" ) ); |
|
1710 } |
|
1711 else if ( errorCode == KErrCANoRights ) |
|
1712 { |
|
1713 aError.SetDescription( _L( "No Rights Exists for Content" ) ); |
|
1714 } |
|
1715 else if ( errorCode == KErrCANotSupported ) |
|
1716 { |
|
1717 aError.SetDescription( _L( "Unable to Open Content" ) ); |
|
1718 } |
|
1719 else if ( errorCode == KErrPermissionDenied ) |
|
1720 { |
|
1721 aError.SetDescription( _L( "No Permission to Open Content" ) ); |
|
1722 } |
|
1723 else if ( errorCode == KErrAccessDenied ) |
|
1724 { |
|
1725 aError.SetDescription( _L( "Content Already in Use or No DRM Capability" ) ); |
|
1726 } |
|
1727 else if ( errorCode == KErrCASizeNotDetermined ) |
|
1728 { |
|
1729 aError.SetDescription( _L( "Cannot Determine Size of Content" ) ); |
|
1730 } |
|
1731 else |
|
1732 { |
|
1733 aError.SetDescription( _L( "Unknown DRM Error" ) ); |
|
1734 } |
|
1735 aError.SetIsWarning( EFalse ); |
|
1736 aError.SetErrorCode( ESvgDRMFailure ); |
|
1737 aError.SetSystemErrorCode( errorCode ); |
|
1738 } |
|
1739 |
|
1740 // ========================================================================== |
|
1741 // Returns true if the first two bytes of the given file could be a gzip file. |
|
1742 // This function is modified from the function in EZGZipFile class. |
|
1743 // ========================================================================== |
|
1744 TBool CSvgDocumentImpl::IsGzipContent( RFile& aFileHandle ) |
|
1745 { |
|
1746 TUint8 ids[2]; |
|
1747 TPtr8 des( ids, 0, sizeof( TUint8 ) * 2 ); |
|
1748 |
|
1749 if ( aFileHandle.Read( des ) != KErrNone ) |
|
1750 return EFalse; |
|
1751 |
|
1752 // reset to start of file |
|
1753 TInt zero = 0; |
|
1754 aFileHandle.Seek( ESeekStart, zero ); |
|
1755 return ( ids[0] == 31 && ids[1] == 139 ); |
|
1756 // return ( ids[0] == EZGZipFile::ID1 && ids[1] == EZGZipFile::ID2 ); |
|
1757 } |
|
1758 |
|
1759 // ========================================================================== |
|
1760 // Returns whether the byte-array header matches a GZIP signature |
|
1761 // ========================================================================== |
|
1762 TBool CSvgDocumentImpl::IsGzipContent( const TDesC8& aByteArray ) |
|
1763 { |
|
1764 return aByteArray.Length() >= 2 && |
|
1765 aByteArray[0] == 31 && aByteArray[1] == 139; |
|
1766 // aByteArray[0] == EZGZipFile::ID1 && aByteArray[1] == EZGZipFile::ID2; |
|
1767 } |
|
1768 |
|
1769 // ========================================================================== |
|
1770 // Returns whether the byte-array header matches a SVG binary signature |
|
1771 // ========================================================================== |
|
1772 TBool CSvgDocumentImpl::IsBinarySvg( const TDesC8& aByteArray ) |
|
1773 { |
|
1774 //const TUint32 KBinaryFile = 66737868; |
|
1775 //const TUint32 KBinaryFile2 = 66737869; |
|
1776 |
|
1777 if ((aByteArray.Length() >= 4 && |
|
1778 aByteArray[0] == 0xCC && aByteArray[1] == 0x56 && |
|
1779 aByteArray[2] == 0xFA && aByteArray[3] == 0x03) || |
|
1780 (aByteArray.Length() >= 4 && |
|
1781 aByteArray[0] == 0xCD && aByteArray[1] == 0x56 && |
|
1782 aByteArray[2] == 0xFA && aByteArray[3] == 0x03) || |
|
1783 (aByteArray.Length() >= 4 && |
|
1784 aByteArray[0] == 0xCE && aByteArray[1] == 0x56 && |
|
1785 aByteArray[2] == 0xFA && aByteArray[3] == 0x03) || |
|
1786 (aByteArray.Length() >= 4 && |
|
1787 aByteArray[0] == 0xCF && aByteArray[1] == 0x56 && |
|
1788 aByteArray[2] == 0xFA && aByteArray[3] == 0x03) ) |
|
1789 { |
|
1790 return ETrue; |
|
1791 } |
|
1792 else |
|
1793 { |
|
1794 return EFalse; |
|
1795 } |
|
1796 } |
|
1797 |
|
1798 // ========================================================================== |
|
1799 // Returns whether the file header matches a DRM signature |
|
1800 // ========================================================================== |
|
1801 TBool CSvgDocumentImpl::IsDRMContent( RFile& aFileHandle ) |
|
1802 { |
|
1803 TUint8 ids[2]; |
|
1804 TPtr8 des( ids, 0, sizeof( TUint8 ) * 2 ); |
|
1805 |
|
1806 if ( aFileHandle.Read( des ) != KErrNone ) |
|
1807 return EFalse; |
|
1808 |
|
1809 // reset to start of file |
|
1810 TInt zero = 0; |
|
1811 aFileHandle.Seek( ESeekStart, zero ); |
|
1812 return ( ids[0] == 0x01 && ids[1] == 0x0D ); |
|
1813 } |
|
1814 |
|
1815 // ========================================================================== |
|
1816 // Returns whether the file header matches a DRM signature |
|
1817 // ========================================================================== |
|
1818 TBool CSvgDocumentImpl::IsDRMContent( const TDesC8& aByteArray ) |
|
1819 { |
|
1820 return ( aByteArray.Length() > 1 && aByteArray[0] == 0x01 && aByteArray[1] == 0x0D ); |
|
1821 } |
|
1822 |
|
1823 // ========================================================================== |
|
1824 // Generate the "c:/private/<sid>" directory name |
|
1825 // ========================================================================== |
|
1826 TInt CSvgDocumentImpl::GetProcessPrivatePath( RFs& aSession, TFileName& aPath ) |
|
1827 { |
|
1828 aSession.PrivatePath( aPath ); |
|
1829 aPath.Insert( 0, _L( "c:" ) ); |
|
1830 return KErrNone; |
|
1831 } |
|
1832 |
|
1833 // ========================================================================== |
|
1834 // Create "c:/private/<sid>" directory if it does not already exist |
|
1835 // ========================================================================== |
|
1836 TInt CSvgDocumentImpl::CreateProcessPrivateDirectory( RFs& aSession, TFileName& aPath ) |
|
1837 { |
|
1838 GetProcessPrivatePath( aSession, aPath ); |
|
1839 return ( !BaflUtils::FolderExists( aSession, aPath ) ) ? aSession.MkDir( aPath ) : KErrNone; |
|
1840 } |
|
1841 |
|
1842 // ========================================================================== |
|
1843 // Open a file session, error is indicated in aError |
|
1844 // ========================================================================== |
|
1845 void CSvgDocumentImpl::OpenSession( RFs& aSession, CSvgErrorImpl& aError ) |
|
1846 { |
|
1847 TInt error = aSession.Connect(); |
|
1848 if ( error != KErrNone ) |
|
1849 { |
|
1850 // couldn't open temp file for writing |
|
1851 PrepareError( aError, ESvgUnknown, error, |
|
1852 _L( "Connecting File Session Failed." ), _L( "" ) ); |
|
1853 } |
|
1854 } |
|
1855 |
|
1856 // ========================================================================== |
|
1857 // Session must be opened successfully |
|
1858 // File name of temp file is store in aFilename |
|
1859 // ========================================================================== |
|
1860 TInt CSvgDocumentImpl::WriteToTempFile( RFs& aSession, const TDesC8& aByteArray, |
|
1861 TFileName& aFilename, CSvgErrorImpl& aError ) |
|
1862 { |
|
1863 // Create temporary file for byte-array |
|
1864 TFileName path; |
|
1865 CreateProcessPrivateDirectory( aSession, path ); |
|
1866 RFile writeFile; |
|
1867 TInt tempError = writeFile.Temp( aSession, path, aFilename, EFileWrite ); |
|
1868 if ( tempError != KErrNone ) |
|
1869 { |
|
1870 PrepareError( aError, ESvgUnknown, tempError, |
|
1871 _L( "Failed open temp file to write data." ), aFilename ); |
|
1872 return tempError; |
|
1873 } |
|
1874 |
|
1875 // Write byte-array to file |
|
1876 TInt writeError = writeFile.Write( aByteArray ); |
|
1877 if ( writeError != KErrNone ) |
|
1878 { |
|
1879 PrepareError( aError, ESvgUnknown, writeError, |
|
1880 _L( "Failed to write data to temp file." ), aFilename ); |
|
1881 writeFile.Close(); |
|
1882 aSession.Delete( aFilename ); |
|
1883 return writeError; |
|
1884 } |
|
1885 writeFile.Flush(); |
|
1886 writeFile.Close(); |
|
1887 |
|
1888 return KErrNone; |
|
1889 } |
|
1890 |
|
1891 // ========================================================================== |
|
1892 // Session must be opened successfully |
|
1893 // File name of temp file is store in aFilename |
|
1894 // ========================================================================== |
|
1895 TInt CSvgDocumentImpl::WriteToTempFile( RFs& aSession, RFile& aFileHandle, |
|
1896 TFileName& aFilename, CSvgErrorImpl& aError ) |
|
1897 { |
|
1898 // Create temporary file for byte-array |
|
1899 TFileName path; |
|
1900 CreateProcessPrivateDirectory( aSession, path ); |
|
1901 RFile writeFile; |
|
1902 TInt tempError = writeFile.Temp( aSession, path, aFilename, EFileWrite ); |
|
1903 if ( tempError != KErrNone ) |
|
1904 { |
|
1905 PrepareError( aError, ESvgUnknown, tempError, |
|
1906 _L( "Failed open temp file to write data." ), path ); |
|
1907 return tempError; |
|
1908 } |
|
1909 |
|
1910 // Write data to temp file |
|
1911 TInt size; |
|
1912 TInt sizeError = aFileHandle.Size( size ); |
|
1913 if ( sizeError != KErrNone ) |
|
1914 { |
|
1915 PrepareError( aError, ESvgUnknown, sizeError, |
|
1916 _L( "Failed to get data length of file." ), aFilename ); |
|
1917 aSession.Delete( aFilename ); |
|
1918 return sizeError; |
|
1919 } |
|
1920 |
|
1921 TBuf8<1024> buffer; |
|
1922 TInt bytesCopied = 0; |
|
1923 while ( bytesCopied < size ) |
|
1924 { |
|
1925 buffer.Zero(); |
|
1926 TInt bytesToCopy = ( size - bytesCopied < 1024 ) ? size - bytesCopied : 1024; |
|
1927 // read data |
|
1928 TInt readError = aFileHandle.Read( buffer, bytesToCopy ); |
|
1929 if ( readError != KErrNone ) |
|
1930 { |
|
1931 PrepareError( aError, ESvgUnknown, readError, |
|
1932 _L( "Failed to read data to copy to temp file: " ), aFilename ); |
|
1933 writeFile.Close(); |
|
1934 aSession.Delete( aFilename ); |
|
1935 return readError; |
|
1936 } |
|
1937 // write data |
|
1938 TInt writeError = writeFile.Write( buffer, bytesToCopy ); |
|
1939 if ( writeError != KErrNone ) |
|
1940 { |
|
1941 PrepareError( aError, ESvgUnknown, writeError, |
|
1942 _L( "Failed to write to temp file: " ), aFilename ); |
|
1943 writeFile.Close(); |
|
1944 aSession.Delete( aFilename ); |
|
1945 return writeError; |
|
1946 } |
|
1947 bytesCopied += bytesToCopy; |
|
1948 } |
|
1949 |
|
1950 writeFile.Flush(); |
|
1951 writeFile.Close(); |
|
1952 |
|
1953 return KErrNone; |
|
1954 } |
|
1955 |
|
1956 // ========================================================================== |
|
1957 // Need method description |
|
1958 // ========================================================================== |
|
1959 void CSvgDocumentImpl::PrepareError( CSvgErrorImpl& aError, |
|
1960 TSvgErrorCode aSvgErrorCode, |
|
1961 TInt aSystemErrorCode, |
|
1962 const TDesC& aMsg1, |
|
1963 const TDesC& aMsg2 ) |
|
1964 { |
|
1965 aError.SetDescription( aMsg1, aMsg2 ); |
|
1966 aError.SetErrorCode( aSvgErrorCode ); |
|
1967 aError.SetSystemErrorCode( aSystemErrorCode ); |
|
1968 aError.SetIsWarning( EFalse ); |
|
1969 } |
|
1970 |
|
1971 // ========================================================================== |
|
1972 // Need method description |
|
1973 // ========================================================================== |
|
1974 void CSvgDocumentImpl::LoadingCompleted() |
|
1975 { |
|
1976 if ( iEngine != NULL && iEngine->GraphicsContext() != NULL ) |
|
1977 { |
|
1978 iEngine->GraphicsContext()->SetDoDithering( iHasGradientElement ); |
|
1979 } |
|
1980 } |
|
1981 |
|
1982 // ========================================================================== |
|
1983 // Need method description |
|
1984 // ========================================================================== |
|
1985 void CSvgDocumentImpl::SetThumbNailMode( TBool aThumbNailMode ) |
|
1986 { |
|
1987 iIsThumbNailMode = aThumbNailMode; |
|
1988 } |
|
1989 |
|
1990 //========================================================================== |
|
1991 // CSvgDocumentImpl::SetDRMRights( TBool aEnable ) |
|
1992 //========================================================================== |
|
1993 void CSvgDocumentImpl::SetDRMRights( TBool aEnable) |
|
1994 { |
|
1995 iDrmRightsConsumptionEnabled = aEnable; |
|
1996 } |
|
1997 // ========================================================================== |
|
1998 // Need method description |
|
1999 // ========================================================================== |
|
2000 TBool CSvgDocumentImpl::IsThumbNailOnly() |
|
2001 { |
|
2002 return iIsThumbNailMode && iIsDRMProtected; |
|
2003 } |
|
2004 |
|
2005 // ========================================================================== |
|
2006 // Need method description |
|
2007 // ========================================================================== |
|
2008 void CSvgDocumentImpl::SetWasPrepared( TBool aBool ) |
|
2009 { |
|
2010 iWasPrepared = aBool; |
|
2011 |
|
2012 } |
|
2013 |
|
2014 // ========================================================================== |
|
2015 // Need method description |
|
2016 // ========================================================================== |
|
2017 TBool CSvgDocumentImpl::WasPrepared() |
|
2018 { |
|
2019 return iWasPrepared; |
|
2020 } |
|
2021 |
|
2022 // ========================================================================== |
|
2023 // Need method description |
|
2024 // ========================================================================== |
|
2025 void CSvgDocumentImpl::SetLoadingListeners( const RPointerArray<MSvgLoadingListener>* aList ) |
|
2026 { |
|
2027 iLoadingListeners = aList; |
|
2028 } |
|
2029 |
|
2030 // ========================================================================== |
|
2031 // Need method description |
|
2032 // ========================================================================== |
|
2033 const RPointerArray<MSvgLoadingListener>* CSvgDocumentImpl::GetLoadingListeners() |
|
2034 { |
|
2035 return iLoadingListeners; |
|
2036 } |
|
2037 |
|
2038 /*---------------------------MouseListener---------------------------*/ |
|
2039 |
|
2040 // ========================================================================== |
|
2041 // Need method description |
|
2042 // ========================================================================== |
|
2043 void CSvgDocumentImpl::AddInternalMouseListener( const MSvgMouseListener* aListener ) |
|
2044 { |
|
2045 TInt index = iSvgMouseListeners.Find( aListener ); |
|
2046 if ( aListener != NULL && index == KErrNotFound ) |
|
2047 { |
|
2048 iSvgMouseListeners.Append( aListener ); |
|
2049 } |
|
2050 } |
|
2051 |
|
2052 // ========================================================================== |
|
2053 // Need method description |
|
2054 // ========================================================================== |
|
2055 void CSvgDocumentImpl::RemoveInternalMouseListener( const MSvgMouseListener* aListener ) |
|
2056 { |
|
2057 TInt index = iSvgMouseListeners.Find( aListener ); |
|
2058 if ( index != KErrNotFound ) |
|
2059 { |
|
2060 iSvgMouseListeners.Remove( index ); |
|
2061 } |
|
2062 } |
|
2063 |
|
2064 // ========================================================================== |
|
2065 // Need method description |
|
2066 // ========================================================================== |
|
2067 TInt CSvgDocumentImpl::MouseInternalListenerCount() |
|
2068 { |
|
2069 return iSvgMouseListeners.Count(); |
|
2070 } |
|
2071 |
|
2072 // ========================================================================== |
|
2073 // Need method description |
|
2074 // ========================================================================== |
|
2075 void CSvgDocumentImpl::NotifyInternalMousePressed( RPointerArray<CSvgElementImpl>& aElements, |
|
2076 TInt aX, TInt aY ) |
|
2077 { |
|
2078 |
|
2079 for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ ) |
|
2080 { |
|
2081 iSvgMouseListeners[i]->MousePressed( aElements, aX, aY ); |
|
2082 } |
|
2083 } |
|
2084 |
|
2085 // ========================================================================== |
|
2086 // Need method description |
|
2087 // ========================================================================== |
|
2088 void CSvgDocumentImpl::NotifyInternalMouseReleased( RPointerArray<CSvgElementImpl>& aElements, |
|
2089 TInt aX, TInt aY ) |
|
2090 { |
|
2091 |
|
2092 for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ ) |
|
2093 { |
|
2094 iSvgMouseListeners[i]->MouseReleased( aElements, aX, aY ); |
|
2095 } |
|
2096 } |
|
2097 |
|
2098 // ========================================================================== |
|
2099 // Need method description |
|
2100 // ========================================================================== |
|
2101 void CSvgDocumentImpl::NotifyInternalMouseEntered( RPointerArray<CSvgElementImpl>& aElements, |
|
2102 TInt aX, TInt aY ) |
|
2103 { |
|
2104 |
|
2105 for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ ) |
|
2106 { |
|
2107 iSvgMouseListeners[i]->MouseEntered( aElements, aX, aY ); |
|
2108 } |
|
2109 } |
|
2110 |
|
2111 // ========================================================================== |
|
2112 // Need method description |
|
2113 // ========================================================================== |
|
2114 void CSvgDocumentImpl::NotifyInternalMouseExited( RPointerArray<CSvgElementImpl>& aElements, |
|
2115 TInt aX, TInt aY ) |
|
2116 { |
|
2117 |
|
2118 for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ ) |
|
2119 { |
|
2120 iSvgMouseListeners[i]->MouseExited( aElements, aX, aY ); |
|
2121 } |
|
2122 } |
|
2123 |
|
2124 // ========================================================================== |
|
2125 // Need method description |
|
2126 // ========================================================================== |
|
2127 void CSvgDocumentImpl::NotifyInternalMouseMoved( RPointerArray<CSvgElementImpl>& aElements, |
|
2128 TInt aX, TInt aY ) |
|
2129 { |
|
2130 |
|
2131 for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ ) |
|
2132 { |
|
2133 iSvgMouseListeners[i]->MouseMoved( aElements, aX, aY ); |
|
2134 } |
|
2135 } |
|
2136 |
|
2137 // ========================================================================== |
|
2138 // Need method description |
|
2139 // ========================================================================== |
|
2140 void CSvgDocumentImpl::NotifyDocumentStart() |
|
2141 { |
|
2142 if ( iLoadingListeners != NULL ) |
|
2143 { |
|
2144 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2145 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2146 { |
|
2147 (*iLoadingListeners)[i]->DocumentStart(); |
|
2148 } |
|
2149 } |
|
2150 } |
|
2151 |
|
2152 // ========================================================================== |
|
2153 // Need method description |
|
2154 // ========================================================================== |
|
2155 void CSvgDocumentImpl::NotifyDocumentEnd() |
|
2156 { |
|
2157 if ( iLoadingListeners != NULL ) |
|
2158 { |
|
2159 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2160 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2161 { |
|
2162 (*iLoadingListeners)[i]->DocumentEnd(); |
|
2163 } |
|
2164 } |
|
2165 } |
|
2166 |
|
2167 // ========================================================================== |
|
2168 // Need method description |
|
2169 // ========================================================================== |
|
2170 void CSvgDocumentImpl::NotifyElementStart( const TDesC& aTagName, |
|
2171 MSvgAttributeList& aAttributeList, |
|
2172 TBool aIsSvgChild ) |
|
2173 { |
|
2174 // Do not send back attribute list if content was decrypted |
|
2175 // from DRM protected content. |
|
2176 if ( iLoadingListeners != NULL && !iIsDRMProtected ) |
|
2177 { |
|
2178 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2179 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2180 { |
|
2181 if ( aIsSvgChild || (*iLoadingListeners)[i]->ReportAllElements() ) |
|
2182 { |
|
2183 (*iLoadingListeners)[i]->ElementStart( aTagName, aAttributeList ); |
|
2184 } |
|
2185 } |
|
2186 } |
|
2187 } |
|
2188 |
|
2189 // ========================================================================== |
|
2190 // Need method description |
|
2191 // ========================================================================== |
|
2192 void CSvgDocumentImpl::NotifyElementEnd( const TDesC& aTagName, TBool aIsSvgChild ) |
|
2193 { |
|
2194 if ( iLoadingListeners != NULL ) |
|
2195 { |
|
2196 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2197 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2198 { |
|
2199 if ( aIsSvgChild || (*iLoadingListeners)[i]->ReportAllElements() ) |
|
2200 { |
|
2201 (*iLoadingListeners)[i]->ElementEnd( aTagName ); |
|
2202 } |
|
2203 } |
|
2204 } |
|
2205 } |
|
2206 |
|
2207 // ========================================================================== |
|
2208 // Need method description |
|
2209 // ========================================================================== |
|
2210 void CSvgDocumentImpl::NotifyUnsupportedElement( const TDesC& aTagName, |
|
2211 MSvgAttributeList& aAttributeList ) |
|
2212 { |
|
2213 if ( iLoadingListeners != NULL ) |
|
2214 { |
|
2215 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2216 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2217 { |
|
2218 (*iLoadingListeners)[i]->UnsupportedElement( aTagName, aAttributeList ); |
|
2219 } |
|
2220 } |
|
2221 } |
|
2222 |
|
2223 // ========================================================================== |
|
2224 // Need method description |
|
2225 // ========================================================================== |
|
2226 void CSvgDocumentImpl::NotifyExternalDataRequested( const TDesC& aUri ) |
|
2227 { |
|
2228 if ( iLoadingListeners != NULL ) |
|
2229 { |
|
2230 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2231 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2232 { |
|
2233 (*iLoadingListeners)[i]->ExternalDataRequested( aUri ); |
|
2234 } |
|
2235 } |
|
2236 } |
|
2237 |
|
2238 // ========================================================================== |
|
2239 // Need method description |
|
2240 // ========================================================================== |
|
2241 void CSvgDocumentImpl::NotifyExternalDataReceived( const TDesC& aUri ) |
|
2242 { |
|
2243 if ( iLoadingListeners != NULL ) |
|
2244 { |
|
2245 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2246 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2247 { |
|
2248 (*iLoadingListeners)[i]->ExternalDataReceived( aUri ); |
|
2249 } |
|
2250 } |
|
2251 } |
|
2252 |
|
2253 // ========================================================================== |
|
2254 // Need method description |
|
2255 // ========================================================================== |
|
2256 void CSvgDocumentImpl::NotifyExternalDataRequestFailed( const TDesC& aUri ) |
|
2257 { |
|
2258 if ( iLoadingListeners != NULL ) |
|
2259 { |
|
2260 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2261 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2262 { |
|
2263 (*iLoadingListeners)[i]->ExternalDataRequestFailed( aUri ); |
|
2264 } |
|
2265 } |
|
2266 } |
|
2267 |
|
2268 // ========================================================================== |
|
2269 // Need method description |
|
2270 // ========================================================================== |
|
2271 TUint32 CSvgDocumentImpl::IsIndefiniteAnimation() |
|
2272 { |
|
2273 if ( !iCheckedAnimationDuration ) |
|
2274 { |
|
2275 AnimationDuration(); |
|
2276 } |
|
2277 // special value for indefinite animation |
|
2278 return ( iAnimationDuration == KIndefiniteAnimationDuration ); |
|
2279 } |
|
2280 |
|
2281 // ========================================================================== |
|
2282 // Need method description |
|
2283 // ========================================================================== |
|
2284 TUint32 CSvgDocumentImpl::AnimationDuration() |
|
2285 { |
|
2286 if ( iCheckedAnimationDuration ) |
|
2287 { |
|
2288 return IsIndefiniteAnimation() ? 0xFFFFFFFF : iAnimationDuration; |
|
2289 } |
|
2290 else if ( iRootElement == NULL ) |
|
2291 { |
|
2292 return 0; |
|
2293 } |
|
2294 |
|
2295 if ( iIsInteractive ) |
|
2296 { |
|
2297 // If there is interactivity in the content, set the animation |
|
2298 // duration to indefinite so that the timer continues to run. |
|
2299 iAnimationDuration = KIndefiniteAnimationDuration; |
|
2300 } |
|
2301 else |
|
2302 { |
|
2303 iAnimationDuration = SubtreeDuration( iRootElement ); |
|
2304 } |
|
2305 |
|
2306 iCheckedAnimationDuration = ETrue; |
|
2307 return IsIndefiniteAnimation() ? 0xFFFFFFFF : iAnimationDuration; |
|
2308 } |
|
2309 |
|
2310 // ========================================================================== |
|
2311 // Return the longest animation in subtree |
|
2312 // ========================================================================== |
|
2313 TUint32 CSvgDocumentImpl::SubtreeDuration( CSvgElementImpl* aRootElement ) |
|
2314 { |
|
2315 TUint dur = 0; |
|
2316 |
|
2317 if ( aRootElement->IsAnimatedElement() ) |
|
2318 { |
|
2319 dur = ( ( CSvgAnimationBase * ) aRootElement )->CompleteDuration(); |
|
2320 } |
|
2321 |
|
2322 else if ( aRootElement->ElemID() == KSvgDiscardElement ) |
|
2323 { |
|
2324 dur = ((CSvgDiscardElementImpl*)aRootElement)->AbsoluteBeginTime(); |
|
2325 } |
|
2326 |
|
2327 // check child duration |
|
2328 TUint childDur; |
|
2329 CSvgElementImpl* child = (CSvgElementImpl*)aRootElement->FirstChild(); |
|
2330 while ( child != NULL ) |
|
2331 { |
|
2332 childDur = SubtreeDuration( child ); |
|
2333 if ( childDur > dur ) |
|
2334 { |
|
2335 dur = childDur; |
|
2336 } |
|
2337 child = (CSvgElementImpl*)child->NextSibling(); |
|
2338 } |
|
2339 return dur; |
|
2340 } |
|
2341 |
|
2342 // ========================================================================== |
|
2343 // notified from outside (AppendChild/RemoveChild) |
|
2344 // ========================================================================== |
|
2345 void CSvgDocumentImpl::ElementAppendedOrRemoved() |
|
2346 { |
|
2347 // Clear flag to retrieve animation duration on AnimationDuration() call |
|
2348 iCheckedAnimationDuration = EFalse; |
|
2349 } |
|
2350 |
|
2351 // ========================================================================== |
|
2352 // Return all elements of the given type |
|
2353 // or all of the elements if the type = -1 |
|
2354 // ========================================================================== |
|
2355 void CSvgDocumentImpl::FindAllElements( CSvgElementImpl* aStartElement, TInt aElementId, |
|
2356 RPointerArray<CSvgElementImpl>& aList, |
|
2357 TSvgSearchFlags aFlags ) |
|
2358 { |
|
2359 if ( aStartElement == NULL ) |
|
2360 return; |
|
2361 |
|
2362 CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild(); |
|
2363 while ( child != NULL ) |
|
2364 { |
|
2365 // add to list if child is found |
|
2366 if ( child->ElemID() == aElementId || aElementId == -1 ) |
|
2367 aList.Append( child ); |
|
2368 |
|
2369 // find in grandchildren |
|
2370 if ( aFlags & ESvgSearchExcludeUseSubtree ) |
|
2371 { |
|
2372 // If Exclude Use Subtree, ignore the subtree under use element |
|
2373 if ( child->ElemID() != KSvgUseElement ) |
|
2374 { |
|
2375 FindAllElements( child, aElementId, aList, aFlags ); |
|
2376 } |
|
2377 } |
|
2378 else |
|
2379 { |
|
2380 FindAllElements( child, aElementId, aList, aFlags ); |
|
2381 } |
|
2382 child = (CSvgElementImpl*)child->NextSibling(); |
|
2383 } |
|
2384 } |
|
2385 |
|
2386 // ========================================================================== |
|
2387 // ImageLoadingObserver interface method |
|
2388 // ========================================================================== |
|
2389 void CSvgDocumentImpl::ImageLoadingCompleted( TInt aError ) |
|
2390 { |
|
2391 iImageElementCnt--; |
|
2392 |
|
2393 if ( iLoadingListeners != NULL && iImageElementCnt == 0) |
|
2394 { |
|
2395 TInt loadingListenersCnt = iLoadingListeners->Count(); |
|
2396 for ( TInt i = 0; i < loadingListenersCnt; i++ ) |
|
2397 { |
|
2398 (*iLoadingListeners)[i]->ImagesLoaded(aError); |
|
2399 } |
|
2400 } |
|
2401 |
|
2402 |
|
2403 } |
|
2404 |
|
2405 // ========================================================================== |
|
2406 // Loops through the tree and prints out all of the elements |
|
2407 // (almost regenerating the DOM tree) |
|
2408 // |
|
2409 // ========================================================================== |
|
2410 void CSvgDocumentImpl::PrintAllElements( CSvgElementImpl* aStartElement ) |
|
2411 { |
|
2412 if ( aStartElement == NULL ) |
|
2413 return; |
|
2414 |
|
2415 aStartElement->Print( EFalse ); |
|
2416 //===> comment the styles out to generate true SVG content |
|
2417 // aStartElement->PrintStyleProperties(); |
|
2418 |
|
2419 CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild(); |
|
2420 PrintAllElements( child ); |
|
2421 |
|
2422 child = (CSvgElementImpl*)aStartElement->NextSibling(); |
|
2423 PrintAllElements( child ); |
|
2424 } |
|
2425 |
|
2426 TBool CSvgDocumentImpl::HasError() |
|
2427 { |
|
2428 return iError && iError->HasError(); |
|
2429 } |
|
2430 |
|
2431 MSvgError* CSvgDocumentImpl::GetError() |
|
2432 { |
|
2433 return iError; |
|
2434 } |
|
2435 |
|
2436 void CSvgDocumentImpl::SetIsWarning( TBool aIsWarning ) |
|
2437 { |
|
2438 if (iError) |
|
2439 { |
|
2440 iError->SetIsWarning( aIsWarning ); |
|
2441 } |
|
2442 } |
|
2443 void CSvgDocumentImpl::SetError( TInt aErrorType, const TDesC& aMsg1, const TDesC& aMsg2 ) |
|
2444 { |
|
2445 if ( !iError ) |
|
2446 { |
|
2447 TRAPD( error, iError = CSvgErrorImpl::NewL() ); |
|
2448 if ( error != KErrNone ) |
|
2449 { |
|
2450 return; |
|
2451 } |
|
2452 PrepareError( *iError, ESvgUnknown, aErrorType, aMsg1, aMsg2 ); |
|
2453 iError->SetIsWarning( ETrue ); |
|
2454 } |
|
2455 } |
|
2456 |
|
2457 |
|
2458 // --------------------------------------------------------------------------- |
|
2459 // Accessor funciton for SyncBehaviorDefault value |
|
2460 // --------------------------------------------------------------------------- |
|
2461 TSvgSyncBehaviour CSvgDocumentImpl::SyncBehaviorDefault() |
|
2462 { |
|
2463 return iSyncBehaviorDefault; |
|
2464 } |
|
2465 |
|
2466 // --------------------------------------------------------------------------- |
|
2467 // Accessor funciton for SyncBehaviorDefault value |
|
2468 // --------------------------------------------------------------------------- |
|
2469 TUint32 CSvgDocumentImpl::SyncToleranceDefault() |
|
2470 { |
|
2471 return iSyncToleranceDefault; |
|
2472 } |
|
2473 |
|
2474 // --------------------------------------------------------------------------- |
|
2475 // CSvgDocumentImpl::SetCurrentTime |
|
2476 // Set Function for the document's current time |
|
2477 // --------------------------------------------------------------------------- |
|
2478 void CSvgDocumentImpl::SetCurrentTime( TInt32 aCurTime ) |
|
2479 { |
|
2480 if ( iTimeContainer ) |
|
2481 { |
|
2482 iTimeContainer->SetCurrentTime( aCurTime ); |
|
2483 } |
|
2484 } |
|
2485 |
|
2486 // --------------------------------------------------------------------------- |
|
2487 // CSvgDocumentImpl::CurrentTime |
|
2488 // Accessor for the Document's current time |
|
2489 // --------------------------------------------------------------------------- |
|
2490 TInt32 CSvgDocumentImpl::CurrentTime() |
|
2491 { |
|
2492 if ( iTimeContainer ) |
|
2493 { |
|
2494 return iTimeContainer->CurrentTime(); |
|
2495 } |
|
2496 return KErrGeneral; |
|
2497 } |
|
2498 |
|
2499 // --------------------------------------------------------------------------- |
|
2500 // CSvgDocumentImpl::SetSyncBehavior |
|
2501 // Set the Synchronised behaviour for the time container |
|
2502 // --------------------------------------------------------------------------- |
|
2503 void CSvgDocumentImpl::SetTCSyncBehavior( const TSvgSyncBehaviour aValue ) |
|
2504 { |
|
2505 if ( iTimeContainer ) |
|
2506 { |
|
2507 iTimeContainer->SetSyncBehavior( aValue ); |
|
2508 } |
|
2509 } |
|
2510 |
|
2511 // --------------------------------------------------------------------------- |
|
2512 // CSvgDocumentImpl::SetSyncTolerance |
|
2513 // Set the Synchronised Tolerance for the time container |
|
2514 // --------------------------------------------------------------------------- |
|
2515 void CSvgDocumentImpl::SetTCSyncTolerance( const TUint32 aValue ) |
|
2516 { |
|
2517 if ( iTimeContainer ) |
|
2518 { |
|
2519 iTimeContainer->SetSyncTolerance( aValue ); |
|
2520 } |
|
2521 } |
|
2522 |
|
2523 // --------------------------------------------------------------------------- |
|
2524 // CSvgDocumentImpl::SetSyncMaster |
|
2525 // Set the time container as Synchronised Master |
|
2526 // --------------------------------------------------------------------------- |
|
2527 void CSvgDocumentImpl::SetTCSyncMaster( const TBool aValue ) |
|
2528 { |
|
2529 if ( iTimeContainer ) |
|
2530 { |
|
2531 iTimeContainer->SetSyncMaster( aValue ); |
|
2532 } |
|
2533 } |
|
2534 |
|
2535 // ----------------------------------------------------------------------------- |
|
2536 // CSvgDocumentImpl::TimeContainer |
|
2537 // Accessor for time container |
|
2538 // ----------------------------------------------------------------------------- |
|
2539 // |
|
2540 CSvgTimeContainer* CSvgDocumentImpl::TimeContainer() |
|
2541 { |
|
2542 return iTimeContainer; |
|
2543 } |
|
2544 |
|
2545 void CSvgDocumentImpl::DocumentTransform(TGfxAffineTransform& aTr) |
|
2546 { |
|
2547 iTransformMatrix = aTr; |
|
2548 } |
|
2549 |
|
2550 TGfxAffineTransform CSvgDocumentImpl::GetDocumentTransform() |
|
2551 { |
|
2552 return iTransformMatrix; |
|
2553 } |
|
2554 |
|
2555 |
|
2556 CSvgBitmapFontProvider * CSvgDocumentImpl::GetBitmapFontProvider() |
|
2557 { |
|
2558 return iSvgBitmapFontProvider ; |
|
2559 } |
|
2560 |
|
2561 // ----------------------------------------------------------------------------- |
|
2562 // CSvgDocumentImpl::SvgHasAnimationElement |
|
2563 // Checks if Document has Animation Element |
|
2564 // ----------------------------------------------------------------------------- |
|
2565 |
|
2566 TBool CSvgDocumentImpl::SvgHasAnimationElement() |
|
2567 { |
|
2568 RPointerArray<CSvgElementImpl> lAnimationEleList; |
|
2569 FindAllElements((CSvgElementImpl* )RootElement(), |
|
2570 KSvgMediaAnimationElement, lAnimationEleList ); |
|
2571 TInt lAnimationEleCnt = lAnimationEleList.Count(); |
|
2572 lAnimationEleList.Close(); |
|
2573 if ( lAnimationEleCnt > 0 ) |
|
2574 { |
|
2575 return ETrue; |
|
2576 } |
|
2577 |
|
2578 return EFalse; |
|
2579 |
|
2580 } |
|
2581 |
|
2582 // ----------------------------------------------------------------------------- |
|
2583 // CSvgDocumentImpl::IsDocumentContentInteractive |
|
2584 // Checks if Document content is InterActive |
|
2585 // ----------------------------------------------------------------------------- |
|
2586 |
|
2587 TBool CSvgDocumentImpl::IsDocumentContentInteractive() |
|
2588 { |
|
2589 RPointerArray<CSvgElementImpl> elements; |
|
2590 FindAllElements( (CSvgElementImpl* )RootElement(), |
|
2591 KSvgAElement, elements ); |
|
2592 if ( elements.Count() != 0 ) |
|
2593 { |
|
2594 elements.Close(); |
|
2595 return ETrue; |
|
2596 } |
|
2597 elements.Close(); |
|
2598 |
|
2599 if ( iIsInteractive ) |
|
2600 return ETrue; |
|
2601 |
|
2602 // Check if animation element is there |
|
2603 RPointerArray<CSvgElementImpl> lAnimationEleList; |
|
2604 FindAllElements((CSvgElementImpl* )RootElement(), |
|
2605 KSvgMediaAnimationElement, lAnimationEleList ); |
|
2606 |
|
2607 // If no animation element is present then return EFalse |
|
2608 TInt lAnimationEleCnt = lAnimationEleList.Count(); |
|
2609 if ( lAnimationEleCnt == 0 ) |
|
2610 { |
|
2611 lAnimationEleList.Close(); |
|
2612 return EFalse; |
|
2613 } |
|
2614 |
|
2615 // Check all animation element and if any child svg has .. |
|
2616 // interactive content then return ETrue |
|
2617 for ( TInt lCurAnimationEle = 0; |
|
2618 lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ ) |
|
2619 { |
|
2620 CSvgMediaAnimationElementImpl* lAnimationElement = |
|
2621 (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ]; |
|
2622 CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument(); |
|
2623 // if child svg has interavitve content then return |
|
2624 if(lChildDoc && lChildDoc->iIsInteractive) |
|
2625 { |
|
2626 lAnimationEleList.Close(); |
|
2627 return ETrue; |
|
2628 } |
|
2629 } |
|
2630 |
|
2631 lAnimationEleList.Close(); |
|
2632 return EFalse; |
|
2633 |
|
2634 } |
|
2635 |
|
2636 |
|
2637 void CSvgDocumentImpl::SetImageElementsCount(TInt aCnt) |
|
2638 { |
|
2639 iImageElementCnt = aCnt; |
|
2640 } |
|
2641 |
|
2642 TInt CSvgDocumentImpl::GetImageElementsCount() |
|
2643 { |
|
2644 return iImageElementCnt; |
|
2645 } |
|
2646 // End of file |
|
2647 |