svgtopt/SVG/SVGEngine/src/Svgdecoder.cpp
changeset 46 88edb906c587
child 19 df65ec4f2d28
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVG Engine source file
       
    15  *
       
    16 */
       
    17 
       
    18 #include <e32def.h>
       
    19 #include <e32base.h>
       
    20 #include <s32mem.h>
       
    21 #include "Svgdecoder.h"
       
    22 #include "SVGClrCssValueImpl.h"
       
    23 #include "SVGFloatCssValueImpl.h"
       
    24 #include "SVGIntCssValueImpl.h"
       
    25 #include "SVGStrCssValueImpl.h"
       
    26 #include "SVGVectorCssValueImpl.h"
       
    27 #include "GfxAffineTransform.h"
       
    28 #include "SVGTextElementImpl.h"
       
    29 #include "SVGFontFaceElementImpl.h"
       
    30 #include "SvgStopElementImpl.h"
       
    31 #include "SVGUseElementImpl.h"
       
    32 #include "SVGAnimationBase.h"
       
    33 #include "SVGAnimateMotionElementImpl.h"
       
    34 #include "SVGMpathElementImpl.h"
       
    35 #include "SVGGradientElementImpl.h"
       
    36 #include "SVGDiscardElementImpl.h"
       
    37 #include "SVGMediaElementBase.h"
       
    38 #include "SVGMediaAnimationElementImpl.h"
       
    39 #include "SVGTimedEntityInterface.h"
       
    40 #include "SVGAudioElementImpl.h"
       
    41 
       
    42 #include "SVGDocumentImpl.h"
       
    43 #include "SVGEngineImpl.h"
       
    44 #include "SVGMemoryManager.h"
       
    45 
       
    46 #include <languages.hrh>
       
    47 
       
    48 _LIT(OFFSET, "offset");
       
    49 _LIT(ZEROVALUE, "0");
       
    50 
       
    51 // --------------------------------------------------------------------------
       
    52 // CSvgDecoder* CSvgDecoder::NewL(const TDesC& aFileName )
       
    53 // ---------------------------------------------------------------------------
       
    54 CSvgDecoder* CSvgDecoder::NewL(const TDesC& aFileName )
       
    55 {
       
    56 	CSvgDecoder *self = new (ELeave) CSvgDecoder();
       
    57 
       
    58 	CleanupStack::PushL(self);
       
    59 
       
    60     self->ConstructL(aFileName);
       
    61 
       
    62 	CleanupStack::Pop();
       
    63 
       
    64 	return self;
       
    65 }
       
    66 
       
    67 
       
    68 // --------------------------------------------------------------------------
       
    69 // void CSvgDecoder::ConstructL(const TDesC& aFileName)
       
    70 // ---------------------------------------------------------------------------
       
    71 void CSvgDecoder::ConstructL(const TDesC& aFileName)
       
    72 {
       
    73 	User::LeaveIfError(iFs.Connect() );
       
    74 	User::LeaveIfError (iFStream.Open(iFs, aFileName, EFileRead));
       
    75 	iStream= iFStream;
       
    76 
       
    77 	/*Arrays Added For forward referencing in USE and Animate elements*/
       
    78 	iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
    79 	iUseElementArray->Reset();
       
    80 
       
    81 	iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
    82 	iAnimRefElementArray->Reset();
       
    83 }
       
    84 
       
    85 
       
    86 // --------------------------------------------------------------------------
       
    87 // CSvgDecoder* CSvgDecoder::NewL(const TDesC8& aByteData )
       
    88 // ---------------------------------------------------------------------------
       
    89 CSvgDecoder* CSvgDecoder::NewL(const TDesC8& aByteData )
       
    90 {
       
    91 	CSvgDecoder *self = new (ELeave) CSvgDecoder();
       
    92 
       
    93 	CleanupStack::PushL(self);
       
    94 
       
    95     self->ConstructL(aByteData);
       
    96 
       
    97 	CleanupStack::Pop();
       
    98 
       
    99 	return self;
       
   100 }
       
   101 
       
   102 
       
   103 // --------------------------------------------------------------------------
       
   104 // void CSvgDecoder::ConstructL(const TDesC8& aByteData)
       
   105 // ---------------------------------------------------------------------------
       
   106 void CSvgDecoder::ConstructL(const TDesC8& aByteData)
       
   107 {
       
   108 	iDStream.Open(aByteData);
       
   109 	iStream= iDStream;
       
   110 
       
   111 	iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   112 	iUseElementArray->Reset();
       
   113 
       
   114 	iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   115 	iAnimRefElementArray->Reset();
       
   116 
       
   117 	// added to hold switch element handles so we can go back and delete false children of the switch
       
   118 	iSwitchElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   119     iSwitchElementArray->Reset();
       
   120 
       
   121 	// Arrays added to reset event listeners for animation element
       
   122 	iAnimationElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   123 	iAnimationElementArray->Reset();
       
   124 
       
   125     //added to hold elements with required features, attributes, or sys language
       
   126     //so we can go back and delete the ones that dont pass at the start.
       
   127     iReqFetAttSysArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   128 	iReqFetAttSysArray->Reset();
       
   129 }
       
   130 
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 // CSvgDecoder::CSvgDecoder()
       
   134 // ---------------------------------------------------------------------------
       
   135 CSvgDecoder::CSvgDecoder()
       
   136 		:iRootElement( NULL ),
       
   137 		 iIsAnimElement(EFalse),
       
   138 		 iIsFixPt(EFalse),
       
   139 		 iIsRGB(EFalse),
       
   140 		 iEmbeddedImagesCount(0)
       
   141 
       
   142 {
       
   143 }
       
   144 
       
   145 
       
   146 // --------------------------------------------------------------------------
       
   147 // CSvgDecoder::~CSvgDecoder()
       
   148 // ---------------------------------------------------------------------------
       
   149 CSvgDecoder::~CSvgDecoder()
       
   150 {
       
   151 	iStream.Close();
       
   152 	iDStream.Close();
       
   153 	iFStream.Close();
       
   154 
       
   155 	iFs.Close();
       
   156 
       
   157 	if(iUseElementArray)
       
   158 	    {
       
   159 		iUseElementArray->Reset();
       
   160 		iUseElementArray->Close();
       
   161 		delete iUseElementArray;
       
   162 		iUseElementArray = NULL;
       
   163 		}
       
   164 
       
   165 	if(iAnimRefElementArray)
       
   166 	    {
       
   167 		iAnimRefElementArray->Reset();
       
   168 		iAnimRefElementArray->Close();
       
   169 		delete iAnimRefElementArray;
       
   170 		iAnimRefElementArray = NULL;
       
   171 		}
       
   172 
       
   173 	if(iSwitchElementArray)
       
   174         {
       
   175         iSwitchElementArray->Close();
       
   176         delete iSwitchElementArray;
       
   177         }
       
   178     if (iReqFetAttSysArray)
       
   179         {
       
   180         iReqFetAttSysArray->Close();
       
   181         delete iReqFetAttSysArray;
       
   182         }
       
   183     if(iAnimationElementArray)
       
   184         {
       
   185 		iAnimationElementArray->Reset();
       
   186         iAnimationElementArray->Close();
       
   187         delete iAnimationElementArray;
       
   188         }
       
   189     
       
   190         iImageElements.Close();
       
   191     
       
   192 }
       
   193 
       
   194 
       
   195 // --------------------------------------------------------------------------
       
   196 // TDesC& CSvgDecoder::DecodeTDesCLC()
       
   197 // ---------------------------------------------------------------------------
       
   198 TDesC& CSvgDecoder::DecodeTDesCLC()
       
   199 {
       
   200 
       
   201 	TUint8 lUniCodeLen = 2;
       
   202 
       
   203 	TUint8 uStrLen;
       
   204 	iStream >> uStrLen ;
       
   205 	HBufC *lBuf = NULL;
       
   206 
       
   207 	if (uStrLen)
       
   208 		{
       
   209 
       
   210 		lBuf = HBufC::NewLC(uStrLen/lUniCodeLen);
       
   211         TPtr lTmp= lBuf->Des();
       
   212     	iStream.ReadL (lTmp, (TInt)  (uStrLen/lUniCodeLen));
       
   213 		}
       
   214 
       
   215 	else
       
   216 		{
       
   217 		lBuf = HBufC::NewLC(0);
       
   218 		}
       
   219 
       
   220 		return (TDesC &) *lBuf;
       
   221 }
       
   222 
       
   223 // --------------------------------------------------------------------------
       
   224 // TDesC& CSvgDecoder::DecodeImageEmbeddedTDesCLC()
       
   225 // ---------------------------------------------------------------------------
       
   226 TDesC& CSvgDecoder::DecodeImageEmbeddedTDesCLC()
       
   227 {
       
   228 
       
   229 //	TUint8 lUniCodeLen = 2;
       
   230 
       
   231 	TInt32 lImageSize;
       
   232 	iStream >> lImageSize ;
       
   233 
       
   234 	HBufC *lBuf = NULL;
       
   235     HBufC8* lBuffer =NULL;
       
   236 
       
   237 	if (lImageSize)
       
   238 		{
       
   239         lBuffer = HBufC8::NewLC(lImageSize);
       
   240         TPtr8 lTemp= lBuffer->Des();
       
   241     	iStream.ReadL (lTemp, (TInt)  (lImageSize));
       
   242 
       
   243 		lBuf = HBufC::NewLC(lImageSize);
       
   244         TPtr lTmp= lBuf->Des();
       
   245         lTmp.Copy(lTemp);
       
   246 		}
       
   247 
       
   248 	else
       
   249 		{
       
   250         lBuffer = HBufC8::NewLC(0);
       
   251 		lBuf = HBufC::NewLC(0);
       
   252 		}
       
   253 
       
   254 
       
   255 	return (TDesC &) *lBuf;
       
   256 }
       
   257 
       
   258 
       
   259 
       
   260 // ==========================================================================
       
   261 // Decodig Attribute
       
   262 // ==========================================================================
       
   263 TInt CSvgDecoder::DecodeAttributeL(const TUint16 aName)
       
   264 	{
       
   265 
       
   266 	if( DecodePresentationAttributeL (aName) ||
       
   267 		DecodeSVGTAttributeL (aName) ||
       
   268 		DecodeSvgElementAttributeL (aName) ||
       
   269 		DecodeIdAndXmlAttributeL ( aName ) ||
       
   270 		DecodeUriRefAttributeL ( aName ) ||
       
   271 		DecodeAnimationAttributeL (aName) ||
       
   272 		DecodeTransformAttributeL (aName) ||
       
   273 		DecodeLangSpaceAttributeL (aName) ||
       
   274 		DecodeTestAttributeL ( aName ) ||
       
   275 		DecodeDiscardAttributeL ( aName )
       
   276 	  )
       
   277 		{
       
   278 		return KErrNone;
       
   279 		}
       
   280 	else
       
   281 		{
       
   282 		return KErrNotFound;
       
   283 		}
       
   284 	}
       
   285 
       
   286 
       
   287 
       
   288 // --------------------------------------------------------------------------
       
   289 // TBool CSvgDecoder::DecodePresentationAttributeL(const TUint16 aName)
       
   290 // ---------------------------------------------------------------------------
       
   291 TBool CSvgDecoder::DecodePresentationAttributeL(const TUint16 aName)
       
   292 	{
       
   293 
       
   294 	if(aName<=KCSS_MAX_ATTR)
       
   295 		{
       
   296 
       
   297 		if (aName== KCSS_ATTR_FILL )
       
   298 			{
       
   299 
       
   300 		    CCssValue* tParentValue = NULL;
       
   301 			CCssValue* tValue = NULL;
       
   302 
       
   303 			iCurrentElement->FindProperty (KCSS_ATTR_FILL,tValue);
       
   304 
       
   305 			if(iCurrentElement!= iRootElement)
       
   306 				{
       
   307 				iCurrentParentElement->FindProperty (KCSS_ATTR_FILL,tParentValue);
       
   308 				}
       
   309 
       
   310 			if (tParentValue == tValue || tValue == NULL)
       
   311 				{
       
   312 				if (iDocument)
       
   313 				{
       
   314 					tValue = iDocument->iMemoryManager->GetCssPaintObjectL(iCurrentElement);
       
   315 				}
       
   316 				SetPaintValueL (tValue);
       
   317 			    iCurrentElement->SetPresentationAttribute (KCSS_ATTR_FILL,tValue);
       
   318 				}
       
   319 			else
       
   320 				{
       
   321 				SetPaintValueL (tValue);
       
   322 				}
       
   323 
       
   324 			return ETrue;
       
   325 			}
       
   326 
       
   327 		if (aName== KCSS_ATTR_STROKE || aName== KCSS_ATTR_COLOR)
       
   328 			{
       
   329 		 	return DecodeColorCssValueL(aName);
       
   330 			}
       
   331 
       
   332 		if (aName== KCSS_ATTR_GROUP_OPACITY)
       
   333 			{
       
   334 			iDocument->iHasGroupOpacity = ETrue;
       
   335 			return DecodeFloatCssValueL(aName);
       
   336 			}
       
   337 		if (aName== KCSS_ATTR_FILL_OPACITY ||
       
   338 			aName== KCSS_ATTR_STROKE_OPACITY ||
       
   339 			aName== KCSS_ATTR_STROKEWIDTH ||
       
   340 			aName== KCSS_ATTR_FONTSIZE ||
       
   341 			aName== KCSS_ATTR_STROKE_MITERLIMIT ||
       
   342 			aName== KCSS_ATTR_STROKE_DASHOFFSET
       
   343 			)
       
   344 
       
   345 			{
       
   346 			return DecodeFloatCssValueL(aName);
       
   347 			}
       
   348 
       
   349 		if (aName== KCSS_ATTR_VISIBILITY ||
       
   350 			aName== KCSS_ATTR_FONTSTYLE ||
       
   351 			aName== KCSS_ATTR_FONTWEIGHT ||
       
   352 			aName== KCSS_ATTR_DISPLAY ||
       
   353             aName== KCSS_ATTR_TEXTANCHOR ||
       
   354 			aName== KCSS_ATTR_TEXTDECORATION
       
   355 			)
       
   356 
       
   357 			{
       
   358 			return DecodeIntCssValueL(aName);
       
   359 			}
       
   360 
       
   361 		if (aName== KCSS_ATTR_FONTFAMILY ||
       
   362 			aName== KCSS_ATTR_FILLRULE ||
       
   363 			aName== KCSS_ATTR_STROKE_LINECAP ||
       
   364 			aName== KCSS_ATTR_STROKE_LINEJOIN
       
   365 			)
       
   366 
       
   367 			{
       
   368 			return DecodeStringCssValueL(aName);
       
   369 			}
       
   370 
       
   371 
       
   372 		if (aName== KCSS_ATTR_STROKE_DASHARRAY)
       
   373 			{
       
   374 			CArrayFix<TFloatFixPt>* lArrayFix;
       
   375 			TInt8 lCount;
       
   376 			iStream >> lCount;
       
   377 			if (lCount)
       
   378 				{
       
   379 				lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( lCount );
       
   380 				}
       
   381 			else
       
   382 				{
       
   383 				lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( 1 );
       
   384 				}
       
   385 
       
   386 			 CleanupStack::PushL(lArrayFix); //cleanup
       
   387 
       
   388 			TFloatFixPt lTempFix;
       
   389 			TReal32 lTempReal;
       
   390 			
       
   391 			for(TInt8 i=0; i<lCount; i++)
       
   392 				{
       
   393 					if (iIsFixPt)
       
   394 					{
       
   395 					//was encoded as fixed point
       
   396 					lTempFix.iValue = iStream.ReadInt32L();
       
   397 					lArrayFix->AppendL( lTempFix );	
       
   398 					}
       
   399 					else
       
   400 					{
       
   401 					//was encoded as floats
       
   402 					
       
   403 					iStream >> lTempReal;
       
   404 					lArrayFix->AppendL( (TFloatFixPt) lTempReal);	
       
   405 					}
       
   406 				}
       
   407 
       
   408 			CCssValue* tParentValue = NULL;
       
   409 		    CCssValue* tValue = NULL;
       
   410 
       
   411 			iCurrentElement->FindProperty ((TInt8)aName,tValue);
       
   412 
       
   413 			if(iCurrentElement!= iRootElement)
       
   414 				{
       
   415 				iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
       
   416 				}
       
   417 
       
   418             if ( tParentValue == tValue || tValue == NULL )
       
   419                 {
       
   420                 // This attribute is inherited from parent, or not 
       
   421                 // defined in parent
       
   422                 if ( iDocument )
       
   423                     {
       
   424                     // Create a new Vector object and clone lArrayFix
       
   425                     tValue = iDocument->iMemoryManager->GetCssVectorObjectL( lArrayFix );
       
   426                     // Associate tValue with the current element
       
   427                     iCurrentElement->SetPresentationAttribute ( ( TInt8 ) aName,tValue );
       
   428                     }
       
   429                 // tValue contains a copy of lArrayFix, hence lArrayFix is not needed
       
   430                 // anymore. 
       
   431                 // tValue is owned by the element.
       
   432                 CleanupStack::PopAndDestroy( lArrayFix ); //cleanup
       
   433                 }
       
   434             else
       
   435                 {
       
   436                 // stroke dash array was already present in the element
       
   437                 // SetValueL function takes ownership of lArrayFix
       
   438                 ((CVectorCssValueImpl*)tValue)->SetValueL ( lArrayFix );
       
   439                 // No need to destroy lArrayFix as it is now owned 
       
   440                 // by the element.
       
   441                 CleanupStack::Pop( lArrayFix ); //cleanup
       
   442                 }
       
   443 
       
   444 
       
   445 			return ETrue;
       
   446 
       
   447 			}
       
   448 
       
   449 		else
       
   450 			{
       
   451 			return ETrue;
       
   452 			}
       
   453 
       
   454 		}
       
   455 
       
   456 	else
       
   457 		{
       
   458 		return EFalse;
       
   459 		}
       
   460 
       
   461 	}
       
   462 
       
   463 
       
   464 // --------------------------------------------------------------------------
       
   465 // TBool CSvgDecoder::DecodeSVGTAttributeL(const TUint16 aName)
       
   466 // ---------------------------------------------------------------------------
       
   467 TBool CSvgDecoder::DecodeSVGTAttributeL(const TUint16 aName)
       
   468 	{
       
   469 
       
   470 	if( (iCurrentElement->ElemID() == KSvgSvgElement) &&
       
   471       ( aName== KAtrWidth || aName== KAtrHeight ) )
       
   472 		{
       
   473 		TUint8 lFlag;
       
   474 		
       
   475 		iStream >> lFlag ;
       
   476 		
       
   477 		if (iIsFixPt)
       
   478 		{
       
   479 			TFloatFixPt lAtrValue;
       
   480 			lAtrValue.iValue = iStream.ReadInt32L();
       
   481 			
       
   482 				// Flag is used to ckech whether height and width are percentage or not.
       
   483 			if(lFlag)
       
   484 			{
       
   485 			    if(aName == KAtrWidth)
       
   486 			    {
       
   487 			        ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = ETrue;
       
   488 			        ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInUserCoordinate = lAtrValue;
       
   489 			    }
       
   490 			    else if(aName == KAtrHeight)
       
   491 			    {
       
   492 			        ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = ETrue;
       
   493 			        ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInUserCoordinate = lAtrValue;
       
   494 			    }
       
   495 			}
       
   496 			else
       
   497 			{
       
   498 			    if(aName == KAtrWidth)
       
   499 			    {
       
   500 			        ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = EFalse;
       
   501 			    }
       
   502 			    else if(aName == KAtrHeight)
       
   503 			    {
       
   504 			        ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = EFalse;
       
   505 			    }
       
   506 			iCurrentElement->SetAttributeFloatL( (TInt)aName, lAtrValue );
       
   507 			}
       
   508 		}
       
   509 		else
       
   510 		{
       
   511 			TReal32 lAtrValue;
       
   512 			iStream >> lAtrValue;
       
   513 			
       
   514 				// Flag is used to ckech whether height and width are percentage or not.
       
   515 			if(lFlag)
       
   516 			{
       
   517 			    if(aName == KAtrWidth)
       
   518 			    {
       
   519 			        ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = ETrue;
       
   520 			        ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInUserCoordinate = lAtrValue;  
       
   521 			    }
       
   522 			    else if (aName == KAtrHeight)
       
   523 			    {
       
   524 			        ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = ETrue;
       
   525 			        ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInUserCoordinate = lAtrValue;
       
   526 			    }
       
   527 
       
   528 			}
       
   529 			else
       
   530 			{
       
   531 			    if(aName == KAtrWidth)
       
   532 			    {
       
   533 			        ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = EFalse;
       
   534 			    }
       
   535 			    else if(aName == KAtrHeight)
       
   536 			    {
       
   537 			        ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = EFalse;
       
   538 			    }   
       
   539 			iCurrentElement->SetAttributeFloatL( (TInt)aName, (TFloatFixPt)lAtrValue );
       
   540 			}
       
   541 		}
       
   542 		
       
   543 	    return ETrue;
       
   544 		}
       
   545 
       
   546 	if(iCurrentElement->ElemID() == KSvgTextElement)
       
   547 		{
       
   548 		if (aName== KAtrX || aName== KAtrY)
       
   549 			{
       
   550 			CArrayFixFlat<TFloatFixPt>* lArrayFix;
       
   551 			TInt8 lCount;
       
   552 			iStream >> lCount;
       
   553 			if (lCount)
       
   554 				{
       
   555 				lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( lCount );
       
   556 				}
       
   557 			else
       
   558 				{
       
   559 				lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( 1 );
       
   560 				}
       
   561 
       
   562 			CleanupStack::PushL(lArrayFix); //cleanup
       
   563 
       
   564 			for(TInt8 i=0; i<lCount; i++)
       
   565 				{
       
   566 				if (iIsFixPt)
       
   567 				{
       
   568 					TFloatFixPt lTemp;
       
   569 					lTemp.iValue = iStream.ReadInt32L();
       
   570 					lArrayFix->AppendL( lTemp );
       
   571 				}
       
   572 				else
       
   573 				{
       
   574 					TReal32 lTemp;
       
   575 					iStream >> lTemp ;
       
   576 					lArrayFix->AppendL( (TFloatFixPt) lTemp);	
       
   577 				}
       
   578 				
       
   579 				}
       
   580 
       
   581 			((CSvgTextElementImpl*)iCurrentElement)->SetXYArray(aName,lArrayFix);
       
   582 			CleanupStack::Pop(lArrayFix); //cleanup
       
   583 			return ETrue;
       
   584 			}
       
   585 		}
       
   586 
       
   587 
       
   588 	if( aName<KSvgFloatAttrEndIndex ||
       
   589 		aName== KAtrFx ||
       
   590 		aName== KAtrFy ||
       
   591 		aName== KAtrOffset ||
       
   592 		aName== KAtrStopOpacity
       
   593 	  )
       
   594 		{
       
   595 
       
   596 		return DecodeAttributeFloatL(aName);
       
   597 		}
       
   598 
       
   599 	else if(aName == KAtrK)
       
   600 		{
       
   601 		iCurrentElement->iReqAttrFlag =0;
       
   602 		return DecodeAttributeFloatL(aName);
       
   603 		}
       
   604 
       
   605 	else if( aName<= KSvgDesAttrEndIndex ||
       
   606     		 aName== KAtrMedia ||
       
   607 			 aName== KAtrTitle
       
   608 		   )
       
   609 		{
       
   610 
       
   611 		return DecodeAttributeDesL(aName);
       
   612 		}
       
   613  else if (aName== KAtrVolume)
       
   614 			{
       
   615 			if (iIsFixPt)
       
   616 			{
       
   617 				TFloatFixPt lTemp;
       
   618 				lTemp.iValue = iStream.ReadInt32L();
       
   619 				TBuf<16> lTemp2;
       
   620 				_LIT(KAudioLevelFormat, "%f");
       
   621 				lTemp2.Format(KAudioLevelFormat, (float)lTemp );
       
   622 				//lTemp2.AppendNum((float)lTemp );
       
   623 				((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("volume"),lTemp2);
       
   624 			}
       
   625 			else
       
   626 			{
       
   627 				TReal32 lTemp;
       
   628 				iStream >> lTemp;
       
   629 				TBuf<16> lTemp2;
       
   630 				_LIT(KAudioLevelFormat, "%f");
       
   631 				lTemp2.Format(KAudioLevelFormat, (float)lTemp );
       
   632 				//lTemp2.AppendNum(lTemp);
       
   633 				((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("volume"),lTemp2);
       
   634 			}
       
   635 			return ETrue;
       
   636 			}
       
   637 	else if (aName== KAtrAudioLevel)
       
   638 			{
       
   639 			if (iIsFixPt)
       
   640 			{
       
   641 				TFloatFixPt lTemp;
       
   642 				lTemp.iValue = iStream.ReadInt32L();
       
   643 				TBuf<16> lTemp2;
       
   644 				_LIT(KAudioLevelFormat, "%f");
       
   645 				lTemp2.Format(KAudioLevelFormat, (float)lTemp );
       
   646 				//lTemp2.AppendNum((float)lTemp );
       
   647 				((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("audio-level"),lTemp2);
       
   648 			}
       
   649 			else
       
   650 			{
       
   651 				TReal32 lTemp;
       
   652 				iStream >> lTemp;
       
   653 				TBuf<16> lTemp2;
       
   654 				_LIT(KAudioLevelFormat, "%f");
       
   655 				lTemp2.Format(KAudioLevelFormat, (float)lTemp );
       
   656 				//lTemp2.AppendNum(lTemp);
       
   657 				((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("audio-level"),lTemp2);
       
   658 			}
       
   659 			return ETrue;
       
   660 			}
       
   661 
       
   662 	switch( aName )
       
   663 		{
       
   664 		case KAtrType:
       
   665 			{
       
   666 			if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
   667 				{
       
   668 				if (iCurrentElement->iReqAttrFlag == KAtrSVGTrf)
       
   669 					{
       
   670 					iCurrentElement->iReqAttrFlag=KAtrAttributeName;
       
   671 					}
       
   672 				else
       
   673 					{
       
   674 					iCurrentElement->iReqAttrFlag= 0;
       
   675 					}
       
   676 				TUint8 lType, lSize;
       
   677 				iStream >> lType;
       
   678 				((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
       
   679 				iStream >> lSize;
       
   680 				((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixDataSize(lSize);
       
   681 				return ETrue;
       
   682 				}
       
   683 			else if(iCurrentElement->ElemID()== KSvgAudioElement)
       
   684 				    {
       
   685 				    TPtrC lPtr(DecodeTDesCLC());
       
   686 				    ((CSvgAudioElementImpl*)iCurrentElement)->SetAttributeL(_L("type"),lPtr);
       
   687 		            CleanupStack::PopAndDestroy( 1 );				    
       
   688 				return ETrue;
       
   689 				}
       
   690 			else
       
   691 				{
       
   692 				return DecodeAttributeDesL(aName);
       
   693 				}
       
   694 			}
       
   695 
       
   696         case KAtrCdata:
       
   697             {
       
   698             if ( iCurrentElement->ElemID() == KSvgTextElement )
       
   699                 {
       
   700                 // DecodeTDesCLC() allocates the string on the cleanup stack 
       
   701                 // and advances the file pointer beyond the CData
       
   702                 // SetTextL() makes a copy of the CData in the text element. 
       
   703                 ( ( CSvgTextElementImpl* )iCurrentElement )->SetTextL( 
       
   704                         DecodeTDesCLC() ); 
       
   705                 }
       
   706             else
       
   707                 {
       
   708                 // Skip the CData
       
   709                 DecodeTDesCLC();
       
   710                 }
       
   711             // Free the CData allocated inside DecodeTDesCLC()
       
   712             CleanupStack::PopAndDestroy( 1 );
       
   713             return ETrue;
       
   714             }
       
   715 
       
   716 		case KAtrD:
       
   717 		case KAtrPoints:
       
   718 			{
       
   719 			iCurrentElement->iReqAttrFlag = 0;
       
   720 			return DecodeAttributePathL(aName);
       
   721 			}
       
   722 
       
   723 		case KAtrSpreadMethods:
       
   724 		case KAtrGradientUnits:
       
   725 			{
       
   726 			return DecodeAttributeIntL(aName);
       
   727 			}
       
   728 
       
   729 		case KAtrRotate:
       
   730 			{
       
   731 			// for AnimateMotion Element
       
   732 			if (iCurrentElement->ElemID()== KSvgAnimateMotionElement)
       
   733 				{
       
   734 				TInt16 lRotate;
       
   735 				iStream >> lRotate;
       
   736 				((CSvgAnimateMotionElementImpl*)iCurrentElement)->SetAnimRotate(lRotate);
       
   737 				}
       
   738 
       
   739 			// For Text Element
       
   740 			else
       
   741 				{
       
   742 				TInt8 lCount;
       
   743 				CArrayFixFlat<TReal32>*   lArray;
       
   744 				iStream >> lCount;
       
   745 				if(lCount)
       
   746 					{
       
   747 					lArray= new ( ELeave ) CArrayFixFlat<TReal32>( lCount );
       
   748 					CleanupStack::PushL(lArray); //cleanup
       
   749 					for (TInt i=0; i<lCount; i++)
       
   750 						{
       
   751 							TReal32 lTemp;
       
   752 							iStream >> lTemp;
       
   753 							lArray->AppendL((TReal32) lTemp);
       
   754 						}
       
   755     			
       
   756     			    if ( iCurrentElement->ElemID() == KSvgTextElement )	
       
   757 	    		        {
       
   758 		    	        ((CSvgTextElementImpl*)iCurrentElement)->SetRotateArray (lArray);
       
   759 			            }
       
   760 					
       
   761 					CleanupStack::Pop(lArray); //cleanup
       
   762 					}
       
   763 				}
       
   764 
       
   765 			return ETrue;
       
   766 			}
       
   767 
       
   768 		case KAtrStopColor:
       
   769 			{
       
   770 			TUint32 lColor;
       
   771 			iStream >> lColor;
       
   772 			// Shift from XBGR to XRGB
       
   773 			if(!iIsRGB)
       
   774 				{
       
   775 				lColor = (  lColor & 0xFF000000) |
       
   776 					  	 ( (lColor & 0x00FF0000) >> 16 ) |
       
   777 				    	 (  lColor & 0x0000FF00       ) |
       
   778 				     	 ( (lColor & 0x000000FF) << 16 );
       
   779 				}
       
   780 			
       
   781 			if ( iCurrentElement->ElemID() == KSvgStopElement )	
       
   782 			    {
       
   783     		    ((CSvgStopElementImpl*)iCurrentElement)->SetStopColorL(lColor);			    
       
   784 			    }
       
   785 
       
   786 			return ETrue;
       
   787 			}
       
   788 
       
   789 		default:
       
   790 			{
       
   791 			return EFalse;
       
   792 			}
       
   793 		}
       
   794 	}
       
   795 
       
   796 // --------------------------------------------------------------------------
       
   797 // TBool CSvgDecoder::DecodeAnimationAttributeL(const TUint16 aName)
       
   798 // ---------------------------------------------------------------------------
       
   799 TBool CSvgDecoder::DecodeAnimationAttributeL(const TUint16 aName)
       
   800 	{
       
   801 
       
   802 	if (aName== KAtrAttributeName)
       
   803 		{
       
   804 		TUint16 lAtrId;
       
   805 		TUint8 lType;
       
   806 		iStream >> lAtrId;
       
   807 
       
   808 		// For Animate Transform element
       
   809 		if (iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
   810 			{
       
   811 			// Attribute Id of the animate transform has been changed. For binary compatibility
       
   812 			if (lAtrId == KAtrTransform )
       
   813 				{
       
   814                  lAtrId= KAtrAnimateTransformAttrId;
       
   815 				}
       
   816 			((CSvgAnimationBase*)iCurrentElement)->SetAttributeId(lAtrId);
       
   817 
       
   818 			if (iCurrentElement->iReqAttrFlag == KAtrSVGTrf)
       
   819 				{
       
   820 				iCurrentElement->iReqAttrFlag=KAtrType;
       
   821 				}
       
   822 			else
       
   823 				{
       
   824 				iCurrentElement->iReqAttrFlag= 0;
       
   825 				}
       
   826 			}
       
   827 
       
   828 		//For other animation elements
       
   829 		else
       
   830 			{
       
   831 			((CSvgAnimationBase*)iCurrentElement)->SetAttributeId(lAtrId);
       
   832 			iCurrentElement->iReqAttrFlag= 0;
       
   833 			iStream >> lType;
       
   834 			((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
       
   835 			((CSvgAnimationBase*)iCurrentElement)->GetAttrValueL();
       
   836 			}
       
   837 		return ETrue;
       
   838 		}
       
   839 
       
   840 	if (aName== KAtrBegin)
       
   841 		{
       
   842         // Although discard element belongs to animation, the discard element isn't
       
   843         // necessary inherited from giant AnimationBase, so handle attribute separately.
       
   844         //
       
   845     	if ( iCurrentElement->ElemID() == KSvgDiscardElement /*|| 
       
   846              iCurrentElement->ElemID() == KSvgMediaAnimationElement*/ )
       
   847             {
       
   848     	    return EFalse;
       
   849             }
       
   850 
       
   851 		TInt8 lCheck, lCount;
       
   852 		iStream >> lCheck;
       
   853 		// Flag is used to check for Indefinite value.
       
   854 		if(lCheck)
       
   855 			{
       
   856 			((CSvgAnimationBase*)iCurrentElement)->SetAbsoluteBeginTime(KTimeIndefinite);
       
   857             ((CSvgAnimationBase*)iCurrentElement)->SetBeginTime(KTimeIndefinite);
       
   858 			}
       
   859 		else
       
   860 			{
       
   861 			CArrayFixFlat<CSvgAnimationBase::TEventListItem>*  lEventList;
       
   862 			RArray<TInt32>*    lTimeList;
       
   863         // event list
       
   864 			iStream >> lCount;
       
   865 			if (lCount)
       
   866 				{
       
   867                 lEventList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(lCount);
       
   868 				}
       
   869 			else
       
   870 				{
       
   871 				lEventList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(1);
       
   872 				}
       
   873 
       
   874 			CleanupStack::PushL(lEventList); //cleanup
       
   875 
       
   876             for( TInt i=0; i<lCount; i++)
       
   877 				{
       
   878 				CSvgAnimationBase::TEventListItem lItem;
       
   879 				TInt32 lTime;
       
   880 				iStream >> lTime;
       
   881 				lItem.iTime= lTime;
       
   882 
       
   883 				TInt32 lOffset;
       
   884 				iStream >> lOffset;
       
   885 				lItem.iOffset= lOffset;
       
   886 
       
   887 				if (iIsFixPt)
       
   888 				{
       
   889 					TFloatFixPt temp;
       
   890 					temp.iValue = iStream.ReadInt32L();
       
   891 					lItem.iRepeatValue = (TReal32)temp;
       
   892 				}
       
   893 				else
       
   894 				{
       
   895 					TReal32 lValue;
       
   896 					iStream >> lValue;
       
   897 					lItem.iRepeatValue= lValue;
       
   898 				}
       
   899 				
       
   900 
       
   901 				TPtrC lPtr(DecodeTDesCLC());
       
   902 				// check for the use of unique Id of the target element
       
   903 				if(lPtr == _L("unid"))
       
   904 					{
       
   905 					lItem.iTargetElement = (((CSvgAnimationBase*)iCurrentElement)->GetTargetElem());
       
   906 					lItem.iReferenceElemeId= NULL;
       
   907 					}
       
   908 				else
       
   909 					{
       
   910 					// get element by id and append its pointer.
       
   911 
       
   912                 	// there can be an issue if the id is not found. in  case of forward reference.
       
   913                 	// for this we will store the id if it is not found at this time.
       
   914 					lItem.iTargetElement =  (CSvgElementImpl*)iDocument->GetElementById( lPtr );
       
   915 					if( lItem.iTargetElement == NULL)
       
   916                      	{
       
   917                      	// this indicates that this is a forward reference in case of begin.
       
   918 
       
   919                      	lItem.iReferenceElemeId = lPtr.AllocL();
       
   920                      	}
       
   921 					else
       
   922                      	{
       
   923                      	// otherwise the element is found and we
       
   924                      	// do not need to keep iReferenceElemeId so
       
   925                      	// make it NULL;
       
   926                      	lItem.iReferenceElemeId = NULL;
       
   927                      	}
       
   928 					}
       
   929 
       
   930 				CleanupStack::PopAndDestroy( 1 );
       
   931 
       
   932 				TUint16 lCode;
       
   933 				iStream >> lCode;
       
   934 				lItem.iAccessKeyCode= lCode;
       
   935 
       
   936 				TInt8 lEvent;
       
   937 				iStream >> lEvent;
       
   938 				lItem.iEvent= (TSvgEvent) lEvent;
       
   939 
       
   940 				switch(lItem.iEvent)
       
   941 					{
       
   942 					case ESvgEventKey:
       
   943 					case ESvgEventNone:
       
   944 						{
       
   945 						lItem.iTargetElement =NULL;
       
   946 						break;
       
   947 						}
       
   948 					}
       
   949                 lEventList->AppendL((CSvgAnimationBase::TEventListItem) lItem);
       
   950 				}
       
   951 
       
   952 			((CSvgAnimationBase*)iCurrentElement)->SetEventList(lEventList);
       
   953 			CleanupStack::Pop(lEventList); //cleanup
       
   954 
       
   955        //begin time list
       
   956 			iStream >> lCount;
       
   957 			if (lCount)
       
   958 				{
       
   959                 lTimeList= new (ELeave) RArray<TInt32>(lCount);
       
   960 				}
       
   961 			else
       
   962 				{
       
   963 				lTimeList= new (ELeave) RArray<TInt32>(1);
       
   964 				}
       
   965 
       
   966                 // For proper cleanup
       
   967             ((CSvgAnimationBase*)iCurrentElement)->SetBeginTimeList(lTimeList);
       
   968             lTimeList->AppendL(NULL);
       
   969             lTimeList->Remove(0);
       
   970 
       
   971              for( TInt i=0; i<lCount; i++)
       
   972                 {
       
   973                 TInt32 lTime;
       
   974                 iStream >> lTime;
       
   975                 lTimeList->AppendL( (TInt32) lTime);
       
   976                 }
       
   977 
       
   978 			 TInt32 lTime;
       
   979 			 iStream >> lTime;
       
   980 			 ((CSvgAnimationBase*)iCurrentElement)->SetAbsoluteBeginTime(lTime);
       
   981 			 iStream >> lTime;
       
   982 			 ((CSvgAnimationBase*)iCurrentElement)->SetBeginTime(lTime);
       
   983 
       
   984 
       
   985 			 iStream >> lCheck;
       
   986 			 // flag to ckeck Adding to the Reciever EventList
       
   987 			 if(lCheck)
       
   988 				{
       
   989 				iDocument->AddToEventReceiverListL( iCurrentElement,
       
   990                                                         KSvgEventMaskExternalUI );
       
   991 				}
       
   992 			}
       
   993 		return ETrue;
       
   994 		}
       
   995 
       
   996 
       
   997 	if (aName== KAtrEnd)  //End Time
       
   998 		{
       
   999 		TInt8 lCheck;
       
  1000 		iStream >> lCheck;
       
  1001 
       
  1002 		// Flag is used to check for Indefinite value
       
  1003 		if(lCheck)
       
  1004 			{
       
  1005             ((CSvgAnimationBase*)iCurrentElement)->SetEndTime(KTimeIndefinite);
       
  1006 			}
       
  1007 		else
       
  1008 			{
       
  1009 		  	CArrayFixFlat<CSvgAnimationBase::TEventListItem>*  lTimeList;
       
  1010         // event list
       
  1011 
       
  1012 			lTimeList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(1);
       
  1013 			CleanupStack::PushL(lTimeList); //cleanup
       
  1014 
       
  1015 			CSvgAnimationBase::TEventListItem lItem;
       
  1016 			TInt8 lEvent;
       
  1017 			iStream >> lEvent;
       
  1018 			lItem.iEvent = (TSvgEvent) lEvent;
       
  1019 
       
  1020 			if (iIsFixPt)
       
  1021 			{
       
  1022 				TFloatFixPt temp;
       
  1023 				temp.iValue = iStream.ReadInt32L();
       
  1024 				lItem.iRepeatValue = (TReal32)temp;
       
  1025 			}
       
  1026 			else
       
  1027 			{
       
  1028 				TReal32 lValue;
       
  1029 				iStream >> lValue;
       
  1030 				lItem.iRepeatValue= lValue;
       
  1031 			}
       
  1032 			
       
  1033 
       
  1034 			TPtrC lPtr( DecodeTDesCLC() );
       
  1035 
       
  1036 			if (lPtr == _L("unid") )
       
  1037 				{
       
  1038 				lItem.iTargetElement = ((CSvgAnimationBase*)iCurrentElement)->GetTargetElem();
       
  1039 				lItem.iReferenceElemeId = NULL;
       
  1040 				}
       
  1041 			else
       
  1042 				{
       
  1043 				// get element by id and append its pointer.
       
  1044 				lItem.iTargetElement = ( CSvgElementImpl * )
       
  1045 							 iDocument->GetElementById( lPtr );
       
  1046 				if(lItem.iTargetElement == NULL)
       
  1047 					 {
       
  1048 					 lItem.iReferenceElemeId = lPtr.AllocL();
       
  1049 					 }
       
  1050 				 else
       
  1051 					{
       
  1052 					// Set the iEndReferenceElemeId to NULL:
       
  1053 					lItem.iReferenceElemeId = NULL;
       
  1054 					}
       
  1055 				}
       
  1056 
       
  1057 			CleanupStack::PopAndDestroy( 1 );
       
  1058 
       
  1059 			switch ( lItem.iEvent )
       
  1060                 {
       
  1061                 case ESvgEventKey:
       
  1062 					{
       
  1063          			((CSvgAnimationBase*)iCurrentElement)->SetEndTime(KTimeIndefinite );  // same as indefinite
       
  1064 
       
  1065 					TUint16 lCode;
       
  1066 					iStream >> lCode;
       
  1067 					lItem.iAccessKeyCode= lCode;
       
  1068 					lItem.iTargetElement =NULL;
       
  1069 		           iDocument->AddToEventReceiverListL( iCurrentElement,
       
  1070                                                         KSvgEventMaskExternalUI );
       
  1071 	               break;
       
  1072 					}
       
  1073                 case ESvgEventWallClock:
       
  1074                 // not supported yet
       
  1075                 break;
       
  1076                 case ESvgEventNone:
       
  1077 					{
       
  1078 					TInt32 lTime;
       
  1079 					iStream >> lTime;
       
  1080 					lItem.iTime= lTime;
       
  1081 					((CSvgAnimationBase*)iCurrentElement)->AddEndTime(lTime);
       
  1082 					lItem.iTargetElement =NULL;
       
  1083 				    break;
       
  1084 					}
       
  1085                 default:
       
  1086 					{
       
  1087 				    ((CSvgAnimationBase*)iCurrentElement)->SetEndTime( KTimeIndefinite );  // same as indifinite
       
  1088 					TInt32 lOffset;
       
  1089 					iStream >> lOffset;
       
  1090 					lItem.iOffset= lOffset;
       
  1091 
       
  1092 					lItem.iTime = KTimeIndefinite;
       
  1093 		            iDocument->AddToEventReceiverListL( iCurrentElement,
       
  1094                                                        KSvgEventMaskInternal );
       
  1095 					}
       
  1096 
       
  1097                 }
       
  1098 			lTimeList->AppendL( (CSvgAnimationBase::TEventListItem) lItem);
       
  1099 			((CSvgAnimationBase*)iCurrentElement)->SetEndTimeList( lTimeList);
       
  1100 			CleanupStack::Pop(lTimeList); //cleanup
       
  1101 
       
  1102 			}
       
  1103 
       
  1104 		return ETrue;
       
  1105 		}
       
  1106 
       
  1107 ////////// for multiple end times
       
  1108 
       
  1109 	if (aName== KMultipleEndTime)
       
  1110 		{
       
  1111 		TInt8  lCount;
       
  1112 
       
  1113 		CArrayFixFlat<CSvgAnimationBase::TEventListItem>*  lTimeList;
       
  1114        // event list
       
  1115 		iStream >> lCount;
       
  1116 		if (lCount)
       
  1117 			{
       
  1118             lTimeList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(lCount);
       
  1119 			}
       
  1120 		else
       
  1121 			{
       
  1122 			lTimeList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(1);
       
  1123 			}
       
  1124 
       
  1125 		CleanupStack::PushL(lTimeList); //cleanup
       
  1126 
       
  1127 		for( TInt i=0; i<lCount; i++)
       
  1128 			{
       
  1129 			CSvgAnimationBase::TEventListItem lItem;
       
  1130 			TInt32 lTime;
       
  1131 			iStream >> lTime;
       
  1132 			lItem.iTime= lTime;
       
  1133 
       
  1134 			TInt32 lOffset;
       
  1135 			iStream >> lOffset;
       
  1136 			lItem.iOffset= lOffset;
       
  1137 
       
  1138 			if (iIsFixPt)
       
  1139 			{
       
  1140 				TFloatFixPt temp;
       
  1141 				temp.iValue = iStream.ReadInt32L();
       
  1142 				lItem.iRepeatValue = (TReal32)temp;
       
  1143 			}
       
  1144 			else
       
  1145 			{
       
  1146 				TReal32 lValue;
       
  1147 				iStream >> lValue;
       
  1148 				lItem.iRepeatValue= lValue;
       
  1149 			}	
       
  1150 			
       
  1151 
       
  1152 			TPtrC lPtr(DecodeTDesCLC());
       
  1153 			// check for the use of unique Id of the target element
       
  1154 			if(lPtr == _L("unid"))
       
  1155 				{
       
  1156 				lItem.iTargetElement = (((CSvgAnimationBase*)iCurrentElement)->GetTargetElem());
       
  1157 				lItem.iReferenceElemeId= NULL;
       
  1158 				}
       
  1159 			else
       
  1160 				{
       
  1161 				// get element by id and append its pointer.
       
  1162                	// there can be an issue if the id is not found. in  case of forward reference.
       
  1163                	// for this we will store the id if it is not found at this time.
       
  1164 				lItem.iTargetElement =  (CSvgElementImpl*)iDocument->GetElementById( lPtr );
       
  1165 				if( lItem.iTargetElement == NULL)
       
  1166                    	{
       
  1167                    	// this indicates that this is a forward reference in case of begin.
       
  1168 
       
  1169 					lItem.iReferenceElemeId = lPtr.AllocL();
       
  1170                    	}
       
  1171 				else
       
  1172                    	{
       
  1173                    	// otherwise the element is found and we
       
  1174                    	// do not need to keep iReferenceElemeId so
       
  1175                    	// make it NULL;
       
  1176                    	lItem.iReferenceElemeId = NULL;
       
  1177                    	}
       
  1178 				}
       
  1179 
       
  1180 			CleanupStack::PopAndDestroy( 1 );
       
  1181 
       
  1182 			TUint16 lCode;
       
  1183 			iStream >> lCode;
       
  1184 			lItem.iAccessKeyCode= lCode;
       
  1185 
       
  1186 			TInt8 lEvent;
       
  1187 			iStream >> lEvent;
       
  1188 			lItem.iEvent= (TSvgEvent) lEvent;
       
  1189 
       
  1190 			switch ( lItem.iEvent )
       
  1191                 {
       
  1192                 case ESvgEventKey:
       
  1193                 lItem.iTargetElement =NULL;
       
  1194                 ((CSvgAnimationBase*)iCurrentElement)->SetEndTime( KTimeIndefinite );  // same as indefinite
       
  1195 
       
  1196                 iDocument->AddToEventReceiverListL( iCurrentElement,
       
  1197                                                         KSvgEventMaskExternalUI );
       
  1198                 break;
       
  1199 
       
  1200                 case ESvgEventWallClock:
       
  1201                 // not supported yet
       
  1202                 break;
       
  1203 
       
  1204                 case ESvgEventNone:
       
  1205                 lItem.iTargetElement =NULL;
       
  1206                 // Simple Offset-value
       
  1207                 ((CSvgAnimationBase*)iCurrentElement)->AddEndTime( lItem.iTime );
       
  1208 
       
  1209                 break;
       
  1210 
       
  1211                 default:
       
  1212                 // <id>.<event> +/- <offeset>
       
  1213                 ((CSvgAnimationBase*)iCurrentElement)->SetEndTime( KTimeIndefinite );  // same as indifinite
       
  1214 
       
  1215                 iDocument->AddToEventReceiverListL( iCurrentElement,
       
  1216                                                         KSvgEventMaskInternal );
       
  1217                 }
       
  1218 
       
  1219 			lTimeList->AppendL((CSvgAnimationBase::TEventListItem) lItem);
       
  1220 			}
       
  1221 
       
  1222 		((CSvgAnimationBase*)iCurrentElement)->SetEndTimeList(lTimeList);
       
  1223 		CleanupStack::Pop(lTimeList); //cleanup
       
  1224 
       
  1225 
       
  1226 
       
  1227 
       
  1228 		return ETrue;
       
  1229 		}
       
  1230 
       
  1231 
       
  1232 		if (aName== KAtrDur)
       
  1233 			{
       
  1234 			TInt32 lTime;
       
  1235 			TInt8 lCheck;
       
  1236 			iStream >> lTime;
       
  1237 			((CSvgAnimationBase*)iCurrentElement)->SetDurationTime(lTime);
       
  1238 			iStream >> lCheck;
       
  1239 			// Flag is used to check for Indefinite value
       
  1240 			if(lCheck)
       
  1241 				{
       
  1242 				((CSvgAnimationBase*)iCurrentElement)->SetBeginTime(KTimeIndefinite);
       
  1243 				}
       
  1244 			return ETrue;
       
  1245 			}
       
  1246 
       
  1247 		if (aName== KAtrFrom)
       
  1248 			{
       
  1249 			((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
       
  1250 
       
  1251 			//For Animate Transform element
       
  1252 			if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
  1253 				{
       
  1254 				CSvgAnimateTransformElementImpl::TMatrixData  lMatrix;
       
  1255 				
       
  1256 				if (iIsFixPt)
       
  1257 				{
       
  1258 					for (TInt i=0; i<3; i++)
       
  1259 					{
       
  1260 					lMatrix.iData[i].iValue = iStream.ReadInt32L();
       
  1261 					}	
       
  1262 				}
       
  1263 				else
       
  1264 				{
       
  1265 					TReal32 lTemp;
       
  1266 					for (TInt i=0; i<3; i++)
       
  1267 					{
       
  1268 					iStream >> lTemp;
       
  1269 					lMatrix.iData[i]= (TFloatFixPt) lTemp;
       
  1270 					}	
       
  1271 				}
       
  1272 		
       
  1273 				((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixData(0,lMatrix);
       
  1274 				}
       
  1275 
       
  1276 			// for other Animation elements
       
  1277 			else
       
  1278 				{
       
  1279 
       
  1280 				TUint8 lType;
       
  1281 				iStream >>lType;
       
  1282 				((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
       
  1283 				switch ( lType )
       
  1284 					{
       
  1285 					case KSvgTypeOpacity:
       
  1286 					case KSvgTypeLength:
       
  1287 						{
       
  1288 						if (iIsFixPt)
       
  1289 						{	
       
  1290 							TFloatFixPt lValue; 
       
  1291 							lValue.iValue = iStream.ReadInt32L();
       
  1292 							((CSvgAnimationBase*)iCurrentElement)->SetFromFloat(lValue);
       
  1293 						}
       
  1294 						else
       
  1295 						{
       
  1296 							TReal32 lValue;
       
  1297 							iStream >> lValue;
       
  1298 							((CSvgAnimationBase*)iCurrentElement)->SetFromFloat((TFloatFixPt)lValue);
       
  1299 						}
       
  1300 						
       
  1301 						break;
       
  1302 						}
       
  1303 					case KSvgTypeList:
       
  1304 					case KSvgTypePath:
       
  1305 						{
       
  1306 						CGfxGeneralPath* lPath;
       
  1307 						DecodeAnimationPathL(lPath);
       
  1308 						((CSvgAnimationBase*)iCurrentElement)->SetFromPathL(lPath);
       
  1309 						break;
       
  1310 						}
       
  1311 					case KSvgTypeColor:
       
  1312 						{	
       
  1313 						TInt32 lColor;
       
  1314 						iStream >> lColor;
       
  1315 						// Shift from XBGR to XRGB
       
  1316 						if(!iIsRGB)
       
  1317 							{
       
  1318 							lColor = (  lColor & 0xFF000000) |
       
  1319 						         ( (lColor & 0x00FF0000) >> 16 ) |
       
  1320 							     (  lColor & 0x0000FF00       ) |
       
  1321 							     ( (lColor & 0x000000FF) << 16 );
       
  1322 							}
       
  1323 						((CSvgAnimationBase*)iCurrentElement)->SetFromInt(lColor);
       
  1324 						break;
       
  1325 						}
       
  1326 					case KSvgTypeTextAnchor:
       
  1327                     case KSvgTypeGradientUnits:
       
  1328 					case KSvgTypeSpreadMethod:
       
  1329 					case KSvgTypeInteger:
       
  1330 					case KSvgTypeDisplay:
       
  1331 					case KSvgTypeVisibility:
       
  1332 						{
       
  1333 						TInt32 lTemp;
       
  1334 						iStream >> lTemp;
       
  1335 						((CSvgAnimationBase*)iCurrentElement)->SetFromInt(lTemp);
       
  1336 						break;
       
  1337 						}
       
  1338 
       
  1339 				    // viewBox attribute
       
  1340 					case KSvgTypeViewBox:
       
  1341 						{
       
  1342 						
       
  1343 						if (iIsFixPt)
       
  1344 						{
       
  1345 							TGfxRectangle2D temp;
       
  1346 							temp.iX.iValue = iStream.ReadInt32L();
       
  1347 							
       
  1348 							temp.iY.iValue = iStream.ReadInt32L();
       
  1349 							temp.iWidth.iValue = iStream.ReadInt32L();
       
  1350 							temp.iHeight.iValue = iStream.ReadInt32L();
       
  1351 
       
  1352 							((CSvgAnimationBase*)iCurrentElement)->SetFromViewBox(temp);
       
  1353 						}
       
  1354 						else
       
  1355 						{
       
  1356 							TReal32 lValue;
       
  1357 							TGfxRectangle2D temp;
       
  1358 
       
  1359 							this->iStream >> lValue;
       
  1360 							temp.iX = (TFloatFixPt) lValue;
       
  1361 							this->iStream >> lValue;
       
  1362 							temp.iY = (TFloatFixPt) lValue;
       
  1363 							this->iStream >> lValue;
       
  1364 							temp.iWidth = (TFloatFixPt) lValue;
       
  1365 							this->iStream >> lValue;
       
  1366 							temp.iHeight = (TFloatFixPt) lValue;
       
  1367 
       
  1368 							((CSvgAnimationBase*)iCurrentElement)->SetFromViewBox(temp);	
       
  1369 						}
       
  1370 						break;
       
  1371 						}
       
  1372 					}
       
  1373 				}
       
  1374 			 return ETrue;
       
  1375 			}
       
  1376 
       
  1377 		if (aName== KAtrTo)
       
  1378 			{
       
  1379 			((CSvgAnimationBase*)iCurrentElement)->SetToFlag();
       
  1380 
       
  1381 			// For Animate Transform
       
  1382 			if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
  1383 				{
       
  1384 				if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1385 					{
       
  1386 					((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1387 					}
       
  1388 				CSvgAnimateTransformElementImpl::TMatrixData  lMatrix;
       
  1389 				
       
  1390 				if (iIsFixPt)
       
  1391 				{
       
  1392 					for (TInt i=0; i<3; i++)
       
  1393 					{
       
  1394 					lMatrix.iData[i].iValue = iStream.ReadInt32L();
       
  1395 					}
       
  1396 				}
       
  1397 				else
       
  1398 				{
       
  1399 					TReal32 lTemp;
       
  1400 					for (TInt i=0; i<3; i++)
       
  1401 					{
       
  1402 					iStream >> lTemp;
       
  1403 					lMatrix.iData[i]= (TFloatFixPt) lTemp;
       
  1404 					}
       
  1405 				}
       
  1406 			
       
  1407 				((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixData(1,lMatrix);
       
  1408 				((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetAccumMatrix();
       
  1409 				}
       
  1410 
       
  1411 			// for Other Animation Elements
       
  1412 			else
       
  1413 				{
       
  1414 				TUint8 lType;
       
  1415 				iStream >>lType;
       
  1416 				((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
       
  1417 				switch ( lType )
       
  1418 					{
       
  1419 					case KSvgTypeOpacity:
       
  1420 					case KSvgTypeLength:
       
  1421 						{
       
  1422 						
       
  1423 						if (iIsFixPt)
       
  1424 						{
       
  1425 							TFloatFixPt lValue;
       
  1426 							lValue.iValue = iStream.ReadInt32L();
       
  1427 							((CSvgAnimationBase*)iCurrentElement)->SetToFloat(lValue);
       
  1428 						}
       
  1429 						else
       
  1430 						{
       
  1431 							TReal32 lValue;
       
  1432 							iStream >> lValue;
       
  1433 							((CSvgAnimationBase*)iCurrentElement)->SetToFloat((TFloatFixPt)lValue);
       
  1434 						}
       
  1435 					
       
  1436 						break;
       
  1437 						}
       
  1438 					case KSvgTypeList:
       
  1439 					case KSvgTypePath:
       
  1440 						{
       
  1441 						CGfxGeneralPath* lPath;
       
  1442 						DecodeAnimationPathL(lPath);
       
  1443 						((CSvgAnimationBase*)iCurrentElement)->SetToPath(lPath);
       
  1444 						break;
       
  1445 						}
       
  1446 					case KSvgTypeColor:
       
  1447 					{
       
  1448 						TInt32 lColor;
       
  1449 						iStream >> lColor;
       
  1450 						// Shift from XBGR to XRGB
       
  1451 						if(!iIsRGB)
       
  1452 							{
       
  1453 							lColor = (  lColor & 0xFF000000) |
       
  1454 						         ( (lColor & 0x00FF0000) >> 16 ) |
       
  1455 							     (  lColor & 0x0000FF00       ) |
       
  1456 							     ( (lColor & 0x000000FF) << 16 );
       
  1457 							}
       
  1458 						((CSvgAnimationBase*)iCurrentElement)->SetToInt(lColor);
       
  1459 						break;
       
  1460 					}
       
  1461 					case KSvgTypeTextAnchor:
       
  1462 					case KSvgTypeGradientUnits:
       
  1463 					case KSvgTypeSpreadMethod:
       
  1464 					case KSvgTypeInteger:
       
  1465 					case KSvgTypeDisplay:
       
  1466 					case KSvgTypeVisibility:
       
  1467 						{
       
  1468 						TInt32 lTemp;
       
  1469 						iStream >> lTemp;
       
  1470 						((CSvgAnimationBase*)iCurrentElement)->SetToInt(lTemp);
       
  1471 						break;
       
  1472 						}
       
  1473 
       
  1474 					 // viewBox attribute
       
  1475 					case KSvgTypeViewBox:
       
  1476 						{
       
  1477 						if (iIsFixPt)
       
  1478 						{
       
  1479 							TGfxRectangle2D temp;
       
  1480 							temp.iX.iValue = iStream.ReadInt32L();
       
  1481 							temp.iY.iValue = iStream.ReadInt32L();
       
  1482 							temp.iWidth.iValue = iStream.ReadInt32L();
       
  1483 							temp.iHeight.iValue = iStream.ReadInt32L();
       
  1484 
       
  1485 							((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
       
  1486 						}
       
  1487 						else
       
  1488 						{
       
  1489 							TReal32 lValue;
       
  1490 							TGfxRectangle2D temp;
       
  1491 
       
  1492 							this->iStream >> lValue;
       
  1493 							temp.iX = (TFloatFixPt) lValue;
       
  1494 							this->iStream >> lValue;
       
  1495 							temp.iY = (TFloatFixPt) lValue;
       
  1496 							this->iStream >> lValue;
       
  1497 							temp.iWidth = (TFloatFixPt) lValue;
       
  1498 							this->iStream >> lValue;
       
  1499 							temp.iHeight = (TFloatFixPt) lValue;
       
  1500 
       
  1501 							((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);	
       
  1502 						}
       
  1503 			
       
  1504 						break;
       
  1505 						}
       
  1506 
       
  1507 					}
       
  1508 				}
       
  1509 			 return ETrue;
       
  1510 
       
  1511 			}
       
  1512 
       
  1513 		if (aName== KAtrBy) //by
       
  1514 			{
       
  1515 			((CSvgAnimationBase*)iCurrentElement)->SetByFlag();
       
  1516 
       
  1517 			// For Animate Transform
       
  1518 			if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
  1519 				{
       
  1520 				if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1521 					{
       
  1522 					((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1523 					}
       
  1524 				CSvgAnimateTransformElementImpl::TMatrixData  lMatrix;
       
  1525 				
       
  1526 				if (iIsFixPt)
       
  1527 				{
       
  1528 					for (TInt i=0; i<3; i++)
       
  1529 					{
       
  1530 					lMatrix.iData[i].iValue = iStream.ReadInt32L();
       
  1531 					}
       
  1532 				}
       
  1533 				else
       
  1534 				{
       
  1535 					TReal32 lTemp;
       
  1536 					for (TInt i=0; i<3; i++)
       
  1537 					{
       
  1538 					iStream >> lTemp;
       
  1539 					lMatrix.iData[i]= (TFloatFixPt) lTemp;
       
  1540 					}
       
  1541 				}
       
  1542 				
       
  1543 				((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixData(1,lMatrix);
       
  1544 				}
       
  1545 
       
  1546 			// for Other Animation Elements
       
  1547 			else
       
  1548 				{
       
  1549 				TUint8 lType;
       
  1550 				iStream >>lType;
       
  1551 				((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
       
  1552 				switch ( lType )
       
  1553 					{
       
  1554 					case KSvgTypeOpacity:
       
  1555 					case KSvgTypeLength:
       
  1556 						{
       
  1557 						if (iIsFixPt)
       
  1558 						{
       
  1559 							TFloatFixPt lValue;
       
  1560 							lValue.iValue = iStream.ReadInt32L();
       
  1561 							
       
  1562 							((CSvgAnimationBase*)iCurrentElement)->SetToFloat( lValue );
       
  1563 							if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1564 							{
       
  1565 							((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1566                             ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
       
  1567 							((CSvgAnimationBase*)iCurrentElement)->SetFromFloat((TFloatFixPt)0);
       
  1568 							}
       
  1569 						}
       
  1570 						else
       
  1571 						{
       
  1572 							TReal32 lValue;
       
  1573 							iStream >> lValue;
       
  1574 							
       
  1575 							((CSvgAnimationBase*)iCurrentElement)->SetToFloat((TFloatFixPt)lValue);
       
  1576 							if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1577 							{
       
  1578 							((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1579                             ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
       
  1580 							((CSvgAnimationBase*)iCurrentElement)->SetFromFloat((TFloatFixPt)0);
       
  1581 							}
       
  1582 						}
       
  1583 						
       
  1584 						break;
       
  1585 						}
       
  1586 					case KSvgTypeList:
       
  1587 					case KSvgTypePath:
       
  1588 						{
       
  1589 						CGfxGeneralPath* lPath;
       
  1590 						DecodeAnimationPathL(lPath);
       
  1591 						((CSvgAnimationBase*)iCurrentElement)->SetToPath(lPath);
       
  1592 						break;
       
  1593 						}
       
  1594 
       
  1595                     case KSvgTypeColor:
       
  1596 						{
       
  1597 						TInt32 lColor;
       
  1598 						iStream >> lColor;
       
  1599 						// Shift from XBGR to XRGB
       
  1600 						if(!iIsRGB)
       
  1601 							{
       
  1602 							lColor = (  lColor & 0xFF000000) |
       
  1603 						         ( (lColor & 0x00FF0000) >> 16 ) |
       
  1604 							     (  lColor & 0x0000FF00       ) |
       
  1605 							     ( (lColor & 0x000000FF) << 16 );
       
  1606 							}
       
  1607 						((CSvgAnimationBase*)iCurrentElement)->SetToInt(lColor);
       
  1608 						if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1609 							{
       
  1610 							((CSvgAnimationBase*)iCurrentElement)->SetFromInt((TInt32)0);
       
  1611 							}
       
  1612 						break;
       
  1613 						}
       
  1614 					case KSvgTypeTextAnchor:
       
  1615                     case KSvgTypeGradientUnits:
       
  1616 					case KSvgTypeSpreadMethod:
       
  1617 					case KSvgTypeInteger:
       
  1618 						{
       
  1619 						TInt32 lTemp;
       
  1620 						iStream >> lTemp;
       
  1621 						((CSvgAnimationBase*)iCurrentElement)->SetToInt(lTemp);
       
  1622 						if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1623 							{
       
  1624 							((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1625                             ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
       
  1626 							((CSvgAnimationBase*)iCurrentElement)->SetFromInt((TInt32)0);
       
  1627 							}
       
  1628 						break;
       
  1629 						}
       
  1630 
       
  1631                     case KSvgTypeDisplay:
       
  1632 					case KSvgTypeVisibility:
       
  1633 						{
       
  1634 						TInt32 lTemp;
       
  1635 						iStream >> lTemp;
       
  1636 						((CSvgAnimationBase*)iCurrentElement)->SetToInt(lTemp);
       
  1637 						break;
       
  1638 						}
       
  1639 
       
  1640 					 // viewBox attribute
       
  1641 					case KSvgTypeViewBox:
       
  1642 						{
       
  1643 						if (iIsFixPt)
       
  1644 						{
       
  1645 							TGfxRectangle2D temp;
       
  1646 							temp.iX.iValue = iStream.ReadInt32L();
       
  1647 							temp.iY.iValue = iStream.ReadInt32L();
       
  1648 							temp.iWidth.iValue = iStream.ReadInt32L();
       
  1649 							temp.iHeight.iValue = iStream.ReadInt32L();
       
  1650 							
       
  1651 							((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
       
  1652 						}
       
  1653 						else
       
  1654 						{
       
  1655 							TReal32 lValue;
       
  1656 							TGfxRectangle2D temp;
       
  1657 
       
  1658 							iStream >> lValue;
       
  1659 							temp.iX = (TFloatFixPt) lValue;
       
  1660 							iStream >> lValue;
       
  1661 							temp.iY = (TFloatFixPt) lValue;
       
  1662 							iStream >> lValue;
       
  1663 							temp.iWidth = (TFloatFixPt) lValue;
       
  1664 							iStream >> lValue;
       
  1665 							temp.iHeight = (TFloatFixPt) lValue;
       
  1666 							
       
  1667 							((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
       
  1668 						}
       
  1669 						
       
  1670 						if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
       
  1671 							{
       
  1672 							((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1673                             ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
       
  1674 							((CSvgAnimationBase*)iCurrentElement)->SetFromViewBox
       
  1675 								                    (TGfxRectangle2D( 0, 0, 0, 0 ) );
       
  1676 							}
       
  1677 						break;
       
  1678 						}
       
  1679 					}
       
  1680 				}
       
  1681 			return ETrue;
       
  1682 
       
  1683 			}
       
  1684 
       
  1685 
       
  1686 		if (aName== KAtrValues)  // values
       
  1687 			{
       
  1688 			((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
       
  1689 			((CSvgAnimationBase*)iCurrentElement)->SetValuesFlag();
       
  1690 
       
  1691 			// For Animate Transform
       
  1692 			if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
  1693 				{
       
  1694 				TUint16 lCount;
       
  1695 				RArray<CSvgAnimateTransformElementImpl::TMatrixData>* lValues= NULL;
       
  1696 
       
  1697 				iStream >>lCount;
       
  1698 				if (lCount)
       
  1699 					{
       
  1700 					lValues= new (ELeave) RArray<CSvgAnimateTransformElementImpl::TMatrixData>(lCount);
       
  1701 					}
       
  1702 				else
       
  1703 					{
       
  1704 					lValues= new (ELeave) RArray<CSvgAnimateTransformElementImpl::TMatrixData>(1);
       
  1705 					}
       
  1706 
       
  1707 				// for proper cleanup
       
  1708                 ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetTransformValues(lValues);
       
  1709                 CSvgAnimateTransformElementImpl::TMatrixData  lMatrix1;
       
  1710                 lValues->AppendL(lMatrix1);
       
  1711                 lValues->Remove(0);
       
  1712 
       
  1713                 for (TInt i=0; i<lCount; i++)
       
  1714                         {
       
  1715                         CSvgAnimateTransformElementImpl::TMatrixData  lMatrix;
       
  1716                         
       
  1717                         if (iIsFixPt)
       
  1718                         {
       
  1719                         	for (TInt i=0; i<3; i++)
       
  1720                             {
       
  1721                             lMatrix.iData[i].iValue = iStream.ReadInt32L();
       
  1722                             }
       
  1723                         }
       
  1724                         else
       
  1725                         {
       
  1726                         	TReal32 lTemp;
       
  1727                         	for (TInt i=0; i<3; i++)
       
  1728                             {
       
  1729                             iStream >> lTemp;
       
  1730                             lMatrix.iData[i]= (TFloatFixPt) lTemp;
       
  1731                             }
       
  1732                         }
       
  1733                         
       
  1734                         lValues->AppendL( (CSvgAnimateTransformElementImpl::TMatrixData) lMatrix);
       
  1735                         }
       
  1736 				if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
       
  1737 					{
       
  1738 					((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetAccumMatrix();
       
  1739 					}
       
  1740 				}
       
  1741 
       
  1742 
       
  1743 			// For other Animation elements
       
  1744 			else
       
  1745 				{
       
  1746 				TUint8 lType;
       
  1747 				iStream >>lType;
       
  1748 				((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
       
  1749 				switch ( lType )
       
  1750 					{
       
  1751 					case KSvgTypeOpacity:
       
  1752 					case KSvgTypeLength:
       
  1753 						{
       
  1754 						RArray<TFloatFixPt>* lArray;
       
  1755 						TUint16 lCount;
       
  1756 						iStream >> lCount;
       
  1757 						if (lCount)
       
  1758 							{
       
  1759 							lArray= new (ELeave) RArray<TFloatFixPt>(lCount);
       
  1760 							}
       
  1761 						else
       
  1762 							{
       
  1763 							lArray= new (ELeave) RArray<TFloatFixPt>(1);
       
  1764 							}
       
  1765 
       
  1766                         // for proper cleanup
       
  1767                         ((CSvgAnimationBase*)iCurrentElement)->SetFloatValuesArray(lArray);
       
  1768                         lArray->AppendL(NULL);
       
  1769                         lArray->Remove(0);
       
  1770                         
       
  1771                         TFloatFixPt lValueFix;
       
  1772                         TReal32 lValueFloat;
       
  1773                         
       
  1774                         for(TInt i=0; i<lCount; i++)
       
  1775                             {
       
  1776                             
       
  1777                             if(iIsFixPt)
       
  1778                             {
       
  1779                             	lValueFix.iValue = iStream.ReadInt32L();
       
  1780                             	lArray->AppendL( lValueFix );
       
  1781                             }
       
  1782                             else
       
  1783                             {
       
  1784                             	iStream >> lValueFloat;
       
  1785                             	lArray->AppendL((TFloatFixPt) lValueFloat);
       
  1786                             }
       
  1787                             
       
  1788                             }
       
  1789 						break;
       
  1790 						}
       
  1791 					case KSvgTypeList:
       
  1792 					case KSvgTypePath:
       
  1793 						{
       
  1794 						TUint16 lCount;
       
  1795 						RPointerArray<CGfxGeneralPath>* lArray;
       
  1796 						iStream >> lCount;
       
  1797 						if (lCount)
       
  1798 							{
       
  1799 							lArray= new (ELeave) RPointerArray<CGfxGeneralPath>(lCount);
       
  1800 							}
       
  1801 						else
       
  1802 							{
       
  1803 							lArray= new (ELeave) RPointerArray<CGfxGeneralPath>(1);
       
  1804 							}
       
  1805 
       
  1806 						// for proper cleanup
       
  1807                         ((CSvgAnimationBase*)iCurrentElement)->ResetFloatValuesArray();
       
  1808                         ((CSvgAnimationBase*)iCurrentElement)->SetPathValuesArray(lArray);
       
  1809                         lArray->AppendL(NULL);
       
  1810                         lArray->Remove(0);
       
  1811                         for(TInt i=0; i<lCount; i++)
       
  1812                             {
       
  1813                             CGfxGeneralPath* lPath;
       
  1814                             DecodeAnimationPathL(lPath);
       
  1815                             lArray->AppendL( (CGfxGeneralPath*)lPath );
       
  1816                             }
       
  1817                         break;
       
  1818                         }
       
  1819 
       
  1820 					case KSvgTypeColor:
       
  1821 						{
       
  1822 						RArray<TInt32>* lArray;
       
  1823 						TUint16 lCount;
       
  1824 						iStream >> lCount;
       
  1825 						if (lCount)
       
  1826 							{
       
  1827 							lArray= new (ELeave) RArray<TInt32>(lCount);
       
  1828 							}
       
  1829 						else
       
  1830 							{
       
  1831 							lArray= new (ELeave) RArray<TInt32>(1);
       
  1832 							}
       
  1833 
       
  1834 						// for proper cleanup
       
  1835                         ((CSvgAnimationBase*)iCurrentElement)->ResetFloatValuesArray();
       
  1836                         ((CSvgAnimationBase*)iCurrentElement)->SetIntValuesArray(lArray);
       
  1837                         lArray->AppendL(NULL);
       
  1838                         lArray->Remove(0);
       
  1839 
       
  1840                         for(TInt i=0; i<lCount; i++)
       
  1841                             {
       
  1842                             TInt32 lColor;
       
  1843                             iStream >> lColor;
       
  1844 							if(!iIsRGB)
       
  1845 								{
       
  1846 								lColor = (  lColor & 0xFF000000) |
       
  1847 							         ( (lColor & 0x00FF0000) >> 16 ) |
       
  1848 								     (  lColor & 0x0000FF00       ) |
       
  1849 								     ( (lColor & 0x000000FF) << 16 );
       
  1850 								}
       
  1851                             lArray->AppendL((TInt32) lColor);
       
  1852 							}
       
  1853 						break;
       
  1854 						}
       
  1855 
       
  1856                     case KSvgTypeGradientUnits:
       
  1857 					case KSvgTypeSpreadMethod:
       
  1858 					case KSvgTypeInteger:
       
  1859 					case KSvgTypeDisplay:
       
  1860 					case KSvgTypeVisibility:
       
  1861 					case KSvgTypeTextAnchor:
       
  1862 						{
       
  1863 						RArray<TInt32>* lArray;
       
  1864 						TUint16 lCount;
       
  1865 						iStream >> lCount;
       
  1866 						if (lCount)
       
  1867 							{
       
  1868 							lArray= new (ELeave) RArray<TInt32>(lCount);
       
  1869 							}
       
  1870 						else
       
  1871 							{
       
  1872 							lArray= new (ELeave) RArray<TInt32>(1);
       
  1873 							}
       
  1874 
       
  1875 						// for proper cleanup
       
  1876                         ((CSvgAnimationBase*)iCurrentElement)->ResetFloatValuesArray();
       
  1877                         ((CSvgAnimationBase*)iCurrentElement)->SetIntValuesArray(lArray);
       
  1878                         lArray->AppendL(NULL);
       
  1879                         lArray->Remove(0);
       
  1880 
       
  1881                         for(TInt i=0; i<lCount; i++)
       
  1882                             {
       
  1883                             TInt32 lValue;
       
  1884                             iStream >> lValue;
       
  1885                             lArray->AppendL((TInt32) lValue);
       
  1886 							}
       
  1887 						break;
       
  1888 						}
       
  1889 
       
  1890 					// viewBox
       
  1891 					case KSvgTypeViewBox:
       
  1892 						{
       
  1893 						RArray<TGfxRectangle2D>* lArray;
       
  1894 						TUint16 lCount;
       
  1895 						iStream >> lCount;
       
  1896 						if (lCount)
       
  1897 							{
       
  1898 							lArray= new (ELeave) RArray<TGfxRectangle2D>(lCount);
       
  1899 							}
       
  1900 						else
       
  1901 							{
       
  1902 							lArray= new (ELeave) RArray<TGfxRectangle2D>(1);
       
  1903 							}
       
  1904 						TGfxRectangle2D temp1;
       
  1905                         // for proper cleanup
       
  1906                         ((CSvgAnimationBase*)iCurrentElement)->SetViewBoxValuesArray(lArray);
       
  1907                         lArray->AppendL(temp1);
       
  1908                         lArray->Remove(0);
       
  1909                         
       
  1910                         
       
  1911                         TGfxRectangle2D temp;
       
  1912                         TReal32 lValueFloat;
       
  1913                         for(TInt i=0; i<lCount; i++)
       
  1914                             {
       
  1915                             
       
  1916                             if (iIsFixPt)
       
  1917                             {
       
  1918 								temp.iX.iValue = iStream.ReadInt32L();
       
  1919 								temp.iY.iValue = iStream.ReadInt32L();
       
  1920                             	temp.iWidth.iValue = iStream.ReadInt32L();
       
  1921                             	temp.iHeight.iValue = iStream.ReadInt32L();
       
  1922 
       
  1923                             	lArray->AppendL((TGfxRectangle2D) temp);
       
  1924                             }
       
  1925                             else
       
  1926                             {
       
  1927 								iStream >> lValueFloat;
       
  1928 								temp.iX = (TFloatFixPt) lValueFloat;
       
  1929 								iStream >> lValueFloat;
       
  1930                             	temp.iY = (TFloatFixPt) lValueFloat;
       
  1931                             	iStream >> lValueFloat;
       
  1932                             	temp.iWidth = (TFloatFixPt) lValueFloat;
       
  1933                             	iStream >> lValueFloat;
       
  1934                             	temp.iHeight = (TFloatFixPt) lValueFloat;
       
  1935 
       
  1936                             	lArray->AppendL((TGfxRectangle2D) temp);
       
  1937                             }
       
  1938                             }
       
  1939 						break;
       
  1940 						}
       
  1941 					}
       
  1942 				}
       
  1943 			 return ETrue;
       
  1944 
       
  1945 			}
       
  1946 
       
  1947 			// Used to set the Fill attribute of Animation elements
       
  1948 		if (aName== KAnimFreeze)
       
  1949 			{
       
  1950 			((CSvgAnimationBase*)iCurrentElement)->SetAnimFreeze();
       
  1951 			return ETrue;
       
  1952 			}
       
  1953 
       
  1954 		if (aName== KAtrRepeatDur)
       
  1955 			{
       
  1956 			TUint32 lDur;
       
  1957 			iStream >> lDur;
       
  1958 			((CSvgAnimationBase*)iCurrentElement)->SetRepeatDuration(lDur);
       
  1959 			return ETrue;
       
  1960 			}
       
  1961 
       
  1962 		if (aName== KAtrRepeatCount)
       
  1963 			{
       
  1964 			
       
  1965 			if (iIsFixPt)
       
  1966 			{
       
  1967 				TFloatFixPt lCount;
       
  1968 				lCount.iValue = iStream.ReadInt32L();
       
  1969 				((CSvgAnimationBase*)iCurrentElement)->SetRepeatCount(lCount.iValue);
       
  1970 			}
       
  1971 			else
       
  1972 			{
       
  1973 				TReal32 lCount;
       
  1974 				iStream >> lCount;
       
  1975 				((CSvgAnimationBase*)iCurrentElement)->SetRepeatCount(lCount);
       
  1976 			}
       
  1977 			
       
  1978 			return ETrue;
       
  1979 			}
       
  1980 
       
  1981 	    if (aName== KAtrRestart)
       
  1982 			{
       
  1983 			TUint8 lMode;
       
  1984 			iStream >> lMode;
       
  1985 		    ((CSvgAnimationBase*)iCurrentElement)->SetRestartMode((TRestartMode)lMode);
       
  1986 			return ETrue;
       
  1987 			}
       
  1988 
       
  1989 		if (aName== KAtrAccumulate)
       
  1990 			{
       
  1991 			((CSvgAnimationBase*)iCurrentElement)->SetAccumulate(KAccumSum);
       
  1992 			return ETrue;
       
  1993 			}
       
  1994 
       
  1995 		if (aName== KAtrAdditive)
       
  1996 			{
       
  1997 			((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  1998 			return ETrue;
       
  1999 			}
       
  2000 
       
  2001 		if (aName== KAtrCalcMode)
       
  2002 			{
       
  2003 			TUint8 lMode;
       
  2004 			iStream >> lMode;
       
  2005 			((CSvgAnimationBase*)iCurrentElement)->SetCalcMode((TAnimCalcMode) lMode);
       
  2006 			return ETrue;
       
  2007 			}
       
  2008 
       
  2009 		if (aName== KAtrKeyTimes)
       
  2010 			{
       
  2011 			TUint16 lCount;
       
  2012 			RArray<CSvgAnimTimeController::TKeyTime>* lArray;
       
  2013 			iStream >> lCount;
       
  2014 			if (lCount)
       
  2015 				{
       
  2016 				((CSvgAnimationBase*)iCurrentElement)->SetKeyTimeFlag();
       
  2017 				lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(lCount);
       
  2018 				}
       
  2019 			else
       
  2020 				{
       
  2021 				lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(1);
       
  2022 				}
       
  2023 			CSvgAnimTimeController::TKeyTime  lTime1;
       
  2024             // for proper cleanup
       
  2025             ((CSvgAnimationBase*)iCurrentElement)->SetKeyTimeArray(lArray);
       
  2026             lArray->AppendL(lTime1);
       
  2027             lArray->Remove(0);
       
  2028 
       
  2029             for (TInt i=0; i<lCount; i++)
       
  2030                 {
       
  2031                 TUint8 lTemp;
       
  2032                 CSvgAnimTimeController::TKeyTime  lTime;
       
  2033                 iStream >> lTemp;
       
  2034                 lTime.iX = (TUint16) (lTemp);
       
  2035                 iStream >> lTemp;
       
  2036                 lTime.iY = (TUint16) (lTemp);
       
  2037                 lArray->AppendL( (CSvgAnimTimeController::TKeyTime) lTime);
       
  2038                 }
       
  2039 			return ETrue;
       
  2040 			}
       
  2041 
       
  2042 		if (aName== KAtrKeySplines)
       
  2043 			{
       
  2044 			TUint16 lCount;
       
  2045 			RArray<CSvgAnimTimeController::TKeyTime>* lArray;
       
  2046 			RArray<TUint32>* lAnimArray;
       
  2047 
       
  2048 			// keyTime Array
       
  2049 			iStream >> lCount;
       
  2050 			if (lCount)
       
  2051 				{
       
  2052 				lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(lCount);
       
  2053 				}
       
  2054 			else
       
  2055 				{
       
  2056 				lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(1);
       
  2057 				}
       
  2058 			CSvgAnimTimeController::TKeyTime  lTime1;
       
  2059             // for proper cleanup
       
  2060             ((CSvgAnimationBase*)iCurrentElement)->SetKeyTimeArray(lArray);
       
  2061             lArray->AppendL(lTime1);
       
  2062             lArray->Remove(0);
       
  2063             for (TInt i=0; i<lCount; i++)
       
  2064                 {
       
  2065                 TUint8 lTemp;
       
  2066                 CSvgAnimTimeController::TKeyTime  lTime;
       
  2067                 iStream >> lTemp;
       
  2068                 lTime.iX = (TUint16) (lTemp);
       
  2069                 iStream >> lTemp;
       
  2070                 lTime.iY = (TUint16) (lTemp);
       
  2071                 lArray->AppendL( (CSvgAnimTimeController::TKeyTime) lTime);
       
  2072                 }
       
  2073 
       
  2074 			//AnimTime Array
       
  2075 			iStream >> lCount;
       
  2076 			if (lCount)
       
  2077 				{
       
  2078 				lAnimArray = new (ELeave) RArray<TUint32>(lCount);
       
  2079 				}
       
  2080 			else
       
  2081 				{
       
  2082 				lAnimArray= new (ELeave) RArray<TUint32>(1);
       
  2083 				}
       
  2084 
       
  2085             ((CSvgAnimationBase*)iCurrentElement)->SetAnimTimeArray(lAnimArray);
       
  2086             lAnimArray->AppendL(NULL);
       
  2087             lAnimArray->Remove(0);
       
  2088 
       
  2089             for (TInt i=0; i<lCount; i++)
       
  2090                 {
       
  2091                 TUint8 lTemp;
       
  2092                 iStream >> lTemp;
       
  2093                 lAnimArray->AppendL( (TUint32) lTemp);
       
  2094                 }
       
  2095 			return ETrue;
       
  2096 		}
       
  2097 
       
  2098 
       
  2099 	// Animate motion Element is handled here
       
  2100 	if (aName== KAtrAnimateMotion)
       
  2101 		{
       
  2102 		DecodeAttributePathL(KAtrAnimateMotion);
       
  2103 		TUint8 lFlag;
       
  2104 		iStream >> lFlag;
       
  2105 		if(lFlag == KAtrAdditiveSet)
       
  2106 			{
       
  2107             iCurrentElement->iReqAttrFlag= 0;
       
  2108 			((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
       
  2109 			return ETrue;
       
  2110 			}
       
  2111         iCurrentElement->iReqAttrFlag= lFlag;
       
  2112 		return ETrue;
       
  2113 		}
       
  2114 
       
  2115 	if (aName== KAtrXlinkhref)
       
  2116 		{
       
  2117 	    _LIT( KXlink, "xlink:href" );
       
  2118 		TPtrC lPtr(DecodeTDesCLC());
       
  2119 		CSvgMediaAnimationElementImpl* mediaElement = static_cast<CSvgMediaAnimationElementImpl*>(iCurrentElement);
       
  2120 		mediaElement->SetAttributeL(KXlink, lPtr);
       
  2121 		CleanupStack::PopAndDestroy(1);
       
  2122 		return ETrue;
       
  2123 		}
       
  2124 		
       
  2125 	if( aName == KAtrSyncBehavior )
       
  2126 		{
       
  2127 		TUint8 syncBehavior;
       
  2128 		iStream>>syncBehavior;
       
  2129 		((CSvgMediaElementBase*)iCurrentElement)->SetSyncBehavior( (TSvgSyncBehaviour) syncBehavior );
       
  2130 		return ETrue;
       
  2131 		}
       
  2132 	else if( aName == KAtrSyncTolerance)
       
  2133 		{
       
  2134 		TUint8 syncTolerance;
       
  2135 		iStream>>syncTolerance;
       
  2136 		((CSvgMediaElementBase*)iCurrentElement)->SetSyncTolerance( syncTolerance, EFalse );
       
  2137 		return ETrue;
       
  2138 		}
       
  2139 	else if( aName == KAtrSyncMaster )
       
  2140 		{
       
  2141 		TUint8 syncMaster ;
       
  2142 		iStream>>syncMaster ;
       
  2143 		((CSvgMediaElementBase*)iCurrentElement)->SetSyncMaster( syncMaster );
       
  2144 		return ETrue;
       
  2145 		}
       
  2146 					
       
  2147 	return EFalse;
       
  2148 	}
       
  2149 
       
  2150 
       
  2151 
       
  2152 // --------------------------------------------------------------------------
       
  2153 // TBool CSvgDecoder::DecodeSvgElementAttributeL(const TUint16 aName)
       
  2154 // ---------------------------------------------------------------------------
       
  2155 TBool CSvgDecoder::DecodeSvgElementAttributeL(const TUint16 aName)
       
  2156 	{
       
  2157 	if ( ( aName<= KSvgSVGAttrEndIndex) ||
       
  2158 		 ( aName == KAtrSyncBehaviorDefault ) ||	// To support backward compatibility
       
  2159 		 ( aName == KAtrSyncToleranceDefault ))
       
  2160 		{
       
  2161 
       
  2162 		if (aName== KAtrViewBox)
       
  2163 			{
       
  2164 			TGfxRectangle2D lRect;
       
  2165 			
       
  2166 			if (iIsFixPt)
       
  2167 			{
       
  2168 				lRect.iX.iValue = iStream.ReadInt32L();
       
  2169 				lRect.iY.iValue = iStream.ReadInt32L();
       
  2170 				lRect.iWidth.iValue = iStream.ReadInt32L();
       
  2171 				lRect.iHeight.iValue = iStream.ReadInt32L();
       
  2172 
       
  2173 				((CSvgSvgElementImpl *)iCurrentElement)->SetViewBoxL(lRect);
       
  2174 			}
       
  2175 			else
       
  2176 			{
       
  2177 				TReal32 lTemp;
       
  2178 
       
  2179 				iStream >> lTemp;
       
  2180 				lRect.iX= (TFloatFixPt) lTemp;
       
  2181 				iStream >> lTemp;
       
  2182 				lRect.iY= (TFloatFixPt) lTemp;
       
  2183 				iStream >> lTemp;
       
  2184 				lRect.iWidth= (TFloatFixPt) lTemp;
       
  2185 				iStream >> lTemp;
       
  2186 				lRect.iHeight= (TFloatFixPt) lTemp;
       
  2187 
       
  2188 				((CSvgSvgElementImpl *)iCurrentElement)->SetViewBoxL(lRect);
       
  2189 			}
       
  2190 			return ETrue;
       
  2191 			}
       
  2192 
       
  2193 		if (aName== KAtrBaseProfile)
       
  2194 			{
       
  2195 			((CSvgSvgElementImpl *)iCurrentElement)->SetBaseProfileL(DecodeTDesCLC());
       
  2196 			 CleanupStack::PopAndDestroy( 1 );
       
  2197 			 return ETrue;
       
  2198 			}
       
  2199 
       
  2200 		if (aName== KAtrVersion)
       
  2201 			{
       
  2202 			
       
  2203 			if (iIsFixPt)
       
  2204 			{
       
  2205 				TFloatFixPt lTemp;
       
  2206 				lTemp.iValue = iStream.ReadInt32L();
       
  2207 				TBuf<16> lTemp2;
       
  2208 				lTemp2.AppendNum( (float)lTemp );
       
  2209 				((CSvgSvgElementImpl *)iCurrentElement)->SetVersion (lTemp2);
       
  2210 			}
       
  2211 			else
       
  2212 			{
       
  2213 				TReal32 lTemp;
       
  2214 				iStream >> lTemp;
       
  2215 				TBuf<16> lTemp2;
       
  2216 				lTemp2.AppendNum(lTemp);
       
  2217 				((CSvgSvgElementImpl *)iCurrentElement)->SetVersion (lTemp2);
       
  2218 			}
       
  2219 			
       
  2220 			return ETrue;
       
  2221 
       
  2222 			/*
       
  2223 			((CSvgSvgElementImpl *)iCurrentElement)->SetVersion (DecodeTDesCLC());
       
  2224 			CleanupStack::PopAndDestroy( 1 );
       
  2225 			return ETrue;
       
  2226 			*/
       
  2227 			}
       
  2228 
       
  2229 		if (aName== KAtrZoomAndPan)
       
  2230 			{
       
  2231 			TInt8 lTemp;
       
  2232 			iStream >> lTemp;
       
  2233 			TSvgZoomAndPanType lType= (TSvgZoomAndPanType) lTemp;
       
  2234 			((CSvgSvgElementImpl *)iCurrentElement)->SetZoomAndPan(lType);
       
  2235 			return ETrue;
       
  2236 			}
       
  2237 
       
  2238 		if (aName== KAtrPreserveAspectRatio)
       
  2239 			{
       
  2240 			if (iCurrentElement->ElemID()== KSvgSvgElement)
       
  2241 				{
       
  2242 				TInt8 lTemp;
       
  2243 				iStream >> lTemp;
       
  2244 				TSvgPreserveAspectAlignType lAType= (TSvgPreserveAspectAlignType) lTemp;
       
  2245 				iStream >> lTemp;
       
  2246 				TSvgMeetOrSliceType lMType= (TSvgMeetOrSliceType) lTemp;
       
  2247 				((CSvgSvgElementImpl *)iCurrentElement)->SetPreserveAspectRatioL(lAType, lMType);
       
  2248 				return ETrue;
       
  2249 				}
       
  2250 			else if(iCurrentElement->ElemID()== KSvgMediaAnimationElement)
       
  2251 				{
       
  2252 				TInt8 lTemp;
       
  2253 				iStream >> lTemp;
       
  2254 				TSvgPreserveAspectAlignType lAType= (TSvgPreserveAspectAlignType) lTemp;
       
  2255 				iStream >> lTemp;
       
  2256 				TSvgMeetOrSliceType lMType= (TSvgMeetOrSliceType) lTemp;
       
  2257 				((CSvgMediaAnimationElementImpl*)iCurrentElement)->SetPreserveAspectRatioL(lAType, lMType);
       
  2258 				return ETrue; 
       
  2259 				}
       
  2260 			else
       
  2261 				{
       
  2262 				((CSvgImageElementImpl *)iCurrentElement)->SetParL(DecodeTDesCLC());
       
  2263 				CleanupStack::PopAndDestroy( 1 );
       
  2264 				return ETrue;
       
  2265 				}
       
  2266 			}
       
  2267 
       
  2268 		if( aName == KAtrSyncBehaviorDefault )
       
  2269 			{
       
  2270 			TUint8 syncBehaviorDefault;
       
  2271 			iStream>>syncBehaviorDefault;
       
  2272 			((CSvgSvgElementImpl*)iCurrentElement)->SetSyncBehaviorDefault( (TSvgSyncBehaviour) syncBehaviorDefault );
       
  2273 			return ETrue;
       
  2274 			}
       
  2275 		else if( aName == KAtrSyncToleranceDefault )
       
  2276 			{
       
  2277 			TUint8 syncToleranceDefault;
       
  2278 			iStream>>syncToleranceDefault;
       
  2279 			((CSvgSvgElementImpl*)iCurrentElement)->SetSyncToleranceDefault( syncToleranceDefault );
       
  2280 			return ETrue;
       
  2281 			}
       
  2282 		else
       
  2283 			{
       
  2284 			return EFalse;
       
  2285 			}
       
  2286 		}
       
  2287 
       
  2288 	else
       
  2289 		{
       
  2290 		return EFalse;
       
  2291 		}
       
  2292 	}
       
  2293 
       
  2294 
       
  2295 
       
  2296 // --------------------------------------------------------------------------
       
  2297 // TBool CSvgDecoder::DecodeLangSpaceAttributeL(const TUint16 aName)
       
  2298 // ---------------------------------------------------------------------------
       
  2299 TBool CSvgDecoder::DecodeLangSpaceAttributeL(const TUint16 aName)
       
  2300 	{
       
  2301 	if (aName<= KSvgLangAttrEndIndex)
       
  2302 		{
       
  2303 
       
  2304 		if (aName== KAtrXmlLang)
       
  2305 			{
       
  2306 			iCurrentElement->SetXMLLangL (DecodeTDesCLC());
       
  2307 			 CleanupStack::PopAndDestroy( 1 );
       
  2308 			return ETrue;
       
  2309 			}
       
  2310 
       
  2311 		if (aName== KAtrXmlSpace)
       
  2312 			{
       
  2313 			iCurrentElement->SetXMLSpaceL (DecodeTDesCLC());
       
  2314 			 CleanupStack::PopAndDestroy( 1 );
       
  2315 			return ETrue;
       
  2316 			}
       
  2317 
       
  2318 		else
       
  2319 			{
       
  2320 			return EFalse;
       
  2321 			}
       
  2322 		}
       
  2323 
       
  2324 	else
       
  2325 		{
       
  2326 		return EFalse;
       
  2327 		}
       
  2328 	}
       
  2329 
       
  2330 
       
  2331 
       
  2332 // --------------------------------------------------------------------------
       
  2333 // TBool CSvgDecoder::DecodeTransformAttributeL(const TUint16 aName)
       
  2334 // ---------------------------------------------------------------------------
       
  2335 TBool CSvgDecoder::DecodeTransformAttributeL(const TUint16 aName)
       
  2336 	{
       
  2337 
       
  2338 	if (aName== KAtrTransform)
       
  2339 		{
       
  2340 		
       
  2341 		if (iIsFixPt)
       
  2342 		{
       
  2343 			TUint32 lTemp1;
       
  2344 			TGfxAffineTransform lTransform;
       
  2345 			
       
  2346 			lTransform.iM00.iValue = iStream.ReadInt32L();
       
  2347 			lTransform.iM01.iValue = iStream.ReadInt32L();
       
  2348 			lTransform.iM02.iValue = iStream.ReadInt32L();
       
  2349 			lTransform.iM10.iValue = iStream.ReadInt32L();
       
  2350 			lTransform.iM11.iValue = iStream.ReadInt32L();
       
  2351 			lTransform.iM12.iValue = iStream.ReadInt32L();
       
  2352 			iStream >> lTemp1;
       
  2353 			lTransform.iTransType= (TGfxTransformType) lTemp1;
       
  2354 
       
  2355 			iCurrentElement->SetTransformList(lTransform);
       
  2356 		}
       
  2357 		else
       
  2358 		{
       
  2359 			TReal32 lTemp;
       
  2360 			TUint32 lTemp1;
       
  2361 			TGfxAffineTransform lTransform;
       
  2362 
       
  2363 			iStream >> lTemp;
       
  2364 			lTransform.iM00= (TFloatFixPt) lTemp;
       
  2365 			iStream >> lTemp;
       
  2366 			lTransform.iM01= (TFloatFixPt) lTemp;
       
  2367 			iStream >> lTemp;
       
  2368 			lTransform.iM02= (TFloatFixPt) lTemp;
       
  2369 			iStream >> lTemp;
       
  2370 			lTransform.iM10= (TFloatFixPt) lTemp;
       
  2371 			iStream >> lTemp;
       
  2372 			lTransform.iM11= (TFloatFixPt) lTemp;
       
  2373 			iStream >> lTemp;
       
  2374 			lTransform.iM12= (TFloatFixPt) lTemp;
       
  2375 			iStream >> lTemp1;
       
  2376 			lTransform.iTransType= (TGfxTransformType) lTemp1;
       
  2377 
       
  2378 			iCurrentElement->SetTransformList(lTransform);
       
  2379 		}
       
  2380 		
       
  2381 		return ETrue;
       
  2382 		}
       
  2383 
       
  2384 	else if	( aName== KAtrGradientTransform)
       
  2385 		{
       
  2386 		
       
  2387 		if (iIsFixPt)
       
  2388 		{
       
  2389 			SVGReal lMatrix[2][3];
       
  2390 			
       
  2391 			TFloatFixPt lTemp;
       
  2392 			lTemp.iValue = iStream.ReadInt32L();
       
  2393 			lMatrix[0][0]= lTemp.iValue;
       
  2394 			lTemp.iValue = iStream.ReadInt32L();
       
  2395 			lMatrix[0][1]= lTemp.iValue;
       
  2396 			lTemp.iValue = iStream.ReadInt32L();
       
  2397 			lMatrix[0][2]= lTemp.iValue;
       
  2398 			lTemp.iValue = iStream.ReadInt32L();
       
  2399 			lMatrix[1][0]= lTemp.iValue;
       
  2400 			lTemp.iValue = iStream.ReadInt32L();
       
  2401 			lMatrix[1][1]= lTemp.iValue;
       
  2402 			lTemp.iValue = iStream.ReadInt32L();
       
  2403 			lMatrix[1][2]= lTemp.iValue;
       
  2404 
       
  2405 			((CSvgGradientElementImpl*)iCurrentElement)->SetGradientTransMatrix(lMatrix);
       
  2406 		}
       
  2407 		else
       
  2408 		{
       
  2409 			TReal32 lTemp;
       
  2410 			SVGReal lMatrix[2][3];
       
  2411 
       
  2412 			iStream >> lTemp;
       
  2413 			lMatrix[0][0]= (SVGReal) lTemp;
       
  2414 			iStream >> lTemp;
       
  2415 			lMatrix[0][1]= (SVGReal) lTemp;
       
  2416 			iStream >> lTemp;
       
  2417 			lMatrix[0][2]= (SVGReal) lTemp;
       
  2418 			iStream >> lTemp;
       
  2419 			lMatrix[1][0]= (SVGReal) lTemp;
       
  2420 			iStream >> lTemp;
       
  2421 			lMatrix[1][1]= (SVGReal) lTemp;
       
  2422 			iStream >> lTemp;
       
  2423 			lMatrix[1][2]= (SVGReal) lTemp;
       
  2424 
       
  2425 			((CSvgGradientElementImpl*)iCurrentElement)->SetGradientTransMatrix(lMatrix);
       
  2426 		}
       
  2427 
       
  2428 		return ETrue;
       
  2429 		}
       
  2430 
       
  2431 
       
  2432 
       
  2433 	else
       
  2434 		{
       
  2435 		return EFalse;
       
  2436 		}
       
  2437 	}
       
  2438 
       
  2439 
       
  2440 
       
  2441 // --------------------------------------------------------------------------
       
  2442 // TBool CSvgDecoder::DecodeTestAttributeL(const TUint16 aName)
       
  2443 // ---------------------------------------------------------------------------
       
  2444 TBool CSvgDecoder::DecodeTestAttributeL(const TUint16 aName)
       
  2445 	{
       
  2446 	if(aName<= KSvgTestAttrEndIndex)
       
  2447 		{
       
  2448 
       
  2449 		if (
       
  2450 			aName== KAtrRequiredFeatures ||
       
  2451 			aName== KAtrRequiredExtensions ||
       
  2452 			aName== KAtrSystemLanguage
       
  2453 		   )
       
  2454 			{
       
  2455 			CDesCArrayFlat* lFeatures;
       
  2456 			TInt8 lCount;
       
  2457 			iStream >> lCount;
       
  2458 			if(lCount)
       
  2459 				{
       
  2460 				lFeatures= new ( ELeave ) CDesCArrayFlat( lCount );
       
  2461 				}
       
  2462 			else
       
  2463 				{
       
  2464 				lFeatures= new ( ELeave ) CDesCArrayFlat( 1 );
       
  2465 				}
       
  2466 
       
  2467 			CleanupStack::PushL(lFeatures); //cleanup
       
  2468 
       
  2469 			for(TInt8 i=0; i<lCount; i++)
       
  2470 				{
       
  2471 				lFeatures->AppendL((const TDesC&)DecodeTDesCLC());
       
  2472 				CleanupStack::PopAndDestroy( 1 );
       
  2473 				}
       
  2474 
       
  2475             iCurrentElement->CreateSvgTestL(aName);  //instantiates iSvgTest
       
  2476 			if (aName==	 KAtrRequiredFeatures)
       
  2477 				{
       
  2478 		         iCurrentElement->SetRequiredFeatures (lFeatures);
       
  2479 				}
       
  2480 			else if (aName== KAtrRequiredExtensions)
       
  2481 				{
       
  2482 				iCurrentElement->SetRequiredExtensions (lFeatures);
       
  2483 				}
       
  2484 			else
       
  2485 				{
       
  2486 		         iCurrentElement->SetSystemLanguage (lFeatures);
       
  2487 				}
       
  2488 
       
  2489 			CleanupStack::Pop(lFeatures); //cleanup
       
  2490 
       
  2491 		 return ETrue;
       
  2492 			}
       
  2493 
       
  2494 		else
       
  2495 			{
       
  2496 			return EFalse;
       
  2497 			}
       
  2498 		}
       
  2499 
       
  2500 	else
       
  2501 		{
       
  2502 		return EFalse;
       
  2503 		}
       
  2504 	}
       
  2505 
       
  2506 
       
  2507 
       
  2508 
       
  2509 // --------------------------------------------------------------------------
       
  2510 // TBool CSvgDecoder::DecodeIdAndXmlAttributeL(const TUint16 aName)
       
  2511 // ---------------------------------------------------------------------------
       
  2512 TBool CSvgDecoder::DecodeIdAndXmlAttributeL(const TUint16 aName)
       
  2513 	{
       
  2514 
       
  2515 	if (aName== KAtrId)
       
  2516 		{
       
  2517 		iCurrentElement->SetIdandXmlbaseL( _L("id"), DecodeTDesCLC());
       
  2518 		 CleanupStack::PopAndDestroy( 1 );
       
  2519 		return ETrue;
       
  2520 		}
       
  2521 
       
  2522 	if (aName== KAtrXmlBase)
       
  2523 		{
       
  2524 		iCurrentElement->SetIdandXmlbaseL( _L("xml:base"), DecodeTDesCLC());
       
  2525 		 CleanupStack::PopAndDestroy( 1 );
       
  2526 		return ETrue;
       
  2527 		}
       
  2528 
       
  2529 	else
       
  2530 		{
       
  2531 		return EFalse;
       
  2532 		}
       
  2533 	}
       
  2534 
       
  2535 
       
  2536 
       
  2537 
       
  2538 // --------------------------------------------------------------------------
       
  2539 // TBool CSvgDecoder::DecodeUriRefAttributeL(const TUint16 aName)
       
  2540 // ---------------------------------------------------------------------------
       
  2541 TBool CSvgDecoder::DecodeUriRefAttributeL(const TUint16 aName)
       
  2542 	{
       
  2543    	if (aName<= KSvgUriAttrEndIndex)
       
  2544 		{
       
  2545  		if (aName== KAtrXlinkhref)
       
  2546 			{
       
  2547             // Although discard element belongs to animation, the discard element isn't
       
  2548             // necessary inherited from giant AnimationBase, so handle attribute separately.
       
  2549             //
       
  2550         	if ( iCurrentElement->ElemID() == KSvgDiscardElement || iCurrentElement->ElemID() == KSvgMediaAnimationElement )
       
  2551         	    return EFalse;
       
  2552 
       
  2553 			TPtrC lPtr(DecodeTDesCLC());
       
  2554 			/*Code modified for Forward refrence support in animation*/
       
  2555 			iCurrentElement->SetUriRefDesL (aName, lPtr );
       
  2556 			// For Animation Elements
       
  2557 			if(iIsAnimElement)
       
  2558 				{
       
  2559 				CSvgElementImpl* lElement;
       
  2560 				lElement= (CSvgElementImpl*) iDocument->GetElementById(lPtr);
       
  2561 				if(lElement)
       
  2562 					{
       
  2563 					((CSvgAnimationBase*)iCurrentElement)->SetTarget(lElement);
       
  2564 					}
       
  2565 				else
       
  2566 					{
       
  2567 					 if (!iAnimRefElementArray)
       
  2568 						 {
       
  2569                          iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
  2570                          }
       
  2571                      iAnimRefElementArray->AppendL((CSvgElementImpl*)iCurrentElement);
       
  2572                     }
       
  2573 
       
  2574 				CleanupStack::PopAndDestroy( 1 );
       
  2575 				return ETrue;
       
  2576 				}
       
  2577 
       
  2578 
       
  2579 			//Only for Image Element
       
  2580 			if (iCurrentElement->ElemID() == KSvgImageElement)
       
  2581 				{
       
  2582                 ((CSvgImageElementImpl*)iCurrentElement)->SetUriL(lPtr);
       
  2583                 iImageElements.Append((CSvgImageElementImpl*)iCurrentElement);
       
  2584 				}
       
  2585 			CleanupStack::PopAndDestroy( 1 );
       
  2586 
       
  2587 			// setting reference element of use Element
       
  2588 			if (iCurrentElement->ElemID() == KSvgUseElement)
       
  2589 				{
       
  2590 			    if( ((CSvgUseElementImpl*)iCurrentElement)->SetRefElemById
       
  2591 			             (DecodeTDesCLC()) != KErrNone)
       
  2592 			        {
       
  2593 					// if it is null reallocate the memeory again.
       
  2594 					 if (!iUseElementArray)
       
  2595 						 {
       
  2596                          iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
  2597                          }
       
  2598                      iUseElementArray->AppendL((CSvgElementImpl*)iCurrentElement);
       
  2599                     }
       
  2600                 CleanupStack::PopAndDestroy( 1 );
       
  2601                 return ETrue;
       
  2602 				}
       
  2603 // for future animation element
       
  2604 //		    else if (iCurrentElement->ElemID() == KSvgAnimationElement)
       
  2605 //				{
       
  2606 //			    if( ((CSvgAnimationElementImpl*)iCurrentElement)->SetRefElemById
       
  2607 //			             (DecodeTDesCLC()) == KErrNone)
       
  2608 //			        {
       
  2609 					// if it is null reallocate the memeory again.
       
  2610 //					 if (!iAnimationElementArray)
       
  2611 //						 {
       
  2612 //     					 iAnimationElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
  2613 //						 }
       
  2614 //			         User::LeaveIfError(iAnimationElementArray->Append((CSvgElementImpl*)iCurrentElement));
       
  2615 //			        }
       
  2616 //				CleanupStack::PopAndDestroy( 1 );
       
  2617 //				return ETrue;
       
  2618 //				}
       
  2619 
       
  2620 			// setting Path of Mpath element
       
  2621 			if (iCurrentElement->ElemID() == KSvgMpathElement)
       
  2622 				{
       
  2623 				iCurrentElement->iReqAttrFlag =0;
       
  2624 				TInt8 lCheck;
       
  2625 				iStream >> lCheck;
       
  2626 				//  Flag is used to check the validity of reference element
       
  2627 				if (lCheck)
       
  2628 					{
       
  2629 					((CSvgMpathElementImpl*)iCurrentElement)->SetAttributePathByIdL(DecodeTDesCLC());
       
  2630 					CleanupStack::PopAndDestroy( 1 );
       
  2631 					}
       
  2632 				}
       
  2633 
       
  2634 			return ETrue;
       
  2635 			}
       
  2636 
       
  2637 		else if (aName== KAtrXlinkactuate ||
       
  2638 			     aName== KAtrXlinkarcrole ||
       
  2639 				 aName== KAtrXlinkrole ||
       
  2640 				 aName== KAtrXlinktitle ||
       
  2641 				 aName== KAtrXlinktype ||
       
  2642 				 aName== KAtrXlinkshow
       
  2643 			    )
       
  2644 			{
       
  2645 			iCurrentElement->SetUriRefDesL (aName, DecodeTDesCLC() );
       
  2646 			CleanupStack::PopAndDestroy( 1 );
       
  2647 			return ETrue;
       
  2648 			}
       
  2649 
       
  2650 		else
       
  2651 			{
       
  2652 			return EFalse;
       
  2653 			}
       
  2654 		}
       
  2655 
       
  2656 	else if (aName== KXlinkhrefImageEmbedded)
       
  2657 		{
       
  2658 		TPtrC lPtr(DecodeImageEmbeddedTDesCLC());
       
  2659 
       
  2660 		iCurrentElement->SetUriRefDesL (aName, lPtr );
       
  2661 
       
  2662 			//Only for Image Element
       
  2663 		if (iCurrentElement->ElemID() == KSvgImageElement)
       
  2664             {
       
  2665             // Keep track of embedded images
       
  2666             iEmbeddedImagesCount++;
       
  2667             ((CSvgImageElementImpl*)iCurrentElement)->SetUriL(lPtr);
       
  2668             ((CSvgImageElementImpl*)iCurrentElement)->LoadUriL();
       
  2669             }
       
  2670         CleanupStack::PopAndDestroy( 2 );
       
  2671         return ETrue;
       
  2672         }
       
  2673     else
       
  2674 		{
       
  2675 		return EFalse;
       
  2676 		}
       
  2677 	}
       
  2678 
       
  2679 
       
  2680 // --------------------------------------------------------------------------
       
  2681 // TBool CSvgDecoder::DecodeDiscardAttributeL (const TUint16& aName)
       
  2682 // ---------------------------------------------------------------------------
       
  2683 TBool CSvgDecoder::DecodeDiscardAttributeL (const TUint16& aName)
       
  2684 	{
       
  2685 	if ( iCurrentElement->ElemID() != KSvgDiscardElement )
       
  2686 	    return EFalse;
       
  2687 
       
  2688 	TInt8 lCheck;
       
  2689 	TInt16 lTemp;
       
  2690 
       
  2691 	if (aName== KAtrBegin)
       
  2692 	    {
       
  2693 		// Flag is used to check for SyncValue flag.
       
  2694 		iStream >> lCheck;
       
  2695 		if ( lCheck )
       
  2696 			{
       
  2697             ((CSvgDiscardElementImpl*)iCurrentElement)->SetSyncValueDefined(ETrue);
       
  2698 			}
       
  2699         else
       
  2700             {
       
  2701 			((CSvgDiscardElementImpl*)iCurrentElement)->SetSyncValueDefined(EFalse);
       
  2702             }
       
  2703 
       
  2704 		// Flag is used to check for EventValue flag.
       
  2705 		iStream >> lCheck;
       
  2706 		if ( lCheck )
       
  2707 			{
       
  2708             ((CSvgDiscardElementImpl*)iCurrentElement)->SetEventValueDefined(ETrue);
       
  2709             }
       
  2710         else
       
  2711             {
       
  2712             ((CSvgDiscardElementImpl*)iCurrentElement)->SetEventValueDefined(EFalse);
       
  2713             }
       
  2714 
       
  2715 
       
  2716 		// Flag is used to check for SyncElement's id.
       
  2717 		iStream >> lCheck;
       
  2718 		if ( lCheck )
       
  2719 			{
       
  2720     		TPtrC lPtr(DecodeTDesCLC());
       
  2721     		((CSvgDiscardElementImpl*)iCurrentElement)->SetBeginSyncElementId(lPtr);
       
  2722 	        CleanupStack::PopAndDestroy( 1 );
       
  2723             }
       
  2724 
       
  2725 
       
  2726 		iStream >> lTemp;
       
  2727 		((CSvgDiscardElementImpl*)iCurrentElement)->SetAbsoluteBeginTime(lTemp);
       
  2728 
       
  2729 		iStream >> lTemp;
       
  2730 		((CSvgDiscardElementImpl*)iCurrentElement)->SetRefBeginTime(lTemp);
       
  2731 
       
  2732 		iStream >> lTemp;
       
  2733 		((CSvgDiscardElementImpl*)iCurrentElement)->SetKeyValue(lTemp);
       
  2734 
       
  2735 		iStream >> lTemp;
       
  2736 		((CSvgDiscardElementImpl*)iCurrentElement)->SetBeginReferenceEvent((TSvgEvent)lTemp);
       
  2737 
       
  2738 	    }
       
  2739 	else
       
  2740 	if (aName== KAtrXlinkhref)
       
  2741         {
       
  2742 		// Flag is used to check for HrefValue flag.
       
  2743 		iStream >> lCheck;
       
  2744 		if ( lCheck )
       
  2745 			{
       
  2746             ((CSvgDiscardElementImpl*)iCurrentElement)->SetHrefValueDefined(ETrue);
       
  2747     		TPtrC lPtr(DecodeTDesCLC());
       
  2748     		((CSvgDiscardElementImpl*)iCurrentElement)->SetTargetId(lPtr);
       
  2749             CleanupStack::PopAndDestroy( 1 );
       
  2750             }
       
  2751         else
       
  2752             ((CSvgDiscardElementImpl*)iCurrentElement)->SetHrefValueDefined(EFalse);
       
  2753 
       
  2754         }
       
  2755 
       
  2756     return ETrue;
       
  2757     }
       
  2758 
       
  2759 
       
  2760 
       
  2761 // --------------------------------------------------------------------------
       
  2762 // TBool CSvgDecoder::DecodeAttributeFloatL(const TUint16 aName)
       
  2763 // ---------------------------------------------------------------------------
       
  2764 TBool CSvgDecoder::DecodeAttributeFloatL(const TUint16 aName)
       
  2765 	{
       
  2766 	if (iIsFixPt)
       
  2767 	{
       
  2768 		TFloatFixPt lTemp;
       
  2769 		lTemp.iValue = iStream.ReadInt32L();
       
  2770 		iCurrentElement->SetAttributeFloatL( (TInt)aName, lTemp );
       
  2771 	}
       
  2772 	else
       
  2773 	{
       
  2774 		TReal32 lTemp;
       
  2775 		iStream >> lTemp;
       
  2776 		iCurrentElement->SetAttributeFloatL( (TInt)aName, (TFloatFixPt)lTemp );
       
  2777 	}
       
  2778 	
       
  2779 	return ETrue;
       
  2780 	}
       
  2781 
       
  2782 
       
  2783 
       
  2784 // --------------------------------------------------------------------------
       
  2785 // TBool CSvgDecoder::DecodeAttributeIntL(const TUint16 aName)
       
  2786 // ---------------------------------------------------------------------------
       
  2787 TBool CSvgDecoder::DecodeAttributeIntL(const TUint16 aName)
       
  2788 	{
       
  2789 	TInt8 lTemp;
       
  2790 	iStream >> lTemp;
       
  2791 	iCurrentElement->SetAttributeIntL( (TInt)aName, (TInt32)lTemp );
       
  2792 	return ETrue;
       
  2793 	}
       
  2794 
       
  2795 
       
  2796 // --------------------------------------------------------------------------
       
  2797 // TBool CSvgDecoder::DecodeAttributePathL(const TUint16 aName)
       
  2798 // ---------------------------------------------------------------------------
       
  2799 TBool CSvgDecoder::DecodeAttributePathL(const TUint16 aName)
       
  2800 	{
       
  2801 	CGfxGeneralPath* lPath;
       
  2802 	DecodeAnimationPathL(lPath);
       
  2803 
       
  2804 	iCurrentElement->SetAttributePathRef( (TInt)aName, lPath);
       
  2805 
       
  2806 	return  ETrue;
       
  2807 	}
       
  2808 
       
  2809 
       
  2810 // --------------------------------------------------------------------------
       
  2811 // void CSvgDecoder::DecodeAnimationPathL(CGfxGeneralPath*& aPath)
       
  2812 // ---------------------------------------------------------------------------
       
  2813 void CSvgDecoder::DecodeAnimationPathL(CGfxGeneralPath*& aPath)
       
  2814     {
       
  2815 
       
  2816     aPath = CGfxGeneralPath::NewLC();
       
  2817 
       
  2818     {
       
  2819         const TInt KLargePathTypeCount = 4*256;
       
  2820 
       
  2821         TUint16 typeCount = 0;
       
  2822         iStream >> typeCount;
       
  2823 
       
  2824         /******************************************************************/
       
  2825         // Path Type
       
  2826         /******************************************************************/
       
  2827         RArray<TUint32>* pathTypeArray = NULL;
       
  2828         // Put path-type-array to path to handle cleanup
       
  2829         if ( typeCount == 0 )
       
  2830             {
       
  2831             pathTypeArray = new (ELeave)RArray<TUint32>( 1 );
       
  2832             aPath->SetPointTypeArrayRef( pathTypeArray );
       
  2833             }
       
  2834         else
       
  2835             {
       
  2836             pathTypeArray = new (ELeave)RArray<TUint32>( typeCount );
       
  2837             aPath->SetPointTypeArrayRef( pathTypeArray );
       
  2838             }
       
  2839 
       
  2840         // Occurs only for very large paths
       
  2841         if ( typeCount > KLargePathTypeCount )
       
  2842             {
       
  2843             TUint8* byteData = new (ELeave) TUint8[typeCount];
       
  2844             CleanupArrayDeletePushL( byteData );
       
  2845 
       
  2846             iStream.ReadL( byteData, typeCount );
       
  2847             
       
  2848             for ( TInt i = 0; i < typeCount; i++ )
       
  2849                 {
       
  2850             
       
  2851                 if(byteData[i] == EGfxEncodedSegMoveTo)
       
  2852                 {
       
  2853                 	byteData[i] = EGfxSegMoveTo;
       
  2854                 }
       
  2855                 else if(byteData[i] == EGfxEncodedSegLineTo )
       
  2856                 {
       
  2857                 	byteData[i]  = EGfxSegLineTo;
       
  2858                 }
       
  2859                 else if(byteData[i] == EGfxEncodedSegQuadTo)
       
  2860                 {
       
  2861                 	byteData[i]  = EGfxSegQuadTo;
       
  2862                 }
       
  2863                 else if(byteData[i] == EGfxEncodedSegCubicTo)
       
  2864                 {
       
  2865                 	byteData[i]  = EGfxSegCubicTo;
       
  2866                 }
       
  2867                 else if(byteData[i] == EGfxEncodedSegClose)
       
  2868                 {
       
  2869                 	byteData[i]  = EGfxSegClose;
       
  2870                 }
       
  2871                 // Path will close RArray if Leave occurs
       
  2872                 pathTypeArray->AppendL( byteData[i] );
       
  2873                 }
       
  2874                 //Transfering ownership to Path
       
  2875             aPath->PathSegmentTypeArray(byteData);
       
  2876             aPath->Count(typeCount);
       
  2877             CleanupStack::Pop( 1 );
       
  2878             //delete [] byteData;
       
  2879             }
       
  2880         else
       
  2881             {
       
  2882             TUint8 *byteData = new (ELeave) TUint8[KLargePathTypeCount];
       
  2883             CleanupArrayDeletePushL( byteData );
       
  2884             iStream.ReadL( byteData, typeCount );
       
  2885             for ( TInt i = 0; i < typeCount; i++ )
       
  2886                 {
       
  2887             
       
  2888                 if(byteData[i] == EGfxEncodedSegMoveTo)
       
  2889                 {
       
  2890                 	byteData[i] = EGfxSegMoveTo;
       
  2891                 }
       
  2892                 else if(byteData[i] == EGfxEncodedSegLineTo )
       
  2893                 {
       
  2894                 	byteData[i]  = EGfxSegLineTo;
       
  2895                 }
       
  2896                 else if(byteData[i] == EGfxEncodedSegQuadTo)
       
  2897                 {
       
  2898                 	byteData[i]  = EGfxSegQuadTo;
       
  2899                 }
       
  2900                 else if(byteData[i] == EGfxEncodedSegCubicTo)
       
  2901                 {
       
  2902                 	byteData[i]  = EGfxSegCubicTo;
       
  2903                 }
       
  2904                 else if(byteData[i] == EGfxEncodedSegClose)
       
  2905                 {
       
  2906                 	byteData[i]  = EGfxSegClose;
       
  2907                 }
       
  2908                 // Path will close RArray if Leave occurs
       
  2909                 pathTypeArray->AppendL( byteData[i] );
       
  2910                 }
       
  2911             aPath->PathSegmentTypeArray(byteData);
       
  2912             aPath->Count(typeCount);
       
  2913              CleanupStack::Pop( 1 );
       
  2914             }
       
  2915     }
       
  2916 
       
  2917     /******************************************************************/
       
  2918     // Path Points
       
  2919     /******************************************************************/
       
  2920     {
       
  2921         const TInt KLargePathPointsCount = 256;
       
  2922 
       
  2923         TUint16 valueCount = 0;
       
  2924         iStream >> valueCount;
       
  2925 
       
  2926         RArray<TFloatFixPt>* pathPointsArray = NULL;
       
  2927 
       
  2928         if ( valueCount == 0 )
       
  2929             {
       
  2930             pathPointsArray = new (ELeave)RArray<TFloatFixPt>( 1 );
       
  2931             aPath->SetPointCoordsArrayRef( pathPointsArray );
       
  2932             }
       
  2933         else
       
  2934             {
       
  2935             pathPointsArray = new (ELeave)RArray<TFloatFixPt>( valueCount );
       
  2936             aPath->SetPointCoordsArrayRef( pathPointsArray );
       
  2937             }
       
  2938 
       
  2939         if ( valueCount > KLargePathPointsCount )
       
  2940             {
       
  2941             if (iIsFixPt)
       
  2942 	            {
       
  2943 	            TFloatFixPt* fixedData = new (ELeave) TFloatFixPt[valueCount];
       
  2944                 CleanupArrayDeletePushL( fixedData );
       
  2945 
       
  2946 	            TInt byteCount = sizeof( TFloatFixPt ) * valueCount;
       
  2947 	            iStream.ReadL( (TUint8*)fixedData, byteCount );
       
  2948 
       
  2949 	            for ( TInt i = 0; i < valueCount; i++ )
       
  2950 	                {
       
  2951 	                // Path will close RArray if Leave occurs
       
  2952 	                pathPointsArray->AppendL( fixedData[i] );
       
  2953 	                }
       
  2954 
       
  2955 	            CleanupStack::Pop( 1 ); // fixedData 
       
  2956 	            delete [] fixedData;         	
       
  2957             	}
       
  2958             else
       
  2959 	            {
       
  2960 	            TReal32* real32Data = new (ELeave) TReal32[valueCount];
       
  2961                 CleanupArrayDeletePushL( real32Data );
       
  2962 
       
  2963 	            TInt byteCount = sizeof( TReal32 ) * valueCount;
       
  2964 	            iStream.ReadL( (TUint8*)real32Data, byteCount );
       
  2965 
       
  2966 	            for ( TInt i = 0; i < valueCount; i++ )
       
  2967 	                {
       
  2968 	                // Path will close RArray if Leave occurs
       
  2969 	                pathPointsArray->AppendL( (TFloatFixPt)real32Data[i] );
       
  2970 	                }
       
  2971 
       
  2972 	            CleanupStack::Pop( 1 ); // real32Data    
       
  2973 	            delete [] real32Data;       	
       
  2974 	            }
       
  2975             }
       
  2976          else
       
  2977             {
       
  2978             if (iIsFixPt)
       
  2979             	{
       
  2980             	TFloatFixPt fixedData[KLargePathPointsCount];
       
  2981             	TInt byteCount = sizeof( TFloatFixPt ) * valueCount;
       
  2982             	iStream.ReadL( (TUint8*)fixedData, byteCount );
       
  2983 
       
  2984             	for ( TInt i = 0; i < valueCount; i++ )
       
  2985                 	{
       
  2986                	 	pathPointsArray->AppendL( fixedData[i] );
       
  2987                 	}            	
       
  2988             	}
       
  2989             else
       
  2990             	{
       
  2991             	TReal32 real32Data[KLargePathPointsCount];
       
  2992             	TInt byteCount = sizeof( TReal32 ) * valueCount;
       
  2993             	iStream.ReadL( (TUint8*)real32Data, byteCount );
       
  2994 
       
  2995             	for ( TInt i = 0; i < valueCount; i++ )
       
  2996                 	{
       
  2997                 	pathPointsArray->AppendL( (TFloatFixPt)real32Data[i] );
       
  2998                 	}            	
       
  2999             	}
       
  3000             }
       
  3001 
       
  3002     }
       
  3003 
       
  3004     CleanupStack::Pop( 1 ); // aPath
       
  3005     }
       
  3006 
       
  3007 
       
  3008 // --------------------------------------------------------------------------
       
  3009 // TBool CSvgDecoder::DecodeAttributeDesL(const TUint16 aName)
       
  3010 // ---------------------------------------------------------------------------
       
  3011 TBool CSvgDecoder::DecodeAttributeDesL(const TUint16 aName)
       
  3012 	{
       
  3013 	iCurrentElement->SetAttributeDesL ((TInt)aName, DecodeTDesCLC());
       
  3014 	CleanupStack::PopAndDestroy( 1 );
       
  3015 	return ETrue;
       
  3016 	}
       
  3017 
       
  3018 // --------------------------------------------------------------------------
       
  3019 // TBool CSvgDecoder::DecodeStringCssValueL(const TUint16 aName)
       
  3020 // ---------------------------------------------------------------------------
       
  3021 TBool CSvgDecoder::DecodeStringCssValueL(const TUint16 aName)
       
  3022 	{
       
  3023 
       
  3024 	CCssValue* tParentValue = NULL;
       
  3025     CCssValue* tValue = NULL;
       
  3026 
       
  3027 	iCurrentElement->FindProperty ((TInt8)aName,tValue);
       
  3028 
       
  3029 	TPtrC lPtr(DecodeTDesCLC());
       
  3030 
       
  3031 	if(iCurrentElement->ElemID() == KSvgFontfaceElement)
       
  3032 		{
       
  3033 		((CSvgFontFaceElementImpl *)iCurrentElement)->SetFontFamilyL(lPtr);
       
  3034 		}
       
  3035 
       
  3036 	if(iCurrentElement!= iRootElement)
       
  3037 		{
       
  3038 		iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
       
  3039 		}
       
  3040 
       
  3041 	if (tParentValue == tValue || tValue == NULL)
       
  3042 		{
       
  3043 
       
  3044 		if (iDocument)
       
  3045 		{
       
  3046 			tValue = iDocument->iMemoryManager->GetCssStrObjectL( lPtr );
       
  3047 		}
       
  3048 
       
  3049 
       
  3050 
       
  3051 		CleanupStack::PopAndDestroy( 1 );// cleanup : for lPtr
       
  3052 	    iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
       
  3053 		}
       
  3054 	else
       
  3055 		{
       
  3056 		((CStrCssValueImpl*)tValue)->SetValueL ( lPtr );
       
  3057 		 CleanupStack::PopAndDestroy( 1 );
       
  3058 		}
       
  3059 
       
  3060 	return ETrue;
       
  3061 	}
       
  3062 
       
  3063 
       
  3064 
       
  3065 // --------------------------------------------------------------------------
       
  3066 // TBool CSvgDecoder::DecodeIntCssValueL(const TUint16 aName)
       
  3067 // ---------------------------------------------------------------------------
       
  3068 TBool CSvgDecoder::DecodeIntCssValueL(const TUint16 aName)
       
  3069 	{
       
  3070 
       
  3071 	TInt32  lInt32;
       
  3072 	iStream >> lInt32;
       
  3073 
       
  3074 	CCssValue* tParentValue = NULL;
       
  3075     CCssValue* tValue = NULL;
       
  3076 
       
  3077 	iCurrentElement->FindProperty ((TInt8)aName,tValue);
       
  3078 
       
  3079 	if(iCurrentElement!= iRootElement)
       
  3080 		{
       
  3081 		iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
       
  3082 		}
       
  3083 
       
  3084 	if (tParentValue == tValue || tValue == NULL)
       
  3085 		{
       
  3086 
       
  3087 		if (iDocument)
       
  3088 		{
       
  3089 			tValue = iDocument->iMemoryManager->GetCssIntObjectL( (TInt)lInt32 );
       
  3090 		}
       
  3091 
       
  3092 	    iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
       
  3093 		}
       
  3094 	else
       
  3095 		{
       
  3096 		((CIntCssValueImpl*)tValue)->SetValueL ((TInt)lInt32);
       
  3097 		}
       
  3098 
       
  3099 	return ETrue;
       
  3100 	}
       
  3101 
       
  3102 
       
  3103 // --------------------------------------------------------------------------
       
  3104 // TBool CSvgDecoder::DecodeFloatCssValueL(const TUint16 aName)
       
  3105 // ---------------------------------------------------------------------------
       
  3106 TBool CSvgDecoder::DecodeFloatCssValueL(const TUint16 aName)
       
  3107 	{
       
  3108 
       
  3109 	if (iIsFixPt)
       
  3110 	{
       
  3111 		TFloatFixPt lFixed;
       
  3112 		lFixed.iValue = iStream.ReadInt32L();
       
  3113 		
       
  3114 		CCssValue* tParentValue = NULL;
       
  3115     	CCssValue* tValue = NULL;
       
  3116 
       
  3117 		iCurrentElement->FindProperty ((TInt8)aName,tValue);
       
  3118 
       
  3119 		if(iCurrentElement!= iRootElement)
       
  3120 		{
       
  3121 		iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
       
  3122 		}
       
  3123 
       
  3124 		if (tParentValue == tValue || tValue == NULL)
       
  3125 		{
       
  3126 		if (iDocument)
       
  3127 		{
       
  3128 			tValue = iDocument->iMemoryManager->GetCssFloatObjectL( lFixed );
       
  3129 		}
       
  3130 
       
  3131 	    iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
       
  3132 		}
       
  3133 		else
       
  3134 		{
       
  3135 		((CFloatCssValueImpl*)tValue)->SetValueL ( lFixed );
       
  3136 		}		
       
  3137 	}
       
  3138 	else
       
  3139 	{
       
  3140 		TReal32  lFlt32;
       
  3141 		iStream >> lFlt32;
       
  3142 		
       
  3143 		CCssValue* tParentValue = NULL;
       
  3144     	CCssValue* tValue = NULL;
       
  3145 
       
  3146 		iCurrentElement->FindProperty ((TInt8)aName,tValue);
       
  3147 
       
  3148 		if(iCurrentElement!= iRootElement)
       
  3149 		{
       
  3150 		iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
       
  3151 		}
       
  3152 
       
  3153 		if (tParentValue == tValue || tValue == NULL)
       
  3154 		{
       
  3155 		if (iDocument)
       
  3156 		{
       
  3157 			tValue = iDocument->iMemoryManager->GetCssFloatObjectL((TFloatFixPt)lFlt32);
       
  3158 		}
       
  3159 
       
  3160 	    iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
       
  3161 		}
       
  3162 		else
       
  3163 		{
       
  3164 		((CFloatCssValueImpl*)tValue)->SetValueL ((TFloatFixPt)lFlt32);
       
  3165 		}
       
  3166 	}
       
  3167 
       
  3168 	return ETrue;
       
  3169 	}
       
  3170 
       
  3171 
       
  3172 // --------------------------------------------------------------------------
       
  3173 // TBool CSvgDecoder::DecodeColorCssValueL(const TUint16 aName)
       
  3174 // ---------------------------------------------------------------------------
       
  3175 TBool CSvgDecoder::DecodeColorCssValueL(const TUint16 aName)
       
  3176 	{
       
  3177 	TUint32 lColor;
       
  3178 	iStream >> lColor;
       
  3179 
       
  3180 	// Shift from XBGR to XRGB
       
  3181 	if(!iIsRGB)
       
  3182 		{
       
  3183 		lColor = (  lColor & 0xFF000000) |
       
  3184 			 ( (lColor & 0x00FF0000) >> 16 ) |
       
  3185 		     (  lColor & 0x0000FF00       ) |
       
  3186 		     ( (lColor & 0x000000FF) << 16 );
       
  3187 		}
       
  3188 	
       
  3189 	CCssValue* tParentValue = NULL;
       
  3190     CCssValue* tValue = NULL;
       
  3191 
       
  3192 	iCurrentElement->FindProperty ((TInt8)aName,tValue);
       
  3193 
       
  3194 	if(iCurrentElement!= iRootElement)
       
  3195 		{
       
  3196 		iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
       
  3197 		}
       
  3198 
       
  3199 	if (tParentValue == tValue || tValue == NULL)
       
  3200 		{
       
  3201 		if ( iDocument )
       
  3202 		{
       
  3203 			tValue = iDocument->iMemoryManager->GetCssClrObjectL();
       
  3204 		
       
  3205 		CleanupStack::PushL(tValue); //cleanup
       
  3206 
       
  3207 		((CClrCssValueImpl*)tValue)->CloneRGBValueL (lColor);
       
  3208 	    iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
       
  3209 	    CleanupStack::Pop(tValue); //cleanup
       
  3210 	    }
       
  3211 		}
       
  3212 	else
       
  3213 		{
       
  3214 		((CClrCssValueImpl*)tValue)->CloneRGBValueL (lColor);
       
  3215 		}
       
  3216 
       
  3217 	return ETrue;
       
  3218 	}
       
  3219 
       
  3220 
       
  3221 
       
  3222 // --------------------------------------------------------------------------
       
  3223 // void CSvgDecoder::SetPaintValueL (CCssValue*& aValue)
       
  3224 // ---------------------------------------------------------------------------
       
  3225 void CSvgDecoder::SetPaintValueL (CCssValue*& aValue)
       
  3226 	{
       
  3227 	TUint8 lCheckGradient;
       
  3228 	iStream >> lCheckGradient;
       
  3229 
       
  3230 	if( lCheckGradient)
       
  3231 		{
       
  3232 		((CPaintCssValueImpl *)aValue)->SetUrlflag();
       
  3233 		((CPaintCssValueImpl *)aValue)->SetUrlIdL( DecodeTDesCLC() );
       
  3234 		 CleanupStack::PopAndDestroy( 1 );
       
  3235 		}
       
  3236 	else
       
  3237 		{
       
  3238 		TUint32 lColor;
       
  3239  		iStream >> lColor;
       
  3240 		// Shift from XBGR to ARGB
       
  3241 		if(!iIsRGB)
       
  3242 			{
       
  3243 			lColor = (  lColor & 0xFF000000) |
       
  3244 			     ( (lColor & 0x00FF0000) >> 16 ) |
       
  3245 			     (  lColor & 0x0000FF00       ) |
       
  3246 			     ( (lColor & 0x000000FF) << 16 );
       
  3247 			}
       
  3248 		((CPaintCssValueImpl *)aValue)->CloneRGBValueL (lColor);
       
  3249 		}
       
  3250 	}
       
  3251 
       
  3252 
       
  3253 
       
  3254 
       
  3255 
       
  3256 // ==========================================================================
       
  3257 // Start Decoding
       
  3258 // ==========================================================================
       
  3259 CSvgElementImpl* CSvgDecoder::StartDecodingL(CSvgDocumentImpl *aDocument,
       
  3260 											CSvgErrorImpl& aError )
       
  3261 	{
       
  3262 
       
  3263 	iDocument= aDocument;
       
  3264 
       
  3265 	iSvgError = &aError;
       
  3266     aError.SetErrorCode( ESvgNoError );
       
  3267 
       
  3268 	TUint32 lValidBinary;
       
  3269 	iStream >> lValidBinary;
       
  3270 
       
  3271 	if (lValidBinary != KBinaryFile && 
       
  3272 		lValidBinary != KBinaryFile2 && 
       
  3273 		lValidBinary != KBinaryFile3 && 
       
  3274 		lValidBinary != KBinaryFile4)
       
  3275 		{
       
  3276 		iSvgError->SetErrorCode ( ESvgbFileNotValid );
       
  3277         iSvgError->SetDescription( _L( "Not a valid binary file." ) );
       
  3278         iSvgError->SetIsWarning( EFalse );
       
  3279         return NULL;
       
  3280 	}
       
  3281 	
       
  3282 	if (lValidBinary == KBinaryFile2)
       
  3283 		{
       
  3284 		iIsFixPt = ETrue;
       
  3285 		iIsRGB = EFalse;
       
  3286 		}
       
  3287 		
       
  3288 	if (lValidBinary == KBinaryFile3)
       
  3289 		{
       
  3290 		iIsFixPt = ETrue;
       
  3291 		iIsRGB = ETrue;
       
  3292 		}
       
  3293 		
       
  3294 	if(lValidBinary == KBinaryFile4)
       
  3295 		{
       
  3296 		iIsFixPt = EFalse;
       
  3297 		iIsRGB = ETrue;
       
  3298 		}
       
  3299 
       
  3300 	TUint8 lElemId;
       
  3301 	TUint16 lAttrName;
       
  3302 
       
  3303 	MXmlElement* newElement;
       
  3304 
       
  3305 	iStream >> lElemId;
       
  3306 	while (lElemId != KEndSvgFile)
       
  3307 		{
       
  3308 
       
  3309 		 // checks end of element
       
  3310 		while (lElemId==KEndElemIndex)
       
  3311 			{
       
  3312 			if ( iCurrentParentElement != iRootElement )
       
  3313 				{
       
  3314 				// Depth is decreased, so the current parent should be one level up
       
  3315 				iCurrentParentElement = ( CSvgElementImpl * )
       
  3316 			                       iCurrentParentElement->ParentNode();
       
  3317 				}
       
  3318 
       
  3319 			iStream >> lElemId;
       
  3320 			}
       
  3321 
       
  3322 		// checks for Cdata
       
  3323   		if (lElemId == KCDataPresent)
       
  3324 			{
       
  3325 			iCurrentElement= iCurrentParentElement;
       
  3326 			DecodeAttributeL((TUint16)KAtrCdata);
       
  3327 			iStream >> lElemId;
       
  3328 			continue;
       
  3329 			}
       
  3330 
       
  3331 
       
  3332 
       
  3333 		 //checks end of file.
       
  3334 		if (lElemId == KEndSvgFile)
       
  3335 			{
       
  3336 			break;
       
  3337 			}
       
  3338 
       
  3339 
       
  3340 		newElement  = iDocument->CreateElementL( lElemId );
       
  3341 
       
  3342 		if( newElement == NULL)
       
  3343 			{
       
  3344 				User::Leave(KErrCorrupt);
       
  3345 			}
       
  3346 
       
  3347 	    iCurrentElement = ( CSvgElementImpl * ) newElement;
       
  3348 
       
  3349 
       
  3350 		if ( lElemId == KSvgSvgElement && !iRootElement )
       
  3351 			{
       
  3352 	        iRootElement = iCurrentElement;
       
  3353 
       
  3354 	      	//CleanupStack::PushL(iRootElement);
       
  3355 	        iDocument->AppendChildL( newElement );
       
  3356 	        //CleanupStack::Pop(iRootElement);
       
  3357 
       
  3358 		    }
       
  3359 		// for all other elements
       
  3360 		else
       
  3361 			{
       
  3362     		 iCurrentParentElement->AppendChildL( newElement );
       
  3363 		    }
       
  3364 
       
  3365 		// Setting target element for animations
       
  3366 		if( iCurrentElement->IsAnimatedElement() )
       
  3367 			{
       
  3368             ((CSvgAnimationBase*)iCurrentElement)->SetTarget( iCurrentParentElement);
       
  3369             // For media elements do not set iIsAnimElement as 
       
  3370             // the Xlink:Href  is for external files rather
       
  3371             // than internal elements
       
  3372             if (!( iCurrentElement->ElemID() >= KSvgMediaElemsStartIndex &&
       
  3373              iCurrentElement->ElemID() <= KSvgMediaElemsEndIndex ) )
       
  3374                 {
       
  3375 			    iIsAnimElement= ETrue;                
       
  3376                 }
       
  3377 			}
       
  3378 
       
  3379 
       
  3380 		iStream >> lAttrName;
       
  3381 
       
  3382 		// for attribute list.
       
  3383 		while (lAttrName!= KStartNewElem)
       
  3384 			{
       
  3385 			DecodeAttributeL(lAttrName);
       
  3386 			iStream >> lAttrName;
       
  3387 			}
       
  3388 		if( iCurrentElement->ElemID() == KSvgStopElement)
       
  3389 		   {
       
  3390 		   if( ((CSvgElementImpl*)iCurrentElement->ParentNode()) != NULL )
       
  3391               {
       
  3392               if((((((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID()) == KSvgRadialGradientElement) ||
       
  3393 	              ((((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID()) == KSvgLinearGradientElement) ) )
       
  3394 		         {
       
  3395 	    	     CSvgGradientElementImpl *parent = ((CSvgGradientElementImpl *)iCurrentElement->ParentNode());
       
  3396         
       
  3397                  if(parent)
       
  3398 		            {
       
  3399 	                // Initialize the offset value to 0 if its still -1.
       
  3400 	                TFloatFixPt lOffsetValue;
       
  3401 	                TFloatFixPt lDefaultOffsetValue(-1);
       
  3402 	                TBuf<6>     lAttributeName;
       
  3403 	                TBuf<1>     lValueBuffer;
       
  3404 	                      
       
  3405 	                lAttributeName.Append(OFFSET);
       
  3406 	                lValueBuffer.Append(ZEROVALUE);
       
  3407 	                       
       
  3408 	                ((CSvgStopElementImpl*)iCurrentElement)->GetOffset( lOffsetValue );
       
  3409 	                      
       
  3410 	                // Offset Value of -1 indicates that Offset Attribute is not declared in
       
  3411 	                // stop element.
       
  3412 	                if( lOffsetValue == lDefaultOffsetValue )
       
  3413 	                   {
       
  3414 	                    // Deliberately calling SetAttributeL in place of SetAttributeFloatL as the latter inturn
       
  3415 	                    // calls UpdateOffsetValues which should be called on any Stop element once it is added to
       
  3416 	                    // to the Stop element array Owned by parent Gradient element.
       
  3417 	                    ((CSvgStopElementImpl*)iCurrentElement)->SetAttributeL( lAttributeName, lValueBuffer );
       
  3418 	                   }
       
  3419 	                   
       
  3420 	                // The function not only adds the element in Stop element array but also
       
  3421                     // adjusts the offset values of all the previously added elements such that
       
  3422                     // each gradient offset value is greater than the previous gradient stop's
       
  3423                     // offset value.It calls UpdateOffsetValues to adjust the values.
       
  3424 	                ((CSvgGradientElementImpl *)parent)->AddStopElementInArray((CSvgStopElementImpl*)iCurrentElement);
       
  3425 		            }
       
  3426 	              }
       
  3427             }
       
  3428 		}
       
  3429 
       
  3430 
       
  3431 		if (iCurrentElement->ElemID() == KSvgUseElement)
       
  3432 			{
       
  3433 			((CSvgUseElementImpl *)iCurrentElement)->SetReferenceElementL();
       
  3434 			}
       
  3435 /*		else if (iCurrentElement->ElemID() == KSvgAnimationElement)
       
  3436 			{
       
  3437 			((CSvgAnimationElementImpl *)iCurrentElement)->SetReferenceElementL();
       
  3438 			if(((CSvgAnimationElementImpl *)iCurrentElement)->RecursionVariable())
       
  3439 				{
       
  3440 				iSvgError->SetErrorCode( ESvgDocumentNotValid );
       
  3441 				iSvgError->SetIsWarning( EFalse );
       
  3442 				iSvgError->SetDescription( _L( "Invalid Document \n" ) );
       
  3443 				iSvgError->AppendDescription( _L("Animation element in loop") );
       
  3444                 return iRootElement;
       
  3445                 }
       
  3446             }
       
  3447 */
       
  3448         if (iCurrentElement->HasAnyTests())
       
  3449         {
       
  3450             iReqFetAttSysArray->AppendL(iCurrentElement);
       
  3451         }
       
  3452 
       
  3453         if (iCurrentElement->ElemID() == KSvgSwitchElement)
       
  3454         {
       
  3455             iSwitchElementArray->AppendL(iCurrentElement);
       
  3456         }
       
  3457 
       
  3458 		// For DOM reuse
       
  3459 		if( iCurrentElement->IsAnimatedElement() )
       
  3460             {
       
  3461             ((CSvgAnimationBase*)iCurrentElement)->SetOriginalValues_DOMReuse() ;
       
  3462             iAnimationElementArray->AppendL(iCurrentElement);
       
  3463             }
       
  3464 
       
  3465 
       
  3466 		if( iCurrentElement->ElemID() >= KSvgLinearGradientElement &&
       
  3467 			iCurrentElement->ElemID() <= KSvgStopElement )
       
  3468 			{
       
  3469 			iCurrentElement->SetAttributeIntL(KCSS_ATTR_DISPLAY,0);
       
  3470 			}
       
  3471 
       
  3472 		if (	iCurrentElement->ElemID() == KSvgMpathElement &&
       
  3473 				iCurrentParentElement->ElemID() == KSvgAnimateMotionElement &&
       
  3474 				iSvgError->ErrorCode() == ESvgMissingRequiredAttribute &&
       
  3475 				iSvgError->IsWarning()
       
  3476 		   )
       
  3477 
       
  3478 
       
  3479 			{
       
  3480 			iSvgError->SetErrorCode( ESvgNoError );
       
  3481 			// add to event receiver list will have only one copy
       
  3482 			iDocument->AddToEventReceiverListL( iCurrentParentElement, KSvgEventMaskTimer );
       
  3483 			}
       
  3484 
       
  3485 		CheckRequiredAttributesL( lElemId);
       
  3486 		iIsAnimElement= EFalse;
       
  3487 
       
  3488 		iCurrentParentElement = iCurrentElement;
       
  3489 
       
  3490 		iStream >> lElemId;
       
  3491 
       
  3492 		}
       
  3493     //Load Images
       
  3494     
       
  3495     TInt lImageElementCnt = iImageElements.Count();
       
  3496     TInt lTotalImagesCount = lImageElementCnt + iEmbeddedImagesCount;
       
  3497     iDocument->SetImageElementsCount(lTotalImagesCount);
       
  3498     for( TInt index = 0 ; index < lImageElementCnt ; index++)
       
  3499         {
       
  3500           iImageElements[index]->LoadUriL();
       
  3501         }
       
  3502     
       
  3503 	if(iUseElementArray)
       
  3504 		{
       
  3505 	 // support for forward reference in use element
       
  3506 	TInt lCount = iUseElementArray->Count();
       
  3507 	TInt lIndex= 0;
       
  3508 	while(lIndex < lCount)
       
  3509 	{
       
  3510 		TPtrC tPtr2 = ((CSvgElementImpl*)iUseElementArray->operator[](lIndex))->Href();
       
  3511 		TInt Pos1= tPtr2.Locate('#');
       
  3512         HBufC*  tBufC   = HBufC::NewLC( tPtr2.Length() );
       
  3513 	    TPtr    tPtr3    ( tBufC->Des() );
       
  3514 	    tPtr3.Copy( tPtr2 );
       
  3515 	    tPtr3.TrimAll();
       
  3516 	    // remove '#'
       
  3517 		if(Pos1 != KErrNotFound)
       
  3518 			{
       
  3519 			tPtr3.Delete(Pos1,1);
       
  3520 			}
       
  3521 		if(((CSvgUseElementImpl *)iUseElementArray->operator[](lIndex))->SetRefElemById(tPtr3) != KErrNotFound)
       
  3522 			{
       
  3523 			((CSvgUseElementImpl *)iUseElementArray->operator[](lIndex))->SetReferenceElementL();
       
  3524 
       
  3525 			}
       
  3526 			lIndex++;
       
  3527 		CleanupStack::PopAndDestroy( 1 );
       
  3528 	}
       
  3529 		}
       
  3530 	// support for forward reference in use element
       
  3531 	if(iAnimRefElementArray)
       
  3532 		{
       
  3533 		TInt lCount = iAnimRefElementArray->Count();
       
  3534 		TInt lIndex= 0;
       
  3535 	while(lIndex < lCount)
       
  3536 		{
       
  3537 		TPtrC tPtr2 = ((CSvgElementImpl*)iAnimRefElementArray->operator[](lIndex))->Href();
       
  3538 		((CSvgAnimationBase *)iAnimRefElementArray->operator[](lIndex))->SetRefElemById(tPtr2);
       
  3539 		lIndex++;
       
  3540 			}
       
  3541 		}
       
  3542 
       
  3543 	// For Animation elements
       
  3544 	if (iAnimationElementArray)
       
  3545 		{
       
  3546 		TInt lCount = iAnimationElementArray->Count();
       
  3547 		TInt lIndex = 0;
       
  3548 		while(lIndex < lCount)
       
  3549 	    	{
       
  3550 		    ((CSvgAnimationBase *)iAnimationElementArray->operator[](lIndex))->CheckBeginTime();
       
  3551 		    lIndex ++;
       
  3552 		    }
       
  3553 		}
       
  3554     // Reset iCurrentElement, as it is no longer used
       
  3555     iCurrentElement = NULL;
       
  3556 	RemoveFalseElements();
       
  3557 	RemoveFalseSwitchCases();
       
  3558 
       
  3559 	return iRootElement;
       
  3560 	}
       
  3561 
       
  3562 
       
  3563 
       
  3564 // --------------------------------------------------------------------------
       
  3565 // void CSvgDecoder::CheckRequiredAttributesL(const TUint8 aName )
       
  3566 // ---------------------------------------------------------------------------
       
  3567 void CSvgDecoder::CheckRequiredAttributesL(const TUint8 aName )
       
  3568 	{
       
  3569 
       
  3570 
       
  3571 	if( iCurrentElement->iReqAttrFlag != 0)
       
  3572 
       
  3573 			{
       
  3574 
       
  3575 			iSvgError->SetErrorCode( ESvgMissingRequiredAttribute );
       
  3576 			iSvgError->SetIsWarning( ETrue );
       
  3577 			iSvgError->SetDescription( _L( "Missing required attribute \"" ) );
       
  3578 			switch(iCurrentElement->iReqAttrFlag)
       
  3579 			{
       
  3580 			case KSVG_PATH_ELEMFLAG:
       
  3581 				iSvgError->AppendDescription( _L("d") );
       
  3582 				break;
       
  3583 			case KAtrWidth:
       
  3584 				iSvgError->AppendDescription( _L("width") );
       
  3585 				break;
       
  3586 			case KAtrHeight:
       
  3587 				iSvgError->AppendDescription( _L("height") );
       
  3588 				break;
       
  3589 			case KSVG_POLYLINE_ELEMFLAG:
       
  3590 				iSvgError->AppendDescription( _L("points") );
       
  3591 				break;
       
  3592 			case KAtrRy:
       
  3593 				iSvgError->AppendDescription( _L("Ry") );
       
  3594 				break;
       
  3595 			case KAtrRx:
       
  3596 				iSvgError->AppendDescription( _L("Rx") );
       
  3597 				break;
       
  3598 			case KAtrSVGRec:
       
  3599 				iSvgError->AppendDescription( _L("width") );
       
  3600 				iSvgError->AppendDescription( _L( "\" and \"" ) );
       
  3601 				iSvgError->AppendDescription(_L("height"));
       
  3602 				break;
       
  3603 			case KAtrSVGElp:
       
  3604 				iSvgError->AppendDescription( _L("Rx") );
       
  3605 				iSvgError->AppendDescription( _L( "\" and \"" ) );
       
  3606 				iSvgError->AppendDescription(_L("Ry"));
       
  3607 				break;
       
  3608 			case KAtrSVGTrf:
       
  3609 				iSvgError->AppendDescription( _L("attributeName") );
       
  3610 				iSvgError->AppendDescription( _L( "\" and \"" ) );
       
  3611 				iSvgError->AppendDescription(_L("type"));
       
  3612 				break;
       
  3613 			case KSVG_ANIMATE_ELEMFLAG:
       
  3614 				iSvgError->AppendDescription( _L("attributeName") );
       
  3615 				break;
       
  3616 			case KSVG_CIRCLE_ELEMFLAG:
       
  3617 				iSvgError->AppendDescription( _L("r") );
       
  3618 				break;
       
  3619 			case KSVG_HKERN_ELEMFLAG:
       
  3620 				iSvgError->AppendDescription( _L("k") );
       
  3621 				break;
       
  3622 			case KAtrType:
       
  3623 				iSvgError->AppendDescription( _L("type") );
       
  3624 				break;
       
  3625 			case KAtrXlinkhref:
       
  3626 				iSvgError->AppendDescription (_L("Xlink:href"));
       
  3627 				break;
       
  3628 			case KAtrSVGAmo:
       
  3629 				iSvgError->AppendDescription( _L("path") );
       
  3630 				((CSvgDocumentImpl*)iDocument)->RemoveFromEventReceiverList( iCurrentElement );
       
  3631 				break;
       
  3632 			case KAtrToBy:
       
  3633 				iSvgError->AppendDescription( _L("to/by") );
       
  3634 				((CSvgDocumentImpl*)iDocument)->RemoveFromEventReceiverList( iCurrentElement );
       
  3635 				break;
       
  3636 			}
       
  3637 			iSvgError->AppendDescription( _L( "\" for <" ) );
       
  3638 			// access schema data to get the name of the attribute which is missing
       
  3639 			// currently the error msg doesnt not report the name of the attribute
       
  3640 
       
  3641 			TBuf<20> lElemName = _L("svg");
       
  3642 			((CSvgDocumentImpl*)iDocument)->SchemaData()->GetSVGElementName(aName,lElemName);
       
  3643 			iSvgError->AppendDescription( lElemName );
       
  3644 			iSvgError->AppendDescription( _L( ">." ) );
       
  3645 			// turn off element
       
  3646 
       
  3647 			  ((CSvgElementImpl*)iCurrentElement)->SetTurnOff( ETrue );
       
  3648 
       
  3649 			((CSvgElementImpl*)iCurrentElement)->SetPropertyL(KCSS_ATTR_DISPLAY,_L("none"));
       
  3650 
       
  3651 
       
  3652 		}
       
  3653 	}
       
  3654 
       
  3655 //---------------------------------------------------
       
  3656 //Removal of elements that dont pass
       
  3657 //required extensions, required features, and system language
       
  3658 //requirements
       
  3659 //switch statement is special case were only the first one
       
  3660 //that passes these requirements will be used so toss the rest
       
  3661 //---------------------------------------------------
       
  3662 void CSvgDecoder::RemoveFalseElements()
       
  3663     {
       
  3664     if (iReqFetAttSysArray == NULL)
       
  3665         {
       
  3666         // Error Case
       
  3667         return;        
       
  3668         }
       
  3669 
       
  3670     //loop through the list of elements with required features, attributes, or sys language
       
  3671     TInt reqFetSysArrayCnt = iReqFetAttSysArray->Count();
       
  3672     while ( reqFetSysArrayCnt > 0 )
       
  3673         {
       
  3674         CSvgElementImpl* lCurElement = ( CSvgElementImpl* )
       
  3675             iReqFetAttSysArray->operator[]( reqFetSysArrayCnt - 1 );
       
  3676 
       
  3677         if ( lCurElement != NULL )
       
  3678             {
       
  3679             CSvgElementImpl* lCurParent = ( CSvgElementImpl* )
       
  3680                 lCurElement->ParentNode();
       
  3681  
       
  3682             //just a normal element check it and remove it if it doesnt pass
       
  3683             TBool lResult = EFalse;
       
  3684             TRAPD( error, lResult  = VerifyReqExReqFtrSysL( lCurElement ) );
       
  3685             if ( error == KErrNone && !lResult )
       
  3686                 {
       
  3687                 // Remove internal references to the element about to be 
       
  3688                 // removed
       
  3689                 // This function would also remove the lCurElement from
       
  3690                 // iReqFetAttSysArray.
       
  3691                 RemoveInternalReferences( lCurElement );
       
  3692                 //element doesnt have proper required extension, attributes, or system language
       
  3693                 lCurParent->RemoveChild( lCurElement );
       
  3694                 delete (CXmlElementImpl*)lCurElement;
       
  3695                 lCurElement = NULL;
       
  3696                 }
       
  3697             else
       
  3698                 {
       
  3699                 // Remove the last element from the array as it is processed
       
  3700                 iReqFetAttSysArray->Remove( reqFetSysArrayCnt - 1 );
       
  3701                 } // if ( error == KErrNone && !lResult )
       
  3702             }
       
  3703         else
       
  3704             {
       
  3705             // Remove the last element from the array as it is processed
       
  3706             iReqFetAttSysArray->Remove( reqFetSysArrayCnt - 1 );
       
  3707             } // if ( lCurElement != NULL )
       
  3708         // Update the count of elements in the array
       
  3709         reqFetSysArrayCnt = iReqFetAttSysArray->Count();
       
  3710         } // while ( reqFetSysArrayCnt > 0 )
       
  3711     // Clear the array as it is no longer required.
       
  3712     iReqFetAttSysArray->Reset();    
       
  3713     }
       
  3714 
       
  3715 // --------------------------------------------------------------------------
       
  3716 // void CSvgDecoder::RemoveFalseSwitchCases()
       
  3717 // ---------------------------------------------------------------------------
       
  3718 void CSvgDecoder::RemoveFalseSwitchCases()
       
  3719     {
       
  3720     if (iSwitchElementArray == NULL)
       
  3721         {
       
  3722         // Error Case
       
  3723         return;
       
  3724         }
       
  3725         
       
  3726     TInt switchEleArrayCnt = iSwitchElementArray->Count();
       
  3727     while ( switchEleArrayCnt > 0 )
       
  3728         {
       
  3729         TBool foundTrue = EFalse;
       
  3730         CSvgElementImpl* curSwitchElem = ( CSvgElementImpl* )
       
  3731             iSwitchElementArray->operator[]( switchEleArrayCnt - 1 );
       
  3732 
       
  3733         if ( curSwitchElem != NULL )
       
  3734             {
       
  3735             //get the first child...which is where the first
       
  3736             CSvgElementImpl* curCaseElem = (CSvgElementImpl*)curSwitchElem->FirstChild();
       
  3737 
       
  3738             while ( curCaseElem != NULL )
       
  3739                 {
       
  3740                 CSvgElementImpl* nextCaseElem = (CSvgElementImpl*)curCaseElem->NextSibling();
       
  3741                 // foundTrue is set to TRUE when an element whose test passes is found. The
       
  3742                 // subsequent elements are to be removed.
       
  3743                 if ( foundTrue )
       
  3744                     {
       
  3745                     // Remove internal references of the element from 
       
  3746                     // decoder's lists
       
  3747                     RemoveInternalReferences( curCaseElem );
       
  3748                     //already found the true case in the switch delete the rest
       
  3749                     curSwitchElem->RemoveChild( curCaseElem );
       
  3750                     delete ( CXmlElementImpl* )curCaseElem;
       
  3751                     curCaseElem = NULL;
       
  3752                     }
       
  3753                 else
       
  3754                     {
       
  3755                     TBool lResult = EFalse;
       
  3756                     TRAPD(error, lResult  = VerifyReqExReqFtrSysL(curCaseElem));
       
  3757                     if ( error == KErrNone && !lResult )
       
  3758                         {
       
  3759                         // Remove internal references of the element from 
       
  3760                         // decoder's lists
       
  3761                         RemoveInternalReferences( curCaseElem );
       
  3762                         //this element doesnt meet the switch requirements delete it and its children
       
  3763                         curSwitchElem->RemoveChild(curCaseElem);
       
  3764                         delete (CXmlElementImpl*)curCaseElem;
       
  3765                         curCaseElem = NULL;
       
  3766                         }
       
  3767                     else
       
  3768                         {
       
  3769                         //one evaluated to true so keep it but go ahead and delete the rest in the switch
       
  3770                         //should only be one child for switch in end
       
  3771                         foundTrue = ETrue;
       
  3772                         } // if ( error == KErrNone && !lResult )
       
  3773                     } // if ( foundTrue )
       
  3774                 // Proceed checking the next sibling
       
  3775                 curCaseElem = nextCaseElem;
       
  3776                 } // while ( curCaseElem != NULL )
       
  3777             } // if ( curSwitchElem != NULL )
       
  3778         // Remove the last switch element which was processed
       
  3779         iSwitchElementArray->Remove( switchEleArrayCnt - 1 );
       
  3780         // Update the count of the array
       
  3781         switchEleArrayCnt = iSwitchElementArray->Count();
       
  3782         } // while ( switchEleArrayCnt > 0 )
       
  3783     // Clear the array as it is no longer needed
       
  3784     iSwitchElementArray->Reset();    
       
  3785     }
       
  3786 
       
  3787 //---------------------------------------------------
       
  3788 //Check to see
       
  3789 //required extensions, required features, and system language
       
  3790 //requirements
       
  3791 //---------------------------------------------------
       
  3792 TBool CSvgDecoder::VerifyReqExReqFtrSysL( CSvgElementImpl* aElement )
       
  3793 {
       
  3794     const CDesCArrayFlat* tempTestArray = NULL; // 'const' keyword added due to S60 (CW) build team recommendation
       
  3795 
       
  3796 	TBool   doDraw  = ETrue;
       
  3797 
       
  3798     // First check for requiredExtensions
       
  3799     aElement->GetRequiredExtensions( tempTestArray );
       
  3800 
       
  3801     if ( tempTestArray && tempTestArray->MdcaCount() )
       
  3802     {
       
  3803     	// Check for all entries in requiredExtensions
       
  3804 
       
  3805     	TInt lCount = tempTestArray->MdcaCount();
       
  3806 
       
  3807       	for ( TInt i = 0; i < lCount; i++ )
       
  3808       	{
       
  3809       		TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
       
  3810        	 	if ( tmpPtr.Length() )
       
  3811        	 	{
       
  3812         		doDraw = EFalse;
       
  3813           		break;
       
  3814         	}
       
  3815         	else if ( aElement->HasExtension( tmpPtr ) == EFalse )
       
  3816         	{
       
  3817         		doDraw = EFalse;
       
  3818           		break;
       
  3819         	}
       
  3820       	}
       
  3821     }
       
  3822 
       
  3823     // Second, check for requiredFeatures
       
  3824     aElement->GetRequiredFeatures( tempTestArray );
       
  3825     if ( tempTestArray && tempTestArray->MdcaCount() && doDraw)
       
  3826     {
       
  3827     	// Check for all entries in requiredFeatures
       
  3828       TInt lCount = tempTestArray->MdcaCount();
       
  3829       for ( TInt i = 0; i < lCount; i++ )
       
  3830       {
       
  3831       	TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
       
  3832         if ( aElement->HasFeature( tmpPtr ) == EFalse )
       
  3833         {
       
  3834         	doDraw = EFalse;
       
  3835           	break;
       
  3836         }
       
  3837       }
       
  3838     }
       
  3839 
       
  3840 	TBufC<5> iSystemLanguage;
       
  3841 	SystemLanguage( iSystemLanguage.Des() );
       
  3842 
       
  3843 	// Third, check for systemLanguage
       
  3844 	// Future enhancement: System language doesnt need to be stored in seperate array indexes
       
  3845 	// could have just stored it as one big string and use findf without the loop
       
  3846     aElement->GetSystemLanguage( tempTestArray );
       
  3847     TBool doDrawSystem = EFalse;
       
  3848     if ( tempTestArray && tempTestArray->MdcaCount() && doDraw)
       
  3849 	{
       
  3850     	TInt lCount = tempTestArray->MdcaCount();
       
  3851 
       
  3852       	for ( TInt i = 0; i < lCount; i++ )
       
  3853       	{
       
  3854       		TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
       
  3855 
       
  3856         	if ( tmpPtr.FindF( iSystemLanguage ) >= 0 )
       
  3857 			{
       
  3858         		doDrawSystem = ETrue;
       
  3859           		break;
       
  3860 			}
       
  3861       	}
       
  3862 
       
  3863       	if (doDrawSystem == EFalse)
       
  3864      	{
       
  3865      		doDraw = EFalse;
       
  3866      	}
       
  3867      }
       
  3868 
       
  3869 	return doDraw;
       
  3870 }
       
  3871 
       
  3872 // --------------------------------------------------------------------------
       
  3873 // void CSvgDecoder::SystemLanguage( TPtr aValue )
       
  3874 // ---------------------------------------------------------------------------
       
  3875 void CSvgDecoder::SystemLanguage( TPtr aValue )
       
  3876     {
       
  3877     _LIT( KEn, "en" );
       
  3878     _LIT( KFr, "fr" );
       
  3879     _LIT( KDe, "de" );
       
  3880     _LIT( KEs, "es" );
       
  3881 
       
  3882     _LIT( KAf, "af" );
       
  3883     _LIT( KAm, "am" );
       
  3884     _LIT( KAr, "ar" );
       
  3885     _LIT( KBg, "bg" );
       
  3886     _LIT( KBn, "bn" );
       
  3887     _LIT( KBo, "bo" );
       
  3888     _LIT( KCa, "ca" );
       
  3889     _LIT( KCs, "cs" );
       
  3890     _LIT( KCy, "cy" );
       
  3891     _LIT( KDa, "da" );
       
  3892     _LIT( KEl, "el" );
       
  3893     _LIT( KEt, "et" );
       
  3894     _LIT( KFa, "fa" );
       
  3895     _LIT( KFi, "fi" );
       
  3896     _LIT( KGa, "ga" );
       
  3897     _LIT( KGd, "gd" );
       
  3898     _LIT( KGu, "gu" );
       
  3899     _LIT( KHe, "he" );
       
  3900     _LIT( KHi, "hi" );
       
  3901     _LIT( KHu, "hu" );
       
  3902     _LIT( KHr, "hr" );
       
  3903     _LIT( KHy, "hy" );
       
  3904     _LIT( KId, "id" );
       
  3905     _LIT( KIs, "is" );
       
  3906     _LIT( KIt, "it" );
       
  3907     _LIT( KJa, "ja" );
       
  3908     _LIT( KKa, "ka" );
       
  3909     _LIT( KKk, "kk" );
       
  3910     _LIT( KKm, "km" );
       
  3911     _LIT( KKn, "kn" );
       
  3912     _LIT( KKo, "ko" );
       
  3913     _LIT( KLo, "lo" );
       
  3914     _LIT( KLt, "lt" );
       
  3915     _LIT( KLv, "lv" );
       
  3916     _LIT( KMk, "mk" );
       
  3917     _LIT( KMl, "ml" );
       
  3918     _LIT( KMn, "mn" );
       
  3919     _LIT( KMo, "mo" );
       
  3920     _LIT( KMr, "mr" );
       
  3921     _LIT( KMs, "ms" );
       
  3922     _LIT( KMy, "my" );
       
  3923     _LIT( KNo, "no" );
       
  3924     _LIT( KNl, "nl" );
       
  3925     _LIT( KPa, "pa" );
       
  3926     _LIT( KPl, "pl" );
       
  3927     _LIT( KPt, "pt" );
       
  3928     _LIT( KRo, "ro" );
       
  3929     _LIT( KRu, "ru" );
       
  3930     _LIT( KSi, "si" );
       
  3931     _LIT( KSk, "sk" );
       
  3932     _LIT( KSl, "sl" );
       
  3933     _LIT( KSo, "so" );
       
  3934     _LIT( KSr, "sr" );
       
  3935     _LIT( KSq, "sq" );
       
  3936     _LIT( KSv, "sv" );
       
  3937     _LIT( KSw, "sw" );
       
  3938     _LIT( KTa, "ta" );
       
  3939     _LIT( KTe, "te" );
       
  3940     _LIT( KTh, "th" );
       
  3941     _LIT( KTi, "ti" );
       
  3942     _LIT( KTk, "tk" );
       
  3943     _LIT( KTl, "tl" );
       
  3944     _LIT( KTr, "tr" );
       
  3945     _LIT( KUk, "uk" );
       
  3946     _LIT( KUr, "ur" );
       
  3947     _LIT( KVi, "vi" );
       
  3948     //_LIT( KZh, "zh" );
       
  3949     _LIT( KZu, "zu" );
       
  3950 
       
  3951     _LIT( KEnB, "en-UK");
       
  3952     _LIT( KEnUS, "en-US");
       
  3953     _LIT( KZhTW, "zh-TW");
       
  3954     _LIT( KZhHK, "zh-HK");
       
  3955     _LIT( KZhCN, "zh-CN");
       
  3956     _LIT( KFrCA, "fr-CA");
       
  3957     _LIT( KPtBR, "pt-BR");
       
  3958     _LIT( KEnTW, "en-TW");
       
  3959     _LIT( KEnHK, "en-HK");
       
  3960     _LIT( KEnCN, "en-CN");
       
  3961     _LIT( KEnJP, "en-JP");
       
  3962     _LIT( KEnTH, "en-TH");
       
  3963     _LIT( KEsAR, "es-AR");
       
  3964     _LIT( KMsAP, "ms-AP");
       
  3965     _LIT( KEnAP, "en-AP" );    // KLangApacEnglish
       
  3966     _LIT( KIdAP, "id-AP" );    // KLangApacIndonesian
       
  3967     _LIT( KEu, "eu" );    // KLangBasque
       
  3968     _LIT( KGl, "gl" );    // KLangGalician
       
  3969 
       
  3970     _LIT(KDefault, "qqqqq");
       
  3971 
       
  3972     switch ( User::Language() )
       
  3973         {
       
  3974         case ELangTest:
       
  3975         aValue = KEn;
       
  3976         break;
       
  3977 
       
  3978         case ELangEnglish:
       
  3979         aValue = KEnB;
       
  3980         break;
       
  3981         case ELangAmerican:
       
  3982         aValue = KEnUS;
       
  3983         break;
       
  3984         case ELangAustralian:
       
  3985         case ELangNewZealand:
       
  3986         case ELangCanadianEnglish:
       
  3987         case ELangSouthAfricanEnglish:
       
  3988         case ELangInternationalEnglish:
       
  3989         aValue = KEn;
       
  3990         break;
       
  3991 
       
  3992         case ELangFrench:
       
  3993         case ELangSwissFrench:
       
  3994         case ELangBelgianFrench:
       
  3995         aValue = KFr;
       
  3996         break;
       
  3997 
       
  3998         case ELangGerman:
       
  3999         case ELangAustrian:
       
  4000         case ELangSwissGerman:
       
  4001         aValue = KDe;
       
  4002         break;
       
  4003 
       
  4004         case ELangSpanish:
       
  4005         case ELangInternationalSpanish:
       
  4006         aValue = KEs;
       
  4007         break;
       
  4008 
       
  4009         case ELangLatinAmericanSpanish:
       
  4010         aValue = KEsAR;
       
  4011         break;
       
  4012 
       
  4013         case ELangItalian:
       
  4014         case ELangSwissItalian:
       
  4015         aValue = KIt;
       
  4016         break;
       
  4017 
       
  4018         case ELangSwedish:
       
  4019         case ELangFinlandSwedish:
       
  4020         aValue = KSv;
       
  4021         break;
       
  4022 
       
  4023         case ELangDanish:
       
  4024         aValue = KDa;
       
  4025         break;
       
  4026 
       
  4027         case ELangNorwegian:
       
  4028         case ELangNorwegianNynorsk:
       
  4029         aValue = KNo;
       
  4030         break;
       
  4031 
       
  4032         case ELangFinnish:
       
  4033         aValue = KFi;
       
  4034         break;
       
  4035 
       
  4036         case ELangBrazilianPortuguese:
       
  4037         aValue = KPtBR;
       
  4038         break;
       
  4039 
       
  4040         case ELangPortuguese:
       
  4041         aValue = KPt;
       
  4042         break;
       
  4043 
       
  4044         case ELangTurkish:
       
  4045         case ELangCyprusTurkish:
       
  4046         aValue = KTr;
       
  4047         break;
       
  4048 
       
  4049         case ELangIcelandic:
       
  4050         aValue = KIs;
       
  4051         break;
       
  4052 
       
  4053         case ELangRussian:
       
  4054         case ELangBelarussian:
       
  4055         aValue = KRu;
       
  4056         break;
       
  4057 
       
  4058         case ELangHungarian:
       
  4059         aValue = KHu;
       
  4060         break;
       
  4061 
       
  4062         case ELangDutch:
       
  4063         case ELangBelgianFlemish:
       
  4064         aValue = KNl;
       
  4065         break;
       
  4066 
       
  4067         case ELangCzech:
       
  4068         aValue = KCs;
       
  4069         break;
       
  4070 
       
  4071         case ELangSlovak:
       
  4072         aValue = KSk;
       
  4073         break;
       
  4074 
       
  4075         case ELangPolish:
       
  4076         aValue = KPl;
       
  4077         break;
       
  4078 
       
  4079         case ELangSlovenian:
       
  4080         aValue = KSl;
       
  4081         break;
       
  4082 
       
  4083         case ELangPrcChinese:
       
  4084         aValue = KZhCN;
       
  4085         break;
       
  4086         case ELangTaiwanChinese:
       
  4087         aValue = KZhTW;
       
  4088         break;
       
  4089         case ELangHongKongChinese:
       
  4090         aValue = KZhHK;
       
  4091         break;
       
  4092 
       
  4093         case ELangJapanese:
       
  4094         aValue = KJa;
       
  4095         break;
       
  4096 
       
  4097         case ELangThai:
       
  4098         aValue = KTh;
       
  4099         break;
       
  4100 
       
  4101         case ELangAfrikaans:
       
  4102         aValue = KAf;
       
  4103         break;
       
  4104 
       
  4105         case ELangAlbanian:
       
  4106         aValue = KSq;
       
  4107         break;
       
  4108 
       
  4109         case ELangAmharic:
       
  4110         aValue = KAm;
       
  4111         break;
       
  4112 
       
  4113         case ELangArabic:
       
  4114         aValue = KAr;
       
  4115         break;
       
  4116 
       
  4117         case ELangArmenian:
       
  4118         aValue = KHy;
       
  4119         break;
       
  4120 
       
  4121         case ELangTagalog:
       
  4122         aValue = KTl;
       
  4123         break;
       
  4124 
       
  4125         case ELangBengali:
       
  4126         aValue = KBn;
       
  4127         break;
       
  4128 
       
  4129         case ELangBulgarian:
       
  4130         aValue = KBg;
       
  4131         break;
       
  4132 
       
  4133         case ELangBurmese:
       
  4134         aValue = KMy;
       
  4135         break;
       
  4136 
       
  4137         case ELangCatalan:
       
  4138         aValue = KCa;
       
  4139         break;
       
  4140 
       
  4141         case ELangCroatian:
       
  4142         aValue = KHr;
       
  4143         break;
       
  4144 
       
  4145         case ELangEstonian:
       
  4146         aValue = KEt;
       
  4147         break;
       
  4148 
       
  4149         case ELangFarsi:
       
  4150         aValue = KFa;
       
  4151         break;
       
  4152 
       
  4153         case ELangCanadianFrench:
       
  4154         aValue = KFrCA;
       
  4155         break;
       
  4156 
       
  4157         case ELangScotsGaelic:
       
  4158         aValue = KGd;
       
  4159         break;
       
  4160 
       
  4161         case ELangGeorgian:
       
  4162         aValue = KKa;
       
  4163         break;
       
  4164 
       
  4165         case ELangGreek:
       
  4166         case ELangCyprusGreek:
       
  4167         aValue = KEl;
       
  4168         break;
       
  4169 
       
  4170         case ELangGujarati:
       
  4171         aValue = KGu;
       
  4172         break;
       
  4173 
       
  4174         case ELangHebrew:
       
  4175         aValue = KHe;
       
  4176         break;
       
  4177 
       
  4178         case ELangHindi:
       
  4179         aValue = KHi;
       
  4180         break;
       
  4181 
       
  4182         case ELangIndonesian:
       
  4183         aValue = KId;
       
  4184         break;
       
  4185 
       
  4186         case ELangIrish:
       
  4187         aValue = KGa;
       
  4188         break;
       
  4189 
       
  4190         case ELangKannada :
       
  4191         aValue = KKn;
       
  4192         break;
       
  4193 
       
  4194 
       
  4195         case ELangKazakh:
       
  4196         aValue = KKk;
       
  4197         break;
       
  4198 
       
  4199         case ELangKhmer:
       
  4200         aValue = KKm;
       
  4201         break;
       
  4202 
       
  4203         case ELangKorean:
       
  4204         aValue = KKo;
       
  4205         break;
       
  4206 
       
  4207         case ELangLao:
       
  4208         aValue = KLo;
       
  4209         break;
       
  4210 
       
  4211         case ELangLatvian:
       
  4212         aValue = KLv;
       
  4213         break;
       
  4214 
       
  4215         case ELangLithuanian:
       
  4216         aValue = KLt;
       
  4217         break;
       
  4218 
       
  4219         case ELangMacedonian:
       
  4220         aValue = KMk;
       
  4221         break;
       
  4222 
       
  4223         case ELangMalay:
       
  4224         aValue = KMs;
       
  4225         break;
       
  4226 
       
  4227         case ELangMalayalam:
       
  4228         aValue = KMl;
       
  4229         break;
       
  4230 
       
  4231         case ELangMarathi:
       
  4232         aValue = KMr;
       
  4233         break;
       
  4234 
       
  4235         case ELangMoldavian:
       
  4236         aValue = KMo;
       
  4237         break;
       
  4238 
       
  4239         case ELangMongolian:
       
  4240         aValue = KMn;
       
  4241         break;
       
  4242 
       
  4243         case ELangPunjabi:
       
  4244         aValue = KPa;
       
  4245         break;
       
  4246 
       
  4247         case ELangRomanian:
       
  4248         aValue = KRo;
       
  4249         break;
       
  4250 
       
  4251         case ELangSerbian:
       
  4252         aValue = KSr;
       
  4253         break;
       
  4254 
       
  4255         case ELangSinhalese:
       
  4256         aValue = KSi;
       
  4257         break;
       
  4258 
       
  4259         case ELangSomali:
       
  4260         aValue = KSo;
       
  4261         break;
       
  4262 
       
  4263         case ELangSwahili:
       
  4264         aValue = KSw;
       
  4265         break;
       
  4266 
       
  4267         case ELangTamil:
       
  4268         aValue = KTa;
       
  4269         break;
       
  4270 
       
  4271         case ELangTelugu:
       
  4272         aValue = KTe;
       
  4273         break;
       
  4274 
       
  4275         case ELangTibetan:
       
  4276         aValue = KBo;
       
  4277         break;
       
  4278 
       
  4279         case ELangTigrinya:
       
  4280         aValue = KTi;
       
  4281         break;
       
  4282 
       
  4283         case ELangTurkmen:
       
  4284         aValue = KTk;
       
  4285         break;
       
  4286 
       
  4287         case ELangUkrainian:
       
  4288         aValue = KUk;
       
  4289         break;
       
  4290 
       
  4291         case ELangUrdu:
       
  4292         aValue = KUr;
       
  4293         break;
       
  4294 
       
  4295         case ELangVietnamese:
       
  4296         aValue = KVi;
       
  4297         break;
       
  4298 
       
  4299         case ELangWelsh:
       
  4300         aValue = KCy;
       
  4301         break;
       
  4302 
       
  4303         case ELangZulu:
       
  4304         aValue = KZu;
       
  4305         break;
       
  4306 
       
  4307         // from \\epoc32\\include\\oem\\languages.hrh
       
  4308 
       
  4309         case KLangTaiwanEnglish:
       
  4310         aValue = KEnTW;
       
  4311         break;
       
  4312 
       
  4313         case KLangHongKongEnglish:
       
  4314         aValue = KEnHK;
       
  4315                 break;
       
  4316 
       
  4317         case KLangPrcEnglish:
       
  4318         aValue = KEnCN;
       
  4319         break;
       
  4320 
       
  4321         case KLangJapaneseEnglish:
       
  4322         aValue = KEnJP;
       
  4323         break;
       
  4324 
       
  4325         case KLangThaiEnglish:
       
  4326         aValue = KEnTH;
       
  4327         break;
       
  4328 
       
  4329         case KLangApacMalay:
       
  4330         aValue = KMsAP;
       
  4331         break;
       
  4332 
       
  4333         case KLangApacEnglish:
       
  4334             {
       
  4335             aValue = KEnAP;
       
  4336             break;
       
  4337             }
       
  4338         case KLangApacIndonesian:
       
  4339             {
       
  4340             aValue = KIdAP;
       
  4341             break;
       
  4342             }
       
  4343         case KLangBasque:
       
  4344             {
       
  4345             aValue = KEu;
       
  4346             break;
       
  4347             }
       
  4348         case KLangGalician:
       
  4349             {
       
  4350             aValue = KGl;
       
  4351             break;
       
  4352             }
       
  4353 
       
  4354         // Cingular English
       
  4355         case 6154:
       
  4356         aValue = KEnUS;
       
  4357         break;
       
  4358 
       
  4359         default:
       
  4360         aValue = KDefault;
       
  4361         break;
       
  4362         }
       
  4363     }
       
  4364 
       
  4365 // --------------------------------------------------------------------------
       
  4366 // TInt CSvgDecoder::RemoveInternalReferences( CSvgElementImpl* )
       
  4367 // ---------------------------------------------------------------------------
       
  4368 void CSvgDecoder::RemoveInternalReferences( CSvgElementImpl* aElement )
       
  4369     {
       
  4370     // Remove the references of aElement in content handler's lists
       
  4371 
       
  4372     // Use Elements 
       
  4373     TInt lIndex = 0;
       
  4374     if ( aElement->ElemID() == KSvgUseElement )
       
  4375         {
       
  4376         lIndex = iUseElementArray->Find( aElement );
       
  4377         if ( lIndex != KErrNotFound )
       
  4378             {
       
  4379             iUseElementArray->Remove( lIndex );
       
  4380             }
       
  4381         }
       
  4382     else if ( aElement->ElemID() == KSvgSwitchElement )
       
  4383         {
       
  4384         // Switch Elements    
       
  4385         lIndex = iSwitchElementArray->Find( aElement );
       
  4386         if ( lIndex != KErrNotFound )
       
  4387             {
       
  4388             iSwitchElementArray->Remove( lIndex );
       
  4389             }
       
  4390         }
       
  4391     else if ( aElement->IsAnimatedElement() )
       
  4392         {
       
  4393         // Animation elements include animate* elements, set, 
       
  4394         // "animation",  audio elements etc.
       
  4395         lIndex = iAnimationElementArray->Find( aElement );
       
  4396         if ( lIndex != KErrNotFound )
       
  4397             {
       
  4398             iAnimationElementArray->Remove( lIndex );
       
  4399             }        
       
  4400         lIndex = iAnimRefElementArray->Find( aElement );
       
  4401         if ( lIndex != KErrNotFound )
       
  4402             {
       
  4403             iAnimRefElementArray->Remove( lIndex );
       
  4404             }
       
  4405         }
       
  4406     // Elements with test attributes - requiredFeatures, 
       
  4407     // requiredExtensions, systemLanguage
       
  4408     lIndex = iReqFetAttSysArray->Find( aElement );
       
  4409     if ( lIndex != KErrNotFound )
       
  4410         {
       
  4411         iReqFetAttSysArray->Remove( lIndex );
       
  4412         }
       
  4413 
       
  4414     // Remove Internal references of subtree elements as well
       
  4415     CSvgElementImpl* lChild = ( CSvgElementImpl* )aElement->FirstChild();
       
  4416     while ( lChild != NULL )
       
  4417         {
       
  4418         RemoveInternalReferences( lChild );
       
  4419         lChild = ( CSvgElementImpl* )lChild->NextSibling();
       
  4420         }
       
  4421 
       
  4422     }