svgtopt/SVG/SVGImpl/src/SVGUseElementImpl.cpp
changeset 46 88edb906c587
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVG Implementation source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #if !defined(__E32BASE_H__)
       
    20 #include <e32base.h>
       
    21 #endif
       
    22 
       
    23 #include "SVGUseElementImpl.h"
       
    24 #include "SVGElementImpl.h"
       
    25 #include "SVGDocumentImpl.h"
       
    26 
       
    27 #include "GfxAffineTransform.h"
       
    28 
       
    29 #include "SVGImageElementImpl.h"
       
    30 
       
    31 _LIT( XLINKHREF, "xlink:href" );
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 // ---------------------------------------------------------------------------
       
    35 
       
    36 CSvgUseElementImpl* CSvgUseElementImpl::NewL(  const TUint8 aElemID,
       
    37                                               CSvgDocumentImpl* aDoc )
       
    38     {
       
    39     CSvgUseElementImpl* self    = new ( ELeave ) CSvgUseElementImpl( aDoc );
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL(  aElemID );
       
    42 
       
    43     CleanupStack::Pop();
       
    44 
       
    45     return self;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 // ---------------------------------------------------------------------------
       
    51 
       
    52 CSvgUseElementImpl* CSvgUseElementImpl::NewLC(  const TUint8 aElemID,
       
    53                                               CSvgDocumentImpl* aDoc )
       
    54 
       
    55 	{
       
    56     CSvgUseElementImpl* self    = new ( ELeave ) CSvgUseElementImpl( aDoc );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL( aElemID );
       
    59 
       
    60     return self;
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 // ---------------------------------------------------------------------------
       
    67 void CSvgUseElementImpl::ConstructL( const TUint8 aElemID)
       
    68 	{
       
    69     CSvgElementImpl::InitializeL( aElemID );
       
    70 
       
    71 	iSvgStyleProperties = new(ELeave) RPointerArray<CCssValue>(KCSS_MAX_ATTR);
       
    72 	User::LeaveIfError( iSvgStyleProperties->Append( NULL ) );
       
    73 	iSvgStyleProperties->Remove( 0 );
       
    74     iSvgTransformable = CSvgTransformableImpl::NewL();
       
    75     iSvgUriReferenceImpl = CSvgUriReferenceImpl::NewL();
       
    76 
       
    77 	#ifdef SVG_FLOAT_BUILD
       
    78     iX = 0 ;
       
    79     iY = 0 ;
       
    80 	#else
       
    81     iX.operator = ( 0 );
       
    82     iY.operator = ( 0 );
       
    83 	#endif
       
    84     //iXSet = EFalse;
       
    85     //iYSet = EFalse;
       
    86 
       
    87 	iReqAttrFlag = KAtrXlinkhref;
       
    88     }
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 // ---------------------------------------------------------------------------
       
    92 CSvgUseElementImpl::~CSvgUseElementImpl()
       
    93     {
       
    94 
       
    95 	if ( iSvgUriReferenceImpl )
       
    96 		{
       
    97 		delete iSvgUriReferenceImpl;
       
    98 		iSvgUriReferenceImpl = NULL;
       
    99         }
       
   100 
       
   101 	if ( iSvgStyleProperties )
       
   102 		{
       
   103 		iSvgStyleProperties->Close();
       
   104 		delete iSvgStyleProperties;
       
   105 		iSvgStyleProperties = NULL;
       
   106 		}
       
   107 	if ( iUseHRef )
       
   108 	    {
       
   109 		delete iUseHRef;
       
   110 		iUseHRef = NULL;
       
   111 		}	
       
   112     }
       
   113 
       
   114 // *******************************************************
       
   115 // From SVG DOM
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 // ---------------------------------------------------------------------------
       
   120 TFloatFixPt CSvgUseElementImpl::X()
       
   121     {
       
   122     return iX;
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 // ---------------------------------------------------------------------------
       
   128 TFloatFixPt CSvgUseElementImpl::Y()
       
   129     {
       
   130     return iY;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 // ---------------------------------------------------------------------------
       
   136 TFloatFixPt CSvgUseElementImpl::Width()
       
   137     {
       
   138     return iWidth;
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 // ---------------------------------------------------------------------------
       
   144 TFloatFixPt CSvgUseElementImpl::Height()
       
   145     {
       
   146     return iHeight;
       
   147     }
       
   148 
       
   149 // *******************************************************
       
   150 // SVG Implementation
       
   151 
       
   152 
       
   153 // *******************************************************
       
   154 // From MXmlElement
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 // ---------------------------------------------------------------------------
       
   159 TInt CSvgUseElementImpl::SetAttributeL( const TDesC& aName,
       
   160                                         const TDesC& aValue )
       
   161     {
       
   162 
       
   163 	CSvgElementImpl::SetAttributeL(aName,aValue);
       
   164     // Get the path from the xlink
       
   165     _LIT( KXLink, "xlink:href" );
       
   166     if ( aName == KXLink )
       
   167         {
       
   168         iReqAttrFlag = 0;
       
   169 
       
   170         // STEP 1 - Get the reference element
       
   171         // If the first char is '#' then remove it
       
   172         // This is possible if coming from cXML parser and not CVG Decoder
       
   173         
       
   174         TInt pos1 = aValue.Locate('/');
       
   175         
       
   176         if ( pos1 != KErrNotFound)
       
   177         {
       
   178         	if (iOwnerDocument)
       
   179         	{
       
   180         			_LIT( KMsg, "Non-local valid URI in <use> element" );
       
   181                 			((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   182                     		((CSvgDocumentImpl*)iOwnerDocument)->SetIsWarning( ETrue );
       
   183         	}
       
   184         }
       
   185         
       
   186         TInt pos = aValue.Locate( '#' );
       
   187         if ( pos != KErrNotFound && pos == 0 )
       
   188             {
       
   189             TPtrC ptr( &aValue[1], aValue.Length() - 1);
       
   190             
       
   191             // Maintain one more class level member for JSR
       
   192             // This member will contain the value starting with '#'
       
   193             if ( iUseHRef )
       
   194 			    {
       
   195 				delete iUseHRef;
       
   196 				iUseHRef = NULL;
       
   197 			    }
       
   198 			    
       
   199 		    iUseHRef = aValue.AllocL();
       
   200 
       
   201             if ( this->SetXlinkAttributeL( aName, ptr ) )
       
   202                 {
       
   203                 ireferenceEl = NULL;
       
   204                 if ( iOwnerDocument )
       
   205                     {
       
   206                     ireferenceEl = (CSvgElementImpl*)((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( ptr );
       
   207 
       
   208                     if ( ireferenceEl && ireferenceEl->ElemID() == KSvgUseElement)
       
   209                     {
       
   210                     	((CSvgUseElementImpl*)ireferenceEl)->iUseElementThatUsesThisUse = this;
       
   211 
       
   212                     	if ( ((CSvgUseElementImpl*)ireferenceEl)->iUseElementThatUsesThisUse == iUseElementThatUsesThisUse )
       
   213                     	{
       
   214                     		//then there are use elements in recursion
       
   215                     		// Set error in document
       
   216                 			_LIT( KMsg, "URI in <use> causes recursion loop with another <use>: " );
       
   217                 			((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   218                     		((CSvgDocumentImpl*)iOwnerDocument)->SetIsWarning( EFalse );
       
   219 
       
   220                     		//get rid of the loop by removing this one
       
   221                     		ireferenceEl = NULL;
       
   222                     	}
       
   223                     }
       
   224 
       
   225 
       
   226                     }
       
   227                 if(ireferenceEl == NULL)
       
   228                     {
       
   229                     // Set error in document
       
   230                     if ( iOwnerDocument && ((CSvgDocumentImpl*)iOwnerDocument)->iFinishedParsing )
       
   231                         {
       
   232                         _LIT( KMsg, "Invalid URI in <use> element: " );
       
   233                         ((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   234                         }
       
   235                     return KErrReferencedElementNotFound; // failure in finding the referenced element
       
   236                     }
       
   237                 }
       
   238             }
       
   239         else if ( pos > 0 && iOwnerDocument && ((CSvgDocumentImpl*)iOwnerDocument)->iFinishedParsing )
       
   240             {
       
   241             // Set error in document
       
   242             _LIT( KMsg, "Non-local valid URI in <use> element: " );
       
   243             ((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   244             }
       
   245         else if( pos == KErrNotFound )
       
   246             {
       
   247             
       
   248             // Maintain one more class level member for JSR
       
   249             // This member will contain the value starting with '#'
       
   250             if ( iUseHRef )
       
   251 		        {
       
   252 			    delete iUseHRef;
       
   253 			    iUseHRef = NULL;
       
   254 			    }
       
   255 			        
       
   256 		    iUseHRef = aValue.AllocL();
       
   257             TPtrC ptr( &aValue[0], aValue.Length());
       
   258             this->SetXlinkAttributeL( aName, ptr);
       
   259             }
       
   260         }
       
   261     return KErrNone;
       
   262     }
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 //
       
   266 // ---------------------------------------------------------------------------
       
   267 TInt CSvgUseElementImpl::SetAttributeDesL( const TInt aNameId,
       
   268                                         const TDesC& aValue )
       
   269 {
       
   270     switch ( aNameId )
       
   271         {
       
   272         case KAtrXlinkhref:
       
   273             {
       
   274             iReqAttrFlag = 0;
       
   275 
       
   276             // STEP 1 - Get the reference element
       
   277             // If the first char is '#' then remove it
       
   278             // This is possible if coming from cXML parser and not CVG Decoder
       
   279             TInt pos1 = aValue.Locate('/');
       
   280         
       
   281         	if ( pos1 != KErrNotFound)
       
   282         	{
       
   283         		if (iOwnerDocument)
       
   284         		{
       
   285         			_LIT( KMsg, "Non-local valid URI in <use> element" );
       
   286                 			((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   287                     		((CSvgDocumentImpl*)iOwnerDocument)->SetIsWarning( ETrue );
       
   288         		}
       
   289         	}
       
   290         
       
   291             
       
   292             TInt pos = aValue.Locate( '#' );
       
   293             if ( pos != KErrNotFound && pos == 0 )
       
   294                 {
       
   295 
       
   296                 TPtrC ptr( &aValue[1], aValue.Length() - 1);
       
   297                 // Maintain one more class level member for JSR
       
   298                 // This member will contain the value starting with '#'
       
   299 			    if ( iUseHRef )
       
   300 			       {
       
   301 				   delete iUseHRef;
       
   302 				   iUseHRef = NULL;
       
   303 			       }
       
   304 		     	iUseHRef = aValue.AllocL();
       
   305 
       
   306                 if ( this->SetXlinkAttributeL( XLINKHREF, ptr ) )
       
   307                     {
       
   308                     ireferenceEl = NULL;
       
   309                     if ( iOwnerDocument )
       
   310                         {
       
   311                         ireferenceEl = (CSvgElementImpl*)((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( ptr );
       
   312 
       
   313                         if (ireferenceEl && ireferenceEl->ElemID() == KSvgUseElement)
       
   314                             {
       
   315                     	    ((CSvgUseElementImpl*)ireferenceEl)->iUseElementThatUsesThisUse = this;
       
   316 
       
   317                         	if ( ((CSvgUseElementImpl*)ireferenceEl)->iUseElementThatUsesThisUse == iUseElementThatUsesThisUse )
       
   318                     	        {
       
   319                     	    	//then there are use elements in recursion
       
   320                     		    _LIT( KMsg, "URI in <use> causes recursion loop with another <use>: " );
       
   321                 			    ((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   322                     		    ((CSvgDocumentImpl*)iOwnerDocument)->SetIsWarning( EFalse );
       
   323 
       
   324                     	     	//get rid of the loop by removing this one
       
   325                     		    ireferenceEl = NULL;
       
   326                         	    }
       
   327                             }
       
   328 
       
   329                         }
       
   330                 if(ireferenceEl == NULL)
       
   331                     {
       
   332                     // Set error in document
       
   333                     if ( iOwnerDocument && ((CSvgDocumentImpl*)iOwnerDocument)->iFinishedParsing)
       
   334                         {
       
   335                         _LIT( KMsg, "Invalid URI in <use> element: " );
       
   336                         ((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   337                         }
       
   338                     return KErrReferencedElementNotFound; // failure in finding the referenced element
       
   339                     }
       
   340                 }
       
   341             }
       
   342         else if ( pos > 0 && iOwnerDocument && ((CSvgDocumentImpl*)iOwnerDocument)->iFinishedParsing )
       
   343                 {
       
   344                 // Set error in document
       
   345                 _LIT( KMsg, "Non-local valid URI in <use> element: " );
       
   346                 ((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, aValue );
       
   347                 }
       
   348         else if( pos == KErrNotFound )
       
   349                 {
       
   350                 // Maintain one more class level member for JSR
       
   351                 // This member will contain the value starting with '#'
       
   352                 if ( iUseHRef )
       
   353 			        {
       
   354 				    delete iUseHRef;
       
   355 				    iUseHRef = NULL;
       
   356 			        }
       
   357 			    
       
   358 		        iUseHRef = aValue.AllocL();
       
   359 		        
       
   360             	TPtrC ptr( &aValue[0], aValue.Length());
       
   361             	this->SetXlinkAttributeL( XLINKHREF, ptr);
       
   362                 }
       
   363             return KErrNone;
       
   364             }
       
   365 
       
   366         default:
       
   367             {
       
   368             return CSvgElementImpl::SetAttributeDesL( aNameId, aValue );
       
   369             }
       
   370         }
       
   371     }
       
   372 
       
   373 
       
   374 // ---------------------------------------------------------------------------
       
   375 //
       
   376 // ---------------------------------------------------------------------------
       
   377 TInt CSvgUseElementImpl::GetAttributeDes( const TInt aNameId, TPtrC16& aValue )
       
   378     {
       
   379  
       
   380     if ( aNameId == KAtrXlinkhref )
       
   381        	{
       
   382        	// iUseHRef contains value starting with '#'
       
   383        	if ( iUseHRef )
       
   384        	{
       
   385        		aValue.Set( *iUseHRef );
       
   386 		    return KErrNone;
       
   387        	}
       
   388        	
       
   389        	if ( iSvgUriReferenceImpl )
       
   390        	{
       
   391        		aValue.Set( iSvgUriReferenceImpl->Href());
       
   392        		return KErrNone;
       
   393        	}
       
   394        
       
   395        }
       
   396 
       
   397     return CSvgElementImpl::GetAttributeDes( aNameId, aValue );
       
   398 
       
   399     }
       
   400 
       
   401 
       
   402 
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 // ---------------------------------------------------------------------------
       
   406 TInt CSvgUseElementImpl::SetAttributeFloatL( const TInt aNameId,
       
   407                                               const TFloatFixPt aValue )
       
   408     {
       
   409     switch ( aNameId )
       
   410         {
       
   411         case KAtrX:
       
   412 					iX = aValue;
       
   413 					//iXSet = ETrue;
       
   414 			        break;
       
   415         case KAtrY:
       
   416 
       
   417 					iY = aValue;
       
   418 					//iYSet = ETrue;
       
   419 				    break;
       
   420         case KAtrWidth:
       
   421 					iWidth = aValue;
       
   422 			        break;
       
   423 
       
   424         case KAtrHeight:
       
   425 					iHeight = aValue;
       
   426 			        break;
       
   427         default:
       
   428         return CSvgElementImpl::SetAttributeFloatL( aNameId, aValue );
       
   429         }
       
   430     return KErrNone;
       
   431     }
       
   432 
       
   433 
       
   434 // ---------------------------------------------------------------------------
       
   435 //
       
   436 // ---------------------------------------------------------------------------
       
   437 TInt CSvgUseElementImpl::GetAttributeFloat( const TInt aNameId,
       
   438                                              TFloatFixPt& aValue )
       
   439     {
       
   440     switch ( aNameId )
       
   441         {
       
   442         case KAtrX:
       
   443 				 aValue =	iX ;
       
   444 			     break;
       
   445         case KAtrY:
       
   446 
       
   447 				aValue =	iY ;
       
   448 			    break;
       
   449         case KAtrWidth:
       
   450 				aValue =	iWidth ;
       
   451 		        break;
       
   452 
       
   453         case KAtrHeight:
       
   454 				 aValue = 	iHeight ;
       
   455 		        break;
       
   456         default:
       
   457         return CSvgElementImpl::GetAttributeFloat( aNameId, aValue );
       
   458         }
       
   459     return KErrNone;
       
   460     }
       
   461 
       
   462 
       
   463 // *******************************************************
       
   464 // From MXmlElementOpt
       
   465 
       
   466 // *******************************************************
       
   467 // From CSvgElementImpl
       
   468 
       
   469 // perform a deep clone of this object
       
   470 // ---------------------------------------------------------------------------
       
   471 //
       
   472 // ---------------------------------------------------------------------------
       
   473 MXmlElement* CSvgUseElementImpl::CloneL(MXmlElement* aParentElement)
       
   474     {
       
   475 
       
   476 	CSvgUseElementImpl* newElement = CSvgUseElementImpl::NewL(  this->ElemID(),
       
   477 										((CSvgDocumentImpl*)iOwnerDocument) );
       
   478 		CleanupStack::PushL(newElement);
       
   479 
       
   480 	newElement->iParentNode = aParentElement;
       
   481     // copy everything over
       
   482     this->CopyL(newElement);
       
   483 CleanupStack::Pop();
       
   484     return newElement;
       
   485     }
       
   486 
       
   487 //---------------------------------------------------------------------------
       
   488 // perform a deep copy of this object
       
   489 //
       
   490 //---------------------------------------------------------------------------
       
   491 void CSvgUseElementImpl::CopyL( CSvgUseElementImpl* aDestElement )
       
   492     {
       
   493     	if(aDestElement)
       
   494 		{
       
   495 	    // copy stuff from superclass
       
   496 	    this->CSvgElementImpl::CopyL(aDestElement);
       
   497 
       
   498 	    // copy iRectangle items special to circle
       
   499 	    aDestElement->iX = this->iX;
       
   500 	    aDestElement->iY = this->iY;
       
   501 	    aDestElement->iHeight = this->iHeight;
       
   502 	    aDestElement->iWidth = this->iWidth;
       
   503 
       
   504 		aDestElement->ireferenceEl = this->ireferenceEl;
       
   505 		aDestElement->iUseElementThatUsesThisUse = this->iUseElementThatUsesThisUse;
       
   506 
       
   507 		 // copy the reference to idoc (CSvgDocumentImpl)
       
   508 	    aDestElement->iOwnerDocument = this->iOwnerDocument;
       
   509 		}
       
   510     }
       
   511 
       
   512 // ---------------------------------------------------------------------------
       
   513 //
       
   514 // ---------------------------------------------------------------------------
       
   515 TBool CSvgUseElementImpl::DrawL( CGfx2dGc* /* aGc */,
       
   516                                  CSvgElementImpl* /* aElement */ )
       
   517     {
       
   518     return ETrue;
       
   519     }
       
   520 
       
   521 // *******************************************************
       
   522 // Private
       
   523 
       
   524 
       
   525 
       
   526 // ---------------------------------------------------------------------------
       
   527 //
       
   528 // ---------------------------------------------------------------------------
       
   529 CSvgUseElementImpl::CSvgUseElementImpl( CSvgDocumentImpl* aDoc )
       
   530     {
       
   531 	SetOwnerDocument(aDoc);
       
   532     }
       
   533 
       
   534 /*
       
   535 // ---------------------------------------------------------------------------
       
   536 //
       
   537 // ---------------------------------------------------------------------------
       
   538 void CSvgUseElementImpl::DeepClone( MXmlElement* aReferenceEl )
       
   539     {
       
   540     CSvgElementImpl*aNewElement = ( CSvgElementImpl* )
       
   541                                   aReferenceEl->FirstChild();
       
   542     while ( aNewElement )
       
   543         {
       
   544         DeepClone( aNewElement );
       
   545         aNewElement = ( CSvgElementImpl * ) aNewElement->NextSibling();
       
   546         }
       
   547     }
       
   548 */
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 // ---------------------------------------------------------------------------
       
   553 void CSvgUseElementImpl::SetReferenceElementL()
       
   554     {
       
   555 	if( ireferenceEl != NULL )
       
   556 		{
       
   557  		CSvgElementImpl* theElement = (CSvgElementImpl *)ireferenceEl->CloneL((MXmlElement*)this);
       
   558  		CleanupStack::PushL(theElement);
       
   559 		this->CXmlElementImpl::AppendChildL(theElement);
       
   560 		CleanupStack::Pop();
       
   561 
       
   562 		//if reference element is a use element check for recursion loop
       
   563 		if (ireferenceEl->ElemID() == KSvgUseElement)
       
   564             {
       
   565         	((CSvgUseElementImpl*)ireferenceEl)->iUseElementThatUsesThisUse = this;
       
   566 
       
   567         	if ( ireferenceEl == iUseElementThatUsesThisUse )
       
   568             	{
       
   569         		//then there are use elements in recursion
       
   570         		_LIT( KMsg, "URI in <use> causes recursion loop with another <use>: " );
       
   571     			((CSvgDocumentImpl*)iOwnerDocument)->SetError( KErrNotFound, KMsg, Href() );
       
   572         		((CSvgDocumentImpl*)iOwnerDocument)->SetIsWarning( EFalse );
       
   573 
       
   574         		//get rid of the loop by removing this one
       
   575         		ireferenceEl = NULL;
       
   576             	}
       
   577             }
       
   578         }
       
   579     }
       
   580     
       
   581     
       
   582 CSvgElementImpl* CSvgUseElementImpl::GetReferenceElementL()
       
   583 {
       
   584 	return ireferenceEl;
       
   585 }
       
   586 
       
   587 TInt  CSvgUseElementImpl::SetRefElemById(const TDesC& aName)
       
   588     {
       
   589      ireferenceEl = ( CSvgElementImpl * )
       
   590         ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( aName );
       
   591     iReqAttrFlag = 0;
       
   592 
       
   593      return ( ireferenceEl == NULL ) ? KErrNotFound : KErrNone;
       
   594     }
       
   595 
       
   596 void CSvgUseElementImpl::GetUnscaledBBox( TGfxRectangle2D& aBbox )
       
   597 {
       
   598 	TGfxRectangle2D lReferenceBbox;
       
   599 	if (ireferenceEl != NULL)
       
   600 	{
       
   601 		((CSvgElementImpl*)ireferenceEl)->GetUnscaledBBox(lReferenceBbox);
       
   602 	}
       
   603 
       
   604 	// width and height
       
   605 	aBbox.iX = lReferenceBbox.iX + X();
       
   606 	aBbox.iY = lReferenceBbox.iY + Y();
       
   607 	aBbox.iWidth = lReferenceBbox.iWidth;
       
   608 	aBbox.iHeight = lReferenceBbox.iHeight;
       
   609 }
       
   610 
       
   611 TBool CSvgUseElementImpl::IsViewable( )
       
   612 {
       
   613 	if (ireferenceEl)
       
   614 	{
       
   615 		return ireferenceEl->IsViewable();
       
   616 	}
       
   617 
       
   618 	return EFalse;
       
   619 }
       
   620 
       
   621 void CSvgUseElementImpl::GetBBox( TGfxRectangle2D& aBbox )
       
   622 {
       
   623 	TGfxRectangle2D lReferenceBbox;
       
   624 	if (ireferenceEl)
       
   625 	{
       
   626 		((CSvgElementImpl*)ireferenceEl)->GetBBox(lReferenceBbox);
       
   627 	}
       
   628 
       
   629 	// width and height
       
   630 	aBbox.iX = lReferenceBbox.iX + X();
       
   631 	aBbox.iY = lReferenceBbox.iY + Y();
       
   632 	aBbox.iWidth = lReferenceBbox.iWidth;
       
   633 	aBbox.iHeight = lReferenceBbox.iHeight;
       
   634 
       
   635 }
       
   636 
       
   637 void CSvgUseElementImpl::Print( TBool aIsEncodeOn )
       
   638 {
       
   639 	if (!aIsEncodeOn)
       
   640 	{
       
   641 		#ifdef _DEBUG
       
   642 		RDebug::Printf("<use x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"hmm\">", (int)iX, (int)iY, (int)iWidth, (int)iHeight/*, Href()*/);
       
   643 		#endif
       
   644 	}
       
   645 }
       
   646 // new function
       
   647 void CSvgUseElementImpl::GetBoundingBox( TGfxRectangle2D& aBbox ) 
       
   648 {
       
   649 	TGfxRectangle2D lReferenceBbox;
       
   650 	if (ireferenceEl != NULL)
       
   651 	{
       
   652 	TGfxAffineTransform lTempCTM = ((CSvgElementImpl*)ireferenceEl)->GetCTM();
       
   653 	TGfxAffineTransform lElementCTM = ((CSvgElementImpl*)this)->GetCTM();
       
   654 	MSvgTransformList*  trList;
       
   655     TGfxAffineTransform lElementTransform;
       
   656     ((CSvgElementImpl*)ireferenceEl)->GetTransform( trList);
       
   657     lElementTransform = trList->Consolidate( ((CSvgElementImpl*)ireferenceEl)->IsOverwriteTransforms() );
       
   658 	lElementTransform.Concatenate(lElementCTM);
       
   659 	
       
   660 	((CSvgElementImpl*)ireferenceEl)->SetCTM(lElementTransform);
       
   661     //((CSvgElementImpl*)ireferenceEl)->GetBBox(lReferenceBbox);
       
   662 	((CSvgElementImpl*)ireferenceEl)->GetUnscaledBBox(lReferenceBbox);
       
   663 	lReferenceBbox.GetBounds(lElementTransform, lReferenceBbox);
       
   664 	
       
   665     ((CSvgElementImpl*)ireferenceEl)->SetCTM(lTempCTM);
       
   666 	}
       
   667 	// width and height
       
   668 	aBbox.iX = lReferenceBbox.iX + X();
       
   669 	aBbox.iY = lReferenceBbox.iY + Y();
       
   670 	aBbox.iWidth = lReferenceBbox.iWidth;
       
   671 	aBbox.iHeight = lReferenceBbox.iHeight;
       
   672 
       
   673 }