svgtopt/SVG/SVGImpl/src/SVGAnimationElementImpl.cpp
changeset 46 88edb906c587
child 19 df65ec4f2d28
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVG Implementation source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "SVGAnimationElementImpl.h"
       
    21 #include "SVGDocumentImpl.h"
       
    22 #include "SVGSchemaData.h"
       
    23 #include "SVGAnimationBase.h"
       
    24 #include "SVGEvent.h"
       
    25 #include "SVGEventHandler.h"
       
    26 
       
    27 #if !defined(__E32BASE_H__)
       
    28 #include <e32base.h>
       
    29 #endif
       
    30 
       
    31 
       
    32 // ============================= LOCAL FUNCTIONS ===============================
       
    33 
       
    34 // Setter functions
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // SetRecursionVariable: Set aIsRecursion to indicate that the element has been
       
    38 // cloned or not.
       
    39 //
       
    40 // Returns: TFloatFixPt
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 void CSvgAnimationElementImpl::SetRecursionVariable(TBool aIsRecursion)
       
    44 	{
       
    45 	iUseInRecursion = aIsRecursion;
       
    46 	}
       
    47 
       
    48 
       
    49 
       
    50 // ============================ MEMBER FUNCTIONS ===============================
       
    51 
       
    52 // Getter functions
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // X: returns iX
       
    56 //
       
    57 // Returns: TFloatFixPt
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 TFloatFixPt CSvgAnimationElementImpl::X()
       
    61     {
       
    62     return iX;
       
    63     }
       
    64 
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // Y: returns iY
       
    68 //
       
    69 // Returns: TFloatFixPt
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 TFloatFixPt CSvgAnimationElementImpl::Y()
       
    73     {
       
    74     return iY;
       
    75     }
       
    76 
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // Width: returns iWidth
       
    80 //
       
    81 // Returns: TFloatFixPt
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TFloatFixPt CSvgAnimationElementImpl::Width()
       
    85     {
       
    86     return iWidth;
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // Height: return iHeight
       
    92 //
       
    93 // Returns: TFloatFixPt
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 TFloatFixPt CSvgAnimationElementImpl::Height()
       
    97     {
       
    98     return iHeight;
       
    99     }
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // PreservRatio: Returns the PreserveAspecRatio's setting. Mainly used by encoder.
       
   104 //
       
   105 // Returns: Descriptor of PreserveAspecRatio value
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 const TDesC& CSvgAnimationElementImpl::PreservRatio()
       
   109     {
       
   110     return (TDesC&) *iPreservRatio;
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // SetAttributeL: Called by Contenthandler or decoder to set attributes
       
   116 //
       
   117 // Returns: TInt error code
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 TInt CSvgAnimationElementImpl::SetAttributeL( const TDesC& aName,
       
   121                                         const TDesC& aValue )
       
   122     {
       
   123     _LIT( KXlink, "xlink:href" );
       
   124     _LIT( KPreserveAspectRatio, "preserveAspectRatio" );
       
   125 
       
   126     if ( aName == KXlink )
       
   127         {
       
   128         // STEP 1 - Get the reference element
       
   129         // If the first char is '#' then remove it
       
   130         // This is possible if coming from cXML parser and not CVG Decoder
       
   131         TInt pos = aValue.Locate( '#' );
       
   132         if ( pos != KErrNotFound && pos == 0 )
       
   133             {
       
   134             HBufC*  tBufC   = HBufC::NewLC( aValue.Length() );
       
   135             TPtr    tPtr    = tBufC->Des();
       
   136             tPtr.Copy( aValue );
       
   137             tPtr.Delete( pos, 1 );
       
   138 
       
   139 			if ( this->SetXlinkAttributeL( aName, tPtr ) )
       
   140 				{
       
   141 				iReferencedElement = ( CSvgElementImpl * )
       
   142 					((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( tPtr );
       
   143 
       
   144 				if(iReferencedElement == NULL)
       
   145 					{
       
   146 					// failure in finding the referenced element
       
   147 					CleanupStack::PopAndDestroy( 1 ); // tBufC
       
   148 					return KErrReferencedElementNotFound;
       
   149 					}
       
   150 				}
       
   151 
       
   152 			CleanupStack::PopAndDestroy( 1 ); // tBufC
       
   153 			}
       
   154 		}
       
   155 	else if ( aName == KPreserveAspectRatio )
       
   156     	{
       
   157         iPreservRatio = aValue.AllocL();
       
   158     	}
       
   159 	else
       
   160 	    {
       
   161     	CSvgAnimationBase::SetAttributeL(aName, aValue);
       
   162 	    }
       
   163 
       
   164 	return KErrNone;
       
   165     }
       
   166 
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // SetAttributeFloatL: Called by Contenthandler or decoder to set attributes
       
   170 //
       
   171 // Returns: TInt error code
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 TInt CSvgAnimationElementImpl::SetAttributeFloatL( const TInt aNameId,
       
   175                                                    const TFloatFixPt aValue )
       
   176     {
       
   177     switch ( aNameId )
       
   178         {
       
   179         case KAtrX:
       
   180             iX = aValue;
       
   181             break;
       
   182 
       
   183         case KAtrY:
       
   184             iY = aValue;
       
   185             break;
       
   186 
       
   187         case KAtrWidth:
       
   188             iWidth = aValue;
       
   189             break;
       
   190 
       
   191         case KAtrHeight:
       
   192             iHeight = aValue;
       
   193             break;
       
   194 
       
   195         default:
       
   196             return CSvgElementImpl::SetAttributeFloatL( aNameId, aValue );
       
   197         }
       
   198     return KErrNone;
       
   199     }
       
   200 
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // GetAttributeFloat: returns value of the floating attribute
       
   204 //
       
   205 // Returns: TInt error code
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 TInt CSvgAnimationElementImpl::GetAttributeFloat( const TInt aNameId, TFloatFixPt& aValue )
       
   209     {
       
   210     switch ( aNameId )
       
   211         {
       
   212         case KAtrX:
       
   213 				 aValue = iX ;
       
   214 			     break;
       
   215 
       
   216         case KAtrY:
       
   217 				aValue = iY ;
       
   218 			    break;
       
   219 
       
   220         case KAtrWidth:
       
   221 				aValue = iWidth ;
       
   222 		        break;
       
   223 
       
   224         case KAtrHeight:
       
   225 				aValue = iHeight ;
       
   226 		        break;
       
   227 
       
   228         default:
       
   229             return CSvgElementImpl::GetAttributeFloat( aNameId, aValue );
       
   230         }
       
   231     return KErrNone;
       
   232     }
       
   233 
       
   234 
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // GetUriRefId: Get the id of reference target id
       
   238 //
       
   239 // Returns: TDesC& id
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 //const TDesC& CSvgAnimationElementImpl::GetUriRefId()
       
   243 //	{
       
   244 //	return (TDesC&) (iReferencedElement->Id());
       
   245 //	}
       
   246 
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // IsUriRefSet: Return true or not if uri is set
       
   250 //
       
   251 // Returns: TBool
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 TBool CSvgAnimationElementImpl::IsUriRefSet()
       
   255 	{
       
   256     if(iReferencedElement)
       
   257         {
       
   258 		return ETrue;
       
   259 	    }
       
   260 	  else
       
   261 	    {
       
   262 		return EFalse;
       
   263 	    }
       
   264 	}
       
   265 
       
   266 
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // ReceiveEventL: The implemented function will be called whenever subscribed
       
   270 // events are received.
       
   271 //
       
   272 // From MSvgEventReceiver
       
   273 //
       
   274 // Return: TBool ETrue if redraw is needed
       
   275 //               EFalse if redraw is not needed
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 TBool CSvgAnimationElementImpl::ReceiveEventL( MSvgEvent* aEvent )
       
   279     {
       
   280     // Processing events after begin time
       
   281 	if( CSvgElementImpl::IsSVGEnginePaused())
       
   282     {
       
   283     	return EFalse;
       
   284     }
       
   285 	CSvgEngineImpl* engine = ((CSvgDocumentImpl*)iOwnerDocument)->Engine();
       
   286 	if (engine == NULL)
       
   287 		{
       
   288 		return EFalse;
       
   289 		}
       
   290 
       
   291     TInt32 lEngineCurrentTime = engine->CurrentTIme();
       
   292 
       
   293     if ( lEngineCurrentTime < iAbsoluteBeginTime)
       
   294         {
       
   295         // not begin yet.
       
   296         return ETrue;
       
   297         }
       
   298     else
       
   299         {
       
   300         // rewrite engine time to simulate different timer
       
   301     	if ( aEvent->EventType() == ESvgEngineEventTimer )
       
   302     		{
       
   303         	((MSvgTimerEvent*)aEvent)->SetTime( (TInt32)(lEngineCurrentTime
       
   304         		- iAbsoluteBeginTime ));
       
   305     		}
       
   306         }
       
   307 
       
   308     // Basically forward received events to all its children as if they receive
       
   309     // event from DocumentImpl.
       
   310     if ( iAnimationEventHandler->ProcessEventL( aEvent ))
       
   311         {
       
   312         if (iInitSortList)
       
   313             {
       
   314             iAnimationEventHandler->SortEventList();
       
   315             iInitSortList = EFalse;
       
   316             }
       
   317         iAnimationEventHandler->DoAnimProcL(aEvent);
       
   318         engine->RedrawL();
       
   319         }
       
   320     else
       
   321         {
       
   322         // this is to keep the dom in its final state.
       
   323         if(aEvent->EventType() == ESvgEngineEventTimer)
       
   324             {
       
   325             iAnimationEventHandler->DoAnimProcL(aEvent);
       
   326             }
       
   327         }
       
   328 
       
   329     // Process key event separately.
       
   330 	if (aEvent->EventType() == ESvgEngineEventKeyPress)
       
   331 		{
       
   332 		}
       
   333 
       
   334     // return true to be redrawn
       
   335     return ETrue;
       
   336     }
       
   337 
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // RecursionVariable: Getter function that could be called by Contenthandler or
       
   341 // decoder to determine if the element has been cloned.
       
   342 // elements
       
   343 //
       
   344 // Return: TBool ETrue if the element is cloned already
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 TBool CSvgAnimationElementImpl::RecursionVariable()
       
   348 	{
       
   349 	return iUseInRecursion;
       
   350 	}
       
   351 
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 // SetRefElemById: Called by Contenthandler or decoder to set referenced
       
   355 // elements
       
   356 //
       
   357 // Return: none
       
   358 // -----------------------------------------------------------------------------
       
   359 //
       
   360 TInt  CSvgAnimationElementImpl::SetRefElemById(const TDesC& aName)
       
   361 	{
       
   362 	 iReferencedElement = ( CSvgElementImpl * )
       
   363                      ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( aName );
       
   364      if( iReferencedElement == NULL )
       
   365      	{
       
   366      	return KErrNotFound;
       
   367      	}
       
   368      else
       
   369      	{
       
   370          return KErrNone;
       
   371     	}
       
   372 
       
   373 	}
       
   374 
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // SetReferenceElementL: Called by Contenthandler or decoder to clone referenced
       
   378 // element which has been determined in SetRefElemById(...).
       
   379 //
       
   380 // Return: none
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 void CSvgAnimationElementImpl::SetReferenceElementL()
       
   384     {
       
   385     _LIT( KPreserveAspectRatio, "preserveAspectRatio" );
       
   386 
       
   387 	if(!RecursionVariable())
       
   388 		{
       
   389 		if( iReferencedElement != NULL )
       
   390 			{
       
   391 			// Setting iUseInRecursion to True so that the Call to CloneL
       
   392 			// is not called to this instance of use in this recursion
       
   393 			SetRecursionVariable(ETrue);
       
   394 
       
   395      		CSvgElementImpl* theElement = (CSvgElementImpl *)iReferencedElement->CloneL((MXmlElement*)this);
       
   396      		CleanupStack::PushL(theElement);
       
   397 			this->CXmlElementImpl::AppendChildL(theElement);
       
   398 			CleanupStack::Pop();
       
   399 			if(!RecursionVariable())
       
   400 				{
       
   401 				// The Recursion variable is set to false only when the Cloning
       
   402 				// goes into loop.
       
   403 				// Using this information and then Setting the Recursion variable
       
   404 				// back to True to use the information to set error code in
       
   405 				// StartElementL in Content Handler
       
   406 				//
       
   407 				SetRecursionVariable(ETrue);
       
   408 				}
       
   409 			else // Normal CloneL loop exit
       
   410 				{
       
   411 				// Setting iUseInRecursion back to False
       
   412 				SetRecursionVariable(EFalse);
       
   413 				}
       
   414 
       
   415                 CSvgDocumentImpl* doc = ( CSvgDocumentImpl* ) OwnerDocument();
       
   416                 CSvgSvgElementImpl* lSvgRoot = (CSvgSvgElementImpl*) doc->RootElement();
       
   417                 if (iPreservRatio != NULL)
       
   418                 	{
       
   419                 	lSvgRoot->SetAttributeL( KPreserveAspectRatio, iPreservRatio->Des() );
       
   420                 	}
       
   421                 lSvgRoot->SetWidth( iX );
       
   422                 lSvgRoot->SetHeight( iY );
       
   423 
       
   424 			}
       
   425     	}
       
   426     }
       
   427 
       
   428 
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 // ResetEventListener: Reset event listeners for it's children
       
   432 //
       
   433 // Returns: none
       
   434 // -----------------------------------------------------------------------------
       
   435 //
       
   436 void CSvgAnimationElementImpl::ResetEventListener()
       
   437     {
       
   438     FindAllAnimationElements( (CSvgElementImpl* )this, iMyAnimationElementList );
       
   439 
       
   440     // Remove event listening for every animation elements that are child of
       
   441     // this Animation element. This is to implement a separated time container
       
   442     //
       
   443     // Instead, register event linstening to the event handler of this element.
       
   444     //
       
   445     TInt myAnimationEleListCnt = iMyAnimationElementList->Count();
       
   446 	for (int i=0; i<myAnimationEleListCnt; i++)
       
   447     	{
       
   448 		CSvgElementImpl* lCurElem =
       
   449 		    (CSvgElementImpl*)iMyAnimationElementList->operator[](i);
       
   450 		// Removing...
       
   451         ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(lCurElem);
       
   452 
       
   453         // Adding...
       
   454         TUint8 eventMask = iAnimationEventHandler->EventMask(lCurElem);
       
   455         TRAPD(err, iAnimationEventHandler->AddToEventReceiverListL( lCurElem, eventMask ));
       
   456         if (err != KErrNone)
       
   457             {
       
   458             #ifdef _DEBUG
       
   459             _LIT(msg, "CSvgAnimationElementImpl::ResetEventListener():Can't add myself to event receiverList");
       
   460             RDebug::Print(msg);
       
   461             #endif //_DEBUG
       
   462             }
       
   463         }
       
   464     }
       
   465 
       
   466 
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // RemoveEventListener: Remove event listeners for it's children
       
   470 //
       
   471 // Returns: none
       
   472 // -----------------------------------------------------------------------------
       
   473 //
       
   474 void CSvgAnimationElementImpl::RemoveEventListener()
       
   475     {
       
   476     FindAllAnimationElements( (CSvgElementImpl* )this, iMyAnimationElementList );
       
   477 
       
   478     // Remove event listening for every animation elements that are child of
       
   479     // this Animation element. This is to implement a separated time container
       
   480     //
       
   481     // Instead, register event linstening to the event handler of this element.
       
   482     //
       
   483 	for (int i=0; i<iMyAnimationElementList->Count(); i++)
       
   484     	{
       
   485 		CSvgElementImpl* lCurElem =
       
   486 		    (CSvgElementImpl*)iMyAnimationElementList->operator[](i);
       
   487 		// Removing...
       
   488         iAnimationEventHandler->RemoveFromEventReceiverList( lCurElem );
       
   489         }
       
   490     }
       
   491 
       
   492 
       
   493 
       
   494 
       
   495 // -----------------------------------------------------------------------------
       
   496 // CSvgAnimationElementImpl: Find all animation elements and save it to aList
       
   497 //
       
   498 // Returns: none
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 void CSvgAnimationElementImpl::FindAllAnimationElements(
       
   502                                CSvgElementImpl* aElement,
       
   503                                RPointerArray<CSvgElementImpl>* aList )
       
   504     {
       
   505     CSvgElementImpl* child = (CSvgElementImpl*)aElement->FirstChild();
       
   506     while ( child != NULL )
       
   507     	{
       
   508         if ( IsAnimationElement(child) )
       
   509         	{
       
   510             aList->Append( child );
       
   511         	}
       
   512         FindAllAnimationElements( child, aList );
       
   513         child = (CSvgElementImpl*)child->NextSibling();
       
   514     	}
       
   515     }
       
   516 
       
   517 
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // IsAnimationElement: A utility function that check if the element
       
   521 // is an animation element.
       
   522 //
       
   523 // Returns: TBool ETrue if the element is a animation element.
       
   524 //                EFalse if the element is not an animation element.
       
   525 // -----------------------------------------------------------------------------
       
   526 //
       
   527 TBool CSvgAnimationElementImpl::IsAnimationElement(CSvgElementImpl* aElement)
       
   528     {
       
   529 
       
   530 	TInt id = aElement->ElemID();
       
   531 
       
   532     return (( id == KSvgAnimateElement ) ||
       
   533 	        ( id == KSvgAnimateMotionElement ) ||
       
   534 	        ( id == KSvgAnimateTransformElement ) ||
       
   535 	        ( id == KSvgSetElement ) ||
       
   536 	        ( id == KSvgAnimateColorElement ));
       
   537     }
       
   538 
       
   539 
       
   540 // -----------------------------------------------------------------------------
       
   541 // ResetAnimationL: Actions to reset the animation
       
   542 //
       
   543 // Returns: none
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 void CSvgAnimationElementImpl::ResetAnimationL()
       
   547     {
       
   548     }
       
   549 
       
   550 
       
   551 // -----------------------------------------------------------------------------
       
   552 // AnimProcL: Actions to reset the animation
       
   553 //
       
   554 // Returns: none
       
   555 // -----------------------------------------------------------------------------
       
   556 //
       
   557 TBool CSvgAnimationElementImpl::AnimProcL( MSvgTimerEvent* aEvent )
       
   558     {
       
   559 	if (aEvent->EventType() == ESvgEngineEventKeyPress)
       
   560 		{
       
   561 		}
       
   562 
       
   563     return EFalse;
       
   564     }
       
   565 
       
   566 
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CloneL: Perform a deep clone of this object
       
   570 //
       
   571 // Returns: MXmlElement pointer to the newly created element.
       
   572 // -----------------------------------------------------------------------------
       
   573 //
       
   574 MXmlElement* CSvgAnimationElementImpl::CloneL(MXmlElement* aParentElement)
       
   575     {
       
   576 
       
   577 	if(RecursionVariable())
       
   578 		{
       
   579 		SetRecursionVariable(EFalse);
       
   580 		return NULL;
       
   581 		}
       
   582 
       
   583 	CSvgAnimationElementImpl* newElement = CSvgAnimationElementImpl::NewL( this->ElemID(),
       
   584 	        ((CSvgDocumentImpl*)iOwnerDocument) );
       
   585 	CleanupStack::PushL(newElement);
       
   586 	newElement->iParentNode = aParentElement;
       
   587 
       
   588     // copy everything over
       
   589     this->CopyL(newElement);
       
   590     CleanupStack::Pop();
       
   591 
       
   592     return newElement;
       
   593     }
       
   594 
       
   595 
       
   596 // -----------------------------------------------------------------------------
       
   597 // CopyL: Perform a deep copy of this object
       
   598 //
       
   599 // Returns: none
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 void CSvgAnimationElementImpl::CopyL( CSvgAnimationElementImpl* aDestElement )
       
   603     {
       
   604     if(aDestElement)
       
   605 	   	{
       
   606 	    aDestElement->iX = this->iX;
       
   607 	    aDestElement->iY = this->iY;
       
   608 	    aDestElement->iHeight = this->iHeight;
       
   609 	    aDestElement->iWidth = this->iWidth;
       
   610 		aDestElement->iReferencedElement = this->iReferencedElement;
       
   611 
       
   612 		aDestElement->SetRecursionVariable(this->RecursionVariable());
       
   613 	    aDestElement->iOwnerDocument = this->iOwnerDocument;
       
   614 		// copy stuff from superclass
       
   615 	    this->CSvgElementImpl::CopyL(aDestElement);
       
   616 	    }
       
   617     }
       
   618 
       
   619 
       
   620 // -----------------------------------------------------------------------------
       
   621 // Two-phased constructor.
       
   622 // -----------------------------------------------------------------------------
       
   623 //
       
   624 CSvgAnimationElementImpl* CSvgAnimationElementImpl::NewL( const TUint8 aElemID,
       
   625                                                       CSvgDocumentImpl* aDoc)
       
   626     {
       
   627     CSvgAnimationElementImpl* self = new (ELeave)CSvgAnimationElementImpl(aDoc);
       
   628     CleanupStack::PushL( self );
       
   629     self->ConstructL( aElemID );
       
   630     CleanupStack::Pop();
       
   631 
       
   632     return self;
       
   633     }
       
   634 
       
   635 
       
   636 // -----------------------------------------------------------------------------
       
   637 // Two-phased constructor.
       
   638 // -----------------------------------------------------------------------------
       
   639 //
       
   640 CSvgAnimationElementImpl* CSvgAnimationElementImpl::NewLC( const TUint8 aElemID,
       
   641                                                        CSvgDocumentImpl* aDoc)
       
   642     {
       
   643     CSvgAnimationElementImpl* self = new (ELeave) CSvgAnimationElementImpl(aDoc);
       
   644     CleanupStack::PushL( self );
       
   645     self->ConstructL( aElemID );
       
   646 
       
   647     return self;
       
   648     }
       
   649 
       
   650 
       
   651 // -----------------------------------------------------------------------------
       
   652 // C++ default constructor
       
   653 // -----------------------------------------------------------------------------
       
   654 //
       
   655 CSvgAnimationElementImpl::CSvgAnimationElementImpl( CSvgDocumentImpl* aDoc )
       
   656 	 : CSvgAnimationBase( aDoc )
       
   657 	{
       
   658 	iInitSortList = ETrue; //True indicates that the soring has not been done.
       
   659     }
       
   660 
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // Symbian default constructor that can leave.
       
   664 // -----------------------------------------------------------------------------
       
   665 //
       
   666 void CSvgAnimationElementImpl::ConstructL(  const TUint8 aElemID )
       
   667     {
       
   668     CSvgAnimationBase::ConstructL( aElemID );
       
   669 
       
   670 	iSvgStyleProperties = new(ELeave) RPointerArray<CCssValue>(KCSS_MAX_ATTR);
       
   671 	User::LeaveIfError( iSvgStyleProperties->Append( NULL ) );
       
   672 	iSvgStyleProperties->Remove( 0 );
       
   673 
       
   674     iMyAnimationElementList = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   675 	iMyAnimationElementList->Reset();
       
   676 
       
   677     iSvgTransformable = CSvgTransformableImpl::NewL();
       
   678 
       
   679 	#ifdef SVG_FLOAT_BUILD
       
   680     iX = ( 0 );
       
   681     iY = ( 0 );
       
   682 	#else
       
   683     iX.operator = ( 0 );
       
   684     iY.operator = ( 0 );
       
   685 	#endif
       
   686 
       
   687 	iUseInRecursion = EFalse;
       
   688 
       
   689     iAnimationEventHandler = CSvgEventHandler::NewL();
       
   690 
       
   691 //    ((CSvgDocumentImpl*)
       
   692 //    	iOwnerDocument)->AddToEventReceiverListL(this, KSvgEventMaskTimer |
       
   693 //    	    KSvgEventMaskInternal | KSvgEventMaskExternalUI);
       
   694     }
       
   695 
       
   696 
       
   697 // -----------------------------------------------------------------------------
       
   698 // Destructor
       
   699 // -----------------------------------------------------------------------------
       
   700 //
       
   701 CSvgAnimationElementImpl::~CSvgAnimationElementImpl()
       
   702     {
       
   703 
       
   704     // unregister event listening for all childs.
       
   705     RemoveEventListener();
       
   706 
       
   707     if( iAnimationEventHandler )
       
   708         {
       
   709         delete iAnimationEventHandler;
       
   710         iAnimationEventHandler = NULL ;
       
   711         }
       
   712 
       
   713 
       
   714 	if ( iSvgStyleProperties )
       
   715 		{
       
   716 		iSvgStyleProperties->Close();
       
   717 		delete iSvgStyleProperties;
       
   718 		iSvgStyleProperties = NULL;
       
   719 		}
       
   720 
       
   721     if ( iMyAnimationElementList )
       
   722         {
       
   723 		iMyAnimationElementList->Reset();
       
   724         iMyAnimationElementList->Close();
       
   725         delete iMyAnimationElementList;
       
   726         }
       
   727 
       
   728     if ( iPreservRatio )
       
   729         {
       
   730         delete iPreservRatio;
       
   731         }
       
   732 
       
   733     }
       
   734 
       
   735 void CSvgAnimationElementImpl::Print( TBool aIsEncodeOn )
       
   736 {
       
   737 	if (!aIsEncodeOn)
       
   738 	{
       
   739 		#ifdef _DEBUG
       
   740 		RDebug::Printf("<animation x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"hmm\" preserveAspectRatio=\"hmm\" />",
       
   741 	 	(int)iX, (int)iY, (int)iWidth, (int)iHeight/*, Href(), PreservRatio()*/);
       
   742 		#endif
       
   743 	}
       
   744 }
       
   745 //  End of File