svgtopt/SVG/SVGEngine/src/SVGContentHandler.cpp
changeset 0 d46562c3d99d
child 2 0c844a8549ae
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 Engine source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "SVGContentHandler.h"
       
    20 #include "SVGSchemaData.h"
       
    21 #include "SVGDocumentImpl.h"
       
    22 #include "SVGEngineImpl.h"
       
    23 
       
    24 #include "SVGSvgElementImpl.h"
       
    25 #include "SVGStringTokenizer.h"
       
    26 
       
    27 #include "SVGUseElementImpl.h"
       
    28 #include "SVGAnimationElementImpl.h"
       
    29 #include "RXMLReader.h"
       
    30 
       
    31 #include "SVGPaintCssValueImpl.h"
       
    32 #include "SVGPathElementImpl.h"
       
    33 #include "GfxGeneralPath.h"
       
    34 
       
    35 #include "SVGUriReferenceImpl.h"
       
    36 #include "SVGGradientElementImpl.h"
       
    37 #include "SVGAnimationBase.h"
       
    38 
       
    39 #include "SVGTextAreaElementImpl.h"
       
    40 #include "SVGTextElementImpl.h"
       
    41 #include "SVGScriptElementImpl.h"
       
    42 #include "SVGImageElementImpl.h"
       
    43 #include "SVGMediaElementBase.h"
       
    44 
       
    45 #include "SVGFontFaceElementImpl.h"
       
    46 #include <languages.hrh>
       
    47 
       
    48 //#ifdef RD_SVGT_MEDIAANIMATION_SUPPORT
       
    49 #include "SVGMediaAnimationElementImpl.h"
       
    50 //#endif
       
    51 _LIT(WIDTH, "width");
       
    52 _LIT(HEIGHT, "height");
       
    53 _LIT(BEGIN, "begin");
       
    54 _LIT(END, "end");
       
    55 _LIT(MOUSEDOWN, "mousedown");
       
    56 _LIT(MOUSEUP, "mouseup");
       
    57 _LIT(MOUSEOVER, "mouseover");
       
    58 _LIT(MOUSEMOVE, "mousemove");
       
    59 _LIT(MOUSEOUT, "mouseout");
       
    60 _LIT(FOCUSIN, "focusin");
       
    61 _LIT(FOCUSOUT, "focusout");
       
    62 _LIT(ACTIVATE, "activate");
       
    63 _LIT(CLICK, "click");
       
    64 
       
    65 _LIT(FILL, "fill");
       
    66 _LIT(STROKE, "stroke");
       
    67 _LIT(COLOR, "color");
       
    68 _LIT(STOP_COLOR, "stop-color");
       
    69 _LIT(ACCESS,"accessKey");
       
    70 _LIT(OFFSET, "offset");
       
    71 _LIT(ZEROVALUE, "0");
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Constructor
       
    75 // ---------------------------------------------------------------------------
       
    76 CSvgContentHandler::CSvgContentHandler() : iRootElement( NULL ),
       
    77                                            iIsColorAnim( EFalse ),
       
    78                                            iRemoveFalseSwitchElements( ETrue )
       
    79     {
       
    80     iCancelRequested = EFalse;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Destructor
       
    85 // ---------------------------------------------------------------------------
       
    86 CSvgContentHandler::~CSvgContentHandler()
       
    87     {
       
    88     if(iUseElementArray)
       
    89         {
       
    90         iUseElementArray->Reset();
       
    91         iUseElementArray->Close();
       
    92         delete iUseElementArray;
       
    93         iUseElementArray = NULL;
       
    94         }
       
    95     if(iAnimRefElementArray)
       
    96         {
       
    97         iAnimRefElementArray->Reset();
       
    98         iAnimRefElementArray->Close();
       
    99         delete iAnimRefElementArray;
       
   100         iAnimRefElementArray = NULL;
       
   101         }
       
   102     if(iSwitchElementArray)
       
   103         {
       
   104         iSwitchElementArray->Reset();
       
   105         iSwitchElementArray->Close();
       
   106         delete iSwitchElementArray;
       
   107         iSwitchElementArray = NULL;
       
   108         }
       
   109     if (iReqFetAttSysArray)
       
   110         {
       
   111         iReqFetAttSysArray->Reset();
       
   112         iReqFetAttSysArray->Close();
       
   113         delete iReqFetAttSysArray;
       
   114         iReqFetAttSysArray = NULL;
       
   115         }
       
   116     if(iAnimationElementArray)
       
   117         {
       
   118         iAnimationElementArray->Reset();
       
   119         iAnimationElementArray->Close();
       
   120         delete iAnimationElementArray;
       
   121         }
       
   122     if(iCData)
       
   123         {
       
   124         delete iCData;
       
   125         iCData = NULL;
       
   126         }
       
   127     if ( iSystemLanguage )
       
   128         {
       
   129         delete iSystemLanguage;
       
   130         iSystemLanguage = NULL;
       
   131         }
       
   132 
       
   133     iImageElements.Close();
       
   134     }
       
   135 // ---------------------------------------------------------------------------
       
   136 // CSvgContentHandler* CSvgContentHandler::NewL()
       
   137 // ---------------------------------------------------------------------------
       
   138 CSvgContentHandler* CSvgContentHandler::NewL( TBool aRemoveFalseSwitchElements )
       
   139     {
       
   140     CSvgContentHandler* self    = new( ELeave ) CSvgContentHandler();
       
   141     CleanupStack::PushL( self );
       
   142     self->ConstructL( aRemoveFalseSwitchElements );
       
   143     CleanupStack::Pop();
       
   144     return self;
       
   145     }
       
   146 
       
   147 // --------------------------------------------------------------------------
       
   148 // CSvgContentHandler* CSvgContentHandler::NewLC()
       
   149 // ---------------------------------------------------------------------------
       
   150 CSvgContentHandler* CSvgContentHandler::NewLC()
       
   151     {
       
   152     CSvgContentHandler* self    = new( ELeave ) CSvgContentHandler();
       
   153     CleanupStack::PushL( self );
       
   154     self->ConstructL();
       
   155     return self;
       
   156     }
       
   157 
       
   158 
       
   159 
       
   160 // --------------------------------------------------------------------------
       
   161 // void CSvgContentHandler::ConstructL()
       
   162 // ---------------------------------------------------------------------------
       
   163 void CSvgContentHandler::ConstructL( TBool aRemoveFalseSwitchElements )
       
   164     {
       
   165     /*Arrays added to support Forward referencing in Animation and Use elements*/
       
   166     iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   167 
       
   168     iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   169 
       
   170     // added to hold switch element handles so we can go back and delete false children of the switch
       
   171     iSwitchElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   172 
       
   173     // Arrays added to reset event listeners for animation element
       
   174     iAnimationElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   175 
       
   176     //added to hold elements with required features, attributes, or sys language
       
   177     //so we can go back and delete the ones that dont pass at the start.
       
   178     iReqFetAttSysArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
       
   179     // Create a 1KB buffer for CData -- this will expand as needed
       
   180     iCData = HBufC::NewL( 1024 );
       
   181 
       
   182     iSystemLanguage = HBufC::NewL( 5 );
       
   183 
       
   184 		iRemoveFalseSwitchElements = aRemoveFalseSwitchElements;
       
   185     }
       
   186 
       
   187 
       
   188 
       
   189 
       
   190 
       
   191 // --------------------------------------------------------------------------
       
   192 // CSvgElementImpl* CSvgContentHandler::ParseByteData( CSvgDocumentImpl* aDocument,
       
   193 //                                                    const TDesC8& aByteData,
       
   194 //                                                    CSvgErrorImpl& aError )
       
   195 // ---------------------------------------------------------------------------
       
   196 CSvgElementImpl* CSvgContentHandler::ParseByteData( CSvgDocumentImpl* aDocument,
       
   197                                                     const TDesC8& aByteData,
       
   198                                                     CSvgErrorImpl& aError )
       
   199     {
       
   200     iDocument = aDocument;
       
   201 
       
   202     iSvgError = &aError;
       
   203     aError.SetErrorCode( ESvgNoError );
       
   204 
       
   205 
       
   206 
       
   207     // Create XML reader
       
   208     RXMLReader xmlReader;
       
   209     TInt error = KErrNone;
       
   210     TRAP( error, xmlReader.CreateL() );
       
   211     if ( error != KErrNone )
       
   212         {
       
   213         _LIT(OUTMEMORY, "Out of memory");
       
   214         aError.SetErrorCode( ESvgNoMemory );
       
   215         aError.SetDescription( OUTMEMORY );
       
   216         aError.SetIsWarning( EFalse );
       
   217         return iRootElement;
       
   218         }
       
   219 
       
   220     // Parse content
       
   221     xmlReader.SetContentHandler( this );
       
   222     TRAPD( parseError, xmlReader.ParseL( aByteData ) );
       
   223     xmlReader.Destroy();
       
   224     if ( !iCancelRequested && parseError != KErrNone )
       
   225         {
       
   226         if ( iSvgError->HasError() )
       
   227             return iRootElement;
       
   228 
       
   229         aError.SetErrorCode( ESvgUnknown );
       
   230         if ( parseError == -4 )
       
   231             {
       
   232             _LIT(OUTMEMORY, "Out of memory");
       
   233             aError.SetDescription( OUTMEMORY );
       
   234             }
       
   235         else
       
   236             {
       
   237             _LIT(STRING, "Parsing SVG document failed.");
       
   238             aError.SetDescription( STRING );
       
   239             }
       
   240         aError.SetIsWarning( EFalse );
       
   241         aError.SetSystemErrorCode( parseError );
       
   242         return iRootElement;
       
   243         }
       
   244     if ( iRootElement == NULL )
       
   245         {
       
   246         _LIT(STRING, "Invalid SVG Document.");
       
   247         aError.SetErrorCode( ESvgDocumentNotValid );
       
   248         aError.SetDescription( STRING );
       
   249         aError.SetIsWarning( EFalse );
       
   250         return iRootElement;
       
   251         }
       
   252     else if ( !iCancelRequested )
       
   253         {
       
   254         SetForwardReferences(aError);
       
   255         PostParseProcessing();
       
   256         }
       
   257 
       
   258     return iRootElement;
       
   259     }
       
   260 
       
   261 // --------------------------------------------------------------------------
       
   262 // CSvgElementImpl* CSvgContentHandler::Parse16BitData( CSvgDocumentImpl* aDocument,
       
   263 //                                                    const TDesC8& aByteData,
       
   264 //                                                    CSvgErrorImpl& aError )
       
   265 // ---------------------------------------------------------------------------
       
   266 CSvgElementImpl* CSvgContentHandler::Parse16BitData( CSvgDocumentImpl* aDocument,
       
   267                                                     const TDesC16& aSvgString,
       
   268                                                     CSvgErrorImpl& aError )
       
   269     {
       
   270     iDocument = aDocument;
       
   271 
       
   272     iSvgError = &aError;
       
   273     aError.SetErrorCode( ESvgNoError );
       
   274 
       
   275     // Create XML reader
       
   276     RXMLReader xmlReader;
       
   277     TInt error = KErrNone;
       
   278     TRAP( error, xmlReader.CreateL() );
       
   279     if ( error != KErrNone )
       
   280         {
       
   281         _LIT(OUTMEMORY, "Out of memory");
       
   282         aError.SetErrorCode( ESvgNoMemory );
       
   283         aError.SetDescription( OUTMEMORY );
       
   284         aError.SetIsWarning( EFalse );
       
   285         return iRootElement;
       
   286         }
       
   287 
       
   288     // Parse content
       
   289     xmlReader.SetContentHandler( this );
       
   290 
       
   291     //-------------------------------------------------------------------
       
   292     //THIS IS TEMPORARY
       
   293     //convert to 8 bit here temporary until I get 16 bit parsing method...
       
   294     //TRAPD( parseError, xmlReader.ParseXML( aSvgString ) );
       
   295 
       
   296     //convert 16 to 8 bit characters
       
   297     HBufC8* lString8 = NULL;
       
   298     lString8 = HBufC8::New( aSvgString.Length() );
       
   299 
       
   300 
       
   301 	if(NULL==lString8)
       
   302 	{
       
   303 		_LIT(OUTMEMORY, "Out of memory");
       
   304 		aError.SetErrorCode( ESvgNoMemory );
       
   305         aError.SetDescription( OUTMEMORY );
       
   306         aError.SetIsWarning( EFalse );
       
   307 		return iRootElement;
       
   308 	}
       
   309     
       
   310     lString8->Des().Copy(aSvgString);
       
   311     TRAPD( parseError, xmlReader.ParseL( *lString8 ) );
       
   312     delete lString8 ; 
       
   313     //-------------------------------------------------------------------
       
   314 
       
   315     xmlReader.Destroy();
       
   316     if ( !iCancelRequested && parseError != KErrNone )
       
   317         {
       
   318         if ( iSvgError->HasError() )
       
   319             return iRootElement;
       
   320 
       
   321         aError.SetErrorCode( ESvgUnknown );
       
   322         if ( parseError == -4 )
       
   323             {
       
   324             _LIT(OUTMEMORY, "Out of memory");
       
   325             aError.SetDescription( OUTMEMORY );
       
   326             }
       
   327         else
       
   328             {
       
   329             _LIT(STRING, "Parsing SVG document failed.");
       
   330             aError.SetDescription( STRING );
       
   331             }
       
   332         aError.SetIsWarning( EFalse );
       
   333         aError.SetSystemErrorCode( parseError );
       
   334         return iRootElement;
       
   335         }
       
   336     if ( iRootElement == NULL )
       
   337         {
       
   338         _LIT(STRING, "Invalid SVG Document.");
       
   339         aError.SetErrorCode( ESvgDocumentNotValid );
       
   340         aError.SetDescription( STRING );
       
   341         aError.SetIsWarning( EFalse );
       
   342         return iRootElement;
       
   343         }
       
   344     else if ( !iCancelRequested )
       
   345         {
       
   346         //POST PARSING PROCESSING
       
   347         SetForwardReferences(aError);
       
   348         RemoveFalseElementsOrMakeInvisible();
       
   349         RemoveFalseSwitchCasesOrMakeInvisible();
       
   350         if ( !iSvgError->HasError())
       
   351         {
       
   352         LoadImages();
       
   353         }
       
   354         }
       
   355 
       
   356     return iRootElement;
       
   357     }
       
   358 
       
   359 // --------------------------------------------------------------------------
       
   360 // CSvgElementImpl* CSvgContentHandler::ParseFile( CSvgDocumentImpl* aDocument,
       
   361 // ---------------------------------------------------------------------------
       
   362 CSvgElementImpl* CSvgContentHandler::ParseFile( CSvgDocumentImpl* aDocument,
       
   363                                                     const TDesC& aFileName,
       
   364                                                     CSvgErrorImpl& aError )
       
   365     {
       
   366     iDocument = aDocument;
       
   367 
       
   368     iSvgError = &aError;
       
   369     aError.SetErrorCode( ESvgNoError );
       
   370 
       
   371     RFs session;
       
   372     TInt serror = session.Connect ();
       
   373     if( serror != KErrNone)
       
   374         {
       
   375         _LIT(STRING, "Cannot create a session to read the file.");
       
   376         aError.SetErrorCode ( ESvgUnknown );
       
   377         aError.SetDescription( STRING );
       
   378         aError.SetIsWarning( EFalse );
       
   379         return NULL;
       
   380         }
       
   381 
       
   382     // Create XML reader
       
   383     RXMLReader xmlReader;
       
   384     TInt error = KErrNone;
       
   385     TRAP( error, xmlReader.CreateL() );
       
   386     if ( !iCancelRequested && error != KErrNone )
       
   387         {
       
   388         _LIT(OUTMEMORY, "Out of memory");
       
   389         aError.SetErrorCode( ESvgNoMemory );
       
   390         aError.SetDescription( OUTMEMORY );
       
   391         aError.SetIsWarning( EFalse );
       
   392         return iRootElement;
       
   393         }
       
   394 
       
   395     // Parse content
       
   396     xmlReader.SetContentHandler( this );
       
   397     TRAP( error, xmlReader.ParseL( session, aFileName) );
       
   398     xmlReader.Destroy();
       
   399     if ( error != KErrNone || iRootElement == NULL )
       
   400         {
       
   401         _LIT(STRING, "Invalid SVG Document.");
       
   402         aError.SetErrorCode( ESvgDocumentNotValid );
       
   403         aError.SetDescription( STRING );
       
   404         aError.SetIsWarning( EFalse );
       
   405         }
       
   406     else if ( !iCancelRequested )
       
   407         {
       
   408         SetForwardReferences(aError);
       
   409         PostParseProcessing();
       
   410         }
       
   411 
       
   412     session.Close();
       
   413     return iRootElement;
       
   414     }
       
   415 
       
   416 void CSvgContentHandler::PostParseProcessing()
       
   417 {
       
   418 
       
   419     // This situation occurs when parsing is done in a separate thread then the draw thread
       
   420     // Wait for drawing to complete or invalid element pointer may occur during drawing
       
   421     if ( iDocument->iIsRendering )
       
   422         {
       
   423         TInt waitCount = 0;
       
   424         // total of 1 seconds
       
   425         while ( waitCount++ < 200000 && iDocument->iIsRendering )
       
   426             {
       
   427             User::After( 50 ); // 50 microseconds
       
   428             }
       
   429 
       
   430         // Cannot wait any longer, prevent being stuck here
       
   431         if ( iDocument->iIsRendering )
       
   432             {
       
   433             return;
       
   434             }
       
   435         }
       
   436 
       
   437     iDocument->iIsPruningTree = ETrue;
       
   438 
       
   439     RemoveFalseElementsOrMakeInvisible();
       
   440     RemoveFalseSwitchCasesOrMakeInvisible();
       
   441 
       
   442     iDocument->iIsPruningTree = EFalse;
       
   443     iDocument->SetImageElementsCount(iImageElements.Count());
       
   444     if ( (!iSvgError->HasError())  || iSvgError->IsWarning() )
       
   445         {
       
   446     LoadImages();
       
   447         }
       
   448 }
       
   449 
       
   450 // --------------------------------------------------------------------------
       
   451 // TInt CSvgContentHandler::RemoveInternalReferences( CSvgElementImpl* )
       
   452 // ---------------------------------------------------------------------------
       
   453 void CSvgContentHandler::RemoveInternalReferences( CSvgElementImpl* aElement )
       
   454     {
       
   455     // Remove the references of aElement in content handler's lists
       
   456 
       
   457     // Use Elements 
       
   458     TInt lIndex = 0;
       
   459     if ( aElement->ElemID() == KSvgUseElement )
       
   460         {
       
   461         lIndex = iUseElementArray->Find( aElement );
       
   462         if ( lIndex != KErrNotFound )
       
   463             {
       
   464             iUseElementArray->Remove( lIndex );
       
   465             }
       
   466         }
       
   467     else if ( aElement->ElemID() == KSvgImageElement )
       
   468         {
       
   469         // Image elements
       
   470         lIndex = iImageElements.Find( (CSvgImageElementImpl* )aElement );
       
   471         if ( lIndex != KErrNotFound )
       
   472             {
       
   473             iImageElements.Remove( lIndex );
       
   474             }
       
   475         }
       
   476     else if ( aElement->ElemID() == KSvgSwitchElement )
       
   477         {
       
   478         // Switch Elements    
       
   479         lIndex = iSwitchElementArray->Find( aElement );
       
   480         if ( lIndex != KErrNotFound )
       
   481             {
       
   482             iSwitchElementArray->Remove( lIndex );
       
   483             }
       
   484         }
       
   485     else if ( aElement->IsAnimatedElement() )
       
   486         {
       
   487         // Animation elements include animate* elements, set, 
       
   488         // "animation",  audio elements etc.
       
   489         lIndex = iAnimationElementArray->Find( aElement );
       
   490         if ( lIndex != KErrNotFound )
       
   491             {
       
   492             iAnimationElementArray->Remove( lIndex );
       
   493             }        
       
   494         lIndex = iAnimRefElementArray->Find( aElement );
       
   495         if ( lIndex != KErrNotFound )
       
   496             {
       
   497             iAnimRefElementArray->Remove( lIndex );
       
   498             }
       
   499         }
       
   500     // Elements with test attributes - requiredFeatures, 
       
   501     // requiredExtensions, systemLanguage
       
   502     lIndex = iReqFetAttSysArray->Find( aElement );
       
   503     if ( lIndex != KErrNotFound )
       
   504         {
       
   505         iReqFetAttSysArray->Remove( lIndex );
       
   506         }
       
   507 
       
   508     // Remove Internal references of subtree elements as well
       
   509     CSvgElementImpl* lChild = ( CSvgElementImpl* )aElement->FirstChild();
       
   510     while ( lChild != NULL )
       
   511         {
       
   512         RemoveInternalReferences( lChild );
       
   513         lChild = ( CSvgElementImpl* )lChild->NextSibling();
       
   514         }
       
   515 
       
   516     }
       
   517 
       
   518 /************* Start of MXMLContentHandler methods ************/
       
   519 
       
   520 // --------------------------------------------------------------------------
       
   521 // TInt CSvgContentHandler::StartDocument()
       
   522 // ---------------------------------------------------------------------------
       
   523 TInt CSvgContentHandler::StartDocument()
       
   524     {
       
   525     if ( iCancelRequested )
       
   526         {
       
   527         return EFalse;
       
   528         }
       
   529     iDocument->NotifyDocumentStart();
       
   530     iBeginEndAtr = EFalse;
       
   531     return ETrue;
       
   532     }
       
   533 
       
   534 // --------------------------------------------------------------------------
       
   535 // TInt CSvgContentHandler::EndDocument()
       
   536 // ---------------------------------------------------------------------------
       
   537 TInt CSvgContentHandler::EndDocument()
       
   538     {
       
   539     if ( iCancelRequested )
       
   540         {
       
   541         return EFalse;
       
   542         }
       
   543     iDocument->NotifyDocumentEnd();
       
   544     return ETrue;
       
   545     }
       
   546 
       
   547 // --------------------------------------------------------------------------
       
   548 // TInt CSvgContentHandler::StartElement( TDesC& aURI,
       
   549 // ---------------------------------------------------------------------------
       
   550 TInt CSvgContentHandler::StartElement( TDesC& aURI,
       
   551                                        TDesC& aLocalName,
       
   552                                        TDesC& aName,
       
   553                                        MXMLAttributes *aAttributeList )
       
   554     {
       
   555     if ( iCancelRequested )
       
   556         {
       
   557         return EFalse;
       
   558         }
       
   559 
       
   560     // Clear cdata buffer
       
   561     iCData->Des().Zero();
       
   562 
       
   563     TInt result = EFalse;
       
   564     TRAPD( error, result = StartElementL( aURI, aLocalName, aName, aAttributeList ) );
       
   565     if ( error != KErrNone )
       
   566     {
       
   567         _LIT(STRING, "Parsing SVG Content Failed -- Element: ");
       
   568         iSvgError->SetDescription( STRING, aName );
       
   569         iSvgError->SetErrorCode( ESvgUnknown );
       
   570         iSvgError->SetSystemErrorCode( error );
       
   571         iSvgError->SetIsWarning( EFalse );
       
   572         return EFalse;
       
   573     }
       
   574     return result;
       
   575     }
       
   576 
       
   577 // --------------------------------------------------------------------------
       
   578 // TInt CSvgContentHandler::StartElementL( TDesC& /* aURI */,
       
   579 // ---------------------------------------------------------------------------
       
   580 TInt CSvgContentHandler::StartElementL( TDesC& /* aURI */,
       
   581                                           TDesC& /* aLocalName */,
       
   582                                           TDesC& aName,
       
   583                                           MXMLAttributes *aAttributeList )
       
   584     {
       
   585     if ( iRootElement == NULL && aName != _L( "svg" ) )
       
   586     {
       
   587         iSvgError->SetDescription( _L( "Invalid SVG document: Missing Root <svg> Element." ) );
       
   588         iSvgError->SetErrorCode( ESvgUnknown );
       
   589         iSvgError->SetSystemErrorCode( KErrNone );
       
   590         iSvgError->SetIsWarning( EFalse );
       
   591         return EFalse;
       
   592     }
       
   593     if ( iRootElement != NULL && aName == _L( "svg" ) )
       
   594     {
       
   595         iSvgError->SetDescription( _L( "Invalid SVG document: Nested <svg> Element." ) );
       
   596         iSvgError->SetErrorCode( ESvgUnknown );
       
   597         iSvgError->SetSystemErrorCode( KErrNone );
       
   598         iSvgError->SetIsWarning( EFalse );
       
   599         return EFalse;
       
   600     }
       
   601 
       
   602     if ( iIgnoreDepth > 0 )
       
   603         {
       
   604         iIgnoreDepth++;
       
   605         return ETrue;
       
   606         }
       
   607     MXmlElement* newElement;
       
   608 
       
   609     newElement  = iDocument->CreateElementL( aName );
       
   610 
       
   611     if ( newElement != NULL)
       
   612         {
       
   613         iIsSvgElement = ETrue;
       
   614         }
       
   615     else
       
   616         {
       
   617         iDocument->NotifyUnsupportedElement( aName, *aAttributeList );
       
   618         iIsSvgElement = EFalse;
       
   619         iIgnoreDepth = 1;
       
   620         return ETrue;
       
   621         }
       
   622 
       
   623     iCurrentElement = ( CSvgElementImpl * ) newElement;
       
   624 
       
   625     // Set flag to indicate element is incomplete
       
   626     if ( iDocument->GetLoadingListeners() &&
       
   627          iDocument->GetLoadingListeners()->Count() > 0 )
       
   628          {
       
   629          iCurrentElement->SetAllAttributesAdded( EFalse );
       
   630          }
       
   631 
       
   632     _LIT( KElmSvg, "svg" );
       
   633     if ( aName == KElmSvg && !iRootElement )
       
   634         {
       
   635         iDocument->AppendChildL( newElement );
       
   636         iRootElement = iCurrentElement;
       
   637         }
       
   638     // for all other elements
       
   639     else
       
   640         {
       
   641         iCurrentParentElement->AppendChildL( newElement );
       
   642         }
       
   643 
       
   644 
       
   645     // create separate lists for names and values
       
   646     TInt lCount = aAttributeList->GetLength();
       
   647     for ( TInt i =0 ; i< lCount ;i++)
       
   648 
       
   649         {
       
   650 
       
   651         ProcessNConvertAttrL( aName,
       
   652                               aAttributeList->GetName( i ),
       
   653                               aAttributeList->GetValue( i ) );
       
   654         }
       
   655 
       
   656     TInt elementID = iCurrentElement->ElemID();
       
   657 
       
   658     //keep lists so invalid ones can be removed at the end of parsing
       
   659     //all elements that have required features, extensions, sys language
       
   660     if (iCurrentElement->HasAnyTests())
       
   661         {
       
   662         iReqFetAttSysArray->AppendL(iCurrentElement);
       
   663         }
       
   664     else if (elementID == KSvgSwitchElement)
       
   665         {
       
   666         iSwitchElementArray->AppendL(iCurrentElement);
       
   667         }
       
   668 
       
   669     if ( iBeginEndAtr )
       
   670         {
       
   671         ((CSvgDocumentImpl*)iDocument)->iIsInteractive = ETrue;
       
   672         }
       
   673 
       
   674     if(iIsColorAnim)
       
   675         {
       
   676         ProcessColorAttributeL(_L("from"),iFromVal);
       
   677         ProcessColorAttributeL(_L("to"),iToVal);
       
   678         ProcessColorAttributeL(_L("by"),iByVal);
       
   679         }
       
   680     else
       
   681         {
       
   682         if(iFromVal.Length())
       
   683             {
       
   684             iCurrentElement->SetAttributeL(_L("from"),iFromVal );
       
   685             }
       
   686         if(iToVal.Length())
       
   687             {
       
   688             iCurrentElement->SetAttributeL(_L("to"),iToVal );
       
   689             }
       
   690         if(iByVal.Length())
       
   691             {
       
   692             iCurrentElement->SetAttributeL(_L("by"),iByVal );
       
   693             }
       
   694         }
       
   695     if(iValues.Length())
       
   696         {
       
   697         iCurrentElement->SetAttributeL(_L("values"),iValues );
       
   698         }
       
   699     if(iTimes.Length())
       
   700         {
       
   701     	iCurrentElement->SetAttributeL(_L("keyTimes"), iTimes);
       
   702         }
       
   703     if(iSplines.Length())
       
   704         {
       
   705     	iCurrentElement->SetAttributeL(_L("keySplines"), iSplines);
       
   706         }
       
   707     if (elementID == KSvgUseElement)
       
   708         {
       
   709         ((CSvgUseElementImpl *)iCurrentElement)->SetReferenceElementL();
       
   710         }
       
   711     // font-face-src is currently not implemented. Hence such a font is removed
       
   712     // from the font hash-map in order to avoid creating iSvgFont pointer
       
   713     // while drawing the text. 
       
   714     if (elementID == KSvgFontfacesrcElement )
       
   715     	{
       
   716     	//Get the font-face element which is the parent of font-face-src	
       
   717 		CSvgFontFaceElementImpl* currentFontFaceElem = 
       
   718 					(CSvgFontFaceElementImpl*)(iCurrentElement)->ParentNode();
       
   719 	
       
   720 		const TDesC* lFontFamily=currentFontFaceElem->GetFontFamily();
       
   721 		
       
   722 		currentFontFaceElem->RemoveFontFamily(*lFontFamily);
       
   723 	 
       
   724     	}
       
   725 // comment out for future AnimationElement
       
   726 //    else if (elementID == KSvgAnimationElement)
       
   727 //        {
       
   728 //        ((CSvgAnimationElementImpl *)iCurrentElement)->SetReferenceElementL();
       
   729 //        if(((CSvgAnimationElementImpl *)iCurrentElement)->RecursionVariable())
       
   730 //            {
       
   731 //            iSvgError->SetErrorCode( ESvgDocumentNotValid );
       
   732 //            iSvgError->SetIsWarning( EFalse );
       
   733 //            iSvgError->SetDescription( _L( "Invalid Document \n" ) );
       
   734 //            iSvgError->AppendDescription( _L("Animation element in loop") );
       
   735 //            return EFalse;
       
   736 //            }
       
   737 //        User::LeaveIfError(iAnimationElementArray->Append(iCurrentElement));
       
   738 //        }
       
   739 
       
   740     // For DOM reuse
       
   741     if ( iCurrentElement->IsAnimatedElement() )
       
   742             {
       
   743             ((CSvgAnimationBase*)iCurrentElement)->SetOriginalValues_DOMReuse() ;
       
   744             iAnimationElementArray->AppendL(iCurrentElement);
       
   745             }
       
   746 
       
   747 
       
   748     if ( elementID >= KSvgLinearGradientElement &&
       
   749         elementID <= KSvgStopElement )
       
   750             {
       
   751             iCurrentElement->SetAttributeIntL(KCSS_ATTR_DISPLAY,0);
       
   752             }
       
   753 
       
   754     // special case: <animationMotion> may have <mpath> child instead
       
   755     // of "path" attribute.
       
   756 
       
   757     if ( elementID == KSvgMpathElement &&
       
   758          iCurrentParentElement->ElemID() == KSvgAnimateMotionElement &&
       
   759          iSvgError->ErrorCode() == ESvgMissingRequiredAttribute &&
       
   760          iSvgError->IsWarning()
       
   761            )
       
   762         {
       
   763             iSvgError->SetErrorCode( ESvgNoError );
       
   764             // add to event receiver list will have only one copy
       
   765             ((CSvgDocumentImpl*)iDocument)->AddToEventReceiverListL( iCurrentParentElement, KSvgEventMaskTimer );
       
   766         }
       
   767 
       
   768 
       
   769     if ( iCurrentElement->iReqAttrFlag != 0)
       
   770         {
       
   771         iSvgError->SetErrorCode( ESvgMissingRequiredAttribute );
       
   772         iSvgError->SetIsWarning( ETrue );
       
   773         iSvgError->SetDescription( _L( "Missing required attribute \"" ) );
       
   774         switch(iCurrentElement->iReqAttrFlag)
       
   775         {
       
   776         case KAtrSVGRec:
       
   777             iSvgError->AppendDescription( WIDTH );
       
   778             iSvgError->AppendDescription( _L( "\" and \"" ) );
       
   779             iSvgError->AppendDescription(_L("height"));
       
   780             break;
       
   781         case KAtrSVGElp:
       
   782             iSvgError->AppendDescription( _L("Rx") );
       
   783             iSvgError->AppendDescription( _L( "\" and \"" ) );
       
   784             iSvgError->AppendDescription(_L("Ry"));
       
   785             break;
       
   786         case KAtrSVGTrf:
       
   787             iSvgError->AppendDescription( _L("attributeName") );
       
   788             iSvgError->AppendDescription( _L( "\" and \"" ) );
       
   789             iSvgError->AppendDescription(_L("type"));
       
   790             break;
       
   791         case KSVG_ANIMATE_ELEMFLAG:
       
   792             iSvgError->AppendDescription( _L("attributeName") );
       
   793             break;
       
   794         case KSVG_CIRCLE_ELEMFLAG:
       
   795             iSvgError->AppendDescription( _L("r") );
       
   796             break;
       
   797         case KSVG_HKERN_ELEMFLAG:
       
   798             iSvgError->AppendDescription( _L("k") );
       
   799             break;
       
   800         case KSVG_PATH_ELEMFLAG:
       
   801             iSvgError->AppendDescription( _L("d") );
       
   802             break;
       
   803         case KSVG_POLYLINE_ELEMFLAG:
       
   804             iSvgError->AppendDescription( _L("points") );
       
   805             break;
       
   806         case KAtrType:
       
   807             iSvgError->AppendDescription( _L("type") );
       
   808             break;
       
   809         case KAtrRy:
       
   810             iSvgError->AppendDescription( _L("Ry") );
       
   811             break;
       
   812         case KAtrRx:
       
   813             iSvgError->AppendDescription( _L("Rx") );
       
   814             break;
       
   815         case KAtrWidth:
       
   816             iSvgError->AppendDescription( _L("width") );
       
   817             break;
       
   818         case KAtrHeight:
       
   819             iSvgError->AppendDescription( _L("height") );
       
   820             break;
       
   821         case KAtrXlinkhref:
       
   822             iSvgError->AppendDescription (_L("Xlink:href"));
       
   823             break;
       
   824         case KAtrSVGAmo:
       
   825             iSvgError->AppendDescription( _L("path") );
       
   826             ((CSvgDocumentImpl*)iDocument)->RemoveFromEventReceiverList( iCurrentElement );
       
   827             break;
       
   828         case KAtrToBy:
       
   829             iSvgError->AppendDescription( _L("to/by") );
       
   830             ((CSvgDocumentImpl*)iDocument)->RemoveFromEventReceiverList( iCurrentElement );
       
   831             break;
       
   832         }
       
   833         iSvgError->AppendDescription( _L( "\" for <" ) );
       
   834         // access schema data to get the name of the attribute which is missing
       
   835         // currently the error msg doesnt not report the name of the attribute
       
   836         iSvgError->AppendDescription( aName );
       
   837         iSvgError->AppendDescription( _L( ">." ) );
       
   838         
       
   839         TInt32 displayValue = KDisplayEnumNone;
       
   840         TInt   lRetValue = ((CSvgElementImpl*)iCurrentElement)->GetAttributeIntL( KCSS_ATTR_DISPLAY, displayValue );
       
   841         // turn off element if the display attribute is not declared OR if declared its value is "!none"
       
   842         if( (lRetValue == KErrNoAttribute)||(displayValue != KDisplayEnumNone ) )
       
   843         {
       
   844            ((CSvgElementImpl*)iCurrentElement)->SetPropertyL(KCSS_ATTR_DISPLAY,_L("none"));
       
   845            
       
   846            // the following boolean is added to show that the element is explicitly
       
   847            // "turned off" due to the absence of the required attribute for the element,
       
   848            // this element can again be "turned on" when the required attribute is present.
       
   849            ((CSvgElementImpl*)iCurrentElement)->SetTurnOff( ETrue );	
       
   850         }
       
   851        
       
   852     }
       
   853 
       
   854     if ( elementID == KSvgImageElement )
       
   855         {
       
   856         iImageElements.Append( (CSvgImageElementImpl*)iCurrentElement );
       
   857         }
       
   858     else if ( elementID == KSvgGElement && !((CSvgDocumentImpl*)iDocument)->iHasGroupOpacity)
       
   859     {
       
   860        if ( ((CSvgDocumentImpl*)iDocument)->isGroupOpacity( iCurrentElement ))
       
   861        {
       
   862             ((CSvgDocumentImpl*)iDocument)->iHasGroupOpacity = ETrue;
       
   863        }
       
   864     }
       
   865 
       
   866     // Check for invalid child element of leave elements
       
   867     if ( KSvgRectElement == elementID && iCurrentElement->ParentNode() &&
       
   868          KSvgRectElement == ((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID() )
       
   869         {
       
   870         _LIT( KMsg, "Invalid child of <rect> element: " );
       
   871         iDocument->SetError( KErrNotFound, KMsg, aName );
       
   872         }
       
   873 
       
   874     // Notify Loading Listeners of element-start
       
   875     // Send info if element is <svg> or immediate child of <svg>
       
   876     TBool isRootOrChild = (elementID == KSvgSvgElement);
       
   877 
       
   878     if (iCurrentElement->ParentNode())
       
   879     {
       
   880         isRootOrChild = (iCurrentElement->ElemID() == KSvgSvgElement) || (((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID() == KSvgSvgElement);
       
   881     }
       
   882 
       
   883     // Update CTM for new element (if there is a LoadingListener)
       
   884     if ( iDocument->GetLoadingListeners() &&
       
   885          iDocument->GetLoadingListeners()->Count() > 0 )
       
   886          {
       
   887          iCurrentElement->UpdateCTM();
       
   888          iCurrentElement->SetAllAttributesAdded( ETrue );
       
   889          }
       
   890 
       
   891     iDocument->NotifyElementStart( aName, *aAttributeList, isRootOrChild );
       
   892 
       
   893     // Current element becomes new parent for higher depths
       
   894     iCurrentParentElement = iCurrentElement;
       
   895     return ETrue;
       
   896     }
       
   897 
       
   898 // --------------------------------------------------------------------------
       
   899 // TInt CSvgContentHandler::EndElement( TDesC& /* aURI */, TDesC& /* aLocalName */, TDesC& aTagName )
       
   900 // ---------------------------------------------------------------------------
       
   901 TInt CSvgContentHandler::EndElement( TDesC& /* aURI */, TDesC& /* aLocalName */, TDesC& aTagName )
       
   902     {
       
   903     if ( iCancelRequested )
       
   904         {
       
   905         return EFalse;
       
   906         }
       
   907 
       
   908 //    iCurrentElement = NULL; //will do it in ReaderIndex
       
   909 
       
   910     if ( iIgnoreDepth > 0 )
       
   911         {
       
   912         iIgnoreDepth--;
       
   913         if ( iIgnoreDepth == 0 )
       
   914             {
       
   915             iIsSvgElement = ETrue;
       
   916             }
       
   917         return ETrue;
       
   918         }
       
   919     // Notify Loading Listeners of element-end
       
   920     // Send info if element is <svg> or immediate child of <svg>
       
   921     TBool isRootOrChild = ( iRootElement == iCurrentParentElement ) ||
       
   922                         ( iRootElement == iCurrentParentElement->ParentNode() );
       
   923     iDocument->NotifyElementEnd( aTagName, isRootOrChild );
       
   924 
       
   925     if ( iCurrentParentElement != iRootElement )
       
   926         {
       
   927         // Depth is decreased, so the current parent should be one level up
       
   928         iCurrentParentElement = ( CSvgElementImpl * )
       
   929                                 iCurrentParentElement->ParentNode();
       
   930         }
       
   931         
       
   932     if( ((CSvgElementImpl*)iCurrentElement->ParentNode()) != NULL )
       
   933        {
       
   934        if((((((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID()) == KSvgRadialGradientElement) ||
       
   935 	   ((((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID()) == KSvgLinearGradientElement) ) &&
       
   936 	   ( ((CSvgElementImpl*)iCurrentElement)->ElemID() == KSvgStopElement))
       
   937 	      {
       
   938 	      CSvgGradientElementImpl *parent = ((CSvgGradientElementImpl *)iCurrentElement->ParentNode());
       
   939         
       
   940           if(parent)
       
   941 		     {
       
   942 		    
       
   943 	         // Initialize the offset value to 0 if its still -1.
       
   944 	         TFloatFixPt lOffsetValue;
       
   945 	         TFloatFixPt lDefaultOffsetValue(-1);
       
   946 	         TBuf<6>     lAttributeName;
       
   947 	         TBuf<1>     lValueBuffer;
       
   948 	                      
       
   949 	         lAttributeName.Append(OFFSET);
       
   950 	         lValueBuffer.Append(ZEROVALUE);
       
   951 	            
       
   952 	         ((CSvgStopElementImpl*)iCurrentElement)->GetOffset( lOffsetValue );
       
   953 	            
       
   954 	         // Offset Value of -1 indicates that Offset Attribute is not declared in
       
   955 	         // stop element. 
       
   956 	         if( lOffsetValue == lDefaultOffsetValue )
       
   957 	            {   
       
   958 	            // Deliberately calling SetAttributeL in place of SetAttributeFloatL as the latter inturn
       
   959 	            // calls UpdateOffsetValues which should be called on any Stop element once it is added to
       
   960 	            // to the Stop element array Owned by parent Gradient element.  
       
   961 	            TRAP_IGNORE( ((CSvgStopElementImpl*)iCurrentElement)->SetAttributeL( lAttributeName, lValueBuffer ) );
       
   962 	            }
       
   963 	            
       
   964 	         // The function not only adds the element in Stop element array but also
       
   965              // adjusts the offset values of all the previously added elements such that
       
   966              // each gradient offset value is greater than the previous gradient stop's
       
   967              // offset value. It calls UpdateOffsetValues to adjust the values.
       
   968 	         ((CSvgGradientElementImpl *)parent)->AddStopElementInArray((CSvgStopElementImpl*)iCurrentElement);
       
   969 		     }
       
   970 	      }
       
   971     }
       
   972     
       
   973     
       
   974     iIsColorAnim = EFalse;
       
   975     iFromVal.Set( TPtrC() );
       
   976     iToVal.Set( TPtrC() );
       
   977     iByVal.Set( TPtrC() );
       
   978     iValues.Set(TPtrC() );
       
   979     iTimes.Set( TPtrC() );
       
   980     iSplines.Set( TPtrC());
       
   981     return ETrue;
       
   982     }
       
   983 
       
   984 // this method is called by xml-parser for cdata
       
   985 // --------------------------------------------------------------------------
       
   986 // TInt CSvgContentHandler::Charecters( TDesC& aBuf, TInt aStart , TInt aLength )
       
   987 // ---------------------------------------------------------------------------
       
   988 TInt CSvgContentHandler::Charecters( TDesC& aBuf, TInt aStart , TInt aLength )
       
   989     {
       
   990     if ( iCancelRequested )
       
   991         {
       
   992         return EFalse;
       
   993         }
       
   994 
       
   995     AppendToCData( aBuf );
       
   996     if ( !iCurrentElement )
       
   997         {
       
   998         return ETrue;
       
   999         }
       
  1000 
       
  1001     TUint8 id = iCurrentElement->ElemID();
       
  1002     if ( id == KSvgTextElement || id == KSvgTextAreaElement || id == KSvgDescElement || id == KSvgTitleElement || id == KSvgMetadataElement)
       
  1003         {
       
  1004 
       
  1005         if(id == KSvgTextElement)
       
  1006             {
       
  1007             ((CSvgTextElementImpl*)iCurrentElement)->SetFileOffset(aStart);
       
  1008             ((CSvgTextElementImpl*)iCurrentElement)->SetOrgLength(aLength);
       
  1009             }
       
  1010         else if (id == KSvgTextAreaElement)
       
  1011             {
       
  1012             // KSvgTextAreaElement
       
  1013             ((CSvgTextAreaElementImpl*)iCurrentElement)->SetFileOffset(aStart);
       
  1014             ((CSvgTextAreaElementImpl*)iCurrentElement)->SetOrgLength(aLength);
       
  1015             }
       
  1016 
       
  1017         //First get the elements previous text & append the new text
       
  1018         TPtrC elementText;
       
  1019         iCurrentElement->GetAttributeDes(KAtrCdata , elementText);
       
  1020         iCData->Des().Zero();
       
  1021         AppendToCData(elementText);
       
  1022         AppendToCData(aBuf);
       
  1023         TRAPD( error, iCurrentElement->SetAttributeDesL( KAtrCdata, *iCData ) );
       
  1024         if (error != KErrNone)
       
  1025             {
       
  1026                 //do something here.
       
  1027             }
       
  1028         }
       
  1029     else if ( id == KSvgScriptElement  )
       
  1030         {
       
  1031         RDebug::Printf("Calling SetScriptL\n" );
       
  1032         TRAPD( error2, ((CSvgScriptElementImpl*)iCurrentElement)->SetScriptL( *iCData ) );
       
  1033         if (error2 != KErrNone)
       
  1034             {
       
  1035             //do something here
       
  1036             }
       
  1037         }
       
  1038 
       
  1039     return ETrue;
       
  1040     }
       
  1041 // --------------------------------------------------------------------------
       
  1042 // void CSvgContentHandler::DataBuffer( const TDesC16& aBuf)
       
  1043 // ---------------------------------------------------------------------------
       
  1044 void CSvgContentHandler::DataBuffer( const TDesC16& aBuf)
       
  1045     {
       
  1046 
       
  1047     if(iRootElement && !((CSvgSvgElementImpl *)iRootElement)->iContent )
       
  1048         {
       
  1049 
       
  1050         ((CSvgSvgElementImpl *)iRootElement)->iContent = HBufC::New(aBuf.Length());
       
  1051         if( ((CSvgSvgElementImpl *)iRootElement)->iContent == NULL)
       
  1052             return;
       
  1053         else
       
  1054             ((CSvgSvgElementImpl *)iRootElement)->iContent->Des().Copy(aBuf);
       
  1055         }
       
  1056     return;
       
  1057 
       
  1058     }
       
  1059 
       
  1060 // --------------------------------------------------------------------------
       
  1061 // TInt CSvgContentHandler::Comment( TDesC& /* aComment */ )
       
  1062 // ---------------------------------------------------------------------------
       
  1063 TInt CSvgContentHandler::Comment( TDesC& /* aComment */ )
       
  1064     {
       
  1065     return !iCancelRequested;
       
  1066     }
       
  1067 
       
  1068 // --------------------------------------------------------------------------
       
  1069 // TInt CSvgContentHandler::ProcessingInstructions( TDesC& /* aTarget */, TDesC& /* aData */ )
       
  1070 // ---------------------------------------------------------------------------
       
  1071 TInt CSvgContentHandler::ProcessingInstructions( TDesC& /* aTarget */, TDesC& /* aData */ )
       
  1072     {
       
  1073     return !iCancelRequested;
       
  1074     }
       
  1075 
       
  1076 // --------------------------------------------------------------------------
       
  1077 // TInt CSvgContentHandler::IgnoreWhiteSpace( TDesC& /* aString */ )
       
  1078 // ---------------------------------------------------------------------------
       
  1079 TInt CSvgContentHandler::IgnoreWhiteSpace( TDesC& /* aString */ )
       
  1080     {
       
  1081     return !iCancelRequested;
       
  1082     }
       
  1083 
       
  1084 // ---------------------------------------------------------------------------
       
  1085 // Called by XML parser when a valid '&...;' is encountered
       
  1086 // The entity character must be appended to call previous called of "Charecters"
       
  1087 // & 'StartEntity".
       
  1088 // ---------------------------------------------------------------------------
       
  1089 TInt CSvgContentHandler::StartEntity( TDesC& aName  )
       
  1090     {
       
  1091     // Parse entity for possible svg subtree
       
  1092     // ParseEntity return ETrue if it has valid subtree and parsing successful.
       
  1093     // Otherwise append entity as part of CData.
       
  1094     if ( ParseEntity( aName ) )
       
  1095         {
       
  1096         return ETrue;
       
  1097         }
       
  1098 
       
  1099     if ( iCancelRequested )
       
  1100         {
       
  1101         return EFalse;
       
  1102         }
       
  1103 
       
  1104     // content generated with tool uses 0x2019 for apostrophe
       
  1105     if ( aName.Length() == 1 && aName[0] == 0x2019 )
       
  1106         {
       
  1107         AppendToCData( _L( "'" ) );
       
  1108         }
       
  1109     else
       
  1110     {
       
  1111         AppendToCData( aName );
       
  1112     }
       
  1113     // Set CData attribute
       
  1114 
       
  1115     if (!iCurrentElement)
       
  1116     {
       
  1117     	return ETrue;
       
  1118     }
       
  1119 
       
  1120     TUint8 id = iCurrentElement->ElemID();
       
  1121 
       
  1122     if ( (id == KSvgTextElement) || (id == KSvgTextAreaElement) || (id == KSvgTitleElement) || (id == KSvgDescElement) || (id == KSvgMetadataElement))
       
  1123         {
       
  1124         TRAPD( error, iCurrentElement->SetAttributeDesL( KAtrCdata, *iCData ) );
       
  1125         if ( error != KErrNone )
       
  1126            {
       
  1127             #ifdef _DEBUG
       
  1128             RDebug::Printf("CSvgContentHandler::StartEntity error occurred.");
       
  1129             #endif
       
  1130            }
       
  1131         }
       
  1132     return ETrue;
       
  1133     }
       
  1134 
       
  1135 // ---------------------------------------------------------------------------
       
  1136 // Check to see if entity may be needed for parsing
       
  1137 // If so, attemp to parse it as parse of the document
       
  1138 // Return ETrue if parse was successfull, EFalse otherwise.
       
  1139 // ---------------------------------------------------------------------------
       
  1140 TBool CSvgContentHandler::ParseEntity( const TDesC& aEntity )
       
  1141 {
       
  1142     // Look for '<' and '>' to narrow possibility of svg entity
       
  1143     TInt startPos = aEntity.Locate( TChar( '<' ) );
       
  1144     if ( startPos == KErrNotFound )
       
  1145         {
       
  1146         return EFalse;
       
  1147         }
       
  1148 
       
  1149     TInt endPos = aEntity.LocateReverse( TChar( '>' ) );
       
  1150     if ( endPos == KErrNotFound || endPos < startPos )
       
  1151         {
       
  1152         return EFalse;
       
  1153         }
       
  1154 
       
  1155     // Create XML parser
       
  1156     RXMLReader xmlReader;
       
  1157     TInt error = KErrNone;
       
  1158     TRAP( error, xmlReader.CreateL() );
       
  1159     if ( error != KErrNone )
       
  1160         {
       
  1161         return EFalse;
       
  1162         }
       
  1163 
       
  1164     // Copy entity string to byte-array
       
  1165     // Enclosed within <g> element to ensure all elements are parsed
       
  1166     _LIT8( KBeginTag, "<g>" );
       
  1167     _LIT8( KEndTag, "</g>" );
       
  1168     HBufC8* buf8 = NULL;
       
  1169     // create length + room for KBeginTag & KEndTag
       
  1170     buf8 = HBufC8::New( aEntity.Length() + 7 );
       
  1171     if ( buf8 == NULL )
       
  1172         {
       
  1173         xmlReader.Destroy();
       
  1174         return EFalse;
       
  1175         }
       
  1176     TPtr8 des = buf8->Des();
       
  1177     des.Copy( KBeginTag );
       
  1178     des.Append( aEntity );
       
  1179     des.Append( KEndTag );
       
  1180 
       
  1181     // Parse content
       
  1182     xmlReader.SetContentHandler( this );
       
  1183     TRAPD( parseError, xmlReader.ParseL( *buf8 ) );
       
  1184 
       
  1185     // Cleanup
       
  1186     delete buf8;
       
  1187     xmlReader.Destroy();
       
  1188 
       
  1189     return parseError == KErrNone;
       
  1190 }
       
  1191 
       
  1192 
       
  1193 // ---------------------------------------------------------------------------
       
  1194 // Called by XML parser when a valid '&...;' is encountered
       
  1195 // ---------------------------------------------------------------------------
       
  1196 TInt CSvgContentHandler::EndEntity( TDesC&  /*aName*/ )
       
  1197     {
       
  1198     return !iCancelRequested;
       
  1199     }
       
  1200 
       
  1201 // --------------------------------------------------------------------------
       
  1202 // TInt CSvgContentHandler::SkippedEntity( TDesC& /*aName*/ )
       
  1203 // ---------------------------------------------------------------------------
       
  1204 TInt CSvgContentHandler::SkippedEntity( TDesC& /*aName*/ )
       
  1205     {
       
  1206     return !iCancelRequested;
       
  1207     }
       
  1208 
       
  1209 // --------------------------------------------------------------------------
       
  1210 // TInt CSvgContentHandler::StartCDATA()
       
  1211 // ---------------------------------------------------------------------------
       
  1212 TInt CSvgContentHandler::StartCDATA()
       
  1213     {
       
  1214     return !iCancelRequested;
       
  1215     }
       
  1216 
       
  1217 // --------------------------------------------------------------------------
       
  1218 // TInt CSvgContentHandler::EndCDATA()
       
  1219 // ---------------------------------------------------------------------------
       
  1220 TInt CSvgContentHandler::EndCDATA()
       
  1221     {
       
  1222     return !iCancelRequested;
       
  1223     }
       
  1224 
       
  1225 // --------------------------------------------------------------------------
       
  1226 // TInt CSvgContentHandler::Error( TInt /* aErrorCode */, TInt /* aSeverity */ )
       
  1227 // ---------------------------------------------------------------------------
       
  1228 TInt CSvgContentHandler::Error( TInt /* aErrorCode */, TInt /* aSeverity */ )
       
  1229     {
       
  1230     return EFalse;
       
  1231     }
       
  1232 
       
  1233 /************* End of MXMLContentHandler methods ************/
       
  1234 
       
  1235 // --------------------------------------------------------------------------
       
  1236 // void CSvgContentHandler::AppendToCData( const TDesC& aText )
       
  1237 // ---------------------------------------------------------------------------
       
  1238 void CSvgContentHandler::AppendToCData( const TDesC& aText )
       
  1239 {
       
  1240 
       
  1241     // Check to see if appending will overflow
       
  1242     if ( iCData->Des().MaxLength() < iCData->Length() + aText.Length() )
       
  1243     {
       
  1244         HBufC* newBuf = HBufC::NewMax( iCData->Length() + aText.Length() );
       
  1245         // Fail to allocate new buffer
       
  1246         if ( newBuf == NULL )
       
  1247             return;
       
  1248 
       
  1249         newBuf->Des().Copy( *iCData );
       
  1250 
       
  1251         delete iCData;
       
  1252         iCData = newBuf;
       
  1253     }
       
  1254 
       
  1255     iCData->Des().Append( aText );
       
  1256 }
       
  1257 
       
  1258 
       
  1259 
       
  1260 // --------------------------------------------------------------------------
       
  1261 // TBool CSvgContentHandler::ProcessColorAttributeL( const TDesC& aName,
       
  1262 // ---------------------------------------------------------------------------
       
  1263 TBool CSvgContentHandler::ProcessColorAttributeL( const TDesC& aName,
       
  1264                                                   const TDesC& aValue )
       
  1265     {
       
  1266     TUint32 tempColor;
       
  1267     if( aValue.Length() )
       
  1268         {
       
  1269         if(aValue == _L("freeze") )
       
  1270             {
       
  1271             iCurrentElement->SetAttributeL( aName, aValue);
       
  1272             return ETrue;
       
  1273             }
       
  1274         if ( aValue == _L( "inherit" ) )
       
  1275             {
       
  1276             return EFalse;
       
  1277             }
       
  1278         if ( aValue != _L( "none" ) && aValue != _L( "currentColor" ) && aValue.Left(3)!=_L("url") )
       
  1279 
       
  1280             {
       
  1281             TBufC<24>   lColBuf;
       
  1282             TSvgColor tColor(KGfxColorNull);
       
  1283             if ( tColor.GetStringL( aValue, tempColor ) == EFalse )
       
  1284                 {
       
  1285                 TInt32  defColor  = 0;//default color
       
  1286                 ( ( CSvgElementImpl * ) iCurrentElement->ParentNode() )->GetAttributeIntL( KAtrFill,
       
  1287                                                                                            defColor );
       
  1288                 _LIT( KFixptFormat, "%d" );
       
  1289                 ( lColBuf.Des() ).Format( KFixptFormat, defColor );
       
  1290                 }
       
  1291             else
       
  1292                 {
       
  1293                 _LIT( KFixptFormat, "%d" );
       
  1294                 ( lColBuf.Des() ).Format( KFixptFormat, tempColor );
       
  1295                 }
       
  1296             iCurrentElement->SetAttributeL( aName, lColBuf);
       
  1297             }
       
  1298         else
       
  1299             {
       
  1300             iCurrentElement->SetAttributeL( aName, aValue);
       
  1301             }
       
  1302         return ETrue;
       
  1303         }
       
  1304     return EFalse;
       
  1305 
       
  1306     }
       
  1307 
       
  1308 
       
  1309 // --------------------------------------------------------------------------
       
  1310 // TBool CSvgContentHandler::ProcessStyleL( const TDesC& aValue )
       
  1311 // ---------------------------------------------------------------------------
       
  1312 TBool CSvgContentHandler::ProcessStyleL( const TDesC& aValue )
       
  1313     {
       
  1314     TPtrC remaining;
       
  1315     remaining.Set( aValue );
       
  1316     TPtrC name;
       
  1317     TPtrC value;
       
  1318 
       
  1319     TInt semicolonIndex = remaining.Find( _L( ";" ) );
       
  1320     while ( semicolonIndex != KErrNotFound )
       
  1321     {
       
  1322         // make substring, excluding ';'
       
  1323         TPtrC nameValuePair;
       
  1324         nameValuePair.Set( remaining.Ptr(), semicolonIndex );
       
  1325 
       
  1326         // Extract name, value
       
  1327         if ( ExtractStyleValuePair( nameValuePair, name, value ) )
       
  1328         {
       
  1329             // store property
       
  1330             TInt attributeID = (((CSvgDocumentImpl*)iDocument)->SchemaData())->GetPresentationAttributeId( name );
       
  1331             if ( attributeID != KErrNotFound )
       
  1332                 iCurrentElement->SetPropertyL( attributeID, value );
       
  1333             else
       
  1334                 iCurrentElement->SetAttributeL( name, value );
       
  1335         }
       
  1336 
       
  1337         // shorten remaining, start at first character after semicolon
       
  1338         remaining.Set( (TUint16*)&remaining.Ptr()[semicolonIndex+1],
       
  1339                        remaining.Length() - nameValuePair.Length() - 1 );
       
  1340         semicolonIndex = remaining.Find( _L( ";" ) );
       
  1341     }
       
  1342 
       
  1343     // process remaining pair if exists
       
  1344     if ( ExtractStyleValuePair( remaining, name, value ) )
       
  1345     {
       
  1346         // store property
       
  1347         TInt attributeID = (((CSvgDocumentImpl*)iDocument)->SchemaData())->GetPresentationAttributeId( name );
       
  1348         if ( attributeID != KErrNotFound )
       
  1349             iCurrentElement->SetPropertyL( attributeID, value );
       
  1350         else
       
  1351             iCurrentElement->SetAttributeL( name, value );
       
  1352     }
       
  1353 
       
  1354     return ETrue;
       
  1355 }
       
  1356 
       
  1357 
       
  1358 // --------------------------------------------------------------------------
       
  1359 // TBool CSvgContentHandler::ProcessTransformL( const TDesC& /*aName*/,
       
  1360 // ---------------------------------------------------------------------------
       
  1361 TBool CSvgContentHandler::ProcessTransformL( const TDesC& /*aName*/,
       
  1362                                              const TDesC& aValue )
       
  1363     {
       
  1364 
       
  1365     _LIT( KCb, ")" );
       
  1366     _LIT(KTransform ,"transform");
       
  1367 
       
  1368     // Prepare the style value string for parsing
       
  1369     // Should be like transform=matrix( 1 0 0 1 6 6 )
       
  1370     // Notice the space after and not before ( and the space before )
       
  1371 
       
  1372     HBufC*  tFinal  = HBufC::NewLC( aValue.Length() + 1000 );
       
  1373     TPtr    tPf     = tFinal->Des();
       
  1374 
       
  1375     // 1. Copy to a temp buffer
       
  1376     HBufC*  tBufC   = HBufC::NewLC( aValue.Length() );// In case we need room for two extra spaces
       
  1377     TPtr    tPtr    = tBufC->Des();
       
  1378     tPtr.Copy( aValue );
       
  1379 
       
  1380     // 2. Replace "funny" chars to spaces
       
  1381     tPtr.TrimAll();
       
  1382 
       
  1383     TStringTokenizer    lTokenizer  ( tPtr, KCb );
       
  1384     while ( lTokenizer.HasMoreTokens() )
       
  1385         {
       
  1386         TPtrC   lToken  ( lTokenizer.NextToken( KCb ) );
       
  1387 
       
  1388         TInt    pos;
       
  1389         _LIT( KSp, " " );
       
  1390 
       
  1391         HBufC*  tBufC2  = HBufC::NewLC( lToken.Length() + 4 );
       
  1392         TPtr    tPtr2   = tBufC2->Des();
       
  1393         tPtr2.Copy( lToken );
       
  1394         const TUint16*  lValStr = tPtr2.Ptr();
       
  1395 
       
  1396         // Remove spaces between transformation type keyword and (
       
  1397         pos = tPtr2.Locate( '(' );
       
  1398         while ( lValStr[pos - 1] == ' ' )
       
  1399             {
       
  1400             tPtr2.Delete( pos - 1, 1 );
       
  1401             lValStr = tPtr2.Ptr();
       
  1402             pos = tPtr2.Locate( '(' );
       
  1403             }
       
  1404 
       
  1405         // Add space after (
       
  1406         pos = tPtr2.Locate( '(' );
       
  1407         if ( pos != KErrNotFound &&
       
  1408              pos < ( tPtr2.Length() - 1 ) &&
       
  1409              lValStr[pos + 1] != ' ' )
       
  1410             {
       
  1411             tPtr2.Insert( pos + 1, KSp );
       
  1412             lValStr = tPtr2.Ptr();
       
  1413             }
       
  1414 
       
  1415         // Replace ',' with space
       
  1416         pos = tPtr2.Locate( ',' );
       
  1417         while ( pos != KErrNotFound )
       
  1418             {
       
  1419             tPtr2.Replace( pos, 1, KSp );
       
  1420             lValStr = tPtr2.Ptr();
       
  1421             pos = tPtr2.Locate( ',' );
       
  1422             }
       
  1423 
       
  1424         // Add space at end
       
  1425         tPtr2.Append( KSp );
       
  1426         // Add ) to end
       
  1427         tPtr2.Append( KCb );
       
  1428         // Add space at end
       
  1429         tPtr2.Append( KSp );
       
  1430 
       
  1431         const TUint16*  lVal2   = tPtr2.Ptr();
       
  1432 
       
  1433         tPf.Append( lVal2, tPtr2.Length() );
       
  1434         CleanupStack::PopAndDestroy( 1 ); // tBufC2
       
  1435         }
       
  1436 
       
  1437         iCurrentElement->SetTransform(KTransform,tPf);
       
  1438 
       
  1439     CleanupStack::PopAndDestroy( 2 ); // tBufC & TFinal
       
  1440     return ETrue;
       
  1441     }
       
  1442 
       
  1443 // --------------------------------------------------------------------------
       
  1444 // TBool CSvgContentHandler::ProcessUnitsL( const TDesC& /*aName*/, const TDesC& /*aValue*/ )
       
  1445 // ---------------------------------------------------------------------------
       
  1446 TBool CSvgContentHandler::ProcessUnitsL( const TDesC& /*aName*/, const TDesC& /*aValue*/ )
       
  1447     {
       
  1448     return ETrue;
       
  1449     }
       
  1450 
       
  1451 /************** XML Entity Character Methods ****************/
       
  1452 
       
  1453 // --------------------------------------------------------------------------
       
  1454 // void CSvgContentHandler::ConvertEntitiesToCharsL( CDesCArrayFlat& aArray )
       
  1455 // ---------------------------------------------------------------------------
       
  1456 void CSvgContentHandler::ConvertEntitiesToCharsL( CDesCArrayFlat& aArray )
       
  1457     {
       
  1458 
       
  1459     TInt lCount = aArray.Count();
       
  1460     for ( TInt i = 0; i < lCount; i++ )
       
  1461     {
       
  1462         HBufC* substituteString = ConvertEntitiesToCharsL( aArray[i] );
       
  1463         
       
  1464         if ( substituteString != NULL )
       
  1465             {
       
  1466             CleanupStack::PushL( substituteString );
       
  1467             aArray.Delete( i );
       
  1468             aArray.InsertL( i, *substituteString );
       
  1469             CleanupStack::PopAndDestroy(substituteString);
       
  1470     				}
       
  1471         }
       
  1472     }
       
  1473 
       
  1474 // --------------------------------------------------------------------------
       
  1475 // HBufC* CSvgContentHandler::ConvertEntitiesToCharsL( const TDesC& aString )
       
  1476 // ---------------------------------------------------------------------------
       
  1477 HBufC* CSvgContentHandler::ConvertEntitiesToCharsL( const TDesC& aString )
       
  1478     {
       
  1479     // no entity, return NULL
       
  1480     TInt pos = Find( aString, 0, '&' );
       
  1481     if ( pos == -1 )
       
  1482         {
       
  1483         return NULL;
       
  1484         }
       
  1485 
       
  1486     HBufC* substituteString = HBufC::NewLC( aString.Length() );
       
  1487     TPtr ptr = substituteString->Des();
       
  1488 
       
  1489     TInt endPos = 0;
       
  1490     TChar substituteChar = ' ';
       
  1491     while ( pos != -1 )
       
  1492         {
       
  1493         // copy up to pos
       
  1494         Append( ptr, aString, endPos, pos );
       
  1495 
       
  1496         // no entity ending character, copy to end of string
       
  1497         endPos = Find( aString, pos, ';' );
       
  1498         if ( endPos == -1 )
       
  1499             {
       
  1500             endPos = aString.Length()-1;
       
  1501             }
       
  1502 
       
  1503         endPos++;
       
  1504         HBufC* entity = SubstringL( aString, pos, endPos );
       
  1505         // entity is converted to char
       
  1506         if ( ConvertEntityToChar( substituteChar, *entity ) )
       
  1507             {
       
  1508             ptr.Append( substituteChar );
       
  1509             }
       
  1510         // no such entity, copy original string
       
  1511         else
       
  1512             {
       
  1513             ptr.Append( *entity );
       
  1514             }
       
  1515         delete entity;
       
  1516         pos = Find( aString, endPos, '&' );
       
  1517         }
       
  1518 
       
  1519     // check end leftover
       
  1520     if ( endPos < aString.Length() )
       
  1521         {
       
  1522         Append( ptr, aString, endPos, aString.Length() );
       
  1523         }
       
  1524 
       
  1525     CleanupStack::Pop( substituteString );
       
  1526     return substituteString;
       
  1527     }
       
  1528 
       
  1529 // --------------------------------------------------------------------------
       
  1530 // TInt CSvgContentHandler::Find( const TDesC& aString, TInt aStartIndex, TChar aChar )
       
  1531 // ---------------------------------------------------------------------------
       
  1532 TInt CSvgContentHandler::Find( const TDesC& aString, TInt aStartIndex, TChar aChar )
       
  1533     {
       
  1534 
       
  1535     TInt lCount = aString.Length();
       
  1536     for ( TInt i = aStartIndex; i < lCount; i++ )
       
  1537         {
       
  1538         if ( aString[i] == (TUint16)aChar )
       
  1539             {
       
  1540             return i;
       
  1541             }
       
  1542         }
       
  1543     return -1;
       
  1544     }
       
  1545 
       
  1546 
       
  1547 // --------------------------------------------------------------------------
       
  1548 // HBufC* CSvgContentHandler::SubstringL( const TDesC& aString, TInt aStartIndex, TInt aEndIndex )
       
  1549 // ---------------------------------------------------------------------------
       
  1550 HBufC* CSvgContentHandler::SubstringL( const TDesC& aString, TInt aStartIndex, TInt aEndIndex )
       
  1551     {
       
  1552     HBufC* substring = HBufC::NewL( aEndIndex - aStartIndex );
       
  1553     TPtr ptr = substring->Des();
       
  1554 
       
  1555     TInt lCount = aString.Length();
       
  1556     for ( TInt i = aStartIndex; i < aEndIndex && i < lCount ; i++ )
       
  1557         {
       
  1558         ptr.Append( aString[i] );
       
  1559         }
       
  1560 
       
  1561     return substring;
       
  1562     }
       
  1563 
       
  1564 // --------------------------------------------------------------------------
       
  1565 // void CSvgContentHandler::Append( TDes& aDest, const TDesC& aSource, TInt aStartIndex, TInt aEndIndex )
       
  1566 // ---------------------------------------------------------------------------
       
  1567 void CSvgContentHandler::Append( TDes& aDest, const TDesC& aSource, TInt aStartIndex, TInt aEndIndex )
       
  1568     {
       
  1569 
       
  1570     TInt lCount = aSource.Length();
       
  1571     for ( TInt i = aStartIndex; i < aEndIndex && i < lCount; i++ )
       
  1572         {
       
  1573         aDest.Append( aSource[i] );
       
  1574         }
       
  1575     }
       
  1576 
       
  1577 // --------------------------------------------------------------------------
       
  1578 // TBool CSvgContentHandler::ConvertEntityToChar( TChar& aChar, const TDesC& aString )
       
  1579 // ---------------------------------------------------------------------------
       
  1580 TBool CSvgContentHandler::ConvertEntityToChar( TChar& aChar, const TDesC& aString )
       
  1581     {
       
  1582     if ( aString == _L( "&amp;" ) )
       
  1583         {
       
  1584         aChar = '&';
       
  1585         }
       
  1586     else if ( aString == _L( "&quot;" ) )
       
  1587         {
       
  1588         aChar = '"';
       
  1589         }
       
  1590     else if ( aString == _L( "&apos;" ) )
       
  1591         {
       
  1592         aChar = '\'';
       
  1593         }
       
  1594     else if ( aString == _L( "&lt;" ) )
       
  1595         {
       
  1596         aChar = '<';
       
  1597         }
       
  1598     else if ( aString == _L( "&gt;" ) )
       
  1599         {
       
  1600         aChar = '>';
       
  1601         }
       
  1602     // need to check for '&#xx'
       
  1603     else if ( ConvertHexStringToChar( aChar, aString ) )
       
  1604         {
       
  1605         }
       
  1606     else if ( ConvertDecimalStringToChar( aChar, aString ) )
       
  1607         {
       
  1608         }
       
  1609 
       
  1610     return ETrue;
       
  1611     }
       
  1612 
       
  1613 // --------------------------------------------------------------------------
       
  1614 // TBool CSvgContentHandler::ConvertDecimalStringToChar( TChar& aChar, const TDesC& aString )
       
  1615 // ---------------------------------------------------------------------------
       
  1616 TBool CSvgContentHandler::ConvertDecimalStringToChar( TChar& aChar, const TDesC& aString )
       
  1617     {
       
  1618     TLex parser( aString );
       
  1619     // skip '&'
       
  1620     parser.Inc();
       
  1621     if ( !parser.Eos() && parser.Peek() == '#' )
       
  1622         {
       
  1623         parser.Inc();
       
  1624         TUint value = 0;
       
  1625         if ( parser.Val( value, EDecimal ) == KErrNone )
       
  1626             {
       
  1627             aChar = value;
       
  1628             return ETrue;
       
  1629             }
       
  1630         }
       
  1631     return EFalse;
       
  1632     }
       
  1633 
       
  1634 // --------------------------------------------------------------------------
       
  1635 // TBool CSvgContentHandler::ConvertHexStringToChar( TChar& aChar, const TDesC& aString )
       
  1636 // ---------------------------------------------------------------------------
       
  1637 TBool CSvgContentHandler::ConvertHexStringToChar( TChar& aChar, const TDesC& aString )
       
  1638     {
       
  1639     TLex parser( aString );
       
  1640     // skip '&'
       
  1641     parser.Inc();
       
  1642     if ( !parser.Eos() && parser.Peek() == '#' )
       
  1643         {
       
  1644         parser.Inc();
       
  1645         if ( !parser.Eos() && ( parser.Peek() == 'x' || parser.Peek() == 'X' ) )
       
  1646             {
       
  1647             parser.Inc();
       
  1648             TUint value = 0;
       
  1649             if ( parser.Val( value, EHex ) == KErrNone )
       
  1650                 {
       
  1651                 aChar = value;
       
  1652                 return ETrue;
       
  1653                 }
       
  1654             }
       
  1655         }
       
  1656     return EFalse;
       
  1657     }
       
  1658 
       
  1659 // ---------------------------------------------------------------------------
       
  1660 // Filter entity characters for cdata characters
       
  1661 // ---------------------------------------------------------------------------
       
  1662 void CSvgContentHandler::FilterCharactersL( TDesC& aString )
       
  1663     {
       
  1664     HBufC* filteredValue = ConvertEntitiesToCharsL( aString );
       
  1665    
       
  1666     if ( filteredValue == NULL )
       
  1667         {
       
  1668         iCurrentElement->SetAttributeDesL( KAtrCdata, aString );
       
  1669         }
       
  1670     else
       
  1671         {
       
  1672         CleanupStack::PushL( filteredValue );
       
  1673         iCurrentElement->SetAttributeDesL( KAtrCdata, *filteredValue );
       
  1674         CleanupStack::PopAndDestroy(filteredValue);
       
  1675         }
       
  1676 
       
  1677     }
       
  1678 
       
  1679 // ---------------------------------------------------------------------------
       
  1680 // File Offset for the closing tag
       
  1681 // ---------------------------------------------------------------------------
       
  1682 void CSvgContentHandler::ReaderIndex(NW_Uint32 aIndex)
       
  1683     {
       
  1684      if ( iCurrentElement )
       
  1685         {
       
  1686         TUint8 id = iCurrentElement->ElemID();
       
  1687         TInt OrgLength;
       
  1688         if ( id == KSvgTextElement || id == KSvgTextAreaElement)
       
  1689             {
       
  1690                 if(id==KSvgTextElement)
       
  1691                     {
       
  1692                     OrgLength = ((CSvgTextElementImpl *)iCurrentElement)->GetOrgLength();
       
  1693                     if(!OrgLength)
       
  1694                         ((CSvgTextElementImpl *)iCurrentElement)->SetFileOffset(aIndex);
       
  1695                     }
       
  1696                 else
       
  1697                     {
       
  1698                     OrgLength = ((CSvgTextAreaElementImpl *)iCurrentElement)->GetOrgLength();
       
  1699                     if(!OrgLength)
       
  1700                         ((CSvgTextAreaElementImpl *)iCurrentElement)->SetFileOffset(aIndex);
       
  1701                     }
       
  1702             }
       
  1703         }
       
  1704         // Set the current element pointer back to parent as we are 
       
  1705         // going up the tree now.
       
  1706         iCurrentElement = iCurrentParentElement;
       
  1707     }
       
  1708 
       
  1709 
       
  1710 // --------------------------------------------------------------------------
       
  1711 // TBool CSvgContentHandler::ProcessNConvertAttrL( const TDesC& aName, const TDesC& aAttrName,const TDesC& aAttrValue )
       
  1712 // ---------------------------------------------------------------------------
       
  1713 TBool CSvgContentHandler::ProcessNConvertAttrL( const TDesC& aName, const TDesC& aAttrName,const TDesC& aAttrValue )
       
  1714     {
       
  1715 
       
  1716     TInt            tmpAttrID = 0;
       
  1717 	TBool isSvgElement = EFalse ;
       
  1718 
       
  1719       if ( 
       
  1720       (iCurrentElement->ElemID() == KSvgSvgElement) 
       
  1721       && ( aAttrName == WIDTH )
       
  1722       )
       
  1723         {
       
  1724         TInt lFindValue = aAttrValue.Locate('%');
       
  1725         isSvgElement = ETrue ;
       
  1726         if (lFindValue != KErrNotFound)
       
  1727             {
       
  1728             ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = ETrue;
       
  1729             TLex lLex(aAttrValue);
       
  1730             TReal32 attValue=0;
       
  1731             if (lLex.Val(attValue, '.' ) == KErrNone)
       
  1732                 {
       
  1733                 ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInUserCoordinate = attValue;
       
  1734                 }
       
  1735             }
       
  1736         else
       
  1737             {
       
  1738             ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = EFalse;
       
  1739             }
       
  1740         
       
  1741         }
       
  1742      if ( 
       
  1743       (iCurrentElement->ElemID() == KSvgSvgElement) 
       
  1744       && ( aAttrName == HEIGHT )
       
  1745       )
       
  1746         {
       
  1747         TInt lFindValue = aAttrValue.Locate('%');
       
  1748         isSvgElement = ETrue ;
       
  1749         if (lFindValue != KErrNotFound)
       
  1750             {
       
  1751             ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = ETrue;
       
  1752             TLex lLex(aAttrValue);
       
  1753             TReal32 attValue=0;
       
  1754             if (lLex.Val(attValue, '.' ) == KErrNone)
       
  1755                 {
       
  1756                 ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInUserCoordinate = attValue;
       
  1757                 }
       
  1758             }
       
  1759         else
       
  1760             {
       
  1761             ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = EFalse;
       
  1762             }
       
  1763         }
       
  1764         //#ifdef RD_SVGT_MEDIAANIMATION_SUPPORT
       
  1765    if (aName ==_L("animation")  )
       
  1766         {
       
  1767             
       
  1768             _LIT(KX, "x");
       
  1769             _LIT(KY, "y");
       
  1770             if(aAttrName == WIDTH || aAttrName == HEIGHT )
       
  1771                 {
       
  1772                     TLex lLex(aAttrValue);
       
  1773                     TReal32 attValue=0;
       
  1774                     if (lLex.Val(attValue, '.' ) == KErrNone)
       
  1775                     {
       
  1776                     	if ( attValue < 0 )//if values are negative then default to 0
       
  1777                     	attValue = 0;
       
  1778                         if( aAttrName == WIDTH )
       
  1779                          ((CSvgMediaAnimationElementImpl *)iCurrentElement)->SetWidth(attValue);
       
  1780                          else
       
  1781                          ((CSvgMediaAnimationElementImpl *)iCurrentElement)->SetHeight(attValue);
       
  1782                     
       
  1783                     }
       
  1784                     return ETrue;    
       
  1785                 }
       
  1786             
       
  1787              if(!(aAttrName == KX) && !(aAttrName == KY ))
       
  1788                 {
       
  1789                     HBufC*  tBufC   = HBufC::NewLC( aAttrValue.Length() );
       
  1790                     TPtr    tPtr    ( tBufC->Des() );
       
  1791                     tPtr.Copy( aAttrValue );
       
  1792                     tPtr.TrimAll();
       
  1793                     iCurrentElement->SetAttributeL(aAttrName,tPtr );   
       
  1794                     CleanupStack::PopAndDestroy( 1 ); // tBufC
       
  1795                     return ETrue;
       
  1796                 }
       
  1797              
       
  1798                             
       
  1799         }     
       
  1800         //endif
       
  1801     if ( !iBeginEndAtr && ( aAttrName == BEGIN || aAttrName == END ) )
       
  1802     {
       
  1803 
       
  1804         if ( ( aAttrValue.Find( MOUSEDOWN ) != KErrNotFound ) ||
       
  1805              ( aAttrValue.Find( MOUSEUP )   != KErrNotFound ) ||
       
  1806              ( aAttrValue.Find( MOUSEOVER ) != KErrNotFound ) ||
       
  1807              ( aAttrValue.Find( MOUSEMOVE ) != KErrNotFound ) ||
       
  1808              ( aAttrValue.Find( MOUSEOUT )  != KErrNotFound ) ||
       
  1809              ( aAttrValue.Find( FOCUSIN )   != KErrNotFound ) ||
       
  1810              ( aAttrValue.Find( FOCUSOUT )  != KErrNotFound ) ||
       
  1811              ( aAttrValue.Find( ACTIVATE )  != KErrNotFound ) ||
       
  1812              ( aAttrValue.Find( CLICK )     != KErrNotFound ) ||
       
  1813              ( aAttrValue.Find( ACCESS )    != KErrNotFound ) )
       
  1814 
       
  1815         iBeginEndAtr = ETrue;
       
  1816     }
       
  1817 
       
  1818     if( iCurrentElement->ElemID() < KSvgAnimateElement || iCurrentElement->ElemID() > KSvgSetElement )
       
  1819         {
       
  1820         tmpAttrID = (( ( CSvgDocumentImpl* ) iDocument )->SchemaData())->GetPresentationAttributeId(aAttrName);
       
  1821         if( tmpAttrID != KErrNotFound )
       
  1822             {
       
  1823             iCurrentElement->SetPropertyL( tmpAttrID, aAttrValue);
       
  1824             return ETrue;
       
  1825             }
       
  1826         }
       
  1827 
       
  1828     tmpAttrID = (( ( CSvgDocumentImpl* ) iDocument )->SchemaData())->GetSVGTAttributeId(aAttrName);
       
  1829 
       
  1830     if ( iCurrentElement->ElemID() == KSvgTextAreaElement && aAttrName == _L("editable") )
       
  1831         {
       
  1832             ((CSvgTextAreaElementImpl*)iCurrentElement)->SetEditable( aAttrValue );
       
  1833         }
       
  1834     if ( iCurrentElement->ElemID() == KSvgTextElement && aAttrName == _L("editable") )
       
  1835         {
       
  1836             ((CSvgTextElementImpl*)iCurrentElement)->SetEditable( aAttrValue );
       
  1837         }
       
  1838     
       
  1839     if ( iCurrentElement->ElemID() >= KSvgMediaElemsStartIndex &&
       
  1840                  iCurrentElement->ElemID() <= KSvgMediaElemsEndIndex )
       
  1841         {
       
  1842         TBool lIsAttrProcessed = ETrue;
       
  1843         switch ( tmpAttrID )
       
  1844             {
       
  1845             case KAtrSyncBehavior:
       
  1846                 ((CSvgMediaElementBase* )iCurrentElement)->SetSyncBehavior( 
       
  1847                     aAttrValue );
       
  1848                 break;
       
  1849             case KAtrSyncTolerance:
       
  1850                 ((CSvgMediaElementBase* )iCurrentElement)->SetSyncTolerance( 
       
  1851                     aAttrValue );
       
  1852                 break;
       
  1853             case KAtrSyncMaster:
       
  1854                 ((CSvgMediaElementBase* )iCurrentElement)->SetSyncMaster( 
       
  1855                     aAttrValue );
       
  1856                 break;
       
  1857             default:
       
  1858                 lIsAttrProcessed = EFalse;
       
  1859             }
       
  1860         if ( lIsAttrProcessed )
       
  1861             {
       
  1862             return ETrue;
       
  1863             }
       
  1864         }
       
  1865     
       
  1866     if ( iCurrentElement->ElemID() == KSvgSvgElement )
       
  1867         {
       
  1868         TBool lIsAttrProcessed = ETrue;
       
  1869         switch ( tmpAttrID )
       
  1870             {
       
  1871             case KAtrSyncBehaviorDefault:
       
  1872                 ((CSvgSvgElementImpl* )iCurrentElement)->SetSyncBehaviorDefault(
       
  1873                     aAttrValue );
       
  1874                 break;
       
  1875             case KAtrSyncToleranceDefault:
       
  1876                 ((CSvgSvgElementImpl* )iCurrentElement)->SetSyncToleranceDefault(
       
  1877                     aAttrValue );
       
  1878                 break;                
       
  1879             default:
       
  1880                 lIsAttrProcessed = EFalse;
       
  1881             }
       
  1882         if ( lIsAttrProcessed )
       
  1883             {
       
  1884             return ETrue;
       
  1885             }            
       
  1886         }
       
  1887     
       
  1888     if ( iCurrentElement->ElemID() == KSvgMediaAnimationElement && 
       
  1889         tmpAttrID == KAtrInitialVisibility )
       
  1890         {
       
  1891         // Merge with the animation->SetInitialVisibility here.
       
  1892         return ETrue;
       
  1893         }
       
  1894     
       
  1895     
       
  1896     if((tmpAttrID == KAtrOffset)|| ((tmpAttrID >= KSvgNotHandledAttrsIndex
       
  1897                     ||  (tmpAttrID==KAtrRotate && iCurrentElement->ElemID()==KSvgAnimateMotionElement)) && (tmpAttrID != KAtrValues )
       
  1898                     && (tmpAttrID != KAtrKeySplines) && ( tmpAttrID != KAtrKeyTimes))
       
  1899                     &&(tmpAttrID != KAtrFx)&& (tmpAttrID != KAtrFy)&& (tmpAttrID != KAtrGradientTransform)
       
  1900           && (aName !=_L("animation") )          )
       
  1901         {
       
  1902           HBufC*  tBufC   = HBufC::NewLC( aAttrValue.Length() );
       
  1903           TPtr    tPtr    ( tBufC->Des() );
       
  1904           tPtr.Copy( aAttrValue );
       
  1905           tPtr.TrimAll();
       
  1906           TInt errorCode = iCurrentElement->SetAttributeL(aAttrName,tPtr );
       
  1907           if(errorCode == KErrReferencedElementNotFound)
       
  1908               {
       
  1909               //Error Code returned By USE Element when Forward reference element not Found
       
  1910               iUseElementArray->AppendL(iCurrentElement);
       
  1911               }
       
  1912           if(errorCode == KErrAnimateReferenceElementNotFound )
       
  1913             {
       
  1914             //Error Code returned By Animation Element when Forward reference element not Found
       
  1915             iAnimRefElementArray->AppendL(iCurrentElement);
       
  1916             }
       
  1917 
       
  1918           CleanupStack::PopAndDestroy( 1 );
       
  1919 
       
  1920         }
       
  1921     else if( tmpAttrID == KAtrAttributeName )
       
  1922             {
       
  1923             if( aAttrValue == FILL || aAttrValue == STROKE || aAttrValue == COLOR
       
  1924                 || aAttrValue == STOP_COLOR )
       
  1925                 {
       
  1926                 iIsColorAnim = ETrue;
       
  1927                 }
       
  1928                 HBufC*  tBufC   = HBufC::NewLC( aAttrValue.Length() );
       
  1929                 TPtr    tPtr    ( tBufC->Des() );
       
  1930                 tPtr.Copy( aAttrValue );
       
  1931                 tPtr.TrimAll();
       
  1932             iCurrentElement->SetAttributeL(aAttrName,tPtr );
       
  1933             CleanupStack::PopAndDestroy( 1 );
       
  1934             }
       
  1935     else if( tmpAttrID == KAtrValues )
       
  1936             {
       
  1937             iValues.Set(TPtrC( aAttrValue ) );
       
  1938             }
       
  1939     else if( tmpAttrID == KAtrKeyTimes )
       
  1940         {
       
  1941     	iTimes.Set(TPtrC( aAttrValue ));
       
  1942         }
       
  1943     else if( tmpAttrID == KAtrKeySplines )
       
  1944         {
       
  1945     	iSplines.Set(TPtrC (aAttrValue));
       
  1946             }
       
  1947     else if( tmpAttrID == KAtrTransform &&
       
  1948             (iCurrentElement->ElemID() != KSvgRadialGradientElement && iCurrentElement->ElemID()
       
  1949              != KSvgLinearGradientElement)
       
  1950              )
       
  1951             {
       
  1952             ProcessTransformL(aAttrName,aAttrValue );
       
  1953             }
       
  1954             //Added the below else-if block  to support  the % values for X1,Y1,X2,Y2 of LinearGradient element.
       
  1955     else if( tmpAttrID >= KAtrY1 && tmpAttrID <= KAtrX2 && iCurrentElement->ElemID() == KSvgLinearGradientElement )
       
  1956             {
       
  1957             iCurrentElement->SetAttributeL( aAttrName , aAttrValue);
       
  1958             }
       
  1959     else if (tmpAttrID == KAtrGradientTransform &&
       
  1960             (iCurrentElement->ElemID() == KSvgRadialGradientElement || iCurrentElement->ElemID()
       
  1961              == KSvgLinearGradientElement))
       
  1962             {
       
  1963             ProcessTransformL(aAttrName,aAttrValue );
       
  1964 
       
  1965             }
       
  1966     else if( tmpAttrID == KAtrStyle )
       
  1967             {
       
  1968             ProcessStyleL(aAttrValue);
       
  1969             }
       
  1970 
       
  1971     else if( tmpAttrID == KAtrFrom)
       
  1972             {
       
  1973             iFromVal.Set( TPtrC( aAttrValue ) );
       
  1974             }
       
  1975     else if( tmpAttrID == KAtrTo)
       
  1976             {
       
  1977             iToVal.Set( TPtrC( aAttrValue ) );
       
  1978             }
       
  1979     else if ( tmpAttrID == KAtrBy )
       
  1980             {
       
  1981             iByVal.Set( TPtrC( aAttrValue ) );
       
  1982             }
       
  1983     else if (( tmpAttrID >= KSvgDesAttrsIndex ||
       
  1984              (iCurrentElement->ElemID() == KSvgTextElement &&
       
  1985                 (tmpAttrID == KAtrX || tmpAttrID == KAtrY))) && (tmpAttrID != KAtrFx)&& (tmpAttrID != KAtrFy)
       
  1986                &&(aName !=_L("animation") ) )
       
  1987 
       
  1988 
       
  1989             {
       
  1990             iCurrentElement->SetAttributeDesL( tmpAttrID, aAttrValue);
       
  1991             }
       
  1992     else if ( iCurrentElement->ElemID() == KSvgScriptElement )
       
  1993         {
       
  1994             iCurrentElement->SetAttributeL( aAttrName, aAttrValue);
       
  1995         }
       
  1996     else
       
  1997         {
       
  1998             // check if the datatype is lenth.datatype or coordinate.datatype
       
  1999         TUint8 datatype = ( (TUint8) (tmpAttrID < KSvgCoordAttrStartIndex ? KSVG_LENGTH_TYPE : KSVG_COORDINATE_TYPE) );
       
  2000         TReal32 convertedValue;
       
  2001         if( CSvgAttributeVerifier::ValidAttrValue(aAttrValue, convertedValue, datatype, aAttrName, isSvgElement) )
       
  2002                 {
       
  2003                 //check for valid width height 
       
  2004                 //specific checking for svgElement width height
       
  2005                 //particularly the case when width height values 
       
  2006                 //in percentages cannot be greater than 100
       
  2007                 if( iCurrentElement->ElemID() == KSvgSvgElement )
       
  2008                 {
       
  2009                     if(
       
  2010                     (aAttrName == WIDTH )
       
  2011                     &&(((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage)
       
  2012                     )
       
  2013                     {
       
  2014                         if(convertedValue > 100)
       
  2015                             convertedValue = 100;
       
  2016                     }
       
  2017                     
       
  2018                     if(
       
  2019                     (aAttrName == HEIGHT)
       
  2020                     &&(((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage)
       
  2021                     )
       
  2022                     {
       
  2023                         if(convertedValue > 100)
       
  2024                             convertedValue = 100;
       
  2025                     }
       
  2026                 }
       
  2027                 if((tmpAttrID < KSvgDesAttrsIndex) || (tmpAttrID == KAtrFy || tmpAttrID == KAtrFx))
       
  2028                     {
       
  2029                     iCurrentElement->SetAttributeFloatL( tmpAttrID, ((TFloatFixPt) convertedValue));
       
  2030                     }
       
  2031                 else
       
  2032                     {
       
  2033                     iCurrentElement->SetAttributeIntL( tmpAttrID, (TInt) convertedValue );
       
  2034                     }
       
  2035                 }
       
  2036             else
       
  2037                 {
       
  2038                 //if invalid width height specified then 
       
  2039                 //set width/height values as zero
       
  2040                  if(
       
  2041                  ( iCurrentElement->ElemID() == KSvgSvgElement )
       
  2042                  &&(aAttrName == WIDTH || aAttrName == HEIGHT)
       
  2043                  )
       
  2044                  {
       
  2045                     convertedValue = 0;
       
  2046                     iCurrentElement->SetAttributeFloatL( tmpAttrID, (TFloatFixPt) convertedValue );
       
  2047                  }
       
  2048                 _LIT(STRING1, "Invalid \"");
       
  2049                 _LIT(STRING2, "\" value for <");
       
  2050                 _LIT(STRING3, "> : \"");
       
  2051                 _LIT(STRING4, "\"" );
       
  2052                 iSvgError->SetErrorCode( ESvgInvalidAttributeValue );
       
  2053                 iSvgError->SetIsWarning( ETrue );
       
  2054                 iSvgError->SetDescription( STRING1 );
       
  2055                 iSvgError->AppendDescription( aAttrName);
       
  2056                 iSvgError->AppendDescription( STRING2 );
       
  2057                 iSvgError->AppendDescription( aName );
       
  2058                 iSvgError->AppendDescription( STRING3 );
       
  2059                 iSvgError->AppendDescription( aAttrValue );
       
  2060                 iSvgError->AppendDescription( STRING4 );
       
  2061                 }
       
  2062                 return ETrue;
       
  2063         }
       
  2064     return ETrue;
       
  2065     }
       
  2066 
       
  2067 // --------------------------------------------------------------------------
       
  2068 // TBool CSvgContentHandler::ExtractStyleValuePair( const TDesC& aString, TPtrC& aName, TPtrC& aValue )
       
  2069 // ---------------------------------------------------------------------------
       
  2070 TBool CSvgContentHandler::ExtractStyleValuePair( const TDesC& aString, TPtrC& aName, TPtrC& aValue )
       
  2071 {
       
  2072     // find pair divide char index ":"
       
  2073     TInt colonIndex = aString.Find( _L( ":" ) );
       
  2074 
       
  2075     // ':' not found
       
  2076     if ( colonIndex == KErrNotFound )
       
  2077         return EFalse;
       
  2078 
       
  2079     // Skip front white spaces
       
  2080     TInt end = aString.Length();
       
  2081     TInt frontIndex = 0;
       
  2082     while ( frontIndex < end && TChar( aString[frontIndex] ).IsSpace() )
       
  2083         frontIndex++;
       
  2084 
       
  2085     // skip back white spaces
       
  2086     TInt backIndex = colonIndex - 1;
       
  2087     while ( backIndex > frontIndex && TChar( aString[backIndex] ).IsSpace() )
       
  2088         backIndex--;
       
  2089 
       
  2090     aName.Set( (TUint16*)&aString.Ptr()[frontIndex], backIndex - frontIndex + 1 );
       
  2091 
       
  2092     // parse for value
       
  2093     // skip front spaces
       
  2094     frontIndex = colonIndex + 1;
       
  2095     while ( frontIndex < end && TChar( aString[frontIndex] ).IsSpace() )
       
  2096         frontIndex++;
       
  2097 
       
  2098     // assuming ';' is not passed in at the end
       
  2099     // start from end and skip spaces
       
  2100     backIndex = end - 1;
       
  2101     while ( backIndex > frontIndex && TChar( aString[backIndex] ).IsSpace() )
       
  2102         backIndex--;
       
  2103 
       
  2104     aValue.Set( (TUint16*)&aString.Ptr()[frontIndex], backIndex - frontIndex + 1 );
       
  2105 
       
  2106     return ETrue;
       
  2107 }
       
  2108 
       
  2109 // --------------------------------------------------------------------------
       
  2110 // void CSvgContentHandler::SetForwardReferences(CSvgErrorImpl& aError)
       
  2111 // ---------------------------------------------------------------------------
       
  2112 void CSvgContentHandler::SetForwardReferences(CSvgErrorImpl& aError)
       
  2113 {
       
  2114     /*Once the whole DOM is constructed, Forward references need to be set*/
       
  2115     /*For USE elements*/
       
  2116     TInt lCount = iUseElementArray->Count();
       
  2117     TInt lIndex = 0;
       
  2118     TInt error = KErrNone;
       
  2119 
       
  2120     while(lIndex < lCount)
       
  2121     {
       
  2122         TPtrC tPtr2 = ((CSvgElementImpl*)iUseElementArray->operator[](lIndex ))->Href();
       
  2123         if(((CSvgUseElementImpl *)iUseElementArray->operator[](lIndex ))->SetRefElemById(tPtr2) != KErrNotFound)
       
  2124         {
       
  2125             TRAP(error ,((CSvgUseElementImpl *)iUseElementArray->operator[](lIndex ))->SetReferenceElementL());
       
  2126         }
       
  2127         else
       
  2128         {
       
  2129             aError.SetErrorCode( ESvgInvalidAttributeValue );
       
  2130             _LIT(STRING1, "Invalid attribute \n");
       
  2131             _LIT(STRING2, "USE element has invalid xlink:href attribute");
       
  2132             aError.SetDescription( STRING1 );
       
  2133             aError.AppendDescription( STRING2 );
       
  2134             aError.SetIsWarning( EFalse );
       
  2135             break;
       
  2136         }
       
  2137 
       
  2138         lIndex ++;
       
  2139     }
       
  2140 
       
  2141     /*For Animation Elements*/
       
  2142     lCount = iAnimRefElementArray->Count();
       
  2143     lIndex = 0;
       
  2144     while(lIndex < lCount)
       
  2145     {
       
  2146         TPtrC tPtr2 = ((CSvgElementImpl*)iAnimRefElementArray->operator[](lIndex ))->Href();
       
  2147         ((CSvgAnimationBase *)iAnimRefElementArray->operator[](lIndex ))->SetRefElemById(tPtr2);
       
  2148         lIndex ++;
       
  2149     }
       
  2150 
       
  2151 
       
  2152     /*For Animation elements */
       
  2153     lCount = iAnimationElementArray->Count();
       
  2154     lIndex = 0;
       
  2155     while(lIndex < lCount)
       
  2156     {
       
  2157 //        ((CSvgAnimationElementImpl *)iAnimationElementArray->operator[](lIndex))->ResetEventListener();
       
  2158 		((CSvgAnimationBase *)iAnimationElementArray->operator[](lIndex))->CheckBeginTime();
       
  2159         lIndex ++;
       
  2160     }
       
  2161 
       
  2162 }
       
  2163 
       
  2164 //---------------------------------------------------
       
  2165 //Removal of elements that dont pass
       
  2166 //required extensions, required features, and system language
       
  2167 //requirements
       
  2168 //will flag as invisible if remove flag not turned on
       
  2169 //switch statement is special case were only the first one
       
  2170 //that passes these requirements will be used so toss the rest
       
  2171 //---------------------------------------------------
       
  2172 void CSvgContentHandler::RemoveFalseElementsOrMakeInvisible()
       
  2173     {
       
  2174     if ( iReqFetAttSysArray == NULL )
       
  2175         {
       
  2176         // Error Case
       
  2177         return;        
       
  2178         }
       
  2179 
       
  2180     //loop through the list of elements with required features, attributes, or sys language
       
  2181     TInt reqFetAttSysArrayCnt = iReqFetAttSysArray->Count();
       
  2182     // Start processing from the end of the list so to follow the LIFO principle (process 
       
  2183     // from leaf node to root of DOM tree).
       
  2184     while ( reqFetAttSysArrayCnt > 0 )
       
  2185         {
       
  2186         // Access the last element in the array
       
  2187         CSvgElementImpl* lCurElement = ( CSvgElementImpl* )
       
  2188                 iReqFetAttSysArray->operator[]( reqFetAttSysArrayCnt - 1 );
       
  2189 
       
  2190         if ( lCurElement != NULL )
       
  2191             {
       
  2192             // Save the parent node as this would be required for removing 
       
  2193             // this element from the DOM tree
       
  2194             CSvgElementImpl* lParent = ( CSvgElementImpl* )
       
  2195                 lCurElement->ParentNode();
       
  2196 
       
  2197             if ( lParent == NULL )
       
  2198                 {
       
  2199                 iReqFetAttSysArray->Reset();
       
  2200                 return;
       
  2201                 }
       
  2202 
       
  2203             //just a normal element check it and remove it if it doesnt pass
       
  2204             TBool lResult = EFalse;
       
  2205             TRAPD(error, lResult  = VerifyReqExReqFtrSysL( lCurElement ));
       
  2206             if ( error == KErrNone && !lResult )
       
  2207                 {
       
  2208                 if ( iRemoveFalseSwitchElements )
       
  2209                     {
       
  2210                     // Remove references of this element in Content Handler
       
  2211                     // This function removes the element from the iReqFetAttSysArray as well
       
  2212                     RemoveInternalReferences( lCurElement );
       
  2213                     lParent->RemoveChild( lCurElement); 
       
  2214                     delete lCurElement; 
       
  2215                     lCurElement = NULL; 
       
  2216                     }
       
  2217                 else
       
  2218                     {
       
  2219                     //if not removing elements then at least set to false
       
  2220                     TRAP_IGNORE( 
       
  2221                             lCurElement->SetAttributeIntL( 
       
  2222                                 KCSS_ATTR_VISIBILITY, 1 ) );
       
  2223                     // Remove the element from the iReqFetAttSysArray
       
  2224                     iReqFetAttSysArray->Remove( reqFetAttSysArrayCnt - 1 );
       
  2225                     } // if ( iRemoveFalseSwitchElements )
       
  2226                 }
       
  2227             else 
       
  2228                 {
       
  2229                 // Remove the element from the iReqFetAttSysArray
       
  2230                 iReqFetAttSysArray->Remove( reqFetAttSysArrayCnt - 1 );
       
  2231                 } // if ( error == KErrNone && !lResult )
       
  2232             }
       
  2233         else
       
  2234             {
       
  2235             // Remove the element from the iReqFetAttSysArray
       
  2236             iReqFetAttSysArray->Remove( reqFetAttSysArrayCnt - 1 );
       
  2237             } // if ( lCurElement != NULL )
       
  2238 
       
  2239         // Update the array count
       
  2240         reqFetAttSysArrayCnt = iReqFetAttSysArray->Count();            
       
  2241         } // while ( reqFetAttSysArrayCnt > 0 )
       
  2242     // Reset the array as it is no longer required.
       
  2243     iReqFetAttSysArray->Reset();
       
  2244     }
       
  2245 
       
  2246 
       
  2247 
       
  2248 // --------------------------------------------------------------------------
       
  2249 // void CSvgContentHandler::RemoveStyleProperties()
       
  2250 // ---------------------------------------------------------------------------
       
  2251 /*
       
  2252 
       
  2253 //MEMORY MANAGER now in charge of style deletion
       
  2254 void CSvgContentHandler::RemoveStyleProperties(CSvgElementImpl* aElement)
       
  2255     {
       
  2256     CSvgElementImpl* child = (CSvgElementImpl*)aElement->FirstChild();
       
  2257     while ( child != NULL )
       
  2258     	{
       
  2259     	child->DeleteStyleProperties(child);
       
  2260         RemoveStyleProperties( child );
       
  2261         child = (CSvgElementImpl*)child->NextSibling();
       
  2262     	}
       
  2263     }
       
  2264 */
       
  2265 
       
  2266 
       
  2267 // --------------------------------------------------------------------------
       
  2268 // void CSvgContentHandler::RemoveFalseSwitchCases()
       
  2269 // ---------------------------------------------------------------------------
       
  2270 void CSvgContentHandler::RemoveFalseSwitchCasesOrMakeInvisible()
       
  2271     {
       
  2272     if ( iSwitchElementArray == NULL )
       
  2273         {
       
  2274         // Error Case
       
  2275         return;
       
  2276         }
       
  2277 
       
  2278     TInt switchEleArrayCnt = iSwitchElementArray->Count();
       
  2279 
       
  2280     while ( switchEleArrayCnt > 0 )
       
  2281         {
       
  2282         TBool foundTrue = EFalse;
       
  2283         CSvgElementImpl* curSwitchElem = 
       
  2284             (CSvgElementImpl*)iSwitchElementArray->operator[]( switchEleArrayCnt - 1 );
       
  2285         // Remove the switch element from the array. This is done here as 
       
  2286         // below statements could result in iSwitchElementArray getting modified 
       
  2287         // in RemoveInternalReferences. 
       
  2288         iSwitchElementArray->Remove( switchEleArrayCnt - 1 );
       
  2289         if ( curSwitchElem != NULL )
       
  2290             {
       
  2291             //get the first child...which is where the first
       
  2292             CSvgElementImpl* curCaseElem = (CSvgElementImpl*)curSwitchElem->FirstChild();
       
  2293 
       
  2294             while ( curCaseElem != NULL )
       
  2295                 {
       
  2296                 CSvgElementImpl* nextCaseElem = (CSvgElementImpl*)curCaseElem->NextSibling();
       
  2297                 // foundTrue is set to TRUE when an element whose test passes is found. The
       
  2298                 // subsequent elements are to be removed.
       
  2299                 if ( foundTrue )
       
  2300                     {
       
  2301                     if ( iRemoveFalseSwitchElements )
       
  2302                         {
       
  2303                         //already found the true case in the switch delete the rest
       
  2304                         // Remove references of this element in Content Handler
       
  2305                         // This function removes the element from the 
       
  2306                         // iSwitchElementArray as well
       
  2307                         RemoveInternalReferences( curCaseElem );
       
  2308                         curSwitchElem->RemoveChild( curCaseElem );
       
  2309                         delete ( CXmlElementImpl* )curCaseElem;
       
  2310                         curCaseElem = NULL;
       
  2311                         }
       
  2312                     else
       
  2313                         {
       
  2314                         //not removing elements from tree just make invisible
       
  2315                         TRAP_IGNORE( curCaseElem->SetAttributeIntL( KCSS_ATTR_VISIBILITY, 1 ) );
       
  2316                         }
       
  2317                     }
       
  2318                 else
       
  2319                     {
       
  2320                     // Not yet found an element whose test passes,
       
  2321                     // perform the test on the current element to check 
       
  2322                     // whether it does.
       
  2323                     TBool result= EFalse;
       
  2324                     TRAPD( error, result= VerifyReqExReqFtrSysL( curCaseElem ) );
       
  2325                     if ( error == KErrNone )
       
  2326                         {
       
  2327                         if ( !result )
       
  2328                             {
       
  2329                             if ( iRemoveFalseSwitchElements )
       
  2330                                 {
       
  2331                                 // this element doesnt meet the switch requirements 
       
  2332                                 // delete it and its children
       
  2333                                 // Remove references of this element in Content Handler
       
  2334                                 // This function removes the element from the 
       
  2335                                 // iSwitchElementArray as well
       
  2336                                 RemoveInternalReferences( curCaseElem );                                    
       
  2337                                 curSwitchElem->RemoveChild( curCaseElem );
       
  2338                                 delete ( CXmlElementImpl* )curCaseElem;
       
  2339                                 curCaseElem = NULL;
       
  2340                                 }
       
  2341                             else
       
  2342                                 {
       
  2343                                 //not removing elements from tree just make invisible
       
  2344                                 TRAP_IGNORE( curCaseElem->SetAttributeIntL( 
       
  2345                                             KCSS_ATTR_VISIBILITY, 1 ) );
       
  2346                                 }
       
  2347                             }
       
  2348                         else
       
  2349                             {
       
  2350                             //one evaluated to true so keep it but go ahead and delete the rest in the switch
       
  2351                             //should only be one child for switch in end
       
  2352                             foundTrue = ETrue;
       
  2353                             }
       
  2354                         }
       
  2355                     } // if ( foundTrue )
       
  2356 
       
  2357                 // Check the next case element
       
  2358                 curCaseElem = nextCaseElem;
       
  2359                 } // while ( curCaseElem != NULL )
       
  2360             } // if ( curSwitchElem != NULL )
       
  2361         // Update the count of elements
       
  2362         switchEleArrayCnt = iSwitchElementArray->Count();
       
  2363         } // while ( switchEleArrayCnt > 0 )
       
  2364     // Reset the array as it is no longer required.
       
  2365     iSwitchElementArray->Reset();
       
  2366     }
       
  2367 
       
  2368 //---------------------------------------------------
       
  2369 //Check to see
       
  2370 //required extensions, required features, and system language
       
  2371 //requirements
       
  2372 //---------------------------------------------------
       
  2373 TBool CSvgContentHandler::VerifyReqExReqFtrSysL( CSvgElementImpl* aElement )
       
  2374 {
       
  2375     const CDesCArrayFlat* tempTestArray = NULL; // 'const' keyword added due to S60 (CW) build team recommendation
       
  2376 
       
  2377     TBool   doDraw  = ETrue;
       
  2378 
       
  2379     // First check for requiredExtensions
       
  2380     aElement->GetRequiredExtensions( tempTestArray );
       
  2381 
       
  2382     if ( tempTestArray && tempTestArray->MdcaCount() )
       
  2383     {
       
  2384         // Check for all entries in requiredExtensions
       
  2385 
       
  2386         TInt lCount = tempTestArray->MdcaCount();
       
  2387 
       
  2388         for ( TInt i = 0; i < lCount; i++ )
       
  2389         {
       
  2390             TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
       
  2391             if ( tmpPtr.Length() )
       
  2392             {
       
  2393                 doDraw = EFalse;
       
  2394                 break;
       
  2395             }
       
  2396             else if ( aElement->HasExtension( tmpPtr ) == EFalse )
       
  2397             {
       
  2398                 doDraw = EFalse;
       
  2399                 break;
       
  2400             }
       
  2401         }
       
  2402     }
       
  2403 
       
  2404     // Second, check for requiredFeatures
       
  2405     aElement->GetRequiredFeatures( tempTestArray );
       
  2406     if ( tempTestArray && tempTestArray->MdcaCount() && doDraw)
       
  2407     {
       
  2408         // Check for all entries in requiredFeatures
       
  2409       TInt lCount = tempTestArray->MdcaCount();
       
  2410       for ( TInt i = 0; i < lCount; i++ )
       
  2411       {
       
  2412         TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
       
  2413         if ( aElement->HasFeature( tmpPtr ) == EFalse )
       
  2414         {
       
  2415             doDraw = EFalse;
       
  2416             break;
       
  2417         }
       
  2418       }
       
  2419     }
       
  2420 
       
  2421     //set up so it only gets it once...
       
  2422     //just fetch it one time...
       
  2423     if (iSystemLanguage->Length() == 0)
       
  2424     {
       
  2425         SystemLanguage( iSystemLanguage->Des() );
       
  2426     }
       
  2427 
       
  2428     // Third, check for systemLanguage
       
  2429     // SYSTEM LANGUAGE DOESNT NEED TO BE STORED IN SEPERATE ARRAY INDEXES
       
  2430     // COULD HAVE JUST STORED IT AS ONE BIG STRING AND USE FINDF without the loop
       
  2431     TBool lIsNotEmptyString = aElement->GetSystemLanguage( tempTestArray );
       
  2432 
       
  2433     if (!lIsNotEmptyString)
       
  2434     {
       
  2435     	//system language was empty string so dont draw
       
  2436     	return EFalse;
       
  2437     }
       
  2438 
       
  2439     TBool doDrawSystem = EFalse;
       
  2440     if ( tempTestArray && tempTestArray->MdcaCount() && doDraw)
       
  2441     {
       
  2442         TInt lCount = tempTestArray->MdcaCount();
       
  2443 
       
  2444         for ( TInt i = 0; i < lCount; i++ )
       
  2445         {
       
  2446             TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
       
  2447 
       
  2448 			//tmpPtr is the language that was on the element
       
  2449             //match entire content specified string to system systemlanguage
       
  2450             if ( tmpPtr.FindF( iSystemLanguage->Des() ) == 0 )
       
  2451             {
       
  2452                 doDrawSystem = ETrue;
       
  2453                 break;
       
  2454             }
       
  2455 
       
  2456             //match just the prefix of the system systemlanugage to the content specified syslang
       
  2457             if ( iSystemLanguage->Des().Left(2).FindF(tmpPtr) == 0 )
       
  2458             {
       
  2459             	doDrawSystem = ETrue;
       
  2460             	break;
       
  2461             }
       
  2462         }
       
  2463 
       
  2464         if (doDrawSystem == EFalse)
       
  2465         {
       
  2466             doDraw = EFalse;
       
  2467         }
       
  2468      }
       
  2469 
       
  2470     return doDraw;
       
  2471 }
       
  2472 
       
  2473 // --------------------------------------------------------------------------
       
  2474 // void CSvgContentHandler::SystemLanguage( TPtr aValue )
       
  2475 // ---------------------------------------------------------------------------
       
  2476 void CSvgContentHandler::SystemLanguage( TPtr aValue )
       
  2477     {
       
  2478     _LIT( KEn, "en" );
       
  2479     _LIT( KFr, "fr" );
       
  2480     _LIT( KDe, "de" );
       
  2481     _LIT( KEs, "es" );
       
  2482 
       
  2483     _LIT( KAf, "af" );
       
  2484     _LIT( KAm, "am" );
       
  2485     _LIT( KAr, "ar" );
       
  2486     _LIT( KBg, "bg" );
       
  2487     _LIT( KBn, "bn" );
       
  2488     _LIT( KBo, "bo" );
       
  2489     _LIT( KCa, "ca" );
       
  2490     _LIT( KCs, "cs" );
       
  2491     _LIT( KCy, "cy" );
       
  2492     _LIT( KDa, "da" );
       
  2493     _LIT( KEl, "el" );
       
  2494     _LIT( KEt, "et" );
       
  2495     _LIT( KFa, "fa" );
       
  2496     _LIT( KFi, "fi" );
       
  2497     _LIT( KGa, "ga" );
       
  2498     _LIT( KGd, "gd" );
       
  2499     _LIT( KGu, "gu" );
       
  2500     _LIT( KHe, "he" );
       
  2501     _LIT( KHi, "hi" );
       
  2502     _LIT( KHu, "hu" );
       
  2503     _LIT( KHr, "hr" );
       
  2504     _LIT( KHy, "hy" );
       
  2505     _LIT( KId, "id" );
       
  2506     _LIT( KIs, "is" );
       
  2507     _LIT( KIt, "it" );
       
  2508     _LIT( KJa, "ja" );
       
  2509     _LIT( KKa, "ka" );
       
  2510     _LIT( KKk, "kk" );
       
  2511     _LIT( KKm, "km" );
       
  2512     _LIT( KKn, "kn" );
       
  2513     _LIT( KKo, "ko" );
       
  2514     _LIT( KLo, "lo" );
       
  2515     _LIT( KLt, "lt" );
       
  2516     _LIT( KLv, "lv" );
       
  2517     _LIT( KMk, "mk" );
       
  2518     _LIT( KMl, "ml" );
       
  2519     _LIT( KMn, "mn" );
       
  2520     _LIT( KMo, "mo" );
       
  2521     _LIT( KMr, "mr" );
       
  2522     _LIT( KMs, "ms" );
       
  2523     _LIT( KMy, "my" );
       
  2524     _LIT( KNo, "no" );
       
  2525     _LIT( KNl, "nl" );
       
  2526     _LIT( KPa, "pa" );
       
  2527     _LIT( KPl, "pl" );
       
  2528     _LIT( KPt, "pt" );
       
  2529     _LIT( KRo, "ro" );
       
  2530     _LIT( KRu, "ru" );
       
  2531     _LIT( KSi, "si" );
       
  2532     _LIT( KSk, "sk" );
       
  2533     _LIT( KSl, "sl" );
       
  2534     _LIT( KSo, "so" );
       
  2535     _LIT( KSr, "sr" );
       
  2536     _LIT( KSq, "sq" );
       
  2537     _LIT( KSv, "sv" );
       
  2538     _LIT( KSw, "sw" );
       
  2539     _LIT( KTa, "ta" );
       
  2540     _LIT( KTe, "te" );
       
  2541     _LIT( KTh, "th" );
       
  2542     _LIT( KTi, "ti" );
       
  2543     _LIT( KTk, "tk" );
       
  2544     _LIT( KTl, "tl" );
       
  2545     _LIT( KTr, "tr" );
       
  2546     _LIT( KUk, "uk" );
       
  2547     _LIT( KUr, "ur" );
       
  2548     _LIT( KVi, "vi" );
       
  2549     //_LIT( KZh, "zh" );
       
  2550     _LIT( KZu, "zu" );
       
  2551 
       
  2552     _LIT( KEnB, "en-UK");
       
  2553     _LIT( KEnUS, "en-US");
       
  2554     _LIT( KZhTW, "zh-TW");
       
  2555     _LIT( KZhHK, "zh-HK");
       
  2556     _LIT( KZhCN, "zh-CN");
       
  2557     _LIT( KFrCA, "fr-CA");
       
  2558     _LIT( KPtBR, "pt-BR");
       
  2559     _LIT( KEnTW, "en-TW");
       
  2560     _LIT( KEnHK, "en-HK");
       
  2561     _LIT( KEnCN, "en-CN");
       
  2562     _LIT( KEnJP, "en-JP");
       
  2563     _LIT( KEnTH, "en-TH");
       
  2564     _LIT( KEsAR, "es-AR");
       
  2565     _LIT( KMsAP, "ms-AP");
       
  2566     _LIT( KEnAP, "en-AP" );    // KLangApacEnglish
       
  2567     _LIT( KIdAP, "id-AP" );    // KLangApacIndonesian
       
  2568     _LIT( KEu, "eu" );    // KLangBasque
       
  2569     _LIT( KGl, "gl" );    // KLangGalician
       
  2570 
       
  2571 
       
  2572     _LIT(KDefault, "qqqqq");
       
  2573 
       
  2574     switch ( User::Language() )
       
  2575         {
       
  2576         case ELangTest:
       
  2577         aValue = KEn;
       
  2578         break;
       
  2579 
       
  2580         case ELangEnglish:
       
  2581         aValue = KEnB;
       
  2582         break;
       
  2583         case ELangAmerican:
       
  2584         aValue = KEnUS;
       
  2585         break;
       
  2586         case ELangAustralian:
       
  2587         case ELangNewZealand:
       
  2588         case ELangCanadianEnglish:
       
  2589         case ELangSouthAfricanEnglish:
       
  2590         case ELangInternationalEnglish:
       
  2591         aValue = KEn;
       
  2592         break;
       
  2593 
       
  2594         case ELangFrench:
       
  2595         case ELangSwissFrench:
       
  2596         case ELangBelgianFrench:
       
  2597         aValue = KFr;
       
  2598         break;
       
  2599 
       
  2600         case ELangGerman:
       
  2601         case ELangAustrian:
       
  2602         case ELangSwissGerman:
       
  2603         aValue = KDe;
       
  2604         break;
       
  2605 
       
  2606         case ELangSpanish:
       
  2607         case ELangInternationalSpanish:
       
  2608         aValue = KEs;
       
  2609         break;
       
  2610 
       
  2611         case ELangLatinAmericanSpanish:
       
  2612         aValue = KEsAR;
       
  2613         break;
       
  2614 
       
  2615         case ELangItalian:
       
  2616         case ELangSwissItalian:
       
  2617         aValue = KIt;
       
  2618         break;
       
  2619 
       
  2620         case ELangSwedish:
       
  2621         case ELangFinlandSwedish:
       
  2622         aValue = KSv;
       
  2623         break;
       
  2624 
       
  2625         case ELangDanish:
       
  2626         aValue = KDa;
       
  2627         break;
       
  2628 
       
  2629         case ELangNorwegian:
       
  2630         case ELangNorwegianNynorsk:
       
  2631         aValue = KNo;
       
  2632         break;
       
  2633 
       
  2634         case ELangFinnish:
       
  2635         aValue = KFi;
       
  2636         break;
       
  2637 
       
  2638         case ELangBrazilianPortuguese:
       
  2639         aValue = KPtBR;
       
  2640         break;
       
  2641 
       
  2642         case ELangPortuguese:
       
  2643         aValue = KPt;
       
  2644         break;
       
  2645 
       
  2646         case ELangTurkish:
       
  2647         case ELangCyprusTurkish:
       
  2648         aValue = KTr;
       
  2649         break;
       
  2650 
       
  2651         case ELangIcelandic:
       
  2652         aValue = KIs;
       
  2653         break;
       
  2654 
       
  2655         case ELangRussian:
       
  2656         case ELangBelarussian:
       
  2657         aValue = KRu;
       
  2658         break;
       
  2659 
       
  2660         case ELangHungarian:
       
  2661         aValue = KHu;
       
  2662         break;
       
  2663 
       
  2664         case ELangDutch:
       
  2665         case ELangBelgianFlemish:
       
  2666         aValue = KNl;
       
  2667         break;
       
  2668 
       
  2669         case ELangCzech:
       
  2670         aValue = KCs;
       
  2671         break;
       
  2672 
       
  2673         case ELangSlovak:
       
  2674         aValue = KSk;
       
  2675         break;
       
  2676 
       
  2677         case ELangPolish:
       
  2678         aValue = KPl;
       
  2679         break;
       
  2680 
       
  2681         case ELangSlovenian:
       
  2682         aValue = KSl;
       
  2683         break;
       
  2684 
       
  2685         case ELangPrcChinese:
       
  2686         aValue = KZhCN;
       
  2687         break;
       
  2688         case ELangTaiwanChinese:
       
  2689         aValue = KZhTW;
       
  2690         break;
       
  2691         case ELangHongKongChinese:
       
  2692         aValue = KZhHK;
       
  2693         break;
       
  2694 
       
  2695         case ELangJapanese:
       
  2696         aValue = KJa;
       
  2697         break;
       
  2698 
       
  2699         case ELangThai:
       
  2700         aValue = KTh;
       
  2701         break;
       
  2702 
       
  2703         case ELangAfrikaans:
       
  2704         aValue = KAf;
       
  2705         break;
       
  2706 
       
  2707         case ELangAlbanian:
       
  2708         aValue = KSq;
       
  2709         break;
       
  2710 
       
  2711         case ELangAmharic:
       
  2712         aValue = KAm;
       
  2713         break;
       
  2714 
       
  2715         case ELangArabic:
       
  2716         aValue = KAr;
       
  2717         break;
       
  2718 
       
  2719         case ELangArmenian:
       
  2720         aValue = KHy;
       
  2721         break;
       
  2722 
       
  2723         case ELangTagalog:
       
  2724         aValue = KTl;
       
  2725         break;
       
  2726 
       
  2727         case ELangBengali:
       
  2728         aValue = KBn;
       
  2729         break;
       
  2730 
       
  2731         case ELangBulgarian:
       
  2732         aValue = KBg;
       
  2733         break;
       
  2734 
       
  2735         case ELangBurmese:
       
  2736         aValue = KMy;
       
  2737         break;
       
  2738 
       
  2739         case ELangCatalan:
       
  2740         aValue = KCa;
       
  2741         break;
       
  2742 
       
  2743         case ELangCroatian:
       
  2744         aValue = KHr;
       
  2745         break;
       
  2746 
       
  2747         case ELangEstonian:
       
  2748         aValue = KEt;
       
  2749         break;
       
  2750 
       
  2751         case ELangFarsi:
       
  2752         aValue = KFa;
       
  2753         break;
       
  2754 
       
  2755         case ELangCanadianFrench:
       
  2756         aValue = KFrCA;
       
  2757         break;
       
  2758 
       
  2759         case ELangScotsGaelic:
       
  2760         aValue = KGd;
       
  2761         break;
       
  2762 
       
  2763         case ELangGeorgian:
       
  2764         aValue = KKa;
       
  2765         break;
       
  2766 
       
  2767         case ELangGreek:
       
  2768         case ELangCyprusGreek:
       
  2769         aValue = KEl;
       
  2770         break;
       
  2771 
       
  2772         case ELangGujarati:
       
  2773         aValue = KGu;
       
  2774         break;
       
  2775 
       
  2776         case ELangHebrew:
       
  2777         aValue = KHe;
       
  2778         break;
       
  2779 
       
  2780         case ELangHindi:
       
  2781         aValue = KHi;
       
  2782         break;
       
  2783 
       
  2784         case ELangIndonesian:
       
  2785         aValue = KId;
       
  2786         break;
       
  2787 
       
  2788         case ELangIrish:
       
  2789         aValue = KGa;
       
  2790         break;
       
  2791 
       
  2792         case ELangKannada :
       
  2793         aValue = KKn;
       
  2794         break;
       
  2795 
       
  2796 
       
  2797         case ELangKazakh:
       
  2798         aValue = KKk;
       
  2799         break;
       
  2800 
       
  2801         case ELangKhmer:
       
  2802         aValue = KKm;
       
  2803         break;
       
  2804 
       
  2805         case ELangKorean:
       
  2806         aValue = KKo;
       
  2807         break;
       
  2808 
       
  2809         case ELangLao:
       
  2810         aValue = KLo;
       
  2811         break;
       
  2812 
       
  2813         case ELangLatvian:
       
  2814         aValue = KLv;
       
  2815         break;
       
  2816 
       
  2817         case ELangLithuanian:
       
  2818         aValue = KLt;
       
  2819         break;
       
  2820 
       
  2821         case ELangMacedonian:
       
  2822         aValue = KMk;
       
  2823         break;
       
  2824 
       
  2825         case ELangMalay:
       
  2826         aValue = KMs;
       
  2827         break;
       
  2828 
       
  2829         case ELangMalayalam:
       
  2830         aValue = KMl;
       
  2831         break;
       
  2832 
       
  2833         case ELangMarathi:
       
  2834         aValue = KMr;
       
  2835         break;
       
  2836 
       
  2837         case ELangMoldavian:
       
  2838         aValue = KMo;
       
  2839         break;
       
  2840 
       
  2841         case ELangMongolian:
       
  2842         aValue = KMn;
       
  2843         break;
       
  2844 
       
  2845         case ELangPunjabi:
       
  2846         aValue = KPa;
       
  2847         break;
       
  2848 
       
  2849         case ELangRomanian:
       
  2850         aValue = KRo;
       
  2851         break;
       
  2852 
       
  2853         case ELangSerbian:
       
  2854         aValue = KSr;
       
  2855         break;
       
  2856 
       
  2857         case ELangSinhalese:
       
  2858         aValue = KSi;
       
  2859         break;
       
  2860 
       
  2861         case ELangSomali:
       
  2862         aValue = KSo;
       
  2863         break;
       
  2864 
       
  2865         case ELangSwahili:
       
  2866         aValue = KSw;
       
  2867         break;
       
  2868 
       
  2869         case ELangTamil:
       
  2870         aValue = KTa;
       
  2871         break;
       
  2872 
       
  2873         case ELangTelugu:
       
  2874         aValue = KTe;
       
  2875         break;
       
  2876 
       
  2877         case ELangTibetan:
       
  2878         aValue = KBo;
       
  2879         break;
       
  2880 
       
  2881         case ELangTigrinya:
       
  2882         aValue = KTi;
       
  2883         break;
       
  2884 
       
  2885         case ELangTurkmen:
       
  2886         aValue = KTk;
       
  2887         break;
       
  2888 
       
  2889         case ELangUkrainian:
       
  2890         aValue = KUk;
       
  2891         break;
       
  2892 
       
  2893         case ELangUrdu:
       
  2894         aValue = KUr;
       
  2895         break;
       
  2896 
       
  2897         case ELangVietnamese:
       
  2898         aValue = KVi;
       
  2899         break;
       
  2900 
       
  2901         case ELangWelsh:
       
  2902         aValue = KCy;
       
  2903         break;
       
  2904 
       
  2905         case ELangZulu:
       
  2906         aValue = KZu;
       
  2907         break;
       
  2908 
       
  2909         // from \\epoc32\\include\\oem\\languages.hrh
       
  2910 
       
  2911         case KLangTaiwanEnglish:
       
  2912         aValue = KEnTW;
       
  2913         break;
       
  2914 
       
  2915         case KLangHongKongEnglish:
       
  2916         aValue = KEnHK;
       
  2917                 break;
       
  2918 
       
  2919         case KLangPrcEnglish:
       
  2920         aValue = KEnCN;
       
  2921         break;
       
  2922 
       
  2923         case KLangJapaneseEnglish:
       
  2924         aValue = KEnJP;
       
  2925         break;
       
  2926 
       
  2927         case KLangThaiEnglish:
       
  2928         aValue = KEnTH;
       
  2929         break;
       
  2930 
       
  2931         case KLangApacMalay:
       
  2932         aValue = KMsAP;
       
  2933         break;
       
  2934 
       
  2935         case KLangApacEnglish:
       
  2936             {
       
  2937             aValue = KEnAP;
       
  2938             break;
       
  2939             }
       
  2940         case KLangApacIndonesian:
       
  2941             {
       
  2942             aValue = KIdAP;
       
  2943             break;
       
  2944             }
       
  2945         case KLangBasque:
       
  2946             {
       
  2947             aValue = KEu;
       
  2948             break;
       
  2949             }
       
  2950         case KLangGalician:
       
  2951             {
       
  2952             aValue = KGl;
       
  2953             break;
       
  2954             }
       
  2955 
       
  2956         // Cingular English
       
  2957         case 6154:
       
  2958         aValue = KEnUS;
       
  2959         break;
       
  2960 
       
  2961         default:
       
  2962             {
       
  2963             aValue = KDefault;
       
  2964             }
       
  2965 
       
  2966         break;
       
  2967         }
       
  2968     }
       
  2969 
       
  2970 // --------------------------------------------------------------------------
       
  2971 // void CSvgContentHandler::CancelParsing()
       
  2972 // ---------------------------------------------------------------------------
       
  2973 void CSvgContentHandler::CancelParsing()
       
  2974     {
       
  2975         iCancelRequested = ETrue;
       
  2976     }
       
  2977 
       
  2978 // --------------------------------------------------------------------------
       
  2979 // void CSvgContentHandler::LoadImages()
       
  2980 // ---------------------------------------------------------------------------
       
  2981 void CSvgContentHandler::LoadImages()
       
  2982     {
       
  2983     TInt imageEleCnt = iImageElements.Count();
       
  2984     for ( TInt i = 0; i < imageEleCnt; i++ )
       
  2985         {
       
  2986         TRAPD( error, iImageElements[i]->LoadUriL() );
       
  2987         if ( error != KErrNone )
       
  2988             {
       
  2989             #ifdef _DEBUG
       
  2990             RDebug::Printf("LoadUriL failed: %d\n", error );
       
  2991             #endif
       
  2992             }
       
  2993         }
       
  2994     }