svgtopt/SVG/SVGImpl/src/SVGAnimationBase.cpp
changeset 0 d46562c3d99d
child 19 df65ec4f2d28
equal deleted inserted replaced
-1:000000000000 0:d46562c3d99d
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVG Implementation source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #if !defined(__E32BASE_H__)
       
    20 #include <e32base.h>
       
    21 #endif
       
    22 
       
    23 #include "SVGAnimationBase.h"
       
    24 #include "SVGElementImpl.h"
       
    25 #include "SVGDocumentImpl.h"
       
    26 #include "SVGStringTokenizer.h"
       
    27 #include "SVGPointLexer.h"
       
    28 #include "SVGPathDataParser.h"
       
    29 #include "SVGAnimTimingParser.h"
       
    30 #include "SVGPaintCssValueImpl.h"
       
    31 #include "SVGIntCssValueImpl.h"
       
    32 
       
    33 //CONSTANTS
       
    34 _LIT(KSEMICOLON, ";");
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // No NewL or NewLC because this is abstract class
       
    38 // ---------------------------------------------------------------------------
       
    39 void CSvgAnimationBase::ConstructL(  const TUint8 aElemID )
       
    40     {
       
    41     CSvgElementImpl::InitializeL( aElemID );
       
    42 
       
    43     iAnimTime = CSvgAnimTimeController::NewL();
       
    44     iValuesFloat = new ( ELeave ) RArray<TFloatFixPt>( 1 );
       
    45     iValuesInt = new ( ELeave ) RArray<TInt32>( 1 );
       
    46     iValuesPath = new ( ELeave ) RPointerArray<CGfxGeneralPath>( 1 );
       
    47 	// viewBox
       
    48 	iValuesViewBox = new ( ELeave ) RArray<TGfxRectangle2D>( 1 );
       
    49     iEventList = new ( ELeave )CArrayFixFlat<TEventListItem>( 1 );
       
    50     iEndTimeList = new ( ELeave )CArrayFixFlat<TEventListItem>( 1 );
       
    51 	/*Added to Support forward referencing*/
       
    52 	iSvgUriReferenceImpl = CSvgUriReferenceImpl::NewL();
       
    53     ((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL(
       
    54                                                     this, KSvgEventMaskTimer );
       
    55     }
       
    56 
       
    57 
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 // ---------------------------------------------------------------------------
       
    63 
       
    64 CSvgAnimationBase::CSvgAnimationBase( CSvgDocumentImpl* aDoc ) :
       
    65                                                                  iAnimStatus( KAnimNotActive ),
       
    66                                                                  iTargetElement( NULL ),
       
    67                                                                  iEndOffset( 0 ),
       
    68                                                                  iRepeatCount( 1 ),
       
    69                                                                  iRepeatEndValue ( 0 ) ,
       
    70                                                                  iAbsoluteBeginTime ( 0 ),
       
    71                                                                  iBeginTimeIndex( 0 ) ,
       
    72                                                               //   iEndAccessKeyCode( 0 ),
       
    73                                                                  iCurrentRepeatCount( 0 ),
       
    74                                                                  iAttrId( 0xffff ),
       
    75                                                                  iInitDone( EFalse ),
       
    76                                                                  iTargetSet( EFalse ),
       
    77                                                                  iNoFrom( ETrue ),
       
    78                                                                  iHaveTo( EFalse ),
       
    79                                                                  iHaveBy( EFalse ),
       
    80                                                                  iHaveValues (EFalse),
       
    81                                                                  iFill( KAnimFillRemove ),
       
    82                                                                  iHadBegun( EFalse ),
       
    83                                                                  iAnimRestart( KRestartAlways ),
       
    84                                                                  iAccumulate( KAccumNone ),
       
    85                                                                  iAdditive( KAdditivePass ),
       
    86                                                                  iAdditiveOrg( KAdditiveReplace ),
       
    87                                                                  iOverrideTime ( EFalse ),
       
    88                                                                  iRepeatCountSet ( EFalse ),
       
    89 																 iKeyTimesPresent(EFalse),
       
    90 																// iEndReferenceElemeId(NULL),
       
    91 																 iIsUserSeek(EFalse),
       
    92 																 iEndTimeIndex(0)
       
    93 
       
    94 
       
    95     {
       
    96     SetOwnerDocument(aDoc);
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 // ---------------------------------------------------------------------------
       
   102 CSvgAnimationBase::~CSvgAnimationBase()
       
   103     {
       
   104     if ( iAnimTime )
       
   105         {
       
   106         delete iAnimTime;
       
   107         iAnimTime = NULL;
       
   108         }
       
   109 
       
   110 
       
   111 	if (iRepeatId)
       
   112 	{
       
   113 		delete iRepeatId;
       
   114 		iRepeatId = NULL;
       
   115 	}
       
   116 
       
   117     if ( iValuesInt )
       
   118         {
       
   119         iValuesInt->Close();
       
   120         delete iValuesInt;
       
   121         iValuesInt = NULL;
       
   122         }
       
   123 
       
   124     if ( iValuesViewBox )
       
   125         {
       
   126         iValuesViewBox->Close();
       
   127         delete iValuesViewBox;
       
   128         iValuesViewBox = NULL;
       
   129         }
       
   130 
       
   131     if ( iValuesFloat )
       
   132         {
       
   133         iValuesFloat->Close();
       
   134         delete iValuesFloat;
       
   135         iValuesFloat = NULL;
       
   136         }
       
   137 
       
   138     if ( iOrgPath )
       
   139         {
       
   140         delete iOrgPath;
       
   141         iOrgPath = NULL;
       
   142         }
       
   143 
       
   144     if ( iEndPath )
       
   145         {
       
   146         delete iEndPath;
       
   147         iEndPath = NULL;
       
   148         }
       
   149 
       
   150     if ( iOrgFromPath )
       
   151         {
       
   152         delete iOrgFromPath;
       
   153         iOrgFromPath = NULL;
       
   154         }
       
   155 
       
   156     if ( iFromPath )
       
   157         {
       
   158         delete iFromPath;
       
   159         iFromPath = NULL;
       
   160         }
       
   161 
       
   162     if ( iToPath )
       
   163         {
       
   164         delete iToPath;
       
   165         iToPath = NULL;
       
   166         }
       
   167 
       
   168     if ( iValuesPath )
       
   169         {
       
   170         iValuesPath->ResetAndDestroy();
       
   171         iValuesPath->Close();
       
   172         delete iValuesPath;
       
   173         iValuesPath = NULL;
       
   174         }
       
   175 
       
   176 	if ( iSvgUriReferenceImpl )
       
   177 		{
       
   178 		delete iSvgUriReferenceImpl;
       
   179 		iSvgUriReferenceImpl = NULL;
       
   180 		}
       
   181 
       
   182 
       
   183     if ( iEventList )
       
   184         {
       
   185 		TInt lCount = iEventList->Count();
       
   186 	    for(TInt i= 0; i< lCount; i++)
       
   187 	    {
       
   188 	    if(iEventList->operator[](i).iReferenceElemeId)
       
   189 	    	{
       
   190 	    	delete iEventList->operator[](i).iReferenceElemeId;
       
   191 	    	iEventList->operator[](i).iReferenceElemeId = NULL;
       
   192 	    	}
       
   193 	 	}
       
   194         delete iEventList;
       
   195         iEventList = NULL;
       
   196         }
       
   197 
       
   198      if ( iEndTimeList )
       
   199         {
       
   200         TInt lCount2 = iEndTimeList->Count();
       
   201 	    for(TInt i= 0; i< lCount2; i++)
       
   202 	    {
       
   203 	    if(iEndTimeList->operator[](i).iReferenceElemeId)
       
   204 	    	{
       
   205 	    	delete iEndTimeList->operator[](i).iReferenceElemeId;
       
   206 	    	iEndTimeList->operator[](i).iReferenceElemeId = NULL;
       
   207 	    	}
       
   208 	 	}
       
   209 
       
   210         delete iEndTimeList;
       
   211         iEndTimeList = NULL;
       
   212         }
       
   213 
       
   214     //remove this from the animation list
       
   215     CSvgDocumentImpl* lOwnerDocument = (CSvgDocumentImpl*)iOwnerDocument;
       
   216     if (lOwnerDocument)
       
   217     {
       
   218     	TInt index = lOwnerDocument->iSvgAnimations.Find(this);
       
   219 
       
   220     	if (index != KErrNotFound)
       
   221     	{
       
   222     		lOwnerDocument->iSvgAnimations.Remove( index );
       
   223     	}
       
   224     }
       
   225 
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 // ---------------------------------------------------------------------------
       
   231 TUint32 CSvgAnimationBase::SimpleDuration()
       
   232     {
       
   233 	TUint32 lEndTime= KTimeIndefinite;
       
   234 	TUint32 lDur= KTimeIndefinite;
       
   235 
       
   236 	if(iAbsoluteBeginTime == (TInt32)KTimeIndefinite)
       
   237 		{
       
   238 		return KTimeIndefinite;
       
   239 		}
       
   240 	if ( iAnimTime->DurationTime() == 0 )
       
   241         { 
       
   242         // If the animation's dur is specified as 0, then the Simple duration
       
   243         // of this animation is 0. This is done so that the animation should not happen
       
   244         return 0;
       
   245         }
       
   246 
       
   247 	lEndTime = iAnimTime->EndTime();
       
   248 	if ( lEndTime <= iAnimTime->BeginTime() )
       
   249 	   {
       
   250 	    lEndTime= KTimeIndefinite;
       
   251 	   } 
       
   252 
       
   253     if ( iRepeatCount == KRepeatCountMax )
       
   254         {
       
   255         if ( iAnimTime->RepeatDurationTime() == KTimeIndefinite )
       
   256             {
       
   257             lDur=  KTimeIndefinite;   // Neither are specified
       
   258             }
       
   259         else    // RepeatDur was specified.
       
   260             {
       
   261             lDur= iAbsoluteBeginTime + iAnimTime->RepeatDurationTime();
       
   262             }
       
   263         }
       
   264 
       
   265     else if( (iAnimTime->DurationTime() == KTimeIndefinite || iAnimTime->DurationTime() == KIndefiniteAnimationDuration)
       
   266      			&& ( this->ElemID() != KSvgSetElement ) )
       
   267     	{
       
   268          lDur= KTimeIndefinite;
       
   269     	 return lDur;
       
   270     	}
       
   271     else        // RepeatCount was specified.
       
   272         {
       
   273         if ( iAnimTime->RepeatDurationTime() == KTimeIndefinite )
       
   274             {
       
   275             lDur= (TUint32) (iAbsoluteBeginTime + iAnimTime->DurationTime() * iRepeatCount);
       
   276             }
       
   277         else    // Both are specified.  Return the minimum time.
       
   278             {
       
   279             if ( iAnimTime->RepeatDurationTime() < ( iAnimTime->DurationTime() * iRepeatCount ) )
       
   280                 {
       
   281                 lDur= iAbsoluteBeginTime + iAnimTime->RepeatDurationTime();
       
   282                 }
       
   283             else
       
   284                 {
       
   285                 lDur= (TUint32) (iAbsoluteBeginTime + iAnimTime->DurationTime() * iRepeatCount);
       
   286                 }
       
   287             }
       
   288         }
       
   289 
       
   290 	// should return the Minimum of end time and calculated duration
       
   291 	if(lDur <= lEndTime)
       
   292 		return lDur;
       
   293 	else
       
   294 		return lEndTime;
       
   295 
       
   296 
       
   297     }
       
   298 TUint32 CSvgAnimationBase::CompleteDuration()
       
   299     {
       
   300 	TUint32 lDur= KTimeIndefinite;
       
   301 
       
   302     TUint32 lEndTime = iAnimTime->LastEndTime();
       
   303 	TUint32 lBeginTime = iAnimTime->LastBeginTime();
       
   304 	
       
   305 	if(lBeginTime == (TInt32)KTimeIndefinite)
       
   306 		{
       
   307 		return KTimeIndefinite;
       
   308 		}
       
   309 	if ( iAnimTime->DurationTime() == 0 )
       
   310         { 
       
   311         // If the animation's dur is specified as 0, then the Simple duration
       
   312         // of this animation is 0. This is done so that the animation should not happen
       
   313         return 0;
       
   314         }
       
   315 
       
   316 	
       
   317 	if ( lEndTime <= lBeginTime)
       
   318 	   {
       
   319 	    // When animation's end time is <= its begin time, it means that the 
       
   320 	    // animation should be treated as an indefinite animation and animation
       
   321 	    // never becomes active
       
   322 		lEndTime = KTimeIndefinite; 
       
   323 		
       
   324 	   } 
       
   325 
       
   326     if ( iRepeatCount == KRepeatCountMax )
       
   327         {
       
   328         if ( iAnimTime->RepeatDurationTime() == KTimeIndefinite )
       
   329             {
       
   330             lDur=  KTimeIndefinite;   // Neither are specified
       
   331             }
       
   332         else    // RepeatDur was specified.
       
   333             {
       
   334             lDur= lBeginTime + iAnimTime->RepeatDurationTime();
       
   335             }
       
   336         }
       
   337 
       
   338     else if( (iAnimTime->DurationTime() == KTimeIndefinite || iAnimTime->DurationTime() == KIndefiniteAnimationDuration)
       
   339      			&& ( this->ElemID() != KSvgSetElement ) )
       
   340     	{
       
   341          lDur= KTimeIndefinite;
       
   342     	 return lDur;
       
   343     	}
       
   344     else        // RepeatCount was specified.
       
   345         {
       
   346         if ( iAnimTime->RepeatDurationTime() == KTimeIndefinite )
       
   347             {
       
   348             lDur= (TUint32) (lBeginTime + iAnimTime->DurationTime() * iRepeatCount);
       
   349             }
       
   350         else    // Both are specified.  Return the minimum time.
       
   351             {
       
   352             if ( iAnimTime->RepeatDurationTime() < ( iAnimTime->DurationTime() * iRepeatCount ) )
       
   353                 {
       
   354                 lDur= lBeginTime + iAnimTime->RepeatDurationTime();
       
   355                 }
       
   356             else
       
   357                 {
       
   358                 lDur= (TUint32) (lBeginTime + iAnimTime->DurationTime() * iRepeatCount);
       
   359                 }
       
   360             }
       
   361         }
       
   362 
       
   363 	// should return the Minimum of end time and calculated duration
       
   364 	if(lDur <= lEndTime)
       
   365 		return lDur;
       
   366 	else
       
   367 		return lEndTime;
       
   368 
       
   369 
       
   370     }
       
   371 
       
   372 
       
   373 // From SVG DOM / MElementTimeControl
       
   374 // ---------------------------------------------------------------------------
       
   375 //
       
   376 // ---------------------------------------------------------------------------
       
   377 TBool CSvgAnimationBase::BeginElementL()
       
   378     {
       
   379 
       
   380     SetBeginByEventL( this, ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() );
       
   381 
       
   382     return EFalse;
       
   383     }
       
   384 
       
   385 // ---------------------------------------------------------------------------
       
   386 //
       
   387 // ---------------------------------------------------------------------------
       
   388 TBool CSvgAnimationBase::BeginElementAtL( TFloatFixPt aOffset )
       
   389     {
       
   390     TInt32  offset  = aOffset.RawData() / KBeginElementOffsetRatio /* *1000/65536 */;
       
   391     SetBeginByEventL( this, ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() + offset );
       
   392 
       
   393     return EFalse;
       
   394     }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 //
       
   398 // ---------------------------------------------------------------------------
       
   399 TBool CSvgAnimationBase::EndElement()
       
   400     {
       
   401     SetEndByEvent( this, ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() );
       
   402 
       
   403 
       
   404     return EFalse;
       
   405     }
       
   406 
       
   407 // ---------------------------------------------------------------------------
       
   408 //
       
   409 // ---------------------------------------------------------------------------
       
   410 TBool CSvgAnimationBase::EndElementAt( TFloatFixPt aOffset )
       
   411     {
       
   412     TInt32  offset  = aOffset.RawData() / 66 /* *1000/65536 */;
       
   413 
       
   414     SetEndByEvent( this, ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() + offset );
       
   415 
       
   416 
       
   417     return EFalse;
       
   418     }
       
   419 
       
   420 
       
   421 // *******************************************************
       
   422 // SVG Implementation
       
   423 
       
   424 
       
   425 // *******************************************************
       
   426 // From MXmlElement
       
   427 
       
   428 
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 // ---------------------------------------------------------------------------
       
   432 TInt CSvgAnimationBase::SetAttributeL( const TDesC& aName, const TDesC& aValue )
       
   433     {
       
   434 
       
   435     // Before anything else set the target to parent
       
   436     if ( !iTargetSet )
       
   437         {
       
   438         iTargetElement = ( CSvgElementImpl * ) ParentNode();// default is parent element
       
   439 			if (iTargetElement)
       
   440 			{
       
   441         iTargetSet = ETrue;
       
   442 			}
       
   443         }
       
   444 
       
   445     _LIT( KTmpAttrName, "attributeName" );
       
   446     _LIT( KTmpXlinkHref, "xlink:href" );
       
   447     _LIT( KTmpBegin, "begin" );
       
   448     _LIT( KTmpDur, "dur" );
       
   449     _LIT( KTmpRepeatDur, "repeatDur" );
       
   450     _LIT( KTmpEnd, "end" );
       
   451     _LIT( KTmpFrom, "from" );
       
   452     _LIT( KTmpTo, "to" );
       
   453     _LIT( KTmpBy, "by" );
       
   454     _LIT( KTmpFill, "fill" );
       
   455     _LIT( KTmpRestart, "restart" );
       
   456     _LIT( KTmpRepeatCount, "repeatCount" );
       
   457     _LIT( KTmpAccumulate, "accumulate" );
       
   458     _LIT( KTmpAdditive, "additive" );
       
   459 
       
   460     _LIT( KTmpValues, "values" );
       
   461     _LIT( KTmpCalcMode, "calcMode" );
       
   462     _LIT( KTmpKeyTimes, "keyTimes" );
       
   463     _LIT( KTmpKeySplines, "keySplines" );
       
   464 
       
   465     _LIT( KTmpIndefinite, "indefinite" );
       
   466 
       
   467 
       
   468     if ( SetIdandXmlbaseL( aName, aValue ) )
       
   469         {
       
   470         return KErrNone;
       
   471         }
       
   472 
       
   473 
       
   474      if ( aName == KTmpXlinkHref )
       
   475         {
       
   476 		// STEP 1 - Get the reference element
       
   477 		// If the first char is '#' then remove it
       
   478 		// This is possible if coming from cXML parser and not CVG Decoder
       
   479 		TInt pos = aValue.Locate( '#' );
       
   480 		if ( pos != KErrNotFound && pos == 0 )
       
   481 			{
       
   482 			HBufC*  tBufC   = HBufC::NewLC( aValue.Length() );
       
   483 			TPtr    tPtr    = tBufC->Des();
       
   484 			tPtr.Copy( aValue );
       
   485 			tPtr.Delete( pos, 1 );
       
   486 			CSvgElementImpl *lElement = ( CSvgElementImpl * )
       
   487 			((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( tPtr );
       
   488 			if(this->SetXlinkAttributeL( aName, tPtr ))
       
   489 				{
       
   490 				if(lElement)
       
   491 					{
       
   492 					SetTarget(lElement);
       
   493 					}
       
   494 				else
       
   495 					{
       
   496 					CleanupStack::PopAndDestroy( 1 );
       
   497 					return KErrAnimateReferenceElementNotFound;
       
   498 					}
       
   499 				}
       
   500 			CleanupStack::PopAndDestroy( 1 );
       
   501 			}
       
   502 
       
   503         if ( !iTargetElement )
       
   504             {
       
   505             iAttrId = 0xffff;
       
   506             return KErrNoAttribute;
       
   507             }
       
   508        else if((    iTargetElement->ElemID() == KSvgRadialGradientElement
       
   509                     || iTargetElement->ElemID() == KSvgLinearGradientElement)
       
   510                      && (iAttrId == KAtrGradientTransform))
       
   511             {
       
   512             iAttrId = KAtrTransform;
       
   513             }
       
   514         GetAttrValueL();
       
   515         return KErrNone;
       
   516         }
       
   517 
       
   518     if ( aName == KTmpAttrName )
       
   519         {
       
   520         iReqAttrFlag = 0;
       
   521 
       
   522         iAnimStatus = KAnimNotActive;
       
   523 
       
   524         if (iTargetElement)
       
   525             {
       
   526           	iTargetElement->iHasAnimationBase = (TInt)this;
       
   527         	iTargetElement->SetIsAnimating( EFalse );
       
   528         	SetIsAnimating( EFalse );
       
   529             }
       
   530 
       
   531         if ( !IsElementAttrs( aValue ) && !IsPresentationAttrs( aValue ) )
       
   532             {
       
   533             iAttrId = 0xffff; // Not supported attribute.
       
   534             }
       
   535         else
       
   536             {
       
   537             if(!iTargetElement)
       
   538             {
       
   539              iAttrId = 0xffff;
       
   540              return KErrNoAttribute;
       
   541             }
       
   542             GetAttrValueL();
       
   543             }
       
   544         }
       
   545     else if ( aName == KTmpBegin )
       
   546         {
       
   547 		iIsBeginSet=  ETrue;
       
   548         if ( aValue == KTmpIndefinite )
       
   549             {
       
   550             iAnimTime->SetBeginTime( KTimeIndefinite );
       
   551             iAbsoluteBeginTime = KTimeIndefinite;
       
   552             }
       
   553 
       
   554         else
       
   555             {
       
   556             TStringTokenizer    tkn ( aValue, KSEMICOLON );
       
   557 				    while ( tkn.HasMoreTokens() )
       
   558 				        {
       
   559 				        TPtrC   lToken  = tkn.NextToken();
       
   560 				        CSvgAnimTimingParser*   atParser    = CSvgAnimTimingParser::NewLC( lToken, this );
       
   561 				        TInt32                  clockValue;
       
   562 				        HBufC* lBeginSyncElementId = HBufC::NewL(lToken.Length());
       
   563 				        TSvgEvent  lBeginReferenceEvent;
       
   564 				        TReal32    lRepeatBeginValue;
       
   565 				        TPtr ptr = lBeginSyncElementId->Des();
       
   566 				        atParser->Parse( ptr,
       
   567 				                     lBeginReferenceEvent,
       
   568 				                     clockValue,
       
   569 				                     lRepeatBeginValue,
       
   570 				                     ETrue);
       
   571 				
       
   572 				        TEventListItem tmp;
       
   573 				        if ( lBeginSyncElementId->Length() <= 0 )
       
   574 				            {
       
   575 				            tmp.iTargetElement = iTargetElement;
       
   576 				            tmp.iReferenceElemeId= NULL;
       
   577 				            }
       
   578 				         else
       
   579 				         	{
       
   580 				        	// get element by id and append its pointer.
       
   581 				
       
   582 				        	// there can be an issue if the id is not found. in  case of forward reference.
       
   583 				        	// for this we will store the id if it is not found at this time.
       
   584 				        	tmp.iTargetElement = ( CSvgElementImpl * )
       
   585 				             ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( *lBeginSyncElementId );
       
   586 				
       
   587 				             if( tmp.iTargetElement == NULL)
       
   588 				             	{
       
   589 				             	// this indicates that this is a forward reference in case of begin.
       
   590 				
       
   591 				             	tmp.iReferenceElemeId = lBeginSyncElementId->AllocL();
       
   592 				             	}
       
   593 				             else
       
   594 				             	{
       
   595 				             	// otherwise the element is found and we
       
   596 				             	// do not need to keep iBeginReferenceElemeId so
       
   597 				             	// make it NULL;
       
   598 				             	tmp.iReferenceElemeId = NULL;
       
   599 				             	}
       
   600 				          	}
       
   601 				        if ( clockValue < 0 ) // Himanshu:to check the negative begin value
       
   602 				            {
       
   603 				                iNegativeBeginTime = clockValue;
       
   604 				                
       
   605 				                // adjusting the duration time if already set before
       
   606 				                TInt32 aNewDurationTime = iAnimTime->GetDurationTime();
       
   607 				                if ( aNewDurationTime != KTimeIndefinite ) 
       
   608 				                    {
       
   609 				                      aNewDurationTime += clockValue;
       
   610 				                      iAnimTime->SetDurationTime(aNewDurationTime); 
       
   611 				                    }
       
   612 				                // adjusting the end time if already set before    
       
   613 				                TInt32 aNewEndTime = iAnimTime->GetEndTime();   
       
   614 				                if ( aNewEndTime > 0 && aNewEndTime < KTimeIndefinite )  
       
   615 				                    {
       
   616 				                      aNewEndTime += clockValue;
       
   617 				                      iAnimTime->SetEndTime(aNewEndTime);
       
   618 				                    }
       
   619 				                    
       
   620 				                clockValue = 0; // set clockValue to 0 if negative begin
       
   621 				            }
       
   622 				
       
   623 				        tmp.iEvent = lBeginReferenceEvent;
       
   624 				        tmp.iTime  = clockValue;
       
   625 				
       
   626 				        switch ( lBeginReferenceEvent )
       
   627 				            {
       
   628 				            case ESvgEventKey:
       
   629 					            {
       
   630 					            iAnimTime->SetBeginTime( KTimeIndefinite );
       
   631 					            iAbsoluteBeginTime = KTimeIndefinite;
       
   632 					            tmp.iAccessKeyCode = atParser->AccekeyValue();
       
   633 					            tmp.iOffset =  clockValue;
       
   634 					            tmp.iTargetElement = NULL;
       
   635 					            ((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL( this,
       
   636 					                                                KSvgEventMaskExternalUI );
       
   637 					            }
       
   638 				            break;
       
   639 				            case ESvgEventWallClock:
       
   640 				                {
       
   641 				            // not supported yet
       
   642 				                }
       
   643 				            break;
       
   644 				
       
   645 				            case ESvgEventNone:
       
   646 				                 {
       
   647 					            // Simple Offset-value
       
   648 						            iAnimTime->AddBeginTime( clockValue );
       
   649 												iAbsoluteBeginTime = clockValue;
       
   650 												tmp.iTargetElement = NULL;
       
   651 				                }
       
   652 				            break;
       
   653 				
       
   654 				            case ESvgEventRepeatEvent:
       
   655 				                {
       
   656 				                iAnimTime->SetBeginTime( KTimeIndefinite );
       
   657 				                iAbsoluteBeginTime = KTimeIndefinite;
       
   658 				
       
   659 				                tmp.iOffset =  clockValue;
       
   660 				                tmp.iRepeatValue = lRepeatBeginValue;
       
   661 				                }
       
   662 				            break;
       
   663 				            default:
       
   664 					            {
       
   665 				                iAnimTime->SetBeginTime( KTimeIndefinite );
       
   666 				                iAbsoluteBeginTime = KTimeIndefinite;
       
   667 				                tmp.iTime = KTimeIndefinite;
       
   668 				                tmp.iOffset =  clockValue;
       
   669 				
       
   670 				                ((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL( this,
       
   671 				                                                KSvgEventMaskInternal );
       
   672 					            }
       
   673 				            break;
       
   674 				            }
       
   675 								delete lBeginSyncElementId;
       
   676 				        iEventList->AppendL(tmp);
       
   677 				        CleanupStack::PopAndDestroy( 1 );     // atParser
       
   678 				        }
       
   679 				        iAnimTime->SaveBeginTime();
       
   680             }
       
   681 
       
   682             if ( ( ((CSvgDocumentImpl*)iOwnerDocument)->Engine() && iAnimTime && ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() >= iAnimTime->BeginTime() )
       
   683              || ( iAnimTime && ((CSvgDocumentImpl*)iOwnerDocument)->iTimeForJSR226 >= iAnimTime->BeginTime() ) )
       
   684 				{
       
   685         	iTargetElement->SetIsAnimating( ETrue );
       
   686         	SetIsAnimating( ETrue );
       
   687 				}
       
   688 
       
   689         }
       
   690     else if ( aName == KTmpDur )
       
   691         {
       
   692         if ( aValue == KTmpIndefinite )
       
   693             {
       
   694             iAnimTime->SetDurationTime( KTimeIndefinite );
       
   695             }
       
   696         else
       
   697             {
       
   698             CSvgAnimTimingParser*   atParser    = CSvgAnimTimingParser::NewLC( aValue, this );
       
   699             TInt32                  clockValue;
       
   700             TLex                    lex         ( aValue );
       
   701             atParser->ParseClockValue( lex, clockValue );
       
   702             CleanupStack::PopAndDestroy( 1 );     // atParser
       
   703 
       
   704             if (clockValue >= 0)
       
   705                 {
       
   706                   if ( iNegativeBeginTime < 0 ) //Himanshu: adjusting the duration if negative begin time is given
       
   707                     {
       
   708                         clockValue += iNegativeBeginTime; 
       
   709                     }
       
   710                 iAnimTime->SetDurationTime( clockValue );
       
   711                 }
       
   712             else
       
   713                 {
       
   714                 iAnimTime->SetDurationTime( KTimeIndefinite );
       
   715 
       
   716                 if ( !iAnimTime->BeginTime() )
       
   717                     {
       
   718                     iAnimTime->SetBeginTime( KTimeIndefinite );
       
   719                     }
       
   720                 }
       
   721             }
       
   722         }
       
   723     else if ( aName == KTmpRepeatDur )
       
   724         {
       
   725         if ( aValue == KTmpIndefinite )
       
   726             {
       
   727             iAnimTime->SetRepeatDurationTime( KTimeIndefinite );
       
   728             // Set Repeat Count to max if not set
       
   729             if ( ! iRepeatCountSet )
       
   730                 {
       
   731                 iRepeatCount = KRepeatCountMax;
       
   732                 }            
       
   733             }
       
   734         else
       
   735             {
       
   736             CSvgAnimTimingParser*   atParser    = CSvgAnimTimingParser::NewLC( aValue, this );
       
   737             TInt32                  clockValue;
       
   738             TLex                    lex         ( aValue );
       
   739             atParser->ParseClockValue( lex, clockValue );
       
   740             CleanupStack::PopAndDestroy( 1 );     // atParser
       
   741             // Set the repeat duration time only if the clock value 
       
   742             // is valid
       
   743             if( clockValue != KTimeIndefinite )
       
   744                 {
       
   745                 iAnimTime->SetRepeatDurationTime( clockValue );
       
   746                     
       
   747                 // Set Repeat Count to max if not set
       
   748                 if ( ! iRepeatCountSet )
       
   749                     {
       
   750                     iRepeatCount = KRepeatCountMax;
       
   751                     }  
       
   752                 }
       
   753             }
       
   754         }
       
   755     else if ( aName == KTmpEnd )
       
   756         {
       
   757         if ( aValue == KTmpIndefinite )
       
   758             {
       
   759             iAnimTime->SetEndTime( KTimeIndefinite );
       
   760             }
       
   761         else
       
   762             {
       
   763             TStringTokenizer    tkn ( aValue, KSEMICOLON );
       
   764             while ( tkn.HasMoreTokens() )
       
   765             {
       
   766             TPtrC   lToken  = tkn.NextToken();
       
   767             CSvgAnimTimingParser*   atParser    = CSvgAnimTimingParser::NewLC( lToken, this );
       
   768             TInt32                  clockValue;
       
   769 
       
   770 
       
   771 			TBuf<28>   lEndSyncElementId;
       
   772 
       
   773             TSvgEvent  lEndReferenceEvent;
       
   774             TReal32    lRepeatEndValue;
       
   775             atParser->Parse( lEndSyncElementId,
       
   776                              lEndReferenceEvent,
       
   777                              clockValue,
       
   778                              lRepeatEndValue,
       
   779                              EFalse);
       
   780                 TEventListItem tmp;
       
   781 
       
   782              if ( iNegativeBeginTime < 0 ) //Himanshu: adjusting the end time if negative begin is given
       
   783                 {
       
   784                    clockValue += iNegativeBeginTime; 
       
   785                 }  
       
   786               if ( lEndSyncElementId.Length() <= 0 )
       
   787                 {
       
   788                tmp.iTargetElement = iTargetElement;
       
   789                tmp.iReferenceElemeId= NULL;
       
   790 			    }
       
   791             else
       
   792             	{
       
   793             	// get element by id and append its pointer.
       
   794 
       
   795                 	// there can be an issue if the id is not found. in  case of forward reference.
       
   796                 	// for this we will store the id if it is not found at this time.
       
   797                 	tmp.iTargetElement = ( CSvgElementImpl * )
       
   798                      ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( lEndSyncElementId );
       
   799 
       
   800                      if( tmp.iTargetElement == NULL)
       
   801                      	{
       
   802                      	// this indicates that this is a forward reference in case of begin.
       
   803 
       
   804                      	tmp.iReferenceElemeId = lEndSyncElementId.AllocL();
       
   805                      	}
       
   806                      else
       
   807                      	{
       
   808                      	// otherwise the element is found and we
       
   809                      	// do not need to keep iReferenceElemeId so
       
   810                      	// make it NULL;
       
   811                      	tmp.iReferenceElemeId = NULL;
       
   812                      	}
       
   813             	}
       
   814             	 tmp.iEvent = lEndReferenceEvent;
       
   815                 tmp.iTime  = clockValue;
       
   816 				tmp.iRepeatValue = lRepeatEndValue;
       
   817 
       
   818 
       
   819             switch ( lEndReferenceEvent )
       
   820                 {
       
   821                 case ESvgEventKey:
       
   822                 //iAnimTime->SetEndTime( KTimeIndefinite );  // same as indefinite
       
   823                  tmp.iAccessKeyCode = atParser->AccekeyValue();
       
   824                  tmp.iOffset =  clockValue;
       
   825                  tmp.iTargetElement = NULL;
       
   826 
       
   827                 /*iEndAccessKeyCode = atParser->AccekeyValue(); */
       
   828 
       
   829                 ((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL( this,
       
   830                                                         KSvgEventMaskExternalUI );
       
   831                 break;
       
   832 
       
   833                 case ESvgEventWallClock:
       
   834                 // not supported yet
       
   835                 break;
       
   836 
       
   837                 case ESvgEventNone:
       
   838                 // Simple Offset-value
       
   839                 iAnimTime->AddEndTime( clockValue );
       
   840                 tmp.iTargetElement = NULL;
       
   841                 break;
       
   842 
       
   843                 default:
       
   844                 // <id>.<event> +/- <offeset>
       
   845                 //iAnimTime->SetEndTime( KTimeIndefinite );  // same as indifinite
       
   846                /* iEndOffset = clockValue;*/
       
   847 
       
   848 				 tmp.iTime = KTimeIndefinite;
       
   849                  tmp.iOffset =  clockValue;
       
   850 
       
   851                 ((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL( this,
       
   852                                                         KSvgEventMaskInternal );
       
   853                 }
       
   854 			iEndTimeList->AppendL(tmp);
       
   855             CleanupStack::PopAndDestroy( 1 );     // atParser
       
   856             }
       
   857             iAnimTime->SaveEndTime();
       
   858             }
       
   859 
       
   860             if ( ( ((CSvgDocumentImpl*)iOwnerDocument)->Engine() && iAnimTime && ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() > iAnimTime->EndTime() )
       
   861              || ( iAnimTime && ((CSvgDocumentImpl*)iOwnerDocument)->iTimeForJSR226 > iAnimTime->EndTime() ) )
       
   862 				{
       
   863         	    iTargetElement->SetIsAnimating( EFalse );
       
   864             	SetIsAnimating( EFalse );
       
   865 				}
       
   866         }
       
   867     else if ( aName == KTmpFrom )
       
   868         {
       
   869         iNoFrom = EFalse;
       
   870         // parser needed
       
   871         switch ( iDataType )
       
   872             {
       
   873             case KSvgTypeOpacity:
       
   874                 {
       
   875 
       
   876                 TBool lPercentage = EFalse;
       
   877                 if (aValue.Locate('%') != KErrNotFound)
       
   878 		 		{
       
   879 		 			lPercentage = ETrue;
       
   880 		 		}
       
   881 
       
   882                 TLex    lString ( aValue );
       
   883                 TReal32  lVal;
       
   884                 if (lString.Val( lVal, '.' ) != KErrNone)
       
   885                     {
       
   886                     lVal=1;
       
   887                     }
       
   888 
       
   889                 if (lPercentage)
       
   890                 {
       
   891                 	lVal = lVal / TReal32(100);
       
   892                 }
       
   893 
       
   894                 if(lVal>1)
       
   895                     {
       
   896                     lVal=1;
       
   897                     }
       
   898                 if(lVal<0)
       
   899                     {
       
   900                     lVal=0;
       
   901                     }
       
   902                 iOrgFromFloat = iFromFloat = lVal;
       
   903                 }
       
   904             break;
       
   905             case KSvgTypeGradientUnits:
       
   906                     {
       
   907                      if(aValue == _L("objectBoundingBox"))
       
   908                       {
       
   909                       iOrgFromInt = iFromInt =  1;
       
   910                       }
       
   911                      else if(aValue == _L("userSpaceOnUse"))
       
   912                       {
       
   913                      iOrgFromInt = iFromInt =  0;
       
   914                       }
       
   915                     }
       
   916             break;
       
   917             case KSvgTypeLength:
       
   918                 {
       
   919                 TLex    string  ( aValue );
       
   920                 TReal32 val;
       
   921                 if( string.Val( val, '.' ) != KErrNone)
       
   922                     {
       
   923                     val = 0;
       
   924                     }
       
   925                 iOrgFromFloat = iFromFloat = val;
       
   926                 }
       
   927             break;
       
   928             case KSvgTypeList:
       
   929             case KSvgTypePath:
       
   930                 {
       
   931                 if ( iOrgFromPath )
       
   932                     {
       
   933                     delete iOrgFromPath;
       
   934                     iOrgFromPath = NULL;
       
   935                     }
       
   936                 iOrgFromPath = CGfxGeneralPath::NewL();
       
   937 
       
   938                 // Destroy iFromPath first, because it was built before during init
       
   939                 if ( iFromPath )
       
   940                     {
       
   941                     delete iFromPath;
       
   942                     iFromPath = NULL;
       
   943                     }
       
   944                 iFromPath = CGfxGeneralPath::NewL();
       
   945 
       
   946                 if ( iAttrId == KAtrPoints ) //.
       
   947                     {
       
   948                     TSvgPathDataParser::ParsePointDataL( aValue, iOrgFromPath );
       
   949                     TSvgPathDataParser::ParsePointDataL( aValue, iFromPath );
       
   950                     }
       
   951                 else
       
   952                     {
       
   953                     TSvgPathDataParser::ParsePathData( aValue, iOrgFromPath );
       
   954                     TSvgPathDataParser::ParsePathData( aValue, iFromPath );
       
   955                     }
       
   956                 }
       
   957             break;
       
   958             case KSvgTypeSpreadMethod:
       
   959                 {
       
   960                 TInt pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindSpreadMethod(aValue);
       
   961                 if(pos != KErrNotFound)
       
   962                     {
       
   963                     iOrgFromInt = iFromInt = pos;
       
   964                     }
       
   965                 else
       
   966                     {
       
   967                     iOrgFromInt = iFromInt =  0;// default pad
       
   968                     }
       
   969                 }
       
   970                 break;
       
   971             case KSvgTypeColor:
       
   972             	{
       
   973             	TLex lex ( aValue );
       
   974                 TInt32  colorValue;
       
   975                 if ( lex.Val( colorValue ) != KErrNone )
       
   976 	            	{
       
   977             		// means we have a URL color definition
       
   978 	            	iFromPaint = ((CSvgDocumentImpl*)iOwnerDocument)->iMemoryManager->GetCssPaintObjectL(aValue, ((CSvgElementImpl*)((CSvgDocumentImpl*)iOwnerDocument)->RootElement()));
       
   979 
       
   980 	            	if (iFromPaint)
       
   981 	            		{
       
   982 	            		MGfxPaint* lVal = iFromPaint->Value();
       
   983 	            		if (lVal)
       
   984 	            			{
       
   985 	            			iOrgFromInt = iFromInt = lVal->GetColor();
       
   986 	            			}
       
   987 	            		}
       
   988 	            	break;
       
   989             		}
       
   990             	}
       
   991             	// fall through for other color values.
       
   992             case KSvgTypeInteger:
       
   993                 {
       
   994                 TLex    lString ( aValue );
       
   995                 TInt32  lVal;
       
   996                 if (lString.Val( lVal ) != KErrNone)
       
   997                     {
       
   998                     lVal=0;
       
   999                     }
       
  1000                 iOrgFromInt = iFromInt = lVal;
       
  1001                 }
       
  1002             break;
       
  1003             case KSvgTypeDisplay:
       
  1004                 {
       
  1005                 if ( aValue == _L( "inline" ) )
       
  1006                     {
       
  1007                     iOrgFromInt = iFromInt = 0;
       
  1008                     }
       
  1009                 else if ( aValue == _L( "none" ) )
       
  1010                     {
       
  1011                     iOrgFromInt = iFromInt = 16;
       
  1012                     }
       
  1013                 else
       
  1014                 	{
       
  1015                 		//assume inherit on everything else
       
  1016                 	iOrgFromInt = iFromInt = (TInt32) KEnumInherit;
       
  1017                 	}
       
  1018                 }
       
  1019             break;
       
  1020 
       
  1021             case KSvgTypeTextAnchor:
       
  1022 					{
       
  1023 					TInt pos;
       
  1024 					pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindTextAnchorEnum(aValue);
       
  1025 					if(pos!= -1)
       
  1026 						{
       
  1027 						iOrgFromInt = iFromInt = pos ;
       
  1028 						}
       
  1029 					}
       
  1030 				break;
       
  1031 
       
  1032             case KSvgTypeVisibility:
       
  1033                 {
       
  1034                 if ( aValue == _L( "visible" ) )
       
  1035                     {
       
  1036                     iOrgFromInt = iFromInt = 0;
       
  1037                     }
       
  1038                 else if ( aValue == _L( "hidden" ) )
       
  1039                     {
       
  1040                     iOrgFromInt = iFromInt = 1;
       
  1041                     }
       
  1042                 }
       
  1043                 break;
       
  1044 
       
  1045            // viewBox
       
  1046 			case KSvgTypeViewBox:
       
  1047                 {
       
  1048                 ParseViewBoxValue(aValue, iOrgFromViewBox);
       
  1049 				iFromViewBox = iOrgFromViewBox;
       
  1050 				}
       
  1051                 break;
       
  1052             }
       
  1053         }
       
  1054     else if ( aName == KTmpTo )
       
  1055         {
       
  1056         iHaveTo = ETrue;
       
  1057         // parser needed
       
  1058         switch ( iDataType )
       
  1059             {
       
  1060             case KSvgTypeOpacity:
       
  1061                 {
       
  1062                 	TBool lPercentage = EFalse;
       
  1063                 	if (aValue.Locate('%') != KErrNotFound)
       
  1064 		 			{
       
  1065 		 				lPercentage = ETrue;
       
  1066 		 			}
       
  1067 
       
  1068                     TLex    lString ( aValue );
       
  1069                     TReal32  lVal;
       
  1070                     if (lString.Val( lVal, '.' ) != KErrNone)
       
  1071                         {
       
  1072                         lVal=1;
       
  1073                         }
       
  1074 
       
  1075                     if (lPercentage)
       
  1076                 	{
       
  1077                 		lVal = lVal / TReal32(100);
       
  1078                 	}
       
  1079 
       
  1080                     if(lVal>1)
       
  1081                         {
       
  1082                         lVal=1;
       
  1083                         }
       
  1084                     if(lVal<0)
       
  1085                         {
       
  1086                         lVal=0;
       
  1087                         }
       
  1088                     iToFloat = lVal;
       
  1089                     break;
       
  1090                 }
       
  1091             case KSvgTypeGradientUnits:
       
  1092                     {
       
  1093                      if(aValue == _L("objectBoundingBox"))
       
  1094                       {
       
  1095                       iToInt= 1;
       
  1096                       }
       
  1097                      else if(aValue == _L("userSpaceOnUse"))
       
  1098                       {
       
  1099                       iToInt = 0;
       
  1100                       }
       
  1101                     }
       
  1102             break;
       
  1103 
       
  1104             case KSvgTypeTextAnchor:
       
  1105 			                	{
       
  1106 								TInt pos;
       
  1107 								pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindTextAnchorEnum(aValue);
       
  1108 								if(pos!= -1)
       
  1109 									{
       
  1110 									iToInt =  pos ;
       
  1111 									}
       
  1112 								}
       
  1113 				break;
       
  1114 
       
  1115             case KSvgTypeLength:
       
  1116                 {
       
  1117                 TLex    string  ( aValue );
       
  1118                 TReal32 val;
       
  1119                 if( string.Val( val, '.' ) != KErrNone )
       
  1120                     {
       
  1121                     val = 0;
       
  1122                     }
       
  1123                 iToFloat = val;
       
  1124                 }
       
  1125             break;
       
  1126             case KSvgTypeList:
       
  1127             case KSvgTypePath:
       
  1128                 {
       
  1129                 CGfxPathIterator*   itr1;
       
  1130                 CGfxPathIterator*   itr2;
       
  1131                 TGfxAffineTransform idenTransform;
       
  1132 
       
  1133                 if ( iToPath )
       
  1134                     {
       
  1135                     delete iToPath;
       
  1136                     iToPath = NULL;
       
  1137                     }
       
  1138                 iToPath = CGfxGeneralPath::NewL();
       
  1139 
       
  1140                 // Build a new path
       
  1141 
       
  1142                 if ( iAttrId == KAtrPoints )
       
  1143                     {
       
  1144                     TSvgPathDataParser::ParsePointDataL( aValue, iToPath );
       
  1145                     }
       
  1146                 else
       
  1147                     {
       
  1148                     TSvgPathDataParser::ParsePathData( aValue, iToPath );
       
  1149                     }
       
  1150 
       
  1151                 iToPath->GetPathIteratorL( &idenTransform, itr1 );
       
  1152                 CleanupStack::PushL( itr1 );
       
  1153 
       
  1154                 if ( iNoFrom )
       
  1155                     {
       
  1156                     iOrgPath->GetPathIteratorL( &idenTransform, itr2 );
       
  1157                     }
       
  1158                 else
       
  1159                     {
       
  1160                     iFromPath->GetPathIteratorL( &idenTransform, itr2 );
       
  1161                     }
       
  1162                 CleanupStack::PushL( itr2 );
       
  1163 
       
  1164 
       
  1165                 TFloatFixPt  tmpcoords1[6];
       
  1166                 TFloatFixPt  tmpcoords2[6];
       
  1167                 while ( !itr1->IsDone() && !itr2->IsDone() )
       
  1168                     {
       
  1169                     TGfxSegType type1   = itr1->CurrentSegment( tmpcoords1 );
       
  1170                     TGfxSegType type2   = itr2->CurrentSegment( tmpcoords2 );
       
  1171                     if ( type1 != type2 )
       
  1172                         {
       
  1173                         // MISMATCH
       
  1174                         // SHOULD END ANIMATION
       
  1175                         break;
       
  1176                         }
       
  1177 
       
  1178                     itr1->NextL();
       
  1179                     itr2->NextL();
       
  1180                     }
       
  1181                 }
       
  1182             CleanupStack::PopAndDestroy( 2 ); // destroy itr1 & itr2
       
  1183             break;
       
  1184             case KSvgTypeSpreadMethod:
       
  1185                 {
       
  1186                 TInt pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindSpreadMethod(aValue);
       
  1187                 if(pos != KErrNotFound)
       
  1188                     {
       
  1189                     iToInt = pos;
       
  1190                     }
       
  1191                 else
       
  1192                     {
       
  1193                     iToInt= 0;// default pad
       
  1194                     }
       
  1195                 }
       
  1196             break;
       
  1197 
       
  1198             case KSvgTypeColor:
       
  1199             	{
       
  1200             	TLex lex ( aValue );
       
  1201                 TInt32  colorValue;
       
  1202                 if ( lex.Val( colorValue ) != KErrNone )
       
  1203 	            	{
       
  1204             		// means we have a URL color definition
       
  1205             		iToPaint = ((CSvgDocumentImpl*)iOwnerDocument)->iMemoryManager->GetCssPaintObjectL(aValue, ((CSvgElementImpl*)((CSvgDocumentImpl*)iOwnerDocument)->RootElement()));
       
  1206 
       
  1207             		if (iToPaint)
       
  1208 	            		{
       
  1209 	            			MGfxPaint* lVal = iToPaint->Value();
       
  1210 	            			if (lVal)
       
  1211 		            			{
       
  1212 		            			iToInt = lVal->GetColor();
       
  1213 		            			}
       
  1214 	            		}
       
  1215 	            	break;
       
  1216             		}
       
  1217             	}
       
  1218 				// fall through for rgb values
       
  1219             case KSvgTypeInteger:
       
  1220                 {
       
  1221                 TLex    lString ( aValue );
       
  1222                 TInt32  lVal;
       
  1223                 if (lString.Val( lVal ) != KErrNone)
       
  1224                     {
       
  1225                     lVal=0;
       
  1226                     }
       
  1227                 iToInt = lVal;
       
  1228                 }
       
  1229             break;
       
  1230             case KSvgTypeDisplay:
       
  1231                 {
       
  1232                 if ( aValue == _L( "inline" ) )
       
  1233                     {
       
  1234                     iToInt = 0;
       
  1235                     }
       
  1236                 else if ( aValue == _L( "none" ) )
       
  1237                     {
       
  1238                     iToInt = 16;
       
  1239                     }
       
  1240                 else
       
  1241                 	{
       
  1242                 	//assume inherit on everything else
       
  1243                 	iToInt = (TInt32) KEnumInherit;
       
  1244                 	}
       
  1245                 }
       
  1246             break;
       
  1247             case KSvgTypeVisibility:
       
  1248                 {
       
  1249                 if ( aValue == _L( "visible" ) )
       
  1250                     {
       
  1251                     iToInt = 0;
       
  1252                     }
       
  1253                 else if ( aValue == _L( "hidden" ) )
       
  1254                     {
       
  1255                     iToInt = 1;
       
  1256                     }
       
  1257                 }
       
  1258             break;
       
  1259 
       
  1260 			// viewBox
       
  1261 			case KSvgTypeViewBox:
       
  1262                 {
       
  1263                 ParseViewBoxValue(aValue, iToViewBox);
       
  1264 				}
       
  1265                 break;
       
  1266 
       
  1267             default:
       
  1268             break;
       
  1269             }
       
  1270         }
       
  1271     else if ( aName == KTmpBy )
       
  1272         {
       
  1273         iHaveBy = ETrue;
       
  1274 
       
  1275         if(!iHaveTo)
       
  1276             {
       
  1277             switch ( iDataType )
       
  1278                 {
       
  1279                 case KSvgTypeOpacity:
       
  1280                     {
       
  1281 
       
  1282                     TBool lPercentage = EFalse;
       
  1283                 	if (aValue.Locate('%') != KErrNotFound)
       
  1284 		 			{
       
  1285 		 				lPercentage = ETrue;
       
  1286 		 			}
       
  1287 
       
  1288                     TLex    lString ( aValue );
       
  1289                     TReal32  lVal;
       
  1290                     if (lString.Val( lVal, '.' ) != KErrNone)
       
  1291                         {
       
  1292                         lVal=1;
       
  1293                         }
       
  1294 
       
  1295                     if (lPercentage)
       
  1296                 	{
       
  1297                 		lVal = lVal / TReal32(100);
       
  1298                 	}
       
  1299 
       
  1300                     if(lVal>1)
       
  1301                         {
       
  1302                         lVal=1;
       
  1303                         }
       
  1304                     if(lVal<0)
       
  1305                         {
       
  1306                         lVal=0;
       
  1307                         }
       
  1308                     if ( iNoFrom )
       
  1309                         {
       
  1310                         iAdditive = KAdditiveSum;
       
  1311                         iAdditiveOrg = KAdditiveSum;
       
  1312                         iToFloat = iFromFloat + TFloatFixPt( lVal );
       
  1313                         iNoFrom = EFalse;
       
  1314                         iOrgFromFloat = iFromFloat = (TReal32)0;
       
  1315                         }
       
  1316                     else
       
  1317                         {
       
  1318                         iToFloat = iFromFloat + TFloatFixPt( lVal );
       
  1319                         }
       
  1320                     break;
       
  1321                     }
       
  1322                 case KSvgTypeLength:
       
  1323                     {
       
  1324                     TLex    string  ( aValue );
       
  1325                     TReal32 val;
       
  1326 
       
  1327                     if( string.Val( val, '.' ) != KErrNone )
       
  1328                         {
       
  1329                         val = 0;
       
  1330                         }
       
  1331 
       
  1332                     if ( iNoFrom )
       
  1333                         {
       
  1334                         iAdditive = KAdditiveSum;
       
  1335                         iAdditiveOrg = KAdditiveSum;
       
  1336                         iToFloat = iFromFloat + TFloatFixPt( val );
       
  1337                         iNoFrom = EFalse;
       
  1338                         iOrgFromFloat = iFromFloat = (TReal32)0;
       
  1339                         }
       
  1340                     else
       
  1341                         {
       
  1342                         iToFloat = iFromFloat + TFloatFixPt( val );
       
  1343                         }
       
  1344                     }
       
  1345                 break;
       
  1346                 case KSvgTypeList:
       
  1347                 case KSvgTypePath:
       
  1348                     {
       
  1349                     if ( iToPath )
       
  1350                         {
       
  1351                         delete iToPath;
       
  1352                         iToPath = NULL;
       
  1353                         }
       
  1354                     iToPath = CGfxGeneralPath::NewL();
       
  1355 
       
  1356                     if ( iAttrId == KAtrPoints ) //.
       
  1357                         {
       
  1358                         TSvgPathDataParser::ParsePointDataL( aValue, iToPath );
       
  1359                         }
       
  1360                     else
       
  1361                         {
       
  1362                         TSvgPathDataParser::ParsePathData( aValue, iToPath );
       
  1363                         }
       
  1364                     CGfxGeneralPath*lCurPath    = CGfxGeneralPath::NewLC();
       
  1365                     RArray<TFloatFixPt>* fromPoints;
       
  1366                     RArray<TFloatFixPt>* toPoints    = iToPath->PointCoordsArrayAll();
       
  1367 
       
  1368                     if ( iNoFrom )
       
  1369                         {
       
  1370                         fromPoints = iOrgPath->PointCoordsArrayAll();
       
  1371                         lCurPath->SetPointTypeArrayL( iOrgPath->PointTypeArray() );
       
  1372                         }
       
  1373                     else
       
  1374                         {
       
  1375                         fromPoints = iFromPath->PointCoordsArrayAll();
       
  1376                         lCurPath->SetPointTypeArrayL( iFromPath->PointTypeArray() );
       
  1377                         }
       
  1378                     TInt    i       = 0;
       
  1379                     TInt    fromCount   = fromPoints->Count();
       
  1380                     TInt    toCount   = toPoints->Count();
       
  1381 
       
  1382                     while ( i < fromCount &&  i < toCount)
       
  1383                         {
       
  1384                         toPoints->operator[]( i ) = fromPoints->operator[]( i ) +
       
  1385                         toPoints->operator[]( i );
       
  1386                         i++;
       
  1387                         }
       
  1388                     CleanupStack::PopAndDestroy( 1 ); // lCurPath
       
  1389                     return ETrue;
       
  1390                     }
       
  1391                 case KSvgTypeColor:
       
  1392                     {
       
  1393                     TLex    lString ( aValue );
       
  1394                     TInt32  lVal;
       
  1395                     if (lString.Val( lVal ) != KErrNone)
       
  1396                         {
       
  1397                         lVal=0;
       
  1398                         }
       
  1399 
       
  1400                     if ( iNoFrom )
       
  1401                         {
       
  1402                         iToInt = lVal;
       
  1403                         iToInt = AddColor( iPropInt, lVal);
       
  1404                         iOrgFromInt = iFromInt = (TInt32) 0;
       
  1405                         }
       
  1406                     else
       
  1407                         {
       
  1408                         iToInt = AddColor( iFromInt, lVal);
       
  1409                         }
       
  1410                     }
       
  1411                 break;
       
  1412                 case KSvgTypeSpreadMethod:
       
  1413                     {
       
  1414                     TInt pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindSpreadMethod(aValue);
       
  1415                     if(pos != KErrNotFound)
       
  1416                         {
       
  1417                         iToInt = pos;
       
  1418                         }
       
  1419                     else
       
  1420                         {
       
  1421                         iToInt= 0;// default pad
       
  1422                         }
       
  1423 
       
  1424                     if ( iNoFrom )
       
  1425                         {
       
  1426                         iAdditive = KAdditiveSum;
       
  1427                         iAdditiveOrg = KAdditiveSum;
       
  1428                         iNoFrom = EFalse;
       
  1429                         iOrgFromInt = iFromInt = (TInt32) 0;
       
  1430                         }
       
  1431                     // by here has no meaning just take the absolute value
       
  1432                     }
       
  1433                 break;
       
  1434                 case KSvgTypeGradientUnits:
       
  1435                     {
       
  1436                      if(aValue == _L("objectBoundingBox"))
       
  1437                       {
       
  1438                       iToInt= 1;
       
  1439                       }
       
  1440                      else if(aValue == _L("userSpaceOnUse"))
       
  1441                       {
       
  1442                       iToInt = 0;
       
  1443                       }
       
  1444                       if ( iNoFrom )
       
  1445                         {
       
  1446                         iAdditive = KAdditiveSum;
       
  1447                         iAdditiveOrg = KAdditiveSum;
       
  1448                         iNoFrom = EFalse;
       
  1449                         iOrgFromInt = iFromInt = (TInt32) 0;
       
  1450                         }
       
  1451                     // by here has no meaning just take the absolute value
       
  1452                     }
       
  1453             break;
       
  1454                 case KSvgTypeInteger:
       
  1455                     {
       
  1456                     TLex    lString ( aValue );
       
  1457                     TInt32  lVal;
       
  1458                     if (lString.Val( lVal ) != KErrNone)
       
  1459                         {
       
  1460                         lVal=0;
       
  1461                         }
       
  1462 
       
  1463                     if ( iNoFrom )
       
  1464                         {
       
  1465                         iAdditive = KAdditiveSum;
       
  1466                         iAdditiveOrg = KAdditiveSum;
       
  1467                         iToInt = lVal;
       
  1468                         iNoFrom = EFalse;
       
  1469                         iOrgFromInt = iFromInt = (TInt32) 0;
       
  1470                         }
       
  1471                     else
       
  1472                         {
       
  1473                         iToInt = iFromInt + lVal;
       
  1474                         }
       
  1475                     }
       
  1476                 break;
       
  1477                 case KSvgTypeVisibility:
       
  1478                     {
       
  1479                     if ( aValue == _L( "visible" ) )
       
  1480                         {
       
  1481                         iToInt = 0;
       
  1482                         }
       
  1483                     else if ( aValue == _L( "hidden" ) )
       
  1484                         {
       
  1485                         iToInt = 1;
       
  1486                         }
       
  1487                     }
       
  1488                 break;
       
  1489                 case KSvgTypeTextAnchor:
       
  1490                 	{
       
  1491 					TInt pos;
       
  1492 					pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindTextAnchorEnum(aValue);
       
  1493 					if(pos!= -1)
       
  1494 						{
       
  1495 						iToInt = pos ;
       
  1496 						}
       
  1497 					}
       
  1498 				break;
       
  1499                 case KSvgTypeDisplay:
       
  1500                     {
       
  1501                     if ( aValue == _L( "inline" ) )
       
  1502                         {
       
  1503                         iToInt = 0;
       
  1504                         }
       
  1505                     else if ( aValue == _L( "none" ) )
       
  1506                         {
       
  1507                         iToInt = 16;
       
  1508                         }
       
  1509                     else
       
  1510                     	{
       
  1511                     	//assume inherit on everything else
       
  1512                     	iToInt = (TInt32) KEnumInherit;
       
  1513                     	}
       
  1514 
       
  1515                     }
       
  1516                 break;
       
  1517 
       
  1518 					// viewBox
       
  1519 				case KSvgTypeViewBox:
       
  1520 			        {
       
  1521 
       
  1522                     TGfxRectangle2D lVal;
       
  1523 				    ParseViewBoxValue(aValue, lVal);
       
  1524 
       
  1525 					TReal32 lX=0;
       
  1526 					TReal32 lY=0;
       
  1527 					TReal32 lW=0;
       
  1528 					TReal32 lH=0;
       
  1529 					lX = lVal.iX + iFromViewBox.iX;
       
  1530 					lY = lVal.iY + iFromViewBox.iY;
       
  1531 					lW = lVal.iWidth + iFromViewBox.iWidth;
       
  1532 					lH = lVal.iHeight + iFromViewBox.iHeight;
       
  1533 
       
  1534 					TGfxRectangle2D result = TGfxRectangle2D( lX, lY, lW, lH );
       
  1535 
       
  1536 					if ( iNoFrom )
       
  1537                         {
       
  1538                         iAdditive = KAdditiveSum;
       
  1539                         iAdditiveOrg = KAdditiveSum;
       
  1540                         iToViewBox = result;
       
  1541                         iNoFrom = EFalse;
       
  1542                         iOrgFromViewBox = iFromViewBox = TGfxRectangle2D( 0, 0, 0, 0 );
       
  1543                         }
       
  1544                     else
       
  1545                         {
       
  1546                         iToViewBox = result;
       
  1547                         }
       
  1548 					}
       
  1549 				break;
       
  1550 
       
  1551                 default:
       
  1552                 break;
       
  1553                 }
       
  1554             }
       
  1555         }
       
  1556     // repeatCount : numeric value | "indefinite" 
       
  1557     // Specifies the number of iterations of the animation function. It can have the following attribute
       
  1558     // values: 
       
  1559     // * numeric value 
       
  1560     //      This is a (base 10) "floating point" numeric value that specifies the number of iterations. 
       
  1561     //      It can include partial iterations expressed as fraction values. A fractional value describes a
       
  1562     //      portion of the simple duration. Values must be greater than 0. 
       
  1563     // * "indefinite" 
       
  1564     //      The animation is defined to repeat indefinitely (i.e. until the document ends). 
       
  1565     else if ( aName == KTmpRepeatCount )
       
  1566         {
       
  1567         iRepeatCountSet = ETrue;
       
  1568         if ( aValue == KTmpIndefinite )
       
  1569             {
       
  1570             iRepeatCount = KRepeatCountMax;
       
  1571             }
       
  1572         else
       
  1573             {
       
  1574             TLex    lexer  ( aValue );
       
  1575             TReal32  val = 1.0f;
       
  1576             // Check for invalid number string or negative value
       
  1577             // Also check for value value followed by other characters, i.e ("6-4" or "3abd"
       
  1578             // Starting and ending whitespaces are chopped by lexer.
       
  1579             if ( lexer.Val( val, '.' ) != KErrNone || val <= 0 || lexer.Remainder().Length() > 0 )
       
  1580                 {
       
  1581                 val = 1.0f;
       
  1582                 }
       
  1583             iRepeatCount = val;
       
  1584             }
       
  1585         }
       
  1586     else if ( aName == KTmpFill )
       
  1587         {
       
  1588         if ( aValue == _L( "freeze" ) )
       
  1589             {
       
  1590             iFill = KAnimFillFreeze;
       
  1591             }
       
  1592         }
       
  1593     else if ( aName == KTmpRestart )
       
  1594         {
       
  1595         if ( aValue == _L( "whenNotActive" ) )
       
  1596             {
       
  1597             iAnimRestart = KRestartWhenNotActive; //KAnimFillFreeze;
       
  1598             }
       
  1599         else if ( aValue == _L( "never" ) )
       
  1600             {
       
  1601             iAnimRestart = KRestartNever;
       
  1602             }
       
  1603         // Default is 'always'
       
  1604 
       
  1605         }
       
  1606     else if ( aName == KTmpValues )
       
  1607         {
       
  1608 		iHaveValues = ETrue;
       
  1609         iNoFrom = EFalse;
       
  1610 
       
  1611         switch ( iDataType )
       
  1612             {
       
  1613 
       
  1614             case KSvgTypeOpacity:
       
  1615             case KSvgTypeLength:
       
  1616             iValuesFloat->Reset();
       
  1617             break;
       
  1618 
       
  1619             case KSvgTypeList:
       
  1620             case KSvgTypePath:
       
  1621             iValuesFloat->Reset();
       
  1622             iValuesPath->Reset();  // could be ResetAndDestroy()
       
  1623             break;
       
  1624             case KSvgTypeTextAnchor:
       
  1625             case KSvgTypeGradientUnits:
       
  1626             case KSvgTypeColor:
       
  1627             case KSvgTypeInteger:
       
  1628             case KSvgTypeVisibility:
       
  1629             case KSvgTypeDisplay:
       
  1630             iValuesFloat->Reset();
       
  1631             iValuesInt->Reset();
       
  1632             break;
       
  1633 
       
  1634 			case KSvgTypeViewBox:
       
  1635             iValuesFloat->Reset();
       
  1636             iValuesViewBox->Reset();
       
  1637 			break;
       
  1638 
       
  1639             default:
       
  1640             break;
       
  1641             }
       
  1642 
       
  1643         TStringTokenizer    tkn ( aValue, KSEMICOLON );
       
  1644         while ( tkn.HasMoreTokens() )
       
  1645             {
       
  1646             switch ( iDataType )
       
  1647                 {
       
  1648                 case KSvgTypeOpacity:
       
  1649                     {
       
  1650                     TFloatFixPt KZero;
       
  1651                     TFloatFixPt KOne( KFloatFixOne );
       
  1652                     TFloatFixPt opacity;
       
  1653 
       
  1654                     TPtrC lToken = tkn.NextToken();
       
  1655 
       
  1656                     if ( TFloatFixPt::ConvertString( lToken, opacity ) != KErrNone )
       
  1657                         {
       
  1658                         opacity = KOne;
       
  1659                         }
       
  1660                     else
       
  1661                         {
       
  1662 
       
  1663                         if ( lToken.Locate('%') != KErrNotFound )
       
  1664                         {
       
  1665                         opacity = opacity / TFloatFixPt(100);
       
  1666                         }
       
  1667 
       
  1668                         if ( opacity < KZero )
       
  1669                             opacity = KZero;
       
  1670                         else if ( opacity > KOne )
       
  1671                             opacity = KOne;
       
  1672                         }
       
  1673                     User::LeaveIfError( iValuesFloat->Append( opacity ) );
       
  1674                     }
       
  1675                 break;
       
  1676 
       
  1677                 case KSvgTypeLength:
       
  1678                 User::LeaveIfError(iValuesFloat->Append( TFloatFixPt::ConvertString( tkn.NextToken() ) ));
       
  1679                 break;
       
  1680 
       
  1681                 case KSvgTypeList:
       
  1682                 case KSvgTypePath:
       
  1683                     {
       
  1684                     CGfxGeneralPath*tPath   = CGfxGeneralPath::NewL();
       
  1685                     CleanupStack::PushL(tPath);
       
  1686                     if ( iAttrId == KAtrPoints ) //.
       
  1687                         {
       
  1688                         TSvgPathDataParser::ParsePointDataL( tkn.NextToken(), tPath );
       
  1689                         }
       
  1690                         else
       
  1691                         {
       
  1692                     TSvgPathDataParser::ParsePathData( tkn.NextToken(),
       
  1693                                                               tPath );
       
  1694                         }
       
  1695                     User::LeaveIfError(iValuesPath->Append( tPath ));
       
  1696                     CleanupStack::Pop();
       
  1697                     }
       
  1698 
       
  1699                 break;
       
  1700                 case KSvgTypeColor:
       
  1701                     {
       
  1702                     TSvgColor   tColor  ( KGfxColorNull );
       
  1703                     TUint32      tempVal;
       
  1704 
       
  1705 
       
  1706 
       
  1707 
       
  1708                     TBool col = tColor.GetStringL( tkn.NextToken(), tempVal );
       
  1709 
       
  1710                     if(!col)
       
  1711                     {
       
  1712 
       
  1713                     tempVal = 0x000000; // set the default to black,
       
  1714                     }
       
  1715                     User::LeaveIfError(iValuesInt->Append( tempVal ));
       
  1716                     }
       
  1717                 break;
       
  1718 
       
  1719                 case KSvgTypeSpreadMethod:
       
  1720                     {
       
  1721                     TInt pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindSpreadMethod(tkn.NextToken() );
       
  1722                         if(pos != KErrNotFound)
       
  1723                             {
       
  1724                             User::LeaveIfError(iValuesInt->Append( pos ));
       
  1725                             }
       
  1726                         else
       
  1727                             {
       
  1728                             User::LeaveIfError(iValuesInt->Append( 0));// default pad
       
  1729                             }
       
  1730                     }
       
  1731                 break;
       
  1732 
       
  1733                 case KSvgTypeInteger:
       
  1734                 User::LeaveIfError(iValuesInt->Append( TFloatFixPt::ConvertString( tkn.NextToken() ) ));
       
  1735                 break;
       
  1736 
       
  1737                 case KSvgTypeVisibility:
       
  1738                     {
       
  1739                     TPtrC           tmptk           = tkn.NextToken();
       
  1740 
       
  1741                     if (tmptk.Find(_L( "visible" )) != KErrNotFound)
       
  1742                         {
       
  1743                         User::LeaveIfError(iValuesInt->Append( 0 ));
       
  1744                         }
       
  1745                     else if (tmptk.Find(_L( "hidden" )) != KErrNotFound)
       
  1746                         {
       
  1747                         User::LeaveIfError(iValuesInt->Append( 1 ));
       
  1748                         }
       
  1749                     else if ( tmptk.Find(_L("inherit")) != KErrNotFound )
       
  1750                        {
       
  1751                        User::LeaveIfError(iValuesInt->Append(KInherit));
       
  1752                        }
       
  1753                        
       
  1754 
       
  1755                     }
       
  1756                 break;
       
  1757                 case KSvgTypeGradientUnits:
       
  1758                     {
       
  1759                     TPtrC           tmptk           = tkn.NextToken();
       
  1760                     if (tmptk.Find(_L( "objectBoundingBox" )) != KErrNotFound)
       
  1761                         {
       
  1762                         User::LeaveIfError(iValuesInt->Append( 1));
       
  1763                         }
       
  1764                     else if (tmptk.Find(_L( "userSpaceOnUse" )) != KErrNotFound)
       
  1765                         {
       
  1766                         User::LeaveIfError(iValuesInt->Append( 0));
       
  1767                         }
       
  1768 
       
  1769                     }
       
  1770                 break;
       
  1771                 case KSvgTypeDisplay:
       
  1772                     {
       
  1773                     TPtrC tmptk = tkn.NextToken();
       
  1774 
       
  1775                     if (tmptk.Find(_L( "inline" )) != KErrNotFound)
       
  1776                     {
       
  1777              			//found inline
       
  1778              			User::LeaveIfError(iValuesInt->Append( 0 ));
       
  1779                     }
       
  1780                     else if (tmptk.Find(_L( "none" )) != KErrNotFound)
       
  1781                     {
       
  1782                     	User::LeaveIfError(iValuesInt->Append( 16 ));
       
  1783                     }
       
  1784                     else
       
  1785                    	{
       
  1786                     	//assume inherit on everything else
       
  1787                     	User::LeaveIfError(iValuesInt->Append( (TInt32) KEnumInherit ));
       
  1788                     	//iValuesInt->Append( 0 );
       
  1789                    	}
       
  1790 
       
  1791                     }
       
  1792                 break;
       
  1793 
       
  1794                 case KSvgTypeTextAnchor:
       
  1795                     {
       
  1796 
       
  1797                     TInt pos;
       
  1798 
       
  1799                     pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->FindTextAnchorEnum(tkn.NextToken());
       
  1800 
       
  1801                         if(pos!= -1)
       
  1802                         {
       
  1803                         User::LeaveIfError(iValuesInt->Append( pos ));
       
  1804                         }
       
  1805                     }
       
  1806                 break;
       
  1807 
       
  1808                // viewBox attribute
       
  1809 				case KSvgTypeViewBox:
       
  1810 					{
       
  1811                     TGfxRectangle2D lVal;
       
  1812 					ParseViewBoxValue( tkn.NextToken(), lVal);
       
  1813 					User::LeaveIfError(iValuesViewBox->Append( lVal ));
       
  1814 					}
       
  1815 				break;
       
  1816 
       
  1817                 default:
       
  1818                 break;
       
  1819                 }
       
  1820             }
       
  1821         }
       
  1822     else if ( aName == KTmpCalcMode )
       
  1823         {
       
  1824         if ( aValue == _L( "discrete" ) )
       
  1825             {
       
  1826             iAnimTime->SetCalMode( KAnimCalcModeDiscrete );
       
  1827             }
       
  1828         else if ( aValue == _L( "paced" ) )
       
  1829             {
       
  1830             iAnimTime->SetCalMode( KAnimCalcModePaced );
       
  1831             }
       
  1832         else if ( aValue == _L( "spline" ) )
       
  1833             {
       
  1834             iAnimTime->SetCalMode( KAnimCalcModeSpline );
       
  1835             // Indicate to the anim timing controller that
       
  1836             // the Spline mode is set
       
  1837             iAnimTime->SetIsSplineCalcMode( ETrue ); 
       
  1838             TPtrC lSplineValue( iAnimTime->SplineValue() );
       
  1839             if ( lSplineValue.Length() > 0 ) 
       
  1840                 { 
       
  1841                 TStringTokenizer tkn2 (lSplineValue, KSEMICOLON); 
       
  1842                 iAnimTime->PrepareTimeL( NULL ); 
       
  1843                 
       
  1844                 while ( tkn2.HasMoreTokens() ) 
       
  1845                     { 
       
  1846                     TSvgPointLexer  svgplex ( tkn2.NextToken() ); 
       
  1847                     TChar           com;  // ingnor this 
       
  1848                     TFloatFixPt          x1, y1, x2, y2; 
       
  1849                     svgplex.GetNextPoint( com, x1, y1 ); 
       
  1850                     svgplex.GetNextPoint( com, x2, y2 ); 
       
  1851                     svgplex.Cleanup(); 
       
  1852   
       
  1853                     TFloatFixPt tmpZero = TFloatFixPt(0); 
       
  1854                     TFloatFixPt tmpOne  = TFloatFixPt(1); 
       
  1855   
       
  1856 #ifdef SVG_FLOAT_BUILD 
       
  1857                     if ( ( x1 < ( tmpZero ) ) || ( x1 > ( tmpOne ) ) ) 
       
  1858                         { 
       
  1859                         x1 = tmpZero; 
       
  1860                         } 
       
  1861   
       
  1862                     if ( ( y1 < ( tmpZero ) ) || ( y1 > ( tmpOne ) ) ) 
       
  1863                         { 
       
  1864                         y1 = tmpZero; 
       
  1865                         } 
       
  1866   
       
  1867                     if ( ( x2 < ( tmpZero ) ) || ( x2 > ( tmpOne ) ) ) 
       
  1868                         { 
       
  1869                         x2 = tmpOne; 
       
  1870                         } 
       
  1871   
       
  1872                     if ( ( y2 < ( tmpZero ) ) || ( y2 > ( tmpOne ) ) ) 
       
  1873                         { 
       
  1874                         y2 = tmpOne; 
       
  1875                         } 
       
  1876 #else 
       
  1877                     if ( ( x1.operator < ( tmpZero ) ) || ( x1.operator > ( tmpOne ) ) ) 
       
  1878                         { 
       
  1879                         x1 = tmpZero; 
       
  1880                         } 
       
  1881   
       
  1882                     if ( ( y1.operator < ( tmpZero ) ) || ( y1.operator > ( tmpOne ) ) ) 
       
  1883                         { 
       
  1884                         y1 = tmpZero; 
       
  1885                         } 
       
  1886   
       
  1887                     if ( ( x2.operator < ( tmpZero ) ) || ( x2.operator > ( tmpOne ) ) ) 
       
  1888                         { 
       
  1889                         x2 = tmpOne; 
       
  1890                         } 
       
  1891   
       
  1892                     if ( ( y2.operator < ( tmpZero ) ) || ( y2.operator > ( tmpOne ) ) ) 
       
  1893                         { 
       
  1894                         y2 = tmpOne; 
       
  1895                         } 
       
  1896 #endif 
       
  1897                     iAnimTime->AddKeySplineL( x1, y1, x2, y2 ); 
       
  1898                     } 
       
  1899                 }
       
  1900             }
       
  1901         else
       
  1902             {
       
  1903             iAnimTime->SetCalMode( KAnimCalcModeLinear );
       
  1904             }
       
  1905         }
       
  1906     else if ( aName == KTmpKeyTimes )
       
  1907         {
       
  1908         // if paced spec says we ignore keyTimes
       
  1909         if(iAnimTime->CalMode() != KAnimCalcModePaced)
       
  1910             {
       
  1911 			iKeyTimesPresent = ETrue;
       
  1912             iAnimTime->ResetKeyTime();
       
  1913             TStringTokenizer    tkn ( aValue, KSEMICOLON );
       
  1914             TInt32 first = 1;
       
  1915 
       
  1916             TFloatFixPt current_time;
       
  1917 
       
  1918             while ( tkn.HasMoreTokens() )
       
  1919                 {
       
  1920                 current_time = TFloatFixPt::ConvertString( tkn.NextToken() );
       
  1921 
       
  1922                 if( (first && current_time != (TFloatFixPt) 0.0f) ||
       
  1923                      current_time < (TFloatFixPt) 0.0f ||
       
  1924                      current_time > (TFloatFixPt) 1.0f)
       
  1925                     { // put on this keyframe animation
       
  1926                       // Spec says freeze on errors, but it
       
  1927                       // also says ignore keytimes on error
       
  1928 
       
  1929                     iAnimTime->ResetKeyTime();
       
  1930 					iKeyTimesPresent = EFalse;
       
  1931 
       
  1932                     break;
       
  1933                     }
       
  1934 
       
  1935                 first = 0;
       
  1936                 iAnimTime->AddKeyTime( current_time );
       
  1937                 }
       
  1938 
       
  1939 			// last keytime value should be 1 for calcmode= linear or spline
       
  1940             if( (current_time != (TFloatFixPt)1.0f) &&
       
  1941 				         (iAnimTime->CalMode() != KAnimCalcModeDiscrete) )
       
  1942                 {
       
  1943                 iAnimTime->ResetKeyTime();
       
  1944                 }
       
  1945             }
       
  1946         }
       
  1947     else if ( aName == KTmpKeySplines )
       
  1948         {
       
  1949         // Count number of splines
       
  1950         TInt32              splines = 0;
       
  1951         TStringTokenizer    tkn1    ( aValue, KSEMICOLON );
       
  1952         while ( tkn1.HasMoreTokens() )
       
  1953             {
       
  1954             tkn1.NextToken();
       
  1955             splines++;
       
  1956             }
       
  1957             if(!iKeyTimesPresent)
       
  1958         iAnimTime->CreateKeyTime( splines + 1 );
       
  1959         if( iAnimTime->IsSplineCalcMode() ) 
       
  1960             { 
       
  1961             iAnimTime->PrepareTimeL( NULL ); 
       
  1962             TStringTokenizer    tkn2    ( aValue, KSEMICOLON ); 
       
  1963  
       
  1964             while ( tkn2.HasMoreTokens() ) 
       
  1965                 { 
       
  1966                 TSvgPointLexer  svgplex ( tkn2.NextToken() ); 
       
  1967                 TChar           com;  // ingnor this 
       
  1968                 TFloatFixPt          x1, y1, x2, y2; 
       
  1969                 svgplex.GetNextPoint( com, x1, y1 ); 
       
  1970                 svgplex.GetNextPoint( com, x2, y2 ); 
       
  1971                 svgplex.Cleanup(); 
       
  1972  
       
  1973                 TFloatFixPt tmpZero = TFloatFixPt(0); 
       
  1974                 TFloatFixPt tmpOne  = TFloatFixPt(1); 
       
  1975  
       
  1976 #ifdef SVG_FLOAT_BUILD 
       
  1977                 if ( ( x1 < ( tmpZero ) ) || ( x1 > ( tmpOne ) ) ) 
       
  1978                     { 
       
  1979                     x1 = tmpZero; 
       
  1980                     } 
       
  1981  
       
  1982                 if ( ( y1 < ( tmpZero ) ) || ( y1 > ( tmpOne ) ) ) 
       
  1983                     { 
       
  1984                     y1 = tmpZero; 
       
  1985                     } 
       
  1986  
       
  1987                 if ( ( x2 < ( tmpZero ) ) || ( x2 > ( tmpOne ) ) ) 
       
  1988                     { 
       
  1989                     x2 = tmpOne; 
       
  1990                     } 
       
  1991  
       
  1992                 if ( ( y2 < ( tmpZero ) ) || ( y2 > ( tmpOne ) ) ) 
       
  1993                     { 
       
  1994                     y2 = tmpOne; 
       
  1995                     } 
       
  1996 #else 
       
  1997                 if ( ( x1.operator < ( tmpZero ) ) || ( x1.operator > ( tmpOne ) ) ) 
       
  1998                     { 
       
  1999                     x1 = tmpZero; 
       
  2000                     } 
       
  2001  
       
  2002                 if ( ( y1.operator < ( tmpZero ) ) || ( y1.operator > ( tmpOne ) ) ) 
       
  2003                     { 
       
  2004                     y1 = tmpZero; 
       
  2005                     } 
       
  2006  
       
  2007                 if ( ( x2.operator < ( tmpZero ) ) || ( x2.operator > ( tmpOne ) ) ) 
       
  2008                     { 
       
  2009                     x2 = tmpOne; 
       
  2010                     } 
       
  2011  
       
  2012                 if ( ( y2.operator < ( tmpZero ) ) || ( y2.operator > ( tmpOne ) ) ) 
       
  2013                     { 
       
  2014                     y2 = tmpOne; 
       
  2015                     } 
       
  2016 #endif 
       
  2017                 iAnimTime->AddKeySplineL( x1, y1, x2, y2 ); 
       
  2018                 } 
       
  2019             } 
       
  2020          else 
       
  2021             { 
       
  2022             iAnimTime->SetSplineValueL( aValue ); 
       
  2023             } 
       
  2024         }
       
  2025     else if ( aName == KTmpAccumulate )
       
  2026         {
       
  2027         if ( aValue == _L( "sum" ) )
       
  2028             {
       
  2029             iAccumulate = KAccumSum;
       
  2030             }
       
  2031         }
       
  2032     else if ( aName == KTmpAdditive )
       
  2033         {
       
  2034         if ( aValue == _L( "sum" ) )
       
  2035             {
       
  2036             iAdditive = KAdditiveSum;
       
  2037             iAdditiveOrg = KAdditiveSum;
       
  2038             }
       
  2039         }
       
  2040     else
       
  2041         {
       
  2042         if ( this->SetTestAttributeL( aName, aValue ) )
       
  2043             {
       
  2044             return KErrNone;
       
  2045             }
       
  2046         }
       
  2047     return KErrNone;
       
  2048     }
       
  2049 
       
  2050 // ---------------------------------------------------------------------------
       
  2051 // From CSvgElementImpl
       
  2052 // perform a deep clone of this object
       
  2053 // ---------------------------------------------------------------------------
       
  2054 MXmlElement* CSvgAnimationBase::CloneL(MXmlElement*)
       
  2055     {
       
  2056     return NULL;
       
  2057     }
       
  2058 
       
  2059 
       
  2060 // ---------------------------------------------------------------------------
       
  2061 // Animation specific common methods
       
  2062 // ---------------------------------------------------------------------------
       
  2063 TBool CSvgAnimationBase::ReceiveEventProcL( MSvgEvent* aEvent,
       
  2064                                            CSvgAnimationBase* aAnimElement )
       
  2065     {
       
  2066     if ( CSvgElementImpl::IsSVGEnginePaused() )
       
  2067        {
       
  2068        return EFalse;
       
  2069        }
       
  2070 	TBool lGetTimerEvent = EFalse;
       
  2071 	TInt32 lEngineTime =0;
       
  2072 
       
  2073     TInt32 lCurTime = ((CSvgDocumentImpl *)(iOwnerDocument))->CurrentTime();
       
  2074     // Check if target attribute is valid
       
  2075     if ( iAttrId == 0xffff )
       
  2076 	    {
       
  2077 	    ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this );
       
  2078 	    ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1);
       
  2079 	     return EFalse;
       
  2080 	    }
       
  2081 
       
  2082     if ( !iInitDone )
       
  2083         {
       
  2084         iInitDone = ETrue;
       
  2085         aAnimElement->InitAnimationL();
       
  2086         if ( aAnimElement->iTargetElement == NULL )
       
  2087             {
       
  2088             return EFalse;
       
  2089             }
       
  2090         ((CSvgDocumentImpl*)iOwnerDocument)->AddEventBeginTime( aAnimElement, iAbsoluteBeginTime, aAnimElement->iTargetElement );
       
  2091         }
       
  2092     else if ( aAnimElement->iTargetElement == NULL )
       
  2093         {
       
  2094         return EFalse;
       
  2095         }
       
  2096 
       
  2097     // select event type
       
  2098     switch ( aEvent->EventType() )
       
  2099         {
       
  2100         case ESvgEngineEventTimerPrep :
       
  2101         return EFalse;
       
  2102 
       
  2103 
       
  2104         case ESvgEngineInternalEvent:
       
  2105             {
       
  2106             MSvgInternalEvent*  event       = ( MSvgInternalEvent* ) aEvent;
       
  2107             CSvgElementImpl*               leventElement = (CSvgElementImpl*)  ( event->ObjectAddress() );
       
  2108 
       
  2109             CSvgAnimationBase*   ltargetElement = (CSvgAnimationBase*)event->ObjectAddress();
       
  2110             TInt i;
       
  2111             TInt lCount = iEventList->Count();
       
  2112 
       
  2113 			if (event->SvgEvent() == ESvgEventRepeatEvent )
       
  2114 			{
       
  2115 				CSvgElementImpl* lElement = event->ObjectAddress();
       
  2116 
       
  2117 				if (lElement)
       
  2118 				{
       
  2119             //        NotifyAnimationsRepeatingOnThisOneL( lElement->Id(),   ltargetElement);
       
  2120 				}
       
  2121 
       
  2122 			}
       
  2123 
       
  2124             for (i = 0; i < lCount; i++ )
       
  2125                 {
       
  2126                 if ( (iEventList->operator[](i)).iEvent != ESvgEventNone &&
       
  2127                      (iEventList->operator[](i)).iEvent == event->SvgEvent() )
       
  2128                     {
       
  2129                     if ( leventElement == (iEventList->operator[](i)).iTargetElement )
       
  2130                         {
       
  2131                         switch(event->SvgEvent())
       
  2132                             {
       
  2133                                 case ESvgEventRepeatEvent:
       
  2134                                 // Check whether the target element has repeated as many times
       
  2135                                 // as is defined for the begin of this element.
       
  2136                                 if ( ltargetElement->iCurrentRepeatCount == (TInt32) (iEventList->operator[](i)).iRepeatValue )
       
  2137                                     {
       
  2138                                     TReal32 lFractionalTime = (iEventList->operator[](i)).iRepeatValue - ((TInt32) (iEventList->operator[](i)).iRepeatValue);
       
  2139 
       
  2140                                     SetBeginByEventL( aAnimElement,
       
  2141                                                     (TInt32) (lCurTime +
       
  2142                                                     (iEventList->operator[](i)).iOffset +
       
  2143                                                         ltargetElement->Duration()*lFractionalTime), ETrue);
       
  2144 
       
  2145 									// Get THhe Engine's Current Media Time.
       
  2146 									lEngineTime = ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme();
       
  2147 
       
  2148 									// calculate the start time.
       
  2149 									TInt32 lStartTimeForThis = (TInt32) (lCurTime +
       
  2150                                                     (iEventList->operator[](i)).iOffset +
       
  2151                                                     ltargetElement->Duration()*lFractionalTime) ;
       
  2152 
       
  2153 									//compare BOTH.
       
  2154 									if(lStartTimeForThis <= lEngineTime )
       
  2155 										{
       
  2156 										// indicates that this element should get the last timer
       
  2157 										// event.
       
  2158 										lGetTimerEvent = ETrue;
       
  2159 										}
       
  2160 
       
  2161                                     }
       
  2162                                 break;
       
  2163 
       
  2164                                 default :
       
  2165 									{
       
  2166 
       
  2167                                 SetBeginByEventL( aAnimElement, lCurTime + (iEventList->operator[](i)).iOffset , ETrue);
       
  2168 									// calculate the start time.
       
  2169 									TInt32 lStartTimeForThis = (lCurTime + (iEventList->operator[](i)).iOffset ) ;
       
  2170 
       
  2171 									// see the Engine's Current media time.
       
  2172 									lEngineTime = ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme();
       
  2173 
       
  2174 									// Compare BOTH.
       
  2175 								/*	if(lStartTimeForThis <= lEngineTime )
       
  2176 										{
       
  2177 										// indicates that this element should get the last timer
       
  2178 										// event.
       
  2179 										lGetTimerEvent = ETrue;
       
  2180 										}*/
       
  2181 									}
       
  2182                                 break;
       
  2183                             }
       
  2184                         }
       
  2185 					}
       
  2186                     }
       
  2187 
       
  2188           	TInt lCount2 = iEndTimeList->Count();
       
  2189             for (i = 0; i < lCount2; i++ )
       
  2190             {
       
  2191 
       
  2192        		 if ( (iEndTimeList->operator[](i)).iEvent != ESvgEventNone &&
       
  2193                      (iEndTimeList->operator[](i)).iEvent == event->SvgEvent() )
       
  2194                     {
       
  2195                     if ( leventElement == (iEndTimeList->operator[](i)).iTargetElement )
       
  2196                         {
       
  2197                         switch(event->SvgEvent())
       
  2198                             {
       
  2199                                 case ESvgEventRepeatEvent:
       
  2200                                 if ( ltargetElement->iCurrentRepeatCount == (TInt32) (iEndTimeList->operator[](i)).iRepeatValue )
       
  2201                                     {
       
  2202                                     TReal32 lFractionalTime = (iEndTimeList->operator[](i)).iRepeatValue - ((TInt32) (iEndTimeList->operator[](i)).iRepeatValue);
       
  2203 
       
  2204                                     SetEndByEvent( aAnimElement,
       
  2205                                                     (TInt32) (lCurTime +
       
  2206                                                     (iEndTimeList->operator[](i)).iOffset +
       
  2207                                                     ltargetElement->Duration()*lFractionalTime) );
       
  2208 
       
  2209 								     }
       
  2210                                 break;
       
  2211 
       
  2212                                 default :
       
  2213 									{
       
  2214                                 	SetEndByEvent( aAnimElement, lCurTime + (iEndTimeList->operator[](i)).iOffset );
       
  2215 									}
       
  2216                                 break;
       
  2217                             }
       
  2218                         }
       
  2219 					}
       
  2220 
       
  2221 				}
       
  2222 
       
  2223 			}
       
  2224 		if(lGetTimerEvent)
       
  2225 			{
       
  2226 			// NO return this means that the Element should get the Last timer event.
       
  2227 			break;
       
  2228 			}
       
  2229 		else
       
  2230 			{
       
  2231 			// this should not get the last timer event.
       
  2232         return EFalse;
       
  2233 			}
       
  2234 
       
  2235 
       
  2236         case ESvgEngineEventKeyPress:
       
  2237             {
       
  2238             MSvgUiKeyEvent* event   = ( MSvgUiKeyEvent* ) aEvent;
       
  2239             TInt i;
       
  2240 
       
  2241             TInt lCount = iEventList->Count();
       
  2242             for (i = 0; i < lCount; i++ )
       
  2243                  {
       
  2244 
       
  2245                  if ( (iEventList->operator[](i)).iEvent == ESvgEventKey &&
       
  2246                       (iEventList->operator[](i)).iAccessKeyCode == event->KeyCode() )
       
  2247                     {
       
  2248                     SetBeginByEventL( aAnimElement, lCurTime + (iEventList->operator[](i)).iOffset, ETrue );
       
  2249                     }
       
  2250                  }
       
  2251             TInt lEndTimesCount = iEndTimeList->Count();
       
  2252             for (i = 0; i < lEndTimesCount; i++ )
       
  2253                  {
       
  2254             if ( (iEndTimeList->operator[](i)).iEvent == ESvgEventKey &&
       
  2255                       (iEndTimeList->operator[](i)).iAccessKeyCode == event->KeyCode() )
       
  2256                     {
       
  2257                     SetEndByEvent( aAnimElement, lCurTime + (iEndTimeList->operator[](i)).iOffset );
       
  2258                     }
       
  2259                  }
       
  2260 
       
  2261              }
       
  2262         return EFalse;
       
  2263 
       
  2264 
       
  2265         case ESvgEngineEventTimer:
       
  2266         break;
       
  2267 
       
  2268         default:
       
  2269         // mouse event is ignored here
       
  2270         return EFalse;
       
  2271         }
       
  2272 
       
  2273 
       
  2274     // Only timer event come thorugh after here
       
  2275     TSvgTimerEvent* timerEvent  = ( TSvgTimerEvent* ) aEvent;
       
  2276     TSvgTimerEvent lLastEventTime(lEngineTime);
       
  2277 
       
  2278 	// this is treated as
       
  2279 	if(lGetTimerEvent)
       
  2280 		{
       
  2281 		// send the last timer event.
       
  2282 		timerEvent = &lLastEventTime;
       
  2283 		}
       
  2284 
       
  2285   //   if( (!iOverrideTime) )
       
  2286         {
       
  2287         // This condition would not be satisfied for animations having one begin time
       
  2288         // E.g begin='5s' moves on to check if iAnimStatus is NotActive
       
  2289         if ( (iBeginTimeIndex+1 < iAnimTime->BeginTimesCount() ) && ( timerEvent->Time() >= iAnimTime->GetBeginTime( iBeginTimeIndex + 1 )))
       
  2290             {
       
  2291             
       
  2292              if ( iAnimRestart == KRestartWhenNotActive && iAnimStatus == KAnimActive )
       
  2293 		        {
       
  2294 		        return ETrue;     // Not start when active and restart="whenNotActive"
       
  2295 		        }
       
  2296 		    if ( iAnimRestart == KRestartNever && iHadBegun )
       
  2297 		        {
       
  2298 		        return ETrue;     // Not start when anim had begun and if restart="never"
       
  2299 		        }
       
  2300             iBeginTimeIndex++;
       
  2301             iAnimTime->SetBeginTime( iAnimTime->GetBeginTime( iBeginTimeIndex ));
       
  2302 			// added for setting proper end time
       
  2303 			iAbsoluteBeginTime= iAnimTime->GetBeginTime( iBeginTimeIndex );
       
  2304             iAnimStatus = KAnimNotActive;
       
  2305 
       
  2306             if (iTargetElement)
       
  2307             {
       
  2308             	iTargetElement->iHasAnimationBase = (TInt)this;
       
  2309         	iTargetElement->SetIsAnimating( EFalse );
       
  2310         	SetIsAnimating( EFalse );
       
  2311             }
       
  2312         	iAnimTime->GetNextEndTime(iAnimTime->BeginTime());
       
  2313 
       
  2314 			TUint32 lSimpleDur= SimpleDuration();
       
  2315 		   	if(lSimpleDur != KTimeIndefinite)
       
  2316    				{
       
  2317 			   	iAnimTime->SetEndTime( lSimpleDur );
       
  2318 	   			}
       
  2319 
       
  2320           	// in case of multiple begin times we need to sort the list again.
       
  2321         	((CSvgDocumentImpl*)iOwnerDocument)->iInitSortList=ETrue;
       
  2322             }
       
  2323         }
       
  2324 
       
  2325     if ( iAnimStatus == KAnimNotActive )
       
  2326         {
       
  2327         // Animation element becomes active only if current time exceeds 
       
  2328         // the anim's begin time and its duration is not indefinite 
       
  2329         if ( timerEvent->Time() >= iAnimTime->BeginTime() )
       
  2330             {
       
  2331           //  iHasEnded = EFalse;
       
  2332             // start animation
       
  2333             iAnimStatus = KAnimActive;
       
  2334 			iDoFreeze = EFalse;
       
  2335             if (iTargetElement)
       
  2336             {
       
  2337             	iTargetElement->iHasAnimationBase = (TInt)this;
       
  2338         	iTargetElement->SetIsAnimating( ETrue );
       
  2339         	SetIsAnimating( ETrue );
       
  2340             }
       
  2341 			if ((this->ElemID() == KSvgAnimateElement) || 
       
  2342 				(this->ElemID() == KSvgAudioElement) || 
       
  2343 				(this->ElemID() == KSvgMediaAnimationElement ))
       
  2344 				{
       
  2345 				// this will be used to calculate the from values again
       
  2346 				iHadBegun = EFalse;
       
  2347 				}
       
  2348 			else
       
  2349 				{
       
  2350 				iHadBegun = ETrue;
       
  2351 				}
       
  2352             iAdditive = iAdditiveOrg;
       
  2353 			iCurrentRepeatCount= 0;
       
  2354 			((CSvgDocumentImpl*)iOwnerDocument)->Engine()->NotifyAnimationStarted();
       
  2355 			
       
  2356 			//Triggers internal begin event so that animations dependent on this would get the events
       
  2357 				TSvgInternalEvent   event   ( ESvgEventBeginEvent, this,iAnimTime->BeginTime() );
       
  2358 	            
       
  2359 	            ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  2360 	                ( CSvgDocumentImpl* ) OwnerDocument(), &event );
       
  2361 
       
  2362 			}
       
  2363         else
       
  2364             {
       
  2365             iAdditive = KAdditivePass;
       
  2366             }
       
  2367         }
       
  2368 
       
  2369     if ( iAnimStatus == KAnimActive )
       
  2370         {
       
  2371 		// if end time less than the simple duration
       
  2372 
       
  2373 			// DurationTime() shall return the duration set in svg
       
  2374 			// E.g  begin="0s"  dur="10s" repeatCount='3' returns DurationTime() 10000, 
       
  2375 			// repeating of the animation would be handled while checking done 
       
  2376 			// before setting iAnimStatus to KAnimFinished. (see if ( iAnimStatus == KAnimEnd ))
       
  2377 		  if ( iAnimTime->DurationTime() != KTimeIndefinite
       
  2378 	               && timerEvent->Time() >= iAnimTime->BeginTime() + iAnimTime->DurationTime() )
       
  2379 	            {
       
  2380 	            // end animation
       
  2381 	            iAnimStatus = KAnimEnd;
       
  2382 		        if (iTargetElement)
       
  2383 		            {
       
  2384 		            iTargetElement->iHasAnimationBase = (TInt)this;
       
  2385                 	iTargetElement->SetIsAnimating( EFalse );
       
  2386                 	SetIsAnimating( EFalse );
       
  2387                 	
       
  2388 	                }
       
  2389 	            }
       
  2390 	       	// any endtime got from simpleDuration, EndTime values in svg content, event based endtimes 
       
  2391 	       	// E.g  begin="0s"  dur="10s" repeatCount='3' returns EndTime() 30000, 
       
  2392 	        if ( timerEvent->Time() >= iAnimTime->EndTime() )
       
  2393 	            {
       
  2394 	            // end animation
       
  2395 	            iAnimStatus = KAnimEnd;
       
  2396 	            if (iTargetElement)
       
  2397 	                {
       
  2398 	                iTargetElement->iHasAnimationBase = (TInt)this;
       
  2399         	        iTargetElement->SetIsAnimating( EFalse );
       
  2400                 	SetIsAnimating( EFalse );
       
  2401 	        	    }
       
  2402 	            }
       
  2403 
       
  2404         }
       
  2405 
       
  2406     if ( iAnimStatus == KAnimEnd )
       
  2407         {
       
  2408 
       
  2409 						//Check if animation is finished
       
  2410 						// Check 1. repeatcount reached
       
  2411 						//			 2. Repeatduration valid and reached
       
  2412 						//			 3. Endtime reached
       
  2413             if (( ( iCurrentRepeatCount >= iRepeatCount )||
       
  2414             
       
  2415                 ( ( iAnimTime->RepeatDurationTime() != KTimeIndefinite )&&
       
  2416                 ( iRepeatCount == KRepeatCountMax )&& 
       
  2417                 ( timerEvent->Time() >= iAbsoluteBeginTime + iAnimTime->RepeatDurationTime() ) ) )
       
  2418                
       
  2419                || timerEvent->Time() >= iAnimTime->EndTime()
       
  2420                 )
       
  2421                 {
       
  2422                 iEndTimeIndex++;
       
  2423 				TInt32 LEndTIme = lCurTime;
       
  2424 
       
  2425                 iAnimTime->SetEndTime(KTimeIndefinite);
       
  2426                 iAnimStatus = KAnimFinished;
       
  2427 
       
  2428                 if (iTargetElement)
       
  2429                     {
       
  2430                     iTargetElement->iHasAnimationBase = (TInt)this;
       
  2431                 	iTargetElement->SetIsAnimating( EFalse );
       
  2432                 	SetIsAnimating( EFalse );
       
  2433         	        }
       
  2434 
       
  2435                 iOverrideTime = EFalse;
       
  2436 
       
  2437                 // if its begin depends on its end than it might create a problem.
       
  2438                 if(!iIsEndEventSent || IsSelfDependentForBegin())
       
  2439 	                {
       
  2440 					((CSvgDocumentImpl*)iOwnerDocument)->Engine()->NotifyAnimationEnded();
       
  2441 					TSvgInternalEvent   event   ( ESvgEventEndEvent, this,LEndTIme );
       
  2442 					TSvgInternalEvent   event1   ( ESvgEventRepeatEvent, this,LEndTIme );
       
  2443 					//repeatCount Event is also generated
       
  2444 			        ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  2445 			            ( CSvgDocumentImpl* ) OwnerDocument(), &event1 );
       
  2446 			        ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  2447 			            ( CSvgDocumentImpl* ) OwnerDocument(), &event );
       
  2448 					// Update presentation should be called only if the animation gets finished
       
  2449 					// Check for the multiple begin values to make sure that the animation ended completely.
       
  2450 					if ( (iBeginTimeIndex+1 >= iAnimTime->BeginTimesCount() ) || ( iAnimTime->GetBeginTime( iBeginTimeIndex + 1 ) <= timerEvent->Time()))
       
  2451 						{
       
  2452 						((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1);
       
  2453 						}
       
  2454 					return ETrue; 	// so that draw happens if begin depends on its own end event
       
  2455 		            }
       
  2456 		           else
       
  2457 		            {
       
  2458 		            iIsEndEventSent = EFalse;
       
  2459 		            }
       
  2460 
       
  2461                 }
       
  2462                 
       
  2463             else
       
  2464                 {
       
  2465                 	// E.g  begin="0s"  dur="10s" repeatCount='3' 
       
  2466                 	//in such case if curtime < 30s and iAnimStatus is End then animation would repeat
       
  2467                 	iCurrentRepeatCount++;
       
  2468                 if ( iAccumulate == KAccumSum )
       
  2469                     {
       
  2470                     aAnimElement->SetAccumulateValues();
       
  2471                     }
       
  2472                 aAnimElement->ResetAnimationL();
       
  2473                 iAnimTime->ResetBeginTime( iAnimTime->BeginTime() +
       
  2474                                            iAnimTime->DurationTime() );
       
  2475                 iAnimStatus = KAnimActive;
       
  2476 
       
  2477                 if (iTargetElement)
       
  2478                     {
       
  2479                     iTargetElement->iHasAnimationBase = (TInt)this;
       
  2480                 	iTargetElement->SetIsAnimating( ETrue );
       
  2481                 	SetIsAnimating( ETrue );
       
  2482         	        }
       
  2483 
       
  2484                 iOverrideTime = EFalse;
       
  2485 					// Generates repeatEvent 
       
  2486 					//Triggers internal repeat event so that animations dependent on this would get the events
       
  2487 			
       
  2488 					TInt32 lRepeatTime = iAbsoluteBeginTime + iCurrentRepeatCount*iAnimTime->DurationTime();
       
  2489 						
       
  2490 					TSvgInternalEvent   event   ( ESvgEventRepeatEvent, this,lRepeatTime );
       
  2491 		            ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  2492 		                ( CSvgDocumentImpl* ) OwnerDocument(), &event );
       
  2493                 }
       
  2494         }
       
  2495 
       
  2496        // do not redraw.
       
  2497        if(iAnimStatus == KAnimNotActive || (iAnimStatus == KAnimFinished && iDoFreeze))
       
  2498 	       {
       
  2499 	       // this will avoid going in to the draw again.
       
  2500 	       return EFalse;
       
  2501 	       }
       
  2502       return ETrue;
       
  2503 
       
  2504     }
       
  2505 
       
  2506 //
       
  2507 // ---------------------------------------------------------------------------
       
  2508 //
       
  2509 // ---------------------------------------------------------------------------
       
  2510 void CSvgAnimationBase::SetFillValueL()
       
  2511     {
       
  2512     switch ( iDataType )
       
  2513         {
       
  2514         case KSvgTypeOpacity:
       
  2515         case KSvgTypeLength:
       
  2516         iTargetElement->GetAttributeFloat( iAttrId, iPropFloat );
       
  2517         if ( ( iFill == KAnimFillFreeze ) && iNoFrom )
       
  2518             {
       
  2519             iFromFloat = iPropFloat;
       
  2520             }
       
  2521         break;
       
  2522 
       
  2523         case KSvgTypeList:
       
  2524         case KSvgTypePath:
       
  2525         break;
       
  2526 
       
  2527         case KSvgTypeColor:
       
  2528         if ( iAttributeFlag && !iCurrentRepeatCount )
       
  2529             {
       
  2530             iTargetElement->GetAttributeIntL( iAttrId, iPropInt );
       
  2531 
       
  2532             }
       
  2533         break;
       
  2534         case KSvgTypeTextAnchor:
       
  2535         case KSvgTypeGradientUnits:
       
  2536         case KSvgTypeSpreadMethod:
       
  2537         case KSvgTypeInteger:
       
  2538         case KSvgTypeDisplay:
       
  2539         case KSvgTypeVisibility:
       
  2540         if ( iAttributeFlag )
       
  2541             {
       
  2542             iTargetElement->GetAttributeIntL( iAttrId, iPropInt );
       
  2543             }
       
  2544         break;
       
  2545 
       
  2546 		// viewBox
       
  2547         case KSvgTypeViewBox:
       
  2548 			{
       
  2549 			if(iTargetElement->ElemID() == KSvgSvgElement)
       
  2550 				{
       
  2551 				((CSvgSvgElementImpl*)iTargetElement)->GetViewBox( iOrgViewBox );
       
  2552 				if ( ( iFill == KAnimFillFreeze ) && iNoFrom )
       
  2553 					{
       
  2554 					iFromViewBox = iOrgViewBox;
       
  2555 					}
       
  2556 				}
       
  2557 			}
       
  2558 			 break;
       
  2559 
       
  2560         default:
       
  2561         break;
       
  2562         }
       
  2563     }
       
  2564 
       
  2565 
       
  2566 //
       
  2567 // ---------------------------------------------------------------------------
       
  2568 //
       
  2569 // ---------------------------------------------------------------------------
       
  2570 void CSvgAnimationBase::SetToOriginalL()
       
  2571     {
       
  2572     switch ( iDataType )
       
  2573         {
       
  2574         case KSvgTypeOpacity:
       
  2575         case KSvgTypeLength:
       
  2576         iTargetElement->SetAttributeFloatL( iAttrId, iPropFloat );
       
  2577         break;
       
  2578         case KSvgTypeList:
       
  2579         case KSvgTypePath:
       
  2580             iTargetElement->SetAttributePathL( iAttrId, iOrgPath );
       
  2581         break;
       
  2582         case KSvgTypeTextAnchor:
       
  2583         case KSvgTypeGradientUnits:
       
  2584         case KSvgTypeSpreadMethod:
       
  2585         case KSvgTypeColor:
       
  2586         case KSvgTypeInteger:
       
  2587         case KSvgTypeDisplay:
       
  2588         case KSvgTypeVisibility:
       
  2589         if ( iAttributeFlag )
       
  2590             {
       
  2591             iTargetElement->SetAttributeIntL( iAttrId, iPropInt );
       
  2592             }
       
  2593         break;
       
  2594 
       
  2595 		//viewBox
       
  2596         case KSvgTypeViewBox:
       
  2597 			{
       
  2598 		    if(iTargetElement->ElemID() == KSvgSvgElement)
       
  2599 				{
       
  2600 				((CSvgSvgElementImpl*)iTargetElement)->SetViewBoxL( iOrgViewBox );
       
  2601 				}
       
  2602 			}
       
  2603 			break;
       
  2604 
       
  2605         default:
       
  2606         break;
       
  2607         }
       
  2608     }
       
  2609 
       
  2610 // ---------------------------------------------------------------------------
       
  2611 //
       
  2612 // ---------------------------------------------------------------------------
       
  2613 void CSvgAnimationBase::SetToInitialValueL()
       
  2614     {
       
  2615     switch ( iDataType )
       
  2616         {
       
  2617         case KSvgTypeOpacity:
       
  2618         case KSvgTypeLength:
       
  2619             iTargetElement->SetAttributeFloatL( iAttrId, iPropFloat );
       
  2620         break;
       
  2621         case KSvgTypeList:
       
  2622         case KSvgTypePath:
       
  2623              iTargetElement->SetAttributePathL( iAttrId, iOrgPath );
       
  2624         break;
       
  2625         case KSvgTypeColor:
       
  2626         if ( iAttributeFlag )
       
  2627             {
       
  2628             iTargetElement->SetAttributeIntL( iAttrId, iPropInt );
       
  2629             }
       
  2630         else
       
  2631             {
       
  2632             if( iAttrId == KCSS_ATTR_VISIBILITY ||
       
  2633                 iAttrId == KCSS_ATTR_FILL ||
       
  2634                 iAttrId == KCSS_ATTR_STROKE )
       
  2635                 {
       
  2636                 iTargetElement->RemoveAttribute(iAttrId);
       
  2637                 }
       
  2638 
       
  2639             }
       
  2640         break;
       
  2641         case KSvgTypeTextAnchor:
       
  2642         case KSvgTypeGradientUnits:
       
  2643         case KSvgTypeSpreadMethod:
       
  2644         case KSvgTypeInteger:
       
  2645         case KSvgTypeDisplay:
       
  2646         case KSvgTypeVisibility:
       
  2647         if ( iAttributeFlag )
       
  2648             {
       
  2649             iTargetElement->SetAttributeIntL( iAttrId, iPropInt );
       
  2650             }
       
  2651         else
       
  2652             {
       
  2653             if( iAttrId == KCSS_ATTR_VISIBILITY ||
       
  2654                 iAttrId == KCSS_ATTR_FILL ||
       
  2655                 iAttrId == KCSS_ATTR_STROKE )
       
  2656                 {
       
  2657                 iTargetElement->RemoveAttribute(iAttrId);
       
  2658                 }
       
  2659 
       
  2660             }
       
  2661         break;
       
  2662 
       
  2663 		//viewBox
       
  2664         case KSvgTypeViewBox:
       
  2665 			{
       
  2666 		    if(iTargetElement->ElemID() == KSvgSvgElement)
       
  2667 				{
       
  2668 				((CSvgSvgElementImpl*)iTargetElement)->SetViewBoxL( iOrgViewBox );
       
  2669 				}
       
  2670 			}
       
  2671 		break;
       
  2672 
       
  2673         default:
       
  2674             ;
       
  2675         }
       
  2676     }
       
  2677 // ---------------------------------------------------------------------------
       
  2678 //
       
  2679 // ---------------------------------------------------------------------------
       
  2680 void CSvgAnimationBase::SetToEndValueL()
       
  2681     {
       
  2682     switch ( iDataType )
       
  2683         {
       
  2684         case KSvgTypeOpacity:
       
  2685         case KSvgTypeLength:
       
  2686             if( iAdditive == KAdditiveSum && !iNoFrom && (this->ElemID() == KSvgAnimateElement ))
       
  2687             {
       
  2688                 TFloatFixPt lCurValue;
       
  2689                 iTargetElement->GetAttributeFloat( iAttrId, lCurValue );
       
  2690                 iTargetElement->SetAttributeFloatL(iAttrId, lCurValue +  iEndFloat );
       
  2691             }
       
  2692             else
       
  2693             {
       
  2694                 iTargetElement->SetAttributeFloatL( iAttrId, iEndFloat );
       
  2695             }
       
  2696         break;
       
  2697         case KSvgTypeList:
       
  2698         case KSvgTypePath:
       
  2699             {
       
  2700             iTargetElement->SetAttributePathL( iAttrId, iEndPath );
       
  2701             }
       
  2702         break;
       
  2703 		case KSvgTypeTextAnchor:
       
  2704         case KSvgTypeGradientUnits:
       
  2705         case KSvgTypeSpreadMethod:
       
  2706         case KSvgTypeInteger:
       
  2707         case KSvgTypeDisplay:
       
  2708         case KSvgTypeVisibility:
       
  2709 			{
       
  2710         if ( iAttributeFlag )
       
  2711             {
       
  2712             iTargetElement->SetAttributeIntL( iAttrId, iEndInt );
       
  2713             }
       
  2714 			}
       
  2715         break;
       
  2716 
       
  2717         case KSvgTypeColor:
       
  2718 			{
       
  2719 			// fix for accum_addit_7
       
  2720 			if( iAttributeFlag )
       
  2721 				{
       
  2722 				if( iAdditive == KAdditiveSum && !iNoFrom  )
       
  2723 					{
       
  2724 
       
  2725 					TInt32 lCurValue;
       
  2726 					iTargetElement->GetAttributeIntL( iAttrId, lCurValue );
       
  2727 
       
  2728 
       
  2729 				   lCurValue = AddColor( iEndInt, lCurValue );
       
  2730 					iTargetElement->SetAttributeIntL( iAttrId, lCurValue );
       
  2731 					}
       
  2732 
       
  2733 				else
       
  2734 					{
       
  2735 					iTargetElement->SetAttributeIntL( iAttrId, iEndInt );
       
  2736 					}
       
  2737 				}
       
  2738 			}
       
  2739         break;
       
  2740 
       
  2741 		//viewBox
       
  2742         case KSvgTypeViewBox:
       
  2743 			{
       
  2744 		     if( iAdditive == KAdditiveSum && !iNoFrom && (this->ElemID() == KSvgAnimateElement ))
       
  2745 				{
       
  2746 				TGfxRectangle2D  lCurValue;
       
  2747 				if(iTargetElement->ElemID() == KSvgSvgElement)
       
  2748 					{
       
  2749 					((CSvgSvgElementImpl*)iTargetElement)->GetViewBox( lCurValue );
       
  2750 					}
       
  2751 
       
  2752 				lCurValue.iX += iEndViewBox.iX ;
       
  2753 				lCurValue.iY += iEndViewBox.iY ;
       
  2754 				lCurValue.iWidth += iEndViewBox.iWidth ;
       
  2755 				lCurValue.iHeight += iEndViewBox.iHeight ;
       
  2756 
       
  2757 
       
  2758 				// set the vlue to the target element.
       
  2759 				 if(iTargetElement->ElemID() == KSvgSvgElement)
       
  2760 					{
       
  2761 					((CSvgSvgElementImpl*)iTargetElement)->SetViewBoxL( lCurValue );
       
  2762 					}
       
  2763 				}
       
  2764 
       
  2765   			 else
       
  2766 				{
       
  2767 				if(iTargetElement->ElemID() == KSvgSvgElement)
       
  2768 					{
       
  2769 					((CSvgSvgElementImpl*)iTargetElement)->SetViewBoxL( iEndViewBox );
       
  2770 					}
       
  2771 				}
       
  2772 			}
       
  2773         break;
       
  2774 
       
  2775         default:
       
  2776         break;
       
  2777         }
       
  2778     }
       
  2779 
       
  2780 
       
  2781 
       
  2782 // ---------------------------------------------------------------------------
       
  2783 // Initialization before start of animation
       
  2784 // ---------------------------------------------------------------------------
       
  2785 void CSvgAnimationBase::InitAnimationL()
       
  2786     {
       
  2787     // 1. Create keytimes if no keytime but values available
       
  2788     // 2. Set animation time according to calcMode
       
  2789     //
       
  2790     // Also, add target element to event receiver list for mouse event
       
  2791     //Set the First Begin Time
       
  2792 
       
  2793 
       
  2794 
       
  2795     if( iAnimTime->BeginTimesCount() > 0 )
       
  2796         {
       
  2797         iAnimTime->SetBeginTime( iAnimTime->GetBeginTime(0));
       
  2798         iAbsoluteBeginTime = iAnimTime->GetBeginTime(0);
       
  2799         }
       
  2800 
       
  2801 
       
  2802     if( iAnimTime->RepeatDurationTime() != KTimeIndefinite )
       
  2803         {
       
  2804          iAnimTime->CalculateAnimTimes();
       
  2805         }
       
  2806 
       
  2807 
       
  2808 
       
  2809 
       
  2810     iOverrideTime = ETrue;
       
  2811 
       
  2812     switch ( iDataType )
       
  2813         {
       
  2814         case KSvgTypeOpacity:
       
  2815         case KSvgTypeLength:
       
  2816         if ( iNoFrom )
       
  2817             {
       
  2818             iOrgFromFloat = iFromFloat = iPropFloat;
       
  2819             }
       
  2820         iAnimTime->CreateKeyTime( iValuesFloat->Count() );
       
  2821         iAnimTime->PrepareTimeL( iValuesFloat );
       
  2822         break;
       
  2823         case KSvgTypeList:
       
  2824         case KSvgTypePath:
       
  2825             {
       
  2826            
       
  2827             if ( iOrgFromPath )
       
  2828                 {
       
  2829                 delete iOrgFromPath;
       
  2830                 iOrgFromPath = NULL;
       
  2831                 }
       
  2832             iOrgFromPath = CGfxGeneralPath::NewL();
       
  2833 
       
  2834 			CGfxGeneralPath* parentPath = NULL;
       
  2835             iTargetElement->GetAttributePath( iAttrId, parentPath );
       
  2836             CGfxPathIterator*   itr;
       
  2837             TGfxAffineTransform affineTransform;
       
  2838             
       
  2839             if (parentPath != NULL)
       
  2840             {
       
  2841             parentPath->GetPathIteratorL( &affineTransform, itr );
       
  2842             CleanupStack::PushL( itr );
       
  2843 
       
  2844             iOrgFromPath->AppendL( itr );
       
  2845             CleanupStack::PopAndDestroy( 1 ); // destroy itr
       
  2846 			}
       
  2847             // Set keytime
       
  2848 
       
  2849 			iValuesFloat->Reset();
       
  2850             TInt lCount = iValuesPath->Count();
       
  2851             for ( TInt i = 0; i < lCount ; i++ )
       
  2852                 {
       
  2853                 User::LeaveIfError(iValuesFloat->Append( TFloatFixPt( i ) )); // create dummy scalar array
       
  2854                 }
       
  2855             iAnimTime->CreateKeyTime( iValuesFloat->Count() );
       
  2856             iAnimTime->PrepareTimeL( iValuesFloat );
       
  2857             }
       
  2858         break;
       
  2859 
       
  2860         case KSvgTypeColor:
       
  2861             {
       
  2862             // Set keytime
       
  2863             iValuesFloat->Reset();
       
  2864             // Compute the colour distance in iValuesFloat
       
  2865             FindColorDistanceL();
       
  2866             iAnimTime->CreateKeyTime( iValuesFloat->Count() );
       
  2867             iAnimTime->PrepareTimeL( iValuesFloat );
       
  2868             }
       
  2869         break;
       
  2870         case KSvgTypeTextAnchor:
       
  2871         case KSvgTypeGradientUnits:
       
  2872         case KSvgTypeSpreadMethod:
       
  2873         case KSvgTypeVisibility:
       
  2874         case KSvgTypeDisplay:
       
  2875         case KSvgTypeInteger:
       
  2876         iAnimTime->CreateKeyTimeForEnumeration( iValuesInt->Count() );
       
  2877         iAnimTime->PrepareTimeL( ( RArray<TFloatFixPt>* ) iValuesInt );
       
  2878         break;
       
  2879 
       
  2880        // viewBox
       
  2881         case KSvgTypeViewBox:
       
  2882 			{
       
  2883 		    if ( iNoFrom )
       
  2884 			    {
       
  2885 				 iOrgFromViewBox = iFromViewBox = iOrgViewBox;
       
  2886 				}
       
  2887         // Set keytime
       
  2888 			iValuesFloat->Reset();
       
  2889             TInt lCount = iValuesViewBox->Count();
       
  2890             for ( TInt i = 0; i < lCount ; i++ )
       
  2891                 User::LeaveIfError(iValuesFloat->Append( TFloatFixPt( i ) )); // create dummy scalar array
       
  2892             iAnimTime->CreateKeyTime( iValuesFloat->Count() );
       
  2893             iAnimTime->PrepareTimeL( iValuesFloat );
       
  2894 			}
       
  2895 			break;
       
  2896 
       
  2897         default:
       
  2898         // Text
       
  2899 			break;
       
  2900         }
       
  2901 
       
  2902      TUint32 lSimpleDuration = SimpleDuration();
       
  2903      if( lSimpleDuration != KTimeIndefinite)
       
  2904             {
       
  2905             iAnimTime->SetEndTime(lSimpleDuration);
       
  2906 			iAnimTime->SetModifiedEndTime(lSimpleDuration);
       
  2907             }
       
  2908 
       
  2909 	 if(this->ElemID() == KSvgAnimateColorElement)
       
  2910 
       
  2911         {
       
  2912 
       
  2913         // this Is to check that the animateColor is not applied to anything
       
  2914         // other than color.
       
  2915 
       
  2916         switch(iDataType )
       
  2917             {
       
  2918             case KSvgTypeColor:
       
  2919             break;
       
  2920             default :
       
  2921             ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this );
       
  2922             ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1);
       
  2923             break;
       
  2924             }
       
  2925 
       
  2926         }
       
  2927 
       
  2928     // Add to event receiver list
       
  2929     // Also need to look end event...
       
  2930     CSvgElementImpl* targetElement = NULL;
       
  2931 
       
  2932 
       
  2933 		// this is for forward reference.
       
  2934 	 	// first find the count this can be more than one
       
  2935 		// for multiple BeginTimes.
       
  2936 	 	TInt lCount = iEventList->Count();
       
  2937 	 	for (TInt i=0; i< lCount; i++)
       
  2938 	 		{
       
  2939 
       
  2940 			if ( (iEventList->operator[](i)).iTargetElement != NULL )
       
  2941 			{
       
  2942 			((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL(
       
  2943 			                                     (iEventList->operator[](i)).iTargetElement,
       
  2944 			                                     (iEventList->operator[](i)).iEvent,
       
  2945 			                                     KSvgEventMaskExternalUI );
       
  2946 			}
       
  2947 			
       
  2948 	 		// check that this is not NULL;
       
  2949 	 		// NULL means Begin time is absolute.
       
  2950 		 	if(iEventList->operator[](i).iReferenceElemeId != NULL)
       
  2951 			 	{
       
  2952 
       
  2953 			 	// find the element.
       
  2954 			 	targetElement = ( CSvgElementImpl * )
       
  2955 		                      ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById(
       
  2956 		                         iEventList->operator[](i).iReferenceElemeId->Des());
       
  2957 				if(targetElement != NULL)
       
  2958 					{
       
  2959 
       
  2960 					// Add to Event receiver list.
       
  2961 					((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL(
       
  2962 					targetElement ,(iEventList->operator[](i)).iEvent, KSvgEventMaskExternalUI );
       
  2963 
       
  2964 					// update the pointer to the target element.
       
  2965 					iEventList->operator[](i).iTargetElement = targetElement;
       
  2966 					iTargetElement->iHasAnimationBase = (TInt)this;
       
  2967 					}
       
  2968 
       
  2969 				delete  iEventList->operator[](i).iReferenceElemeId;
       
  2970 				iEventList->operator[](i).iReferenceElemeId = NULL;
       
  2971 
       
  2972 				}
       
  2973 
       
  2974 			}
       
  2975 
       
  2976 	// add the end sync element so that it receives mouse events
       
  2977 
       
  2978 	 if( iEndTimeList->Count() > 0 )
       
  2979         {
       
  2980 
       
  2981 		// this is for forward reference.
       
  2982 	 	// first find the count this can be more than one
       
  2983 		// for multiple BeginTimes.
       
  2984 	 	TInt lCount2 = iEndTimeList->Count();
       
  2985 	 	for (TInt i=0; i< lCount2; i++)
       
  2986 	 		{
       
  2987 	 		
       
  2988 	 		if ( (iEndTimeList->operator[](i)).iTargetElement != NULL )
       
  2989 			{
       
  2990 			((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL(
       
  2991 			                                     (iEndTimeList->operator[](i)).iTargetElement,
       
  2992 			                                     (iEndTimeList->operator[](i)).iEvent,
       
  2993 			                                     KSvgEventMaskExternalUI );
       
  2994 			}
       
  2995 			
       
  2996 	 		// check that this is not NULL;
       
  2997 	 		// NULL means Begin time is absolute.
       
  2998 		 	if(iEndTimeList->operator[](i).iReferenceElemeId != NULL)
       
  2999 			 	{
       
  3000 
       
  3001 			 	// find the element.
       
  3002 			 	targetElement = ( CSvgElementImpl * )
       
  3003 		                      ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById(
       
  3004 		                         iEndTimeList->operator[](i).iReferenceElemeId->Des());
       
  3005 				if(targetElement != NULL)
       
  3006 					{
       
  3007 
       
  3008 					// Add to Event receiver list.
       
  3009 					((CSvgDocumentImpl*)iOwnerDocument)->AddToEventReceiverListL(
       
  3010 					                                     targetElement ,
       
  3011 					                                     (iEndTimeList->operator[](0)).iEvent,
       
  3012 					                                     KSvgEventMaskExternalUI );
       
  3013 
       
  3014 					// update the pointer to the target element.
       
  3015 					iEndTimeList->operator[](i).iTargetElement = targetElement;
       
  3016 					iTargetElement->iHasAnimationBase = (TInt)this;
       
  3017 					}
       
  3018 
       
  3019 				delete  iEndTimeList->operator[](i).iReferenceElemeId;
       
  3020 				iEndTimeList->operator[](i).iReferenceElemeId = NULL;
       
  3021 
       
  3022 				}
       
  3023 
       
  3024 			}
       
  3025 
       
  3026 		}
       
  3027 
       
  3028         }
       
  3029 
       
  3030 //
       
  3031 // ---------------------------------------------------------------------------
       
  3032 //
       
  3033 // ---------------------------------------------------------------------------
       
  3034 void CSvgAnimationBase::SetAccumulateValues()
       
  3035     {
       
  3036    /* switch ( iDataType )
       
  3037         {
       
  3038         case KSvgTypeOpacity:
       
  3039         case KSvgTypeLength:
       
  3040         case KSvgTypeList:
       
  3041         case KSvgTypePath:
       
  3042         break;
       
  3043 
       
  3044         case KSvgTypeColor:
       
  3045         break;
       
  3046 
       
  3047         case KSvgTypeInteger:
       
  3048         break;
       
  3049 
       
  3050         default:
       
  3051         // Descriptor
       
  3052         ;
       
  3053         }*/
       
  3054     }
       
  3055 
       
  3056 // ---------------------------------------------------------------------------
       
  3057 //
       
  3058 // ---------------------------------------------------------------------------
       
  3059 TBool CSvgAnimationBase::IsElementAttrs( const TDesC& aAttrName )
       
  3060     {
       
  3061     TInt pos = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->GetSVGTAttributeId(aAttrName);
       
  3062 
       
  3063     if ( pos == KErrNotFound)
       
  3064         {
       
  3065         // Did not find the attribute name
       
  3066         return EFalse;
       
  3067         }
       
  3068     else
       
  3069         {
       
  3070         iAttrId= (TUint16) pos;
       
  3071         if(iAttrId <= KSvgCoordAttrEndIndex || iAttrId == KAtrFy || iAttrId == KAtrFx )
       
  3072             {
       
  3073             iDataType = KSvgTypeLength;
       
  3074             }
       
  3075         else
       
  3076             {
       
  3077             switch(iAttrId)
       
  3078                 {
       
  3079                 case KAtrGradientUnits:
       
  3080                 iDataType = KSvgTypeGradientUnits;
       
  3081                 break;
       
  3082                 case KAtrSpreadMethods:
       
  3083                 iDataType = KSvgTypeSpreadMethod;
       
  3084                 break;
       
  3085 
       
  3086                 case KAtrStopColor:
       
  3087                 iDataType= KSvgTypeColor;
       
  3088                 break;
       
  3089 
       
  3090                 case KAtrPoints:
       
  3091                 case KAtrD:
       
  3092                 iDataType = KSvgTypePath;
       
  3093                 break;
       
  3094 
       
  3095                 case KAtrOffset: // Always need to be between 0 - 1 , thus treating same as opacity.
       
  3096                 case KAtrStopOpacity:
       
  3097                 iDataType= KSvgTypeOpacity;
       
  3098                 break;
       
  3099 
       
  3100 				case KAtrViewBox:
       
  3101                 iDataType= KSvgTypeViewBox;
       
  3102                 break;
       
  3103 
       
  3104                 default:
       
  3105                 return EFalse;
       
  3106                 }
       
  3107             }
       
  3108         }
       
  3109 
       
  3110     return ETrue;
       
  3111     }
       
  3112 
       
  3113 
       
  3114 
       
  3115 // ---------------------------------------------------------------------------
       
  3116 //
       
  3117 // ---------------------------------------------------------------------------
       
  3118 TBool CSvgAnimationBase::IsPresentationAttrs( const TDesC& aAttrName )
       
  3119     {
       
  3120     TInt            ret;
       
  3121     ret = ((CSvgDocumentImpl*)iOwnerDocument)->SchemaData()->GetPresentationAttributeId( aAttrName);
       
  3122     if ( ret  == KErrNotFound )
       
  3123         {
       
  3124         // Did not find the attribute name
       
  3125         return EFalse;
       
  3126         }
       
  3127     else
       
  3128         {
       
  3129         switch ( ret )
       
  3130             {
       
  3131             case KCSS_ATTR_FILL:
       
  3132             // fill
       
  3133             iAttrId = KCSS_ATTR_FILL;
       
  3134             iDataType = KSvgTypeColor;
       
  3135             break;
       
  3136             case KCSS_ATTR_STROKE:
       
  3137             // stroke
       
  3138             iAttrId = KCSS_ATTR_STROKE;
       
  3139             iDataType = KSvgTypeColor;
       
  3140             break;
       
  3141             case KCSS_ATTR_STROKEWIDTH:
       
  3142             // stroke-width
       
  3143             iAttrId = KCSS_ATTR_STROKEWIDTH;
       
  3144             iDataType = KSvgTypeLength;
       
  3145             break;
       
  3146             case KCSS_ATTR_STROKE_DASHOFFSET:
       
  3147             iAttrId = KCSS_ATTR_STROKE_DASHOFFSET;
       
  3148             iDataType = KSvgTypeLength;
       
  3149             break;
       
  3150             case KCSS_ATTR_VISIBILITY:
       
  3151             // visibility
       
  3152             iAttrId = KCSS_ATTR_VISIBILITY;
       
  3153             iDataType = KSvgTypeVisibility;
       
  3154             break;
       
  3155             case KCSS_ATTR_COLOR:
       
  3156             // color
       
  3157             iAttrId = KCSS_ATTR_COLOR;
       
  3158             iDataType = KSvgTypeColor;
       
  3159             break;
       
  3160             case KCSS_ATTR_FONTSIZE:
       
  3161             // font-size
       
  3162             iAttrId = KCSS_ATTR_FONTSIZE;
       
  3163             iDataType = KSvgTypeLength;
       
  3164             break;
       
  3165             case KCSS_ATTR_DISPLAY:
       
  3166             // display
       
  3167             iAttrId = KCSS_ATTR_DISPLAY;
       
  3168             iDataType = KSvgTypeDisplay;
       
  3169             break;
       
  3170             case KCSS_ATTR_TEXTANCHOR:
       
  3171             iAttrId = KCSS_ATTR_TEXTANCHOR;
       
  3172             iDataType = KSvgTypeTextAnchor;
       
  3173             break;
       
  3174             case KCSS_ATTR_FILL_OPACITY:
       
  3175             iAttrId = KCSS_ATTR_FILL_OPACITY;
       
  3176             iDataType = KSvgTypeOpacity;
       
  3177             break;
       
  3178             case KCSS_ATTR_STROKE_OPACITY:
       
  3179             iAttrId = KCSS_ATTR_STROKE_OPACITY;
       
  3180             iDataType = KSvgTypeOpacity;
       
  3181             break;
       
  3182             case KCSS_ATTR_GROUP_OPACITY:
       
  3183             iAttrId = KCSS_ATTR_GROUP_OPACITY;
       
  3184             iDataType = KSvgTypeOpacity;
       
  3185             break;
       
  3186             default:
       
  3187             break;
       
  3188             }
       
  3189 
       
  3190         }
       
  3191 
       
  3192     return ETrue;
       
  3193     }
       
  3194 
       
  3195 
       
  3196 // ---------------------------------------------------------------------------
       
  3197 //
       
  3198 // ---------------------------------------------------------------------------
       
  3199 void CSvgAnimationBase::GetAttrValueL()
       
  3200     {
       
  3201     iAttributeFlag = 1;
       
  3202     switch ( iDataType )
       
  3203         {
       
  3204         case KSvgTypeLength:
       
  3205         case KSvgTypeNumber:
       
  3206             iTargetElement->GetAttributeFloat( iAttrId, iPropFloat );
       
  3207         	iTargetElement->GetAttributeFloat( iAttrId, iOrgFloat );
       
  3208         break;
       
  3209         case KSvgTypeOpacity:
       
  3210             iTargetElement->GetAttributeFloat( iAttrId, iPropFloat );
       
  3211         iTargetElement->GetAttributeFloat( iAttrId, iOrgFloat );
       
  3212         break;
       
  3213         case KSvgTypeList:
       
  3214         case KSvgTypePath:
       
  3215             {
       
  3216             // copy parent -> iOrgPath
       
  3217             CGfxGeneralPath*parentPath = NULL;
       
  3218            
       
  3219 			if ( iOrgPath )
       
  3220 			{
       
  3221 			delete iOrgPath;
       
  3222 			iOrgPath = NULL;
       
  3223 			}
       
  3224 
       
  3225 			if ( iEndPath )
       
  3226 			{
       
  3227 			delete iEndPath;
       
  3228 			iEndPath = NULL;
       
  3229 			}
       
  3230             
       
  3231             iOrgPath = CGfxGeneralPath::NewL();
       
  3232             iEndPath = CGfxGeneralPath::NewL();
       
  3233 
       
  3234             iTargetElement->GetAttributePath( iAttrId, parentPath );
       
  3235             
       
  3236             if(parentPath != NULL)
       
  3237             {
       
  3238             CGfxPathIterator*   itr;
       
  3239             TGfxAffineTransform affineTransform;
       
  3240             parentPath->GetPathIteratorL( &affineTransform, itr );
       
  3241             CleanupStack::PushL( itr );
       
  3242             iOrgPath->AppendL( itr );
       
  3243             CleanupStack::PopAndDestroy( 1 ); // destroy itr
       
  3244 
       
  3245             iTargetElement->GetAttributePath( iAttrId, parentPath );
       
  3246             CGfxPathIterator*   itr1;
       
  3247             TGfxAffineTransform affineTransform1;
       
  3248             parentPath->GetPathIteratorL( &affineTransform1, itr1 );
       
  3249             CleanupStack::PushL( itr1 );
       
  3250             iEndPath->AppendL( itr1 );
       
  3251             CleanupStack::PopAndDestroy( 1 ); // destroy itr 
       
  3252             }
       
  3253             }
       
  3254         break;
       
  3255         case KSvgTypeColor:
       
  3256             {
       
  3257             TInt32  col;
       
  3258 
       
  3259             if ( iTargetElement->GetAttributeIntL( iAttrId, col ) ==
       
  3260                  KErrNoAttribute )
       
  3261                 {
       
  3262                 iPropInt = 0;
       
  3263                 iAttributeFlag = 0;
       
  3264                 }
       
  3265             else
       
  3266                 {
       
  3267 				// convert the color to openVG color
       
  3268                 iPropInt = col;
       
  3269                 iAttributeFlag = 1;
       
  3270                 }
       
  3271             iTargetElement->GetAttributeIntL( iAttrId, iOrgInt );
       
  3272             }
       
  3273         break;
       
  3274         case KSvgTypeTextAnchor:
       
  3275         case KSvgTypeGradientUnits:
       
  3276         case KSvgTypeSpreadMethod:
       
  3277         case KSvgTypeInteger:
       
  3278             iTargetElement->GetAttributeIntL( iAttrId, iPropInt );
       
  3279         iTargetElement->GetAttributeIntL( iAttrId, iOrgInt );
       
  3280         break;
       
  3281         case KSvgTypeVisibility:
       
  3282             iTargetElement->GetAttributeIntL( iAttrId, iOrgInt );
       
  3283             if ( iTargetElement->GetAttributeIntL( iAttrId, iPropInt ) == KErrNoAttribute )
       
  3284             {
       
  3285                 iPropInt = 0;
       
  3286             iAttributeFlag = 0;
       
  3287             }
       
  3288         else
       
  3289             {
       
  3290             iAttributeFlag = 1;
       
  3291             }
       
  3292         break;
       
  3293         case KSvgTypeDisplay:
       
  3294             iTargetElement->GetAttributeIntL( iAttrId, iPropInt );
       
  3295         iTargetElement->GetAttributeIntL( iAttrId, iOrgInt );
       
  3296         break;
       
  3297 
       
  3298 
       
  3299 			// viewBox
       
  3300         case KSvgTypeViewBox:
       
  3301 			{
       
  3302 			if(iTargetElement->ElemID() == KSvgSvgElement)
       
  3303 				{
       
  3304 				((CSvgSvgElementImpl*)iTargetElement)->GetViewBox( iOrgViewBox );
       
  3305 				}
       
  3306 			}
       
  3307 		break;
       
  3308 
       
  3309         default:
       
  3310             iTargetElement->GetAttributeIntL( iAttrId, iOrgInt );
       
  3311             iTargetElement->GetAttributeIntL( iAttrId, iPropInt );
       
  3312         break;
       
  3313         }
       
  3314     }
       
  3315 
       
  3316 
       
  3317 void CSvgAnimationBase::ResetAttrValueL()
       
  3318     {
       
  3319 
       
  3320     if (!iTargetElement)
       
  3321     {
       
  3322     	return;
       
  3323     }
       
  3324 
       
  3325     switch ( iDataType )
       
  3326         {
       
  3327         case KSvgTypeLength:
       
  3328         case KSvgTypeNumber:
       
  3329             iTargetElement->SetAttributeFloatL( iAttrId, iOrgFloat );
       
  3330             break;
       
  3331         case KSvgTypeOpacity:
       
  3332             iTargetElement->SetAttributeFloatL( iAttrId, iOrgFloat );
       
  3333             break;
       
  3334         case KSvgTypeColor:
       
  3335             iTargetElement->SetAttributeIntL( iAttrId, iOrgInt );
       
  3336             break;
       
  3337         case KSvgTypeTextAnchor:
       
  3338         case KSvgTypeGradientUnits:
       
  3339         case KSvgTypeSpreadMethod:
       
  3340         case KSvgTypeInteger:
       
  3341             iTargetElement->SetAttributeIntL( iAttrId, iOrgInt );
       
  3342             break;
       
  3343         case KSvgTypeVisibility:
       
  3344             iTargetElement->SetAttributeIntL( iAttrId, iOrgInt );
       
  3345             break;
       
  3346         case KSvgTypeDisplay:
       
  3347             iTargetElement->SetAttributeIntL( iAttrId, iOrgInt );
       
  3348             break;
       
  3349         default:
       
  3350             iTargetElement->SetAttributeIntL( iAttrId, iOrgInt );
       
  3351             break;
       
  3352         }
       
  3353     }
       
  3354 
       
  3355 
       
  3356 //
       
  3357 // ---------------------------------------------------------------------------
       
  3358 //
       
  3359 // ---------------------------------------------------------------------------
       
  3360 void CSvgAnimationBase::SetTarget( CSvgElementImpl* aTarget )
       
  3361     {
       
  3362 		if (aTarget)
       
  3363 		{
       
  3364     iTargetSet = ETrue;
       
  3365     // Before anything else set the target to parent
       
  3366     iTargetElement = aTarget;
       
  3367     iTargetElement->iHasAnimationBase = (TInt)this;
       
  3368 		}
       
  3369     }
       
  3370 
       
  3371 //
       
  3372 // ---------------------------------------------------------------------------
       
  3373 //
       
  3374 // ---------------------------------------------------------------------------
       
  3375 void CSvgAnimationBase::SetBeginByEventL( CSvgAnimationBase* aAnimElement,
       
  3376                                          TInt32 aBeginTime, TBool aAddTime )
       
  3377     {
       
  3378     if ( iAnimRestart == KRestartWhenNotActive && iAnimStatus == KAnimActive )
       
  3379         {
       
  3380         return;     // Not start when active and restart="whenNotActive"
       
  3381         }
       
  3382     if ( iAnimRestart == KRestartNever && iHadBegun )
       
  3383         {
       
  3384         return;     // Not start when anim had begun and if restart="never"
       
  3385         }
       
  3386 
       
  3387 
       
  3388     aAnimElement->ResetAnimationL();
       
  3389 
       
  3390     if ( aAddTime )
       
  3391     	{
       
  3392 	    iAnimTime->AddBeginTime( aBeginTime );
       
  3393     	}
       
  3394     else
       
  3395 		{
       
  3396     	iAnimTime->ResetBeginTime( aBeginTime );
       
  3397 		}
       
  3398 
       
  3399     iAnimStatus = KAnimNotActive;
       
  3400 
       
  3401     if (iTargetElement)
       
  3402         {
       
  3403         iTargetElement->iHasAnimationBase = (TInt)this;
       
  3404        	iTargetElement->SetIsAnimating( EFalse );
       
  3405        	SetIsAnimating( EFalse );
       
  3406         }
       
  3407     iOverrideTime = ETrue;
       
  3408     TInt32 lCurTime = ((CSvgDocumentImpl*)(iOwnerDocument))->CurrentTime();
       
  3409     iAnimTime->SetNextBeginTime(lCurTime);
       
  3410     iAbsoluteBeginTime = iAnimTime->BeginTime();
       
  3411 
       
  3412 	if(iAnimTime->GetOriginalEndTime() == KTimeIndefinite)
       
  3413 		{
       
  3414 		iAnimTime->SetEndTime(KTimeIndefinite);
       
  3415 		}
       
  3416 
       
  3417     TUint32 lSimpleDuration = SimpleDuration();
       
  3418     if( lSimpleDuration != KTimeIndefinite)
       
  3419        {
       
  3420        iAnimTime->SetEndTime(lSimpleDuration);
       
  3421        }
       
  3422 
       
  3423     ((CSvgDocumentImpl*)iOwnerDocument)->AddEventBeginTime( aAnimElement, iAbsoluteBeginTime, aAnimElement->iTargetElement );
       
  3424     ((CSvgDocumentImpl*)iOwnerDocument)->iInitSortList=ETrue;
       
  3425 
       
  3426 
       
  3427     }
       
  3428 
       
  3429 
       
  3430 //
       
  3431 // ---------------------------------------------------------------------------
       
  3432 //
       
  3433 // ---------------------------------------------------------------------------
       
  3434 void CSvgAnimationBase::SetEndByEvent( CSvgAnimationBase* /* aAnimElement */,
       
  3435                                        TInt32 aEndTime )
       
  3436     {
       
  3437     iAnimTime->AddEndTime( aEndTime );
       
  3438 
       
  3439     iAnimTime->GetNextEndTime(iAnimTime->BeginTime());
       
  3440 	TUint32 lSimpleDur= SimpleDuration();
       
  3441    	if(lSimpleDur != KTimeIndefinite)
       
  3442    		{
       
  3443 	   	iAnimTime->SetEndTime( lSimpleDur );
       
  3444 	   	}
       
  3445 
       
  3446   	iIsEndEventSent = EFalse;
       
  3447     }
       
  3448 
       
  3449 // ---------------------------------------------------------------------------
       
  3450 // Blending methods aAlpha must be [0 - 255]
       
  3451 // ---------------------------------------------------------------------------
       
  3452 TFloatFixPt CSvgAnimationBase::BlendFloat( TInt32 aAlpha, TFloatFixPt aV1, TFloatFixPt aV2 )
       
  3453     {
       
  3454 	#ifdef SVG_FLOAT_BUILD
       
  3455     TFloatFixPt percent = ((float)aAlpha)/255.0f;
       
  3456     TFloatFixPt percentValue = ( aV2 - aV1 ) * percent;
       
  3457     return aV1 + percentValue;
       
  3458 	#else
       
  3459     TUint32 v1  = aV1.RawData() >> 8;
       
  3460     TUint32 v2  = aV2.RawData() >> 8;
       
  3461     return TFloatFixPt( BlendInt( aAlpha, v1, v2 ) << 8, ETrue );
       
  3462 #endif
       
  3463     }
       
  3464 
       
  3465 // ---------------------------------------------------------------------------
       
  3466 // Blending methods aAlpha must be [0 - 255]
       
  3467 // ---------------------------------------------------------------------------
       
  3468 TInt32 CSvgAnimationBase::BlendInt( TInt32 aAlpha, TInt32 aV1, TInt32 aV2 )
       
  3469     {
       
  3470     return ( (aV2 - aV1) * (((TReal32)aAlpha)/((TReal32)255)) ) + aV1 ;
       
  3471     }
       
  3472 
       
  3473 // ---------------------------------------------------------------------------
       
  3474 //
       
  3475 // ---------------------------------------------------------------------------
       
  3476 TUint32 CSvgAnimationBase::BlendColor( TInt32 aAlpha, // Interpolation factor
       
  3477                                                       //  between [0-255]
       
  3478         TUint32 aV1, // Initial Colour value in RGB format
       
  3479         TUint32 aV2 ) // Final Colour value
       
  3480     {
       
  3481     TUint32 r, g, b; 
       
  3482     TInt32 c1, c2; 
       
  3483 
       
  3484     // aAlpha is a value between 0-255 which indicates current interpolated
       
  3485     // value of the animation.
       
  3486     // Since colour value is divided by 256 (for optimisation - bit shift 
       
  3487     //  by 8 bits) alpha is set to 256 when it is 255. 
       
  3488     if( 255 == aAlpha ) 
       
  3489         {
       
  3490         aAlpha = 256;
       
  3491         }
       
  3492 
       
  3493     // Compute Red component
       
  3494     c1 = aV2 & KRmask; 
       
  3495     c2 = aV1 & KRmask; 
       
  3496     r = ( ( ( c1 - c2 ) * aAlpha + c2 * 256 ) >> 8 ) & KRmask; 
       
  3497 
       
  3498     // Compute Green Component
       
  3499     c1 = aV2 & KGmask; 
       
  3500     c2 = aV1 & KGmask; 
       
  3501     g = ( ( ( c1 - c2 ) * aAlpha + c2 * 256 ) >> 8 ) & KGmask; 
       
  3502 
       
  3503     // Compute Blue component
       
  3504     c1 = aV2 & KBmask; 
       
  3505     c2 = aV1 & KBmask; 
       
  3506     b = ( ( ( c1 - c2 ) * aAlpha + c2 * 256 ) >> 8 ) & KBmask; 
       
  3507 
       
  3508     // Combine r,g,b and return
       
  3509     return r | g | b; 
       
  3510     }
       
  3511 
       
  3512 // ---------------------------------------------------------------------------
       
  3513 //
       
  3514 // ---------------------------------------------------------------------------
       
  3515 TUint32 CSvgAnimationBase::AddColor( TUint32 aV1, TUint32 aV2 )
       
  3516     {
       
  3517     TInt32 r, g, b;
       
  3518     TInt32 r1, r2, g1, g2, b1, b2;
       
  3519     TUint sign1, sign2;
       
  3520 
       
  3521     // WARNING, spare high order bits store sign of 8 bit components
       
  3522     // on input values only the use is limited in scope to
       
  3523     // SetAccumulateValues method
       
  3524     // return value is unsigned & clamped
       
  3525     // MSB better be blank for normal use
       
  3526 
       
  3527     sign1 = (TInt32)( aV1 & 0xff000000) >> 24;
       
  3528     sign2 = (TInt32)( aV2 & 0xff000000) >> 24;
       
  3529 	r1 = (aV1 & 0x00ff0000) >> 16;
       
  3530 	r2 = (aV2 & 0x00ff0000) >> 16;
       
  3531 	g1 = (aV1 & 0x0000ff00) >> 8;
       
  3532 	g2 = (aV2 & 0x0000ff00) >> 8;
       
  3533 	b1 = (aV1 & 0x000000ff);
       
  3534 	b2 = (aV2 & 0x000000ff);
       
  3535 
       
  3536     if(sign1 & 0x04)
       
  3537         {
       
  3538         r1 *= -1;
       
  3539         }
       
  3540     if(sign1 & 0x02)
       
  3541         {
       
  3542         g1 *= -1;
       
  3543         }
       
  3544     if(sign1 & 0x01)
       
  3545         {
       
  3546         b1 *= -1;
       
  3547         }
       
  3548     if(sign2 & 0x04)
       
  3549         {
       
  3550         r2 *= -1;
       
  3551         }
       
  3552     if(sign2 & 0x02)
       
  3553         {
       
  3554         g2 *= -1;
       
  3555         }
       
  3556     if(sign2 & 0x01)
       
  3557         {
       
  3558         b2 *= -1;
       
  3559         }
       
  3560 
       
  3561     r = ( ( r1 + r2 ) );
       
  3562     g = ( ( g1 + g2 ) );
       
  3563     b = ( ( b1 + b2 ) );
       
  3564 
       
  3565         // clamp for overflow & underflow
       
  3566     if ( r > 255 )
       
  3567         {
       
  3568         r = 255;
       
  3569         }
       
  3570     if ( g > 255 )
       
  3571         {
       
  3572         g = 255;
       
  3573         }
       
  3574     if ( b > 255 )
       
  3575         {
       
  3576         b = 255;
       
  3577         }
       
  3578 
       
  3579     if ( r < 0 )
       
  3580         {
       
  3581         r = 0;
       
  3582         }
       
  3583     if ( g < 0 )
       
  3584         {
       
  3585         g = 0;
       
  3586         }
       
  3587 
       
  3588     if ( b < 0 )
       
  3589         {
       
  3590         b = 0;
       
  3591         }
       
  3592     return ( ( ( r & 0xFF ) << 16 ) | ( ( g & 0xFF ) << 8 ) | ( b & 0xFF ) );
       
  3593         }
       
  3594 
       
  3595 // ---------------------------------------------------------------------------
       
  3596 //
       
  3597 // ---------------------------------------------------------------------------
       
  3598 TUint32 CSvgAnimationBase::SubtractColor( TUint32 aV1, TUint32 aV2 )
       
  3599     {
       
  3600     TInt32 r, g, b;
       
  3601     TInt32 r1, r2, g1, g2, b1, b2;
       
  3602     TUint sign =  0x0;
       
  3603 
       
  3604     // WARNING, spare high order bits store sign of 8 bit components
       
  3605     // the use is limited in scope to SetAccumulateValues method
       
  3606     // the commented code would handle signed input but this isn't
       
  3607     // used by calling code
       
  3608     // output components are not clamped
       
  3609 	r1 = (aV1 & 0x00ff0000) >> 16;
       
  3610 	r2 = (aV2 & 0x00ff0000) >> 16;
       
  3611 	g1 = (aV1 & 0x0000ff00) >> 8;
       
  3612 	g2 = (aV2 & 0x0000ff00) >> 8;
       
  3613 	b1 = (aV1 & 0x000000ff);
       
  3614 	b2 = (aV2 & 0x000000ff);
       
  3615 
       
  3616     r = ( ( r1 - r2 ) );
       
  3617     g = ( ( g1 - g2 ) );
       
  3618     b = ( ( b1 - b2 ) );
       
  3619 
       
  3620     if ( r < 0 )
       
  3621         {
       
  3622         sign = 0x04;
       
  3623         r *= -1;
       
  3624         }
       
  3625 
       
  3626     if ( g < 0 )
       
  3627         {
       
  3628         sign |= 0x02;
       
  3629         g *= -1;
       
  3630         }
       
  3631 
       
  3632     if ( b < 0 )
       
  3633         {
       
  3634         sign |= 0x01;
       
  3635         b *= -1;
       
  3636         }
       
  3637     return ( ( ( r & 0xFF ) << 16 ) | ( ( g & 0xFF ) << 8 ) | ( b & 0xFF ) );
       
  3638 
       
  3639     }
       
  3640 
       
  3641 // ---------------------------------------------------------------------------
       
  3642 //
       
  3643 // ---------------------------------------------------------------------------
       
  3644 TInt32      CSvgAnimationBase::GetNumberOfEvents(const TDesC& aValue)
       
  3645     {
       
  3646     TInt32 result=1;
       
  3647     TStringTokenizer tkn ( aValue, KSEMICOLON );
       
  3648     while( tkn.HasMoreTokens()  )
       
  3649         {
       
  3650         tkn.NextToken( );
       
  3651         result++;
       
  3652         }
       
  3653     return result;
       
  3654     }
       
  3655 
       
  3656 // ---------------------------------------------------------------------------
       
  3657 //
       
  3658 // ---------------------------------------------------------------------------
       
  3659 
       
  3660 TInt32       CSvgAnimationBase::Duration()
       
  3661     {
       
  3662     return (TInt32)iAnimTime->DurationTime();
       
  3663     }
       
  3664 
       
  3665 
       
  3666 void CSvgAnimationBase::SaveBeginTimeToList(TInt aTimeInMilliseconds)
       
  3667     {
       
  3668     iAnimTime->AddToInitialList(aTimeInMilliseconds);
       
  3669     }
       
  3670 // ---------------------------------------------------------------------------
       
  3671 //
       
  3672 // ---------------------------------------------------------------------------
       
  3673 
       
  3674 void CSvgAnimationBase::ReInitializeAnimation()
       
  3675     {
       
  3676 
       
  3677 
       
  3678 	iHadBegun= EFalse;
       
  3679     iBeginTimeIndex = 0 ;
       
  3680     iCurrentRepeatCount= 0;
       
  3681     iInitDone = EFalse;
       
  3682     iOverrideTime = EFalse;
       
  3683     iAnimStatus = KAnimNotActive;
       
  3684 
       
  3685     if (iTargetElement)
       
  3686         {
       
  3687         iTargetElement->iHasAnimationBase = (TInt)this;
       
  3688        	iTargetElement->SetIsAnimating( EFalse );
       
  3689        	SetIsAnimating( EFalse );
       
  3690         }
       
  3691 
       
  3692 			//JSR226 Change in question
       
  3693 //    	if (iOwnerDocument && ((CSvgDocumentImpl*)iOwnerDocument)->Engine() && iTargetElement )
       
  3694 //    	{
       
  3695     		//hope these are parrallel vectors
       
  3696     		//for (TInt i=0; i < iAnimTime->BeginTimesCount(); i++)
       
  3697         	//{
       
  3698 //        		if ( (iAnimTime->BeginTime() <= ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() )
       
  3699 //        		  && ( iAnimTime->EndTime() >= ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme() ) )
       
  3700 //        		{
       
  3701 //        			iTargetElement->iAnimating = ETrue;
       
  3702 //        			iAnimating = ETrue;
       
  3703 //        		}
       
  3704         	//}
       
  3705 //    	}
       
  3706 			//--end of change in question
       
  3707 //
       
  3708 	if(iAdditiveOrg == KAdditiveReplace)
       
  3709 		{
       
  3710 		iAdditive= KAdditivePass;
       
  3711 		}
       
  3712 
       
  3713 
       
  3714 	if (iAnimTime)
       
  3715 		{
       
  3716 		if (iIsUserSeek)
       
  3717 			iAnimTime->ReInitializeForSeek();
       
  3718        else
       
  3719 			iAnimTime->ReInitialize();
       
  3720 		
       
  3721 	if( iAnimTime->BeginTimesCount()== 0 )
       
  3722         {
       
  3723          if(iIsBeginSet ) // begin on events
       
  3724 			  {
       
  3725 			  if(!iIsUserSeek)// for DOM Reusage only
       
  3726 				{
       
  3727 				iAnimTime->SetBeginTime(KTimeIndefinite);
       
  3728 				iAbsoluteBeginTime = KTimeIndefinite ;
       
  3729 				}
       
  3730 			  else
       
  3731 				{
       
  3732 				// if begin depends on event and repeat is there,
       
  3733 				//then iAbsoluteBeginTime != iBeginTime.
       
  3734 				if((TUint32)iAbsoluteBeginTime != iAnimTime->BeginTime() )
       
  3735 					iAnimTime->SetBeginTime(iAbsoluteBeginTime);
       
  3736 				}
       
  3737 
       
  3738 			}
       
  3739 		 else
       
  3740 			{
       
  3741             iAnimTime->SetBeginTime(0);
       
  3742 	    	 iAbsoluteBeginTime = 0 ;
       
  3743 			}
       
  3744         }
       
  3745 
       
  3746      }
       
  3747     }
       
  3748 
       
  3749 // ---------------------------------------------------------------------------
       
  3750 // Functions used by Decoder
       
  3751 // ---------------------------------------------------------------------------
       
  3752 
       
  3753 
       
  3754 void CSvgAnimationBase::SetAttributeId(const TUint16 aAtrId)
       
  3755     {
       
  3756     iAttrId= aAtrId;
       
  3757     }
       
  3758 
       
  3759 void CSvgAnimationBase::SetAttributeType(const TUint8 aAtrType)
       
  3760     {
       
  3761     iDataType= (TUint16) aAtrType;
       
  3762     }
       
  3763 
       
  3764 void CSvgAnimationBase::SetBeginTimeList(RArray<TInt32>*& aList)
       
  3765     {
       
  3766     if (iAnimTime)
       
  3767         {
       
  3768         iAnimTime->SetBeginTimeList(aList);
       
  3769         }
       
  3770     }
       
  3771 
       
  3772 void CSvgAnimationBase::SetBeginTime(TInt32 aTime)
       
  3773     {
       
  3774     if (iAnimTime)
       
  3775         {
       
  3776         iAnimTime->SetBeginTime(aTime);
       
  3777         }
       
  3778     }
       
  3779 
       
  3780 void CSvgAnimationBase::SetAbsoluteBeginTime(TInt32 aTime)
       
  3781     {
       
  3782     iAbsoluteBeginTime= aTime;
       
  3783     iIsBeginSet = ETrue;
       
  3784     }
       
  3785 
       
  3786 void CSvgAnimationBase::SetEventList(CArrayFixFlat<TEventListItem>*& aEventList)
       
  3787     {
       
  3788     if (iEventList)
       
  3789         {
       
  3790         iEventList->Reset();
       
  3791         delete iEventList;
       
  3792         iEventList= NULL;
       
  3793         }
       
  3794     iEventList= aEventList;
       
  3795     }
       
  3796 
       
  3797 void CSvgAnimationBase::SetEndTimeList(CArrayFixFlat<TEventListItem>*& aTimeList)
       
  3798     {
       
  3799     if (iEndTimeList)
       
  3800         {
       
  3801         iEndTimeList->Reset();
       
  3802         delete iEndTimeList;
       
  3803         iEndTimeList= NULL;
       
  3804         }
       
  3805     iEndTimeList= aTimeList;
       
  3806     }
       
  3807 
       
  3808 void CSvgAnimationBase::SetDurationTime(TInt32 aTime)
       
  3809     {
       
  3810     if (iAnimTime)
       
  3811         {
       
  3812         iAnimTime->SetDurationTime(aTime);
       
  3813         }
       
  3814     }
       
  3815 
       
  3816 void CSvgAnimationBase::SetFromFlag()
       
  3817     {
       
  3818     iNoFrom= EFalse;
       
  3819     }
       
  3820 
       
  3821 void CSvgAnimationBase::SetFromInt(TInt32 aValue)
       
  3822     {
       
  3823     iFromInt= aValue;
       
  3824     iOrgFromInt= aValue;
       
  3825     }
       
  3826 
       
  3827 void CSvgAnimationBase::SetFromFloat(TFloatFixPt aValue)
       
  3828     {
       
  3829     iFromFloat= aValue;
       
  3830     iOrgFromFloat= aValue;
       
  3831     }
       
  3832 
       
  3833 void CSvgAnimationBase::SetFromViewBox(TGfxRectangle2D aValue)
       
  3834     {
       
  3835     iFromViewBox= aValue;
       
  3836     iOrgFromViewBox= aValue;
       
  3837     }
       
  3838 
       
  3839 void CSvgAnimationBase::SetFromPathL(CGfxGeneralPath*& aPath)
       
  3840     {
       
  3841     if (iFromPath)
       
  3842         {
       
  3843         delete iFromPath;
       
  3844         iFromPath= NULL;
       
  3845         }
       
  3846     iFromPath= aPath;
       
  3847 
       
  3848     if ( iOrgFromPath )
       
  3849        {
       
  3850        delete iOrgFromPath;
       
  3851        iOrgFromPath = NULL;
       
  3852        }
       
  3853 
       
  3854     iOrgFromPath = CGfxGeneralPath::NewL();
       
  3855     iOrgFromPath->SetPointTypeArrayL(aPath->PointTypeArray());
       
  3856     iOrgFromPath->SetPointCoordsArrayL(aPath->PointCoordsArrayAll());
       
  3857     }
       
  3858 
       
  3859 void CSvgAnimationBase::SetToFlag()
       
  3860     {
       
  3861     iHaveTo= ETrue;
       
  3862     }
       
  3863 
       
  3864 void CSvgAnimationBase:: SetToInt(TInt32 aValue)
       
  3865     {
       
  3866     iToInt= aValue;
       
  3867     }
       
  3868 
       
  3869 void CSvgAnimationBase:: SetToFloat(TFloatFixPt aValue)
       
  3870     {
       
  3871     iToFloat= aValue;
       
  3872     }
       
  3873 
       
  3874 void CSvgAnimationBase::SetToPath(CGfxGeneralPath*& aPath)
       
  3875     {
       
  3876     iToPath= aPath;
       
  3877     }
       
  3878 
       
  3879 void CSvgAnimationBase::SetToViewBox(TGfxRectangle2D aValue)
       
  3880     {
       
  3881     iToViewBox= aValue;
       
  3882     }
       
  3883 
       
  3884 CSvgElementImpl*& CSvgAnimationBase::GetTargetElem()
       
  3885     {
       
  3886         return iTargetElement;
       
  3887     }
       
  3888 
       
  3889 void CSvgAnimationBase::SetAnimFreeze()
       
  3890     {
       
  3891     iFill= KAnimFillFreeze;
       
  3892     }
       
  3893 
       
  3894 void CSvgAnimationBase::SetValuesFlag()
       
  3895     {
       
  3896     iHaveValues = ETrue;
       
  3897     }
       
  3898 
       
  3899 void CSvgAnimationBase::SetIntValuesArray( RArray<TInt32>*& aArray)
       
  3900     {
       
  3901     if (iValuesInt)
       
  3902         {
       
  3903         iValuesInt->Close();
       
  3904         delete iValuesInt;
       
  3905         }
       
  3906         iValuesInt= aArray;
       
  3907     }
       
  3908 
       
  3909 void CSvgAnimationBase::SetFloatValuesArray( RArray<TFloatFixPt>*& aArray)
       
  3910     {
       
  3911     if (iValuesFloat)
       
  3912         {
       
  3913         iValuesFloat->Close();
       
  3914         delete iValuesFloat;
       
  3915         }
       
  3916 
       
  3917         iValuesFloat= aArray;
       
  3918     }
       
  3919 
       
  3920 void CSvgAnimationBase::SetViewBoxValuesArray( RArray<TGfxRectangle2D>*& aArray)
       
  3921     {
       
  3922     if (iValuesViewBox)
       
  3923         {
       
  3924         iValuesViewBox->Close();
       
  3925         delete iValuesViewBox;
       
  3926         }
       
  3927 
       
  3928         iValuesViewBox= aArray;
       
  3929     }
       
  3930 
       
  3931 void CSvgAnimationBase::SetPathValuesArray( RPointerArray<CGfxGeneralPath>*& aArray)
       
  3932     {
       
  3933     if (iValuesPath)
       
  3934         {
       
  3935         iValuesPath->Close();
       
  3936         delete iValuesPath;
       
  3937         }
       
  3938 
       
  3939         iValuesPath= aArray;
       
  3940     }
       
  3941 
       
  3942 void CSvgAnimationBase::ResetFloatValuesArray()
       
  3943     {
       
  3944     if (iValuesFloat)
       
  3945         {
       
  3946         iValuesFloat->Reset();
       
  3947         }
       
  3948     }
       
  3949 
       
  3950 void CSvgAnimationBase::SetRepeatCount(TReal32 aCount)
       
  3951     {
       
  3952         // fix for repeatCount
       
  3953         if(aCount <= 0)
       
  3954             {
       
  3955             iRepeatCount = 1;
       
  3956             }
       
  3957         else
       
  3958             {
       
  3959             iRepeatCount= aCount;
       
  3960             }
       
  3961     iRepeatCountSet = ETrue;
       
  3962 
       
  3963     }
       
  3964 
       
  3965 void CSvgAnimationBase::SetRepeatDuration(TUint32 aDur)
       
  3966     {
       
  3967     if(!iRepeatCountSet)
       
  3968         {
       
  3969         iRepeatCount = KRepeatCountMax;
       
  3970         }
       
  3971 
       
  3972     if (iAnimTime)
       
  3973         {
       
  3974         iAnimTime->SetRepeatDurationTime(aDur);
       
  3975         }
       
  3976     }
       
  3977 
       
  3978 
       
  3979 void  CSvgAnimationBase::SetEndTime(TInt32 aTime)
       
  3980     {
       
  3981     if(iAnimTime)
       
  3982         {
       
  3983         iAnimTime->SetEndTime(aTime);
       
  3984         }
       
  3985     }
       
  3986 
       
  3987 void CSvgAnimationBase::SetRestartMode(TRestartMode aMode)
       
  3988     {
       
  3989     iAnimRestart= aMode;
       
  3990     }
       
  3991 
       
  3992 void CSvgAnimationBase::SetAccumulate(TAccumulate aValue)
       
  3993     {
       
  3994     iAccumulate= aValue;
       
  3995     }
       
  3996 
       
  3997 void CSvgAnimationBase::SetAdditive(TAdditive aValue)
       
  3998     {
       
  3999     iAdditive= aValue;
       
  4000     iAdditiveOrg= aValue;
       
  4001     }
       
  4002 
       
  4003 void CSvgAnimationBase::SetCalcMode(TAnimCalcMode aMode)
       
  4004     {
       
  4005     if (iAnimTime)
       
  4006         {
       
  4007         iAnimTime->SetCalMode(aMode);
       
  4008         }
       
  4009     }
       
  4010 
       
  4011 void CSvgAnimationBase::SetKeyTimeArray(RArray<CSvgAnimTimeController::TKeyTime>*& aArray)
       
  4012     {
       
  4013     if (iAnimTime)
       
  4014         {
       
  4015         iAnimTime->SetKeyTimeArray(aArray);
       
  4016         }
       
  4017     }
       
  4018 
       
  4019 void  CSvgAnimationBase::SetAnimTimeArray(RArray<TUint32>*& aArray)
       
  4020     {
       
  4021     if (iAnimTime)
       
  4022         {
       
  4023         iAnimTime->SetAnimTimeArray(aArray);
       
  4024         }
       
  4025     }
       
  4026 
       
  4027 void CSvgAnimationBase::SetByFlag()
       
  4028     {
       
  4029     iHaveBy= ETrue;
       
  4030     }
       
  4031 
       
  4032 TBool CSvgAnimationBase::  GetFromFlag()
       
  4033     {
       
  4034     return iNoFrom;
       
  4035     }
       
  4036 
       
  4037 TUint16 CSvgAnimationBase::GetAttributeId()
       
  4038     {
       
  4039     return iAttrId;
       
  4040     }
       
  4041 
       
  4042 void CSvgAnimationBase::SetKeyTimeFlag()
       
  4043     {
       
  4044     iKeyTimesPresent= ETrue;
       
  4045     }
       
  4046 
       
  4047 TInt  CSvgAnimationBase::GetAttributeFloat( const TInt aNameId,
       
  4048                                                        TFloatFixPt& aValue )
       
  4049     {
       
  4050  switch(aNameId)
       
  4051     {
       
  4052      case KAtrAttributeName:
       
  4053             {
       
  4054             aValue = (TFloatFixPt)(TInt)(iAttrId);
       
  4055             break;
       
  4056     }
       
  4057     case KAtrBegin:
       
  4058             {
       
  4059             aValue = (TInt32)iAnimTime->GetBeginTime( iBeginTimeIndex );
       
  4060             break;
       
  4061             }
       
  4062     case KAtrDur:
       
  4063     {
       
  4064             aValue = (TFloatFixPt)(TInt) (iAnimTime->DurationTime());
       
  4065             break;
       
  4066     }
       
  4067     case KAtrRepeatCount:
       
  4068     {
       
  4069             aValue = (TInt)iRepeatCount;
       
  4070             break;
       
  4071             }
       
  4072     case KAtrRepeatDur:
       
  4073         {
       
  4074             aValue = (TInt32) iAnimTime->RepeatDurationTime();
       
  4075         break;
       
  4076             }
       
  4077     case KAtrEnd:
       
  4078             {
       
  4079             aValue = (TInt32)iAnimTime->EndTime();
       
  4080             break;
       
  4081             }
       
  4082      case KAtrFrom:
       
  4083          {
       
  4084              if(! iNoFrom)
       
  4085                 {
       
  4086                  switch(iDataType)
       
  4087                     {   // Length float.
       
  4088                       case KSvgTypeOpacity:
       
  4089                       case KSvgTypeLength:
       
  4090             {
       
  4091                           aValue = iFromFloat;
       
  4092             break;
       
  4093             }
       
  4094                       default: break;
       
  4095                      }
       
  4096                 }
       
  4097          }
       
  4098      break;
       
  4099      case KAtrTo:
       
  4100             {
       
  4101              if(iHaveTo)
       
  4102                 {
       
  4103                  switch(iDataType)
       
  4104                     {   // Length float.
       
  4105                       case KSvgTypeOpacity:
       
  4106                       case KSvgTypeLength:
       
  4107             {
       
  4108                           aValue = iToFloat;
       
  4109             break;
       
  4110             }
       
  4111                       default: break;
       
  4112 
       
  4113                     }
       
  4114                  }
       
  4115              }
       
  4116      break;
       
  4117      case KAtrBy:
       
  4118             {
       
  4119             if(iHaveBy)
       
  4120                 {
       
  4121                  switch(iDataType)
       
  4122                     {   // Length float.
       
  4123                       case KSvgTypeOpacity:
       
  4124                       case KSvgTypeLength:
       
  4125                           {
       
  4126                           aValue = iToFloat - iFromFloat;
       
  4127                           break;
       
  4128                           }
       
  4129                       default:
       
  4130             break;
       
  4131             }
       
  4132                  }
       
  4133             }
       
  4134          break;
       
  4135      default:
       
  4136      	//this is for the JSR because it wants the original value returned instead of the animated
       
  4137     	//version that element would return if it gets down to the default of this case statement
       
  4138     	if (aNameId == iAttrId)
       
  4139 				{
       
  4140 					aValue = iOrgFloat;
       
  4141 					return KErrNone;
       
  4142 				}
       
  4143 			else
       
  4144 			{
       
  4145      	return CSvgElementImpl::GetAttributeFloat( aNameId,aValue );
       
  4146     	}
       
  4147     }
       
  4148     return KErrNone;
       
  4149             }
       
  4150 
       
  4151 TInt CSvgAnimationBase::SetAttributeFloatL( const TInt aNameId,
       
  4152                                                         const TFloatFixPt aValue )
       
  4153 {
       
  4154     switch(aNameId)
       
  4155     {
       
  4156         case KAtrAttributeName:
       
  4157             {
       
  4158             iAttrId = (TUint16)(TInt32)aValue;
       
  4159             break;
       
  4160             }
       
  4161         case KAtrBegin:
       
  4162             {
       
  4163             iAnimTime->SetBeginTime( aValue );
       
  4164             break;
       
  4165             }
       
  4166         case KAtrDur:
       
  4167             {
       
  4168             iAnimTime->SetDurationTime( aValue );
       
  4169             break;
       
  4170             }
       
  4171 
       
  4172     case KAtrRepeatCount:
       
  4173             {
       
  4174             if((TInt32)aValue <= 0)
       
  4175                 {
       
  4176                 iRepeatCount = 1;
       
  4177                 }
       
  4178             else
       
  4179                 {
       
  4180                 iRepeatCount= (TUint16) (TInt32)aValue;
       
  4181                 }
       
  4182             iRepeatCountSet = ETrue;
       
  4183             break;
       
  4184             }
       
  4185 
       
  4186         case KAtrRepeatDur:
       
  4187 
       
  4188             {
       
  4189             iAnimTime->SetRepeatDurationTime( (TInt32)aValue );
       
  4190             break;
       
  4191             }
       
  4192         case KAtrEnd:
       
  4193             {
       
  4194             iAnimTime->SetEndTime( aValue );
       
  4195             break;
       
  4196             }
       
  4197      case KAtrFrom:
       
  4198             {
       
  4199 
       
  4200                  switch(iDataType)
       
  4201                     {   // Length float.
       
  4202                       case KSvgTypeOpacity:
       
  4203                       case KSvgTypeLength:
       
  4204                           {
       
  4205                           iFromFloat = aValue;
       
  4206                           break;
       
  4207                           }
       
  4208                       default:
       
  4209                           break;
       
  4210                     }
       
  4211 
       
  4212             }
       
  4213      break;
       
  4214      case KAtrTo:
       
  4215             {
       
  4216 
       
  4217                  switch(iDataType)
       
  4218                     {   // Length float.
       
  4219                       case KSvgTypeOpacity:
       
  4220                       case KSvgTypeLength:
       
  4221                           {
       
  4222                           iToFloat=  aValue ;
       
  4223                           break;
       
  4224                           }
       
  4225                       default:
       
  4226                       break;
       
  4227                       // color and integer values.
       
  4228 
       
  4229                     }
       
  4230 
       
  4231              }
       
  4232      break;
       
  4233      case KAtrBy:
       
  4234             {
       
  4235             switch(iDataType)
       
  4236                 {   // Length float.
       
  4237                   case KSvgTypeOpacity:
       
  4238                   case KSvgTypeLength:
       
  4239                       {
       
  4240                       iToFloat  =  iFromFloat + aValue;
       
  4241                       break;
       
  4242                       }
       
  4243                     default:
       
  4244                     break;
       
  4245                 }
       
  4246 
       
  4247             }
       
  4248          break;
       
  4249      default:
       
  4250      {
       
  4251 		//JSR226 change in question.  This is so you can set the original value from the JSR226 side.
       
  4252      	if (aNameId == iAttrId)
       
  4253 		{
       
  4254 			iOrgFloat = aValue;
       
  4255 		}
       
  4256 
       
  4257 		return CSvgElementImpl::SetAttributeFloatL( aNameId,aValue );
       
  4258      }
       
  4259         }
       
  4260     return KErrNone;
       
  4261 
       
  4262     }
       
  4263 
       
  4264 TInt CSvgAnimationBase::SetAttributeIntL( const TInt aNameId,
       
  4265                                                       const TInt32 aValue )
       
  4266     {
       
  4267     switch(aNameId)
       
  4268         {
       
  4269     case KAtrFrom:
       
  4270         {
       
  4271             switch(iDataType)
       
  4272                 {
       
  4273                 case KSvgTypeTextAnchor:
       
  4274                 case KSvgTypeColor:
       
  4275                 case KSvgTypeVisibility:
       
  4276                 case KSvgTypeGradientUnits:
       
  4277                 case KSvgTypeSpreadMethod:
       
  4278                 case KSvgTypeDisplay:
       
  4279                     iFromInt = aValue;
       
  4280                     iNoFrom = EFalse;
       
  4281                 break;
       
  4282 
       
  4283                 default:return KErrNotFound;
       
  4284                 }
       
  4285         }
       
  4286         break;
       
  4287     case KAtrTo:
       
  4288         {
       
  4289             switch(iDataType)
       
  4290                 {
       
  4291                 // only these are supported as Int
       
  4292                 case KSvgTypeTextAnchor:
       
  4293                 case KSvgTypeColor:
       
  4294                 case KSvgTypeVisibility:
       
  4295                 case KSvgTypeGradientUnits:
       
  4296                 case KSvgTypeSpreadMethod:
       
  4297                 case KSvgTypeDisplay:
       
  4298                     iToInt = aValue;
       
  4299                     iHaveTo = ETrue;
       
  4300                 break;
       
  4301                 default:return KErrNotFound;
       
  4302                 }
       
  4303         }
       
  4304         break;
       
  4305     case KAtrBy:
       
  4306             {
       
  4307             // By is not supported.
       
  4308             if(iDataType ==  KSvgTypeColor)
       
  4309                 {
       
  4310                 iToInt = (TInt32 ) AddColor( iFromInt, (TInt32)aValue);
       
  4311                 break;
       
  4312                 }
       
  4313             }
       
  4314         break;
       
  4315         case KAtrAdditive:
       
  4316             {
       
  4317             iAdditive = (TUint8)aValue;
       
  4318             iAdditiveOrg = (TUint8)aValue;
       
  4319             break;
       
  4320             }
       
  4321 
       
  4322         case KAtrAccumulate:
       
  4323             {
       
  4324             iAccumulate = (TUint8)aValue;
       
  4325             break;
       
  4326             }
       
  4327 
       
  4328         case KAtrCalcMode:
       
  4329             {
       
  4330             iAnimTime->SetCalMode( (TUint8)aValue );
       
  4331             break;
       
  4332             }
       
  4333 
       
  4334         case KAtrRestart:
       
  4335             {
       
  4336             iAnimRestart = (TUint8) aValue;
       
  4337             break;
       
  4338             }
       
  4339 
       
  4340         // this is confusing but in case of animation
       
  4341         // elements the style attributes really do not matter.
       
  4342         case KCSS_ATTR_FILL:
       
  4343             {
       
  4344             iFill = (TUint8) aValue;
       
  4345             break;
       
  4346             }
       
  4347 
       
  4348     default:
       
  4349         return CSvgElementImpl::SetAttributeIntL( aNameId, aValue );
       
  4350             }
       
  4351  return KErrNone;
       
  4352 }
       
  4353 
       
  4354 TInt CSvgAnimationBase::GetAttributeIntL( const TInt aNameId,
       
  4355                                                      TInt32& aValue )
       
  4356 {
       
  4357 switch(aNameId)
       
  4358     {
       
  4359     case KAtrFrom:
       
  4360         {
       
  4361             if(!iNoFrom)
       
  4362                 {
       
  4363                 switch(iDataType)
       
  4364                     {
       
  4365                     case KSvgTypeTextAnchor:
       
  4366                     case KSvgTypeColor:
       
  4367                     case KSvgTypeVisibility:
       
  4368                     case KSvgTypeGradientUnits:
       
  4369                     case KSvgTypeSpreadMethod:
       
  4370                     case KSvgTypeDisplay:
       
  4371                         aValue = iFromInt;
       
  4372                     break;
       
  4373 
       
  4374                     default:return KErrNotFound;
       
  4375                     }
       
  4376                 }
       
  4377         }
       
  4378         break;
       
  4379     case KAtrTo:
       
  4380         {
       
  4381             if(iHaveTo)
       
  4382                 {
       
  4383                 switch(iDataType)
       
  4384                     {
       
  4385                     case KSvgTypeTextAnchor:
       
  4386                     case KSvgTypeColor:
       
  4387                     case KSvgTypeVisibility:
       
  4388                     case KSvgTypeGradientUnits:
       
  4389                     case KSvgTypeSpreadMethod:
       
  4390                     case KSvgTypeDisplay:
       
  4391                         aValue = iToInt;
       
  4392                     break;
       
  4393                     default:return KErrNotFound;
       
  4394                     }
       
  4395                 }
       
  4396         }
       
  4397         break;
       
  4398     case KAtrBy:
       
  4399             {
       
  4400             // By is not supported.
       
  4401             if(iDataType == KSvgTypeColor)
       
  4402                 {
       
  4403                 aValue = (TInt32 ) SubtractColor( iToInt, iFromInt );
       
  4404                 }
       
  4405             }
       
  4406         break;
       
  4407     case KAtrAdditive:
       
  4408             {
       
  4409             aValue = iAdditive ;
       
  4410             break;
       
  4411             }
       
  4412 
       
  4413     case KAtrAccumulate:
       
  4414             {
       
  4415             aValue = iAccumulate ;
       
  4416             break;
       
  4417             }
       
  4418     case KAtrCalcMode:
       
  4419             {
       
  4420             aValue = iAnimTime->CalMode();
       
  4421             break;
       
  4422             }
       
  4423     case KAtrRestart:
       
  4424             {
       
  4425             aValue =  iAnimRestart ;
       
  4426             break;
       
  4427             }
       
  4428     case KCSS_ATTR_FILL:
       
  4429             {
       
  4430             aValue =  iFill ;
       
  4431             break;
       
  4432             }
       
  4433         default:
       
  4434             return CSvgElementImpl::GetAttributeIntL( aNameId, aValue );
       
  4435         }
       
  4436     return KErrNone;
       
  4437     }
       
  4438 
       
  4439 void CSvgAnimationBase::ResetL(MSvgEvent* aEvent, CSvgAnimationBase* aAnimElement)
       
  4440 	{
       
  4441 
       
  4442 	TSvgTimerEvent* timerEvent  			= ( TSvgTimerEvent* ) aEvent;
       
  4443 	TInt32     lCurrentTime 				= timerEvent->Time();
       
  4444 	iAnimTime->Reset();
       
  4445 	TInt32 lBeginTime 						=  iAbsoluteBeginTime;
       
  4446 	
       
  4447 	//If Stop was called Dynamic endtime list(iEndTimeList) was reset to iInitialEndTimesList
       
  4448 	// This needs recalculation of iEndTime inside animTimeController
       
  4449 	TInt32 lSimpleDur						= SimpleDuration();
       
  4450 	if( lSimpleDur != KTimeIndefinite)
       
  4451         {
       
  4452         iAnimTime->SetEndTime(lSimpleDur);
       
  4453         }
       
  4454 	
       
  4455 	TInt32 lDuration 						= iAnimTime->DurationTime();
       
  4456 
       
  4457 	// reset back to the original values.
       
  4458 	aAnimElement->ResetReferenceElementL();
       
  4459 
       
  4460 	// Set the Additive;
       
  4461 	iAdditive = iAdditiveOrg;
       
  4462 
       
  4463 	if(lCurrentTime >= lBeginTime && lCurrentTime < lSimpleDur)
       
  4464 		{
       
  4465 		// set the new status.
       
  4466 		iAnimStatus = KAnimActive;
       
  4467 		iHadBegun = ETrue;
       
  4468 
       
  4469 		// calculate the CurrentRepeatCount.
       
  4470 		if(lDuration> 0)
       
  4471 			{
       
  4472 			iCurrentRepeatCount = (TUint16)((lCurrentTime - lBeginTime ) / lDuration);
       
  4473 
       
  4474 			// check it if it is bigger than the allowed repeatCount.
       
  4475 			if(iCurrentRepeatCount > iRepeatCount)
       
  4476 				{
       
  4477 				// truncate the repeatCount
       
  4478 				iCurrentRepeatCount = (TUint16)iRepeatCount;
       
  4479 				}
       
  4480 			}
       
  4481 		else
       
  4482 			{
       
  4483 			// No duration means repeatCount is ignored.
       
  4484 			iCurrentRepeatCount = 0;
       
  4485 			}
       
  4486 
       
  4487 		if(aAnimElement->ElemID()== KSvgAnimateTransformElement ||aAnimElement->ElemID()== KSvgAnimateMotionElement )
       
  4488 			{
       
  4489 			if(aAnimElement->ElemID() == KSvgAnimateMotionElement)
       
  4490 				{
       
  4491 				aAnimElement->ResetAnimationL();
       
  4492 				}
       
  4493 			aAnimElement->SetAccumulateValuesForSetMediaTime();
       
  4494 			}
       
  4495 		// set the begin time.
       
  4496 		iAnimTime->SetBeginTime(lBeginTime + (iCurrentRepeatCount*lDuration));
       
  4497 
       
  4498 		// Send the begin event.
       
  4499 		((CSvgDocumentImpl*)iOwnerDocument)->Engine()->NotifyAnimationStarted();
       
  4500 		TSvgInternalEvent   Beginevent   ( ESvgEventBeginEvent, this, lBeginTime );
       
  4501 		((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  4502 		    ( CSvgDocumentImpl* ) OwnerDocument(), &Beginevent );
       
  4503 
       
  4504 
       
  4505 		// Send Repeat Events.
       
  4506 		if(iAnimTime->DurationTime() != KTimeIndefinite)
       
  4507 			{
       
  4508 			TUint16 lTotalRepeatEvents = (TUint16)iCurrentRepeatCount;
       
  4509 			for(TUint16 i= 0; i < lTotalRepeatEvents; i++)
       
  4510 				{
       
  4511 				TUint32 lDur = (TUint32)iAnimTime->DurationTime();
       
  4512 				 TInt lCount = (TUint16)(i+1);
       
  4513 	             TInt32 lRepeatTime = lBeginTime + (TInt32)(lDur*lCount);
       
  4514 				 TSvgInternalEvent   Repeatevent   ( ESvgEventRepeatEvent, this, lRepeatTime );
       
  4515 				((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  4516 				    ( CSvgDocumentImpl* ) OwnerDocument(), &Repeatevent );
       
  4517 				}
       
  4518 			}
       
  4519 		}
       
  4520 	else if(lCurrentTime >= lSimpleDur)
       
  4521 		{
       
  4522 		// made active to calculate the freeze value.
       
  4523 		iAnimStatus 			= KAnimActive;
       
  4524 		iHadBegun 				= ETrue;
       
  4525 		TBool lAcuumulate 		= EFalse;
       
  4526 		if(lDuration> 0)
       
  4527 			{
       
  4528 			iCurrentRepeatCount = (TUint16)((lCurrentTime - lBeginTime ) / lDuration);
       
  4529 
       
  4530 			// check below is for the correct repeatCount setting this is
       
  4531 			// necessary for accumulate values calculation.
       
  4532 			if(iCurrentRepeatCount >= iRepeatCount || iRepeatCount == KRepeatCountMax)
       
  4533 				{
       
  4534 				// this means that the repeatCount was not specified so it is not supposed to send the
       
  4535 				// repeatEvents.
       
  4536 				if(iRepeatCount == 1)
       
  4537 					{
       
  4538 					iCurrentRepeatCount = 0;
       
  4539 					}
       
  4540 				else
       
  4541 					{
       
  4542 					if(iRepeatCountSet)
       
  4543 						{
       
  4544 						// repeatCount was specified.
       
  4545 						if(iRepeatCount != KRepeatCountMax)
       
  4546 							{
       
  4547 							// repeatCount is not "indefinite"
       
  4548 							iCurrentRepeatCount = (TUint16) iRepeatCount;
       
  4549 							}
       
  4550 						}
       
  4551 					else
       
  4552 						{
       
  4553 						// what if repeatDuration was specified.
       
  4554 						if(KTimeIndefinite != iAnimTime->RepeatDurationTime())
       
  4555 							{
       
  4556 							// repeatDuration is not "indefinite"
       
  4557 							iCurrentRepeatCount = (iAnimTime->RepeatDurationTime()) / lDuration;
       
  4558 							}
       
  4559 						}
       
  4560 					lAcuumulate = ETrue;
       
  4561 					}
       
  4562 				}
       
  4563 			}
       
  4564 		else
       
  4565 			{
       
  4566 			iCurrentRepeatCount = 0;
       
  4567 			}
       
  4568 		//take the last begin time so that accumulation happens correctly.
       
  4569 		// if "end" needs to be checked
       
  4570 		TInt32 lEnd 				= iAnimTime->GetOriginalEndTime();
       
  4571 		TInt   count				=0;
       
  4572 		TBool  lChangeRepeatCount 	= EFalse;
       
  4573 		if(KTimeIndefinite != lEnd)
       
  4574 			{
       
  4575 			for(; count <= iCurrentRepeatCount; count++)
       
  4576 				{
       
  4577 				// check is the repaetCount is more than the valid range.
       
  4578 				// depending on the end time.
       
  4579 				if((lBeginTime+(count*lDuration)) < lEnd)
       
  4580 					{
       
  4581 
       
  4582 				 	}
       
  4583 				else
       
  4584 					{
       
  4585 					// original end time must be grater than the begin time to be valid.
       
  4586 					if(lEnd > lBeginTime)
       
  4587 						{
       
  4588 						// repeatCount needs to be changed.
       
  4589 						lChangeRepeatCount = ETrue;
       
  4590 						}
       
  4591 					break;
       
  4592 
       
  4593 					}
       
  4594 				}
       
  4595 			}
       
  4596 		if(lChangeRepeatCount)
       
  4597 			{
       
  4598 			if(count >0)
       
  4599 				{
       
  4600 				iCurrentRepeatCount = count - 1;
       
  4601 				}
       
  4602 			else
       
  4603 				{
       
  4604 				iCurrentRepeatCount = 0;
       
  4605 				}
       
  4606 			}
       
  4607 		iAnimTime->SetBeginTime(lBeginTime + (iCurrentRepeatCount)*lDuration);
       
  4608 
       
  4609 		// Decrement the repeatCount; this is because the accumulate will give
       
  4610 		//additional one repeatCouont for seeking beyond the end time.
       
  4611 		TReal32 RealRepeatCount = iCurrentRepeatCount;
       
  4612 		if(iCurrentRepeatCount > 0 && ( RealRepeatCount == iRepeatCount || iRepeatCount == KRepeatCountMax))
       
  4613 			{
       
  4614 			iCurrentRepeatCount--;
       
  4615 			}
       
  4616 
       
  4617 		// check for animateTransforms and animateMotion for iAccumulate
       
  4618 		// which means that these need to accumulate separately.
       
  4619 		if(aAnimElement->ElemID()== KSvgAnimateTransformElement ||aAnimElement->ElemID()== KSvgAnimateMotionElement )
       
  4620 			{
       
  4621 			if(iAccumulate == KAccumSum && lAcuumulate)
       
  4622 				{
       
  4623 				// if it is animateMotion reset the current path indicaters.
       
  4624 				if(aAnimElement->ElemID() == KSvgAnimateMotionElement)
       
  4625 					{
       
  4626 					aAnimElement->ResetAnimationL();
       
  4627 					}
       
  4628 				// accumulate.
       
  4629 				aAnimElement->SetAccumulateValuesForSetMediaTime();
       
  4630 				}
       
  4631 			}
       
  4632 
       
  4633 		// send the begin
       
  4634 		((CSvgDocumentImpl*)iOwnerDocument)->Engine()->NotifyAnimationStarted();
       
  4635 		TSvgInternalEvent   Beginevent   ( ESvgEventBeginEvent, this, lBeginTime );
       
  4636 		((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  4637 		    ( CSvgDocumentImpl* ) OwnerDocument(), &Beginevent );
       
  4638 		// send the begin, repeat, and end Events.
       
  4639 		if(iAnimTime->DurationTime() != KTimeIndefinite)
       
  4640 			{
       
  4641 			TUint16 lTotalRepeatEvents = (TUint16)iCurrentRepeatCount;
       
  4642 			for(TUint16 i= 0; i < lTotalRepeatEvents; i++)
       
  4643 				{
       
  4644 				TUint32 lDur = (TUint32)iAnimTime->DurationTime();
       
  4645 				 TInt lCount = (TUint16)(i+1);
       
  4646 	             TInt32 lRepeatTime = lBeginTime + (TInt32)(lDur*lCount);
       
  4647 				 TSvgInternalEvent   Repeatevent   ( ESvgEventRepeatEvent, this, lRepeatTime );
       
  4648 				((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  4649 				    ( CSvgDocumentImpl* ) OwnerDocument(), &Repeatevent );
       
  4650 				}
       
  4651 			}
       
  4652 
       
  4653 		// send end events.
       
  4654 		if(lSimpleDur != (TInt32)KTimeIndefinite)
       
  4655 			{
       
  4656 			((CSvgDocumentImpl*)iOwnerDocument)->Engine()->NotifyAnimationEnded();
       
  4657 			TSvgInternalEvent   Endevent   ( ESvgEventEndEvent, this, lSimpleDur );
       
  4658 			((CSvgDocumentImpl*)iOwnerDocument)->Engine()->ProcessEventL( 
       
  4659 			    ( CSvgDocumentImpl* ) OwnerDocument(), &Endevent );
       
  4660 			TSvgTimerEvent   lEndTime1(lSimpleDur);
       
  4661 			iIsEndEventSent = ETrue;
       
  4662 			// calculate the freeze values.
       
  4663 			if(iFill == KAnimFillFreeze)
       
  4664 				{
       
  4665 				// if it has to freeze than calculate the final values.
       
  4666 				aAnimElement->AnimProcL(&lEndTime1);
       
  4667 
       
  4668 				// this is to avoid it going in the AnimProcL again. Which will change
       
  4669 				// the freeze values.
       
  4670 				// THIS MUST BE DONE ONLY WHEN THE repeatCount is fractional.
       
  4671 				TReal32 lFractReapeatDur = 0;
       
  4672 				if(KTimeIndefinite != iAnimTime->RepeatDurationTime())
       
  4673 					{
       
  4674 					// this is to check whether this matches a fractional repeatCount.
       
  4675 					lFractReapeatDur = iAnimTime->RepeatDurationTime();
       
  4676 					lFractReapeatDur = (lFractReapeatDur - (lDuration*(iCurrentRepeatCount+1))) ;
       
  4677 					}
       
  4678 				if((iRepeatCount - TInt(iRepeatCount)>0 || lFractReapeatDur > 0 )
       
  4679 					|| ((iAnimTime->BeginTime() + iAnimTime->DurationTime()) > lSimpleDur &&
       
  4680 					iAnimTime->BeginTime()!= lSimpleDur))
       
  4681 				 	{
       
  4682 				 	// do not go to AnimProcL only once.
       
  4683 					iDoFreeze = ETrue;
       
  4684 					}
       
  4685 				}
       
  4686 			else
       
  4687 				{
       
  4688 				// this should be ok . But how do we get the initial value.
       
  4689 				aAnimElement->SetToInitialValueL();
       
  4690 				// do not go to animProcL;
       
  4691 				iDoFreeze = ETrue;
       
  4692 				}
       
  4693 			}
       
  4694 		}
       
  4695 	}
       
  4696 
       
  4697 void  CSvgAnimationBase::SetOriginalValues_DOMReuse()
       
  4698 	{
       
  4699 
       
  4700 	if(iAnimTime)
       
  4701 		{
       
  4702 		iAnimTime->SetOriginalValues_DOMReuse();
       
  4703 		}
       
  4704 	}
       
  4705 CGfxGeneralPath*  CSvgAnimationBase::GetPathAttribute(TInt aAttributeId)
       
  4706 {
       
  4707 if(iDataType == KSvgTypePath)
       
  4708 	{
       
  4709 	switch(aAttributeId)
       
  4710 		{
       
  4711 		case KAtrTo:	return iToPath;
       
  4712 		case KAtrFrom: return iOrgFromPath;
       
  4713 		default :
       
  4714 			return NULL;
       
  4715 		}
       
  4716 	}
       
  4717 return NULL;
       
  4718 }
       
  4719 void CSvgAnimationBase::SetPathAttribute(TInt aAttributeId, CGfxGeneralPath* aPathHandle)
       
  4720 {
       
  4721  if(iDataType == KSvgTypePath)
       
  4722 	{
       
  4723 	switch(aAttributeId)
       
  4724 		{
       
  4725 		case KAtrTo:
       
  4726 			{
       
  4727 				if(iToPath == aPathHandle)
       
  4728 					{
       
  4729 					return;
       
  4730 					}
       
  4731 			delete iToPath;
       
  4732 			iToPath = aPathHandle;
       
  4733 			}
       
  4734 			break;
       
  4735 		case KAtrFrom:
       
  4736 			{
       
  4737 
       
  4738 				if(iOrgFromPath == aPathHandle)
       
  4739 					{
       
  4740 					return;
       
  4741 					}
       
  4742 
       
  4743 			delete iOrgFromPath;
       
  4744 			iOrgFromPath = aPathHandle;
       
  4745 
       
  4746 			// clone it .
       
  4747 			delete iFromPath;
       
  4748 			iFromPath = NULL;
       
  4749 
       
  4750 			/************************************/
       
  4751 			TRAPD(error ,iFromPath = CGfxGeneralPath::NewL());
       
  4752 			if(error == KErrNone)
       
  4753 				{
       
  4754 				RArray<TUint32>* lTypes = aPathHandle->PointTypeArray();
       
  4755                 RArray<TFloatFixPt>* lCoords = aPathHandle->PointCoordsArrayAll();
       
  4756                 TRAP_IGNORE( iFromPath->SetPointTypeArrayL(lTypes) );
       
  4757                 TRAP_IGNORE( iFromPath->SetPointCoordsArrayL(lCoords) );
       
  4758                 }
       
  4759 			/************************************/
       
  4760 
       
  4761 			}
       
  4762 			break;
       
  4763 		default :
       
  4764 			break;
       
  4765 		}
       
  4766 	}
       
  4767 
       
  4768 }
       
  4769 
       
  4770 
       
  4771 TUint8 CSvgAnimationBase::GetAnimStatus()
       
  4772 {
       
  4773 	return iAnimStatus;
       
  4774 }
       
  4775 
       
  4776 // added for forward referencing
       
  4777 TInt  CSvgAnimationBase::SetRefElemById(const TDesC& aName)
       
  4778 	{
       
  4779 	//If iTargetElement is Set to Null means that some junk Href was given
       
  4780 	 iTargetElement = ( CSvgElementImpl*)((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( aName );
       
  4781 
       
  4782      if(iTargetElement==NULL)
       
  4783      	{
       
  4784      	return KErrNotFound;
       
  4785      	}
       
  4786      else
       
  4787      	{
       
  4788     iTargetElement->iHasAnimationBase = (TInt)this;
       
  4789 		TRAPD(lError,GetAttrValueL());
       
  4790 		if ( lError != KErrNone )
       
  4791 		   {
       
  4792 		   // ignore trap error
       
  4793 	       }
       
  4794 		return KErrNone;
       
  4795 		}
       
  4796 	}
       
  4797 
       
  4798 void CSvgAnimationBase::CopyL(CSvgAnimationBase* newElement)
       
  4799 	{
       
  4800 	if(newElement)
       
  4801 	{
       
  4802 
       
  4803 	// copy this pointer.
       
  4804 	this->iAnimTime->CopyL(newElement->iAnimTime);
       
  4805 
       
  4806 	if(iEndPath)
       
  4807 	{
       
  4808 	newElement->iEndPath = CGfxGeneralPath::NewL();
       
  4809 
       
  4810     RArray<TUint32>* lTypes = this->iEndPath->PointTypeArray();
       
  4811     RArray<TFloatFixPt>* lCoords = this->iEndPath->PointCoordsArrayAll();
       
  4812     newElement->iEndPath->SetPointTypeArrayL(lTypes);
       
  4813     newElement->iEndPath->SetPointCoordsArrayL(lCoords);
       
  4814     }
       
  4815 	if(iOrgPath)
       
  4816 	{
       
  4817 	newElement->iOrgPath = CGfxGeneralPath::NewL();
       
  4818 
       
  4819     RArray<TUint32>* lTypes = this->iOrgPath->PointTypeArray();
       
  4820     RArray<TFloatFixPt>* lCoords = this->iOrgPath->PointCoordsArrayAll();
       
  4821     newElement->iOrgPath->SetPointTypeArrayL(lTypes);
       
  4822     newElement->iOrgPath->SetPointCoordsArrayL(lCoords);
       
  4823     }
       
  4824 	if(iFromPath)
       
  4825 	{
       
  4826 	newElement->iFromPath = CGfxGeneralPath::NewL();
       
  4827 
       
  4828     RArray<TUint32>* lTypes = this->iFromPath->PointTypeArray();
       
  4829     RArray<TFloatFixPt>* lCoords = this->iFromPath->PointCoordsArrayAll();
       
  4830     newElement->iFromPath->SetPointTypeArrayL(lTypes);
       
  4831     newElement->iFromPath->SetPointCoordsArrayL(lCoords);
       
  4832     }
       
  4833 	if(iToPath)
       
  4834 	{
       
  4835 	newElement->iToPath = CGfxGeneralPath::NewL();
       
  4836 
       
  4837     RArray<TUint32>* lTypes = this->iToPath->PointTypeArray();
       
  4838     RArray<TFloatFixPt>* lCoords = this->iToPath->PointCoordsArrayAll();
       
  4839     newElement->iToPath->SetPointTypeArrayL(lTypes);
       
  4840     newElement->iToPath->SetPointCoordsArrayL(lCoords);
       
  4841     }
       
  4842 	if(iOrgFromPath)
       
  4843 	{
       
  4844 	newElement->iOrgFromPath = CGfxGeneralPath::NewL();
       
  4845 
       
  4846     RArray<TUint32>* lTypes = this->iOrgFromPath->PointTypeArray();
       
  4847     RArray<TFloatFixPt>* lCoords = this->iOrgFromPath->PointCoordsArrayAll();
       
  4848     newElement->iOrgFromPath->SetPointTypeArrayL(lTypes);
       
  4849     newElement->iOrgFromPath->SetPointCoordsArrayL(lCoords);
       
  4850     }
       
  4851 	if(iValuesFloat)
       
  4852 		{
       
  4853 
       
  4854 		TInt lCount = iValuesFloat->Count();
       
  4855 		newElement->iValuesFloat->Reset();
       
  4856 		for(TInt i=0; i<lCount; i++)
       
  4857             {
       
  4858             newElement->iValuesFloat->AppendL(iValuesFloat->operator[](i));
       
  4859 			}
       
  4860 		}
       
  4861 	if(iValuesInt)
       
  4862 		{
       
  4863 		TInt lCount = iValuesInt->Count();
       
  4864 		newElement->iValuesInt->Reset();
       
  4865 		for(TInt i=0; i<lCount; i++)
       
  4866 			{
       
  4867 			User::LeaveIfError(newElement->iValuesInt->Append(iValuesInt->operator[](i)));
       
  4868 			}
       
  4869 		}
       
  4870 
       
  4871 	//iValuesPath
       
  4872     if(iValuesPath)
       
  4873 		{
       
  4874 		TInt lCount = iValuesPath->Count();
       
  4875 		newElement->iValuesPath->Reset();
       
  4876 		for(TInt i=0; i<lCount; i++)
       
  4877 			{
       
  4878 			CGfxGeneralPath* lOrgPath = (this->iValuesPath)->operator[](i);
       
  4879 			RArray<TUint32>* lTypes = lOrgPath->PointTypeArray();
       
  4880 			RArray<TFloatFixPt>* lCoords = lOrgPath->PointCoordsArrayAll();
       
  4881 
       
  4882             CGfxGeneralPath* lClonePath = CGfxGeneralPath::NewL();
       
  4883             CleanupStack::PushL(lClonePath);
       
  4884             lClonePath->SetPointTypeArrayL(lTypes);
       
  4885             lClonePath->SetPointCoordsArrayL(lCoords);
       
  4886             newElement->iValuesPath->AppendL((CGfxGeneralPath*)lClonePath);
       
  4887             CleanupStack::Pop(lClonePath);
       
  4888 			}
       
  4889 		}
       
  4890 
       
  4891 	//iValuesViewBox
       
  4892 	if(iValuesViewBox)
       
  4893 		{
       
  4894 		TInt lCount = iValuesViewBox->Count();
       
  4895 		newElement->iValuesViewBox->Reset();
       
  4896 		for(TInt i=0; i<lCount; i++)
       
  4897 			{
       
  4898 			User::LeaveIfError(newElement->iValuesViewBox->Append(iValuesViewBox->operator[](i)));
       
  4899 			}
       
  4900 		}
       
  4901 
       
  4902 	newElement->iEndOffset = iEndOffset;
       
  4903 	newElement->iRepeatCount = iRepeatCount;
       
  4904 	newElement->iRepeatEndValue = iRepeatEndValue;
       
  4905 	newElement->iAbsoluteBeginTime = iAbsoluteBeginTime;
       
  4906 	newElement->iAttributeFlag = iAttributeFlag;
       
  4907 	newElement->iEndInt = iEndInt;
       
  4908 	newElement->iPropInt = iPropInt;
       
  4909 	newElement->iOrgInt = iOrgInt;
       
  4910 	newElement->iFromInt = iFromInt;
       
  4911 	newElement->iToInt = iToInt;
       
  4912 	newElement->iOrgFromInt = iOrgFromInt;
       
  4913 	newElement->iIsBeginSet = iIsBeginSet;
       
  4914 	newElement->iPropFloat = iPropFloat;
       
  4915 	newElement->iOrgFloat = iOrgFloat;
       
  4916 	newElement->iFromFloat = iFromFloat;
       
  4917 	newElement->iToFloat = iToFloat;
       
  4918 	newElement->iOrgFromFloat = iOrgFromFloat;
       
  4919 	newElement->iEndFloat = iEndFloat;
       
  4920 	newElement->iBeginTimeIndex = iBeginTimeIndex;
       
  4921 	//newElement->iEndAccessKeyCode = iEndAccessKeyCode;
       
  4922 	newElement->iCurrentRepeatCount = iCurrentRepeatCount;
       
  4923 	newElement->iAttrId = iAttrId;
       
  4924 	newElement->iDataType = iDataType;
       
  4925 	newElement->iInitDone = iInitDone;
       
  4926 	newElement->iTargetSet = iTargetSet;
       
  4927 	newElement->iNoFrom = iNoFrom;
       
  4928 	newElement->iHaveTo = iHaveTo;
       
  4929 	newElement->iHaveBy = iHaveBy;
       
  4930 	newElement->iHaveValues = iHaveValues;
       
  4931 	newElement->iAnimStatus = iAnimStatus;
       
  4932 
       
  4933 	//viewBox
       
  4934 	newElement->iOrgViewBox = iOrgViewBox;
       
  4935 	newElement->iFromViewBox = iFromViewBox;
       
  4936 	newElement->iToViewBox = iToViewBox;
       
  4937 	newElement->iOrgFromViewBox = iOrgFromViewBox;
       
  4938 	newElement->iEndViewBox = iEndViewBox;
       
  4939 
       
  4940 //	newElement->iEndReferenceEvent = iEndReferenceEvent;
       
  4941 	//////////////////////////////
       
  4942 	newElement->iAnimStatus = iAnimStatus;
       
  4943 	newElement->iFill = iFill;
       
  4944 	newElement->iHadBegun = iHadBegun;
       
  4945 	newElement->iAnimRestart = iAnimRestart;
       
  4946 	newElement->iAccumulate = iAccumulate;
       
  4947 	newElement->iAdditive = iAdditive;
       
  4948 	newElement->iAdditiveOrg = iAdditiveOrg;
       
  4949 	newElement->iOverrideTime = iOverrideTime;
       
  4950 	newElement->iRepeatCountSet = iRepeatCountSet;
       
  4951 	newElement->iDoFreeze = iDoFreeze;
       
  4952 	newElement->iKeyTimesPresent = iKeyTimesPresent;
       
  4953 	newElement->iCheckFirstAnim = iCheckFirstAnim;
       
  4954 
       
  4955 	newElement->iIsUserSeek = EFalse;
       
  4956 
       
  4957 
       
  4958 
       
  4959 
       
  4960 	if(iEventList)
       
  4961 		{
       
  4962 		TInt lCount = iEventList->Count();
       
  4963 
       
  4964 
       
  4965 		newElement->iEventList->Reset();
       
  4966 		for(TInt i=0;i<lCount;i++ )
       
  4967 			{
       
  4968 			newElement->iEventList->AppendL(iEventList->operator[](i));
       
  4969 			(newElement->iEventList->operator[](i)).iReferenceElemeId = NULL;
       
  4970 			if(iEventList->operator[](i).iReferenceElemeId)
       
  4971 				{
       
  4972 				(newElement->iEventList->operator[](i)).iReferenceElemeId = (iEventList->operator[](i).iReferenceElemeId)->AllocL();
       
  4973 				}
       
  4974 			else
       
  4975 				{
       
  4976 				(newElement->iEventList->operator[](i)).iReferenceElemeId = NULL;
       
  4977 				}
       
  4978 			}
       
  4979 		}
       
  4980 
       
  4981 
       
  4982 	if(iEndTimeList)
       
  4983 		{
       
  4984 		TInt lCount = iEndTimeList->Count();
       
  4985 		newElement->iEndTimeList->Reset();
       
  4986 		for(TInt i=0;i<lCount;i++ )
       
  4987 			{
       
  4988 			newElement->iEndTimeList->AppendL(iEndTimeList->operator[](i));
       
  4989 			(newElement->iEndTimeList->operator[](i)).iReferenceElemeId = NULL;
       
  4990 			if(iEndTimeList->operator[](i).iReferenceElemeId)
       
  4991 				{
       
  4992 				(newElement->iEndTimeList->operator[](i)).iReferenceElemeId = (iEndTimeList->operator[](i).iReferenceElemeId)->AllocL();
       
  4993 				}
       
  4994 			else
       
  4995 				{
       
  4996 				(newElement->iEndTimeList->operator[](i)).iReferenceElemeId = NULL;
       
  4997 				}
       
  4998 			}
       
  4999 		}
       
  5000 	}
       
  5001 
       
  5002 	}
       
  5003 // Call stack on Stop and Play
       
  5004 // CSvgEngineInterfaceImpl::Replay
       
  5005 // CSvgEngineImpl::SetMediaTime
       
  5006 // CSvgEngineImpl::SeekEngine
       
  5007 // CSvgTimeContainer::UserSeek
       
  5008 // CSvgDocumentImpl::Reset
       
  5009 // CSvgEventHandler::Reset	
       
  5010 // CSvgEventHandler::DeactivateAnimations 
       
  5011 // CSvgAnimateElementImpl::DeactivateAnimation
       
  5012 void CSvgAnimationBase::DeactivateAnimation(CSvgAnimationBase* aElement)
       
  5013 {
       
  5014 	if(!aElement)return;
       
  5015 
       
  5016 	iDoFreeze = EFalse;
       
  5017 
       
  5018 	// this should work for multiple begins.
       
  5019 	if(iEventList->Count()> 0)
       
  5020 		{
       
  5021 		if(iEventList->operator[](0).iEvent != ESvgEventNone || iEventList->Count() > 1)
       
  5022 			{
       
  5023 			// if it is not absolute.
       
  5024 			// reset this to initials.
       
  5025 			iAbsoluteBeginTime = KTimeIndefinite;
       
  5026 			iHadBegun= EFalse;
       
  5027 			iBeginTimeIndex = 0 ;
       
  5028 			iCurrentRepeatCount= 0;
       
  5029 			iInitDone = EFalse;
       
  5030 			iOverrideTime = EFalse;
       
  5031 			iAnimStatus = KAnimNotActive;
       
  5032 			iAnimTime->SetBeginTime(KTimeIndefinite);
       
  5033 
       
  5034 			// reset the time related stuffs.
       
  5035 			iAnimTime->ReInitialize();
       
  5036 
       
  5037 			// this is necessary.
       
  5038 			if(iAdditiveOrg == KAdditiveReplace)
       
  5039 				{
       
  5040 				iAdditive= KAdditivePass;
       
  5041 				}
       
  5042 			// this is a virtual function.
       
  5043 			aElement->ReInitializeAnimation();
       
  5044 			}
       
  5045 		}
       
  5046 
       
  5047 	// Set the end times to indefinite.
       
  5048 	if(iEndTimeList->Count()> 0   )
       
  5049 		{
       
  5050 		if(iEndTimeList->operator[](0).iEvent != ESvgEventNone )
       
  5051 			{
       
  5052 			iAnimTime->SetEndTimesIndefinite();
       
  5053 			}
       
  5054 		}
       
  5055 }
       
  5056 
       
  5057 TBool CSvgAnimationBase::ParseViewBoxValue(const TDesC& aValue, TGfxRectangle2D& aRect)
       
  5058 	{
       
  5059 
       
  5060 	TLex input( aValue );
       
  5061 	TReal32 vBoxX=0;
       
  5062 	TReal32 vBoxY=0;
       
  5063 	TReal32 vBoxW=0;
       
  5064 	TReal32 vBoxH=0;
       
  5065 
       
  5066     input.SkipSpace();
       
  5067     if (input.Val( vBoxX, '.' ) != KErrNone)
       
  5068        	 vBoxX= 0;
       
  5069 
       
  5070     if( input.Peek() == ',' )
       
  5071        	input.Inc();
       
  5072     input.SkipSpace();
       
  5073     if( input.Peek() == ',' )
       
  5074        	input.Inc();
       
  5075 
       
  5076     if (input.Val( vBoxY, '.' ) != KErrNone)
       
  5077        	 vBoxY= 0;
       
  5078 
       
  5079 
       
  5080     if( input.Peek() == ',' )
       
  5081        	input.Inc();
       
  5082     input.SkipSpace();
       
  5083     if( input.Peek() == ',' )
       
  5084        	input.Inc();
       
  5085 
       
  5086     if (input.Val( vBoxW, '.' ) != KErrNone)
       
  5087       	 vBoxW= 0;
       
  5088 
       
  5089     if( input.Peek() == ',' )
       
  5090        	input.Inc();
       
  5091     input.SkipSpace();
       
  5092     if( input.Peek() == ',' )
       
  5093        	input.Inc();
       
  5094 
       
  5095     if (input.Val( vBoxH, '.' ) != KErrNone)
       
  5096        	 vBoxH= 0;
       
  5097 
       
  5098      aRect= TGfxRectangle2D( vBoxX, vBoxY, vBoxW, vBoxH );
       
  5099 	 return ETrue;
       
  5100 	}
       
  5101 void CSvgAnimationBase::CheckForEndTimesAndFreezeL(CSvgAnimationBase* aElement)
       
  5102 {
       
  5103 	if(iAnimStatus == KAnimFinished) // KAnimFinished
       
  5104         {
       
  5105       	    if(!iDoFreeze)
       
  5106       	    	{
       
  5107       	    	iDoFreeze = ETrue;
       
  5108       	    	return;
       
  5109       	    	}
       
  5110   		    if ( iFill == KAnimFillFreeze )
       
  5111 		        {
       
  5112 		        aElement->SetToEndValueL();
       
  5113 		        }
       
  5114 
       
  5115         }
       
  5116 }
       
  5117 
       
  5118 // function for decoder
       
  5119 void CSvgAnimationBase::AddEndTime( TInt32 aEndTime )
       
  5120     {
       
  5121      if(iAnimTime)
       
  5122 		 iAnimTime->AddEndTime(aEndTime);
       
  5123     }
       
  5124 
       
  5125 void CSvgAnimationBase::SetAccumulateValuesForSetMediaTime()
       
  5126 {
       
  5127 }
       
  5128 
       
  5129 TBool CSvgAnimationBase::IsSelfDependentForBegin()
       
  5130 {
       
  5131 
       
  5132 	/*********************************************************************
       
  5133 
       
  5134 	 This is used only after setmediaTime is done on the svg DOCUMENT.
       
  5135 	 This function is to tell whether the elements begin depends on its end.
       
  5136 
       
  5137 	*********************************************************************/
       
  5138 
       
  5139 	if(iEventList->Count()> 0)
       
  5140 		{
       
  5141 		TInt lCount = iEventList->Count();
       
  5142 		for(TInt i=0; i< lCount; i++)
       
  5143 			{
       
  5144 			if(iEventList->operator[](i).iTargetElement == this &&
       
  5145 			   iEventList->operator[](i).iEvent == ESvgEventEndEvent)
       
  5146 				{
       
  5147 				return ETrue;
       
  5148 				}
       
  5149 			}
       
  5150 		}
       
  5151 
       
  5152 	return EFalse;
       
  5153 }
       
  5154  void CSvgAnimationBase::SetFromValuesL()
       
  5155 {
       
  5156 	/*
       
  5157 	* this is to make sure that the iOrg values do not  get modified once set.
       
  5158 	*/
       
  5159 	 switch ( iDataType )
       
  5160         {
       
  5161         case KSvgTypeOpacity:
       
  5162         case KSvgTypeLength:
       
  5163 	        {
       
  5164 	        // This is to handle all cases, was only fill="freeze" cases.
       
  5165 	        if (iNoFrom)
       
  5166 	            {
       
  5167 	            TFloatFixPt    lTempValue;
       
  5168 		        iTargetElement->GetAttributeFloat( iAttrId, lTempValue );
       
  5169 	            iFromFloat = lTempValue;
       
  5170 	            }
       
  5171 	        }
       
  5172         break;
       
  5173 
       
  5174         case KSvgTypeList:
       
  5175         case KSvgTypePath:
       
  5176 
       
  5177         	{
       
  5178 
       
  5179         	if (iNoFrom )
       
  5180 	            {
       
  5181 	            if ( iFromPath )
       
  5182                     {
       
  5183                     delete iFromPath;
       
  5184                     iFromPath = NULL;
       
  5185                     }
       
  5186                 CGfxGeneralPath*parentPath;
       
  5187 	            iFromPath = CGfxGeneralPath::NewL();
       
  5188 	            iTargetElement->GetAttributePath( iAttrId, parentPath );
       
  5189 	            CGfxPathIterator*   itr;
       
  5190 	            TGfxAffineTransform affineTransform;
       
  5191 	            parentPath->GetPathIteratorL( &affineTransform, itr );
       
  5192 	            CleanupStack::PushL( itr );
       
  5193 	            iFromPath->AppendL( itr );
       
  5194 	            CleanupStack::PopAndDestroy( 1 ); // destroy itr
       
  5195              	}
       
  5196 
       
  5197         	}
       
  5198         	break;
       
  5199 		/*
       
  5200 		 *   The above algorithm can be applicable to color as well.
       
  5201 		 *   Results are not same as adobe.
       
  5202 		 */
       
  5203         case KSvgTypeColor:
       
  5204 
       
  5205         break;
       
  5206 
       
  5207         // following are all strings data types.
       
  5208         case KSvgTypeTextAnchor:
       
  5209         case KSvgTypeGradientUnits:
       
  5210         case KSvgTypeSpreadMethod:
       
  5211         case KSvgTypeInteger:
       
  5212         case KSvgTypeDisplay:
       
  5213         case KSvgTypeVisibility:
       
  5214         	if (iAttributeFlag)
       
  5215         	if ( iNoFrom )
       
  5216 	            {
       
  5217 	            iTargetElement->GetAttributeIntL( iAttrId, iFromInt);
       
  5218 	            }
       
  5219         break;
       
  5220 
       
  5221 		// viewBox
       
  5222         case KSvgTypeViewBox:
       
  5223 			{
       
  5224 			if(iTargetElement->ElemID() == KSvgSvgElement)
       
  5225 				{
       
  5226 				if (iNoFrom)
       
  5227 					{
       
  5228 					TGfxRectangle2D   lTempVierwBox;
       
  5229 					((CSvgSvgElementImpl*)iTargetElement)->GetViewBox( lTempVierwBox );
       
  5230 					iFromViewBox = lTempVierwBox;
       
  5231 					}
       
  5232 				}
       
  5233 			}
       
  5234 			 break;
       
  5235 
       
  5236         default:
       
  5237         break;
       
  5238         }
       
  5239 }
       
  5240 
       
  5241 
       
  5242 TInt32 CSvgAnimationBase::GetAbsoluteBeginTime()
       
  5243     {
       
  5244     return iAbsoluteBeginTime;
       
  5245     }
       
  5246 
       
  5247 TInt32 CSvgAnimationBase::GetEndTime()
       
  5248     {
       
  5249     return iAnimTime->EndTime();
       
  5250     }
       
  5251 
       
  5252 
       
  5253 void CSvgAnimationBase::CheckBeginTime()
       
  5254     {
       
  5255 
       
  5256     if (iAnimTime->BeginTimesCount() == 0 && iAnimTime->BeginTime() == 0)
       
  5257         {
       
  5258         iAnimTime->AddBeginTime(0);
       
  5259         iAnimTime->AddToInitialList(0);
       
  5260         }
       
  5261     }
       
  5262 
       
  5263 void CSvgAnimationBase::StoreRepeatId( const TDesC& aValue, TBool aRepeatWasInBeginAtt )
       
  5264 {
       
  5265 	if (iRepeatId)
       
  5266 	{
       
  5267 		delete iRepeatId;
       
  5268 		iRepeatId = NULL;
       
  5269 	}
       
  5270 
       
  5271     iRepeatInBegin = aRepeatWasInBeginAtt;
       
  5272     TRAPD( error, iRepeatId = aValue.AllocL() );
       
  5273     if ( error != KErrNone )
       
  5274         {
       
  5275         #ifdef _DEBUG
       
  5276         RDebug::Printf("CSvgAnimationBase::StoreRepeatId: iRepeatId = aValue.AllocL() leaves");
       
  5277         #endif
       
  5278         }
       
  5279 }
       
  5280 
       
  5281 void CSvgAnimationBase::NotifyAnimationsRepeatingOnThisOneL( const TDesC* aId )
       
  5282 {
       
  5283 	// Get THhe Engine's Current Media Time.
       
  5284 	CSvgDocumentImpl* lDocument = ((CSvgDocumentImpl*)iOwnerDocument);
       
  5285 
       
  5286     if ( !aId || aId->Length() == 0 )
       
  5287     return;
       
  5288 
       
  5289     TInt32 lEngineTime = ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->CurrentTIme();
       
  5290 
       
  5291     TInt lAnimationCount = lDocument->iSvgAnimations.Count();
       
  5292     for (TInt i=0; i < lAnimationCount; i++)
       
  5293     {
       
  5294     	CSvgAnimationBase* lAnimatingElement = lDocument->iSvgAnimations[i];
       
  5295     	if ( lAnimatingElement->iRepeatId && (lAnimatingElement->iRepeatId->CompareF(*aId) == 0 ) )
       
  5296     	{
       
  5297     		if (lAnimatingElement->iRepeatInBegin)
       
  5298     		{
       
  5299     			lAnimatingElement->SetBeginByEventL( lAnimatingElement,lEngineTime, ETrue );
       
  5300     		}
       
  5301     		else
       
  5302     		{
       
  5303     			//it must have been in an end attribute
       
  5304     			lAnimatingElement->SetEndByEvent(lAnimatingElement, lEngineTime );
       
  5305     		}
       
  5306 
       
  5307     	}
       
  5308     }
       
  5309 }
       
  5310 
       
  5311 // ---------------------------------------------------------------------------
       
  5312 // void CSvgAnimationBase::FindColorDistanceL() 
       
  5313 //  This function computes the distance between colours for the purpose 
       
  5314 //  of animateColor element. Colours are treated as a 3D point 
       
  5315 //  with r, g, b acting as axes. It modifies the iValuesFloat array and each 
       
  5316 //  index contains the cummulative length(from start colour) of the segment 
       
  5317 //  with same index
       
  5318 // ---------------------------------------------------------------------------
       
  5319 void CSvgAnimationBase::FindColorDistanceL() 
       
  5320     {
       
  5321     TInt lcount = iValuesInt->Count(); 
       
  5322 
       
  5323     //Fix for MLIO-743FRR:check whether "values" attribute is present
       
  5324     if ( lcount > 0 )
       
  5325         {
       
  5326 	    iValuesFloat->AppendL( 0 ); 
       
  5327         }
       
  5328         
       
  5329     TFloatFixPt len = 0; 
       
  5330 
       
  5331     for(TInt i = 1; i < lcount; i++) 
       
  5332         { 
       
  5333         TInt c1 = (*iValuesInt)[i-1]; 
       
  5334         TInt c2 = (*iValuesInt)[i]; 
       
  5335         TInt r1 = c1 & 0x00FF0000; 
       
  5336         r1 = r1 >> 16; 
       
  5337         TInt g1 = c1 & 0x0000FF00; 
       
  5338         g1 = g1 >> 8; 
       
  5339         TInt b1 = c1 & 0x000000FF; 
       
  5340         
       
  5341         TInt r2 = c2 & 0x00FF0000; 
       
  5342         r2 = r2 >> 16; 
       
  5343         TInt g2 = c2 & 0x0000FF00; 
       
  5344         g2 = g2 >> 8; 
       
  5345         TInt b2 = c2 & 0x000000FF; 
       
  5346         
       
  5347         TInt dr = r1 - r2; 
       
  5348         TInt dg = g1 - g2; 
       
  5349         TInt db = b1 - b2; 
       
  5350         
       
  5351         TFloatFixPt length = TFloatFixPt::Sqrt( dr * dr + dg * dg + db * db ); 
       
  5352         //TFloatFixPt length = Math::Sqrt( dr * dr + dg * dg + db * db ); 
       
  5353         len += length; 
       
  5354         iValuesFloat->AppendL( len ); 
       
  5355         } 
       
  5356     } 
       
  5357 
       
  5358 TBool CSvgAnimationBase::IsFillFreeze()
       
  5359     {
       
  5360         if ( iFill == KAnimFillFreeze )
       
  5361             return ETrue;
       
  5362         else
       
  5363             return EFalse;
       
  5364     }
       
  5365 void CSvgAnimationBase::ResetTimes()
       
  5366     {
       
  5367 	iAnimTime->ResetBeginTime();
       
  5368     iAnimTime->ResetEndTime();
       
  5369     }
       
  5370 
       
  5371 // End of file