svgtopt/SVGTPlugin/src/Svgtplugin.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:  SVGT Plugin Implementation source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <eikenv.h>
       
    22 #include <barsread.h>
       
    23 #include <fbs.h>
       
    24 #include <gdi.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 #include <featmgr.h>
       
    28 
       
    29 #include <eikappui.h>
       
    30 
       
    31 #include <SVGEngineInterfaceImpl.h>
       
    32 
       
    33 #include "Svgtplugin.h"
       
    34 
       
    35 #include "VolumeKeyListener.h"
       
    36 #include "RepositoryVolumeListener.h"
       
    37 
       
    38 _LIT(KWidth, "width");
       
    39 _LIT(KHeight, "height");
       
    40 
       
    41 CSvgtPlugin* CSvgtPlugin::NewL(NPP anInstance)
       
    42 	{
       
    43     CSvgtPlugin *self = new (ELeave) CSvgtPlugin;
       
    44 	CleanupStack::PushL( self );
       
    45 	self->ConstructL(anInstance);
       
    46 
       
    47 	CleanupStack::Pop();
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 
       
    52 CSvgtPlugin::~CSvgtPlugin()
       
    53 	{
       
    54 	if ( iControl )
       
    55 		{
       
    56     	delete iControl;
       
    57     	iControl=NULL;
       
    58     	}
       
    59 
       
    60 	if ( iSvgModule )
       
    61 		{
       
    62 		iSvgModule->Stop();
       
    63 		delete iSvgModule;
       
    64 		iSvgModule = NULL;
       
    65 		}
       
    66 
       
    67 	if ( iRenderBuffer )
       
    68 		{
       
    69 		delete iRenderBuffer;
       
    70 		iRenderBuffer = NULL;
       
    71 		}
       
    72 	
       
    73  	iImageUrlInfoList.ResetAndDestroy();        
       
    74 	iImageUrlInfoList.Close();
       
    75 
       
    76 	if(iKeyListener)
       
    77 	    {
       
    78 	    delete iKeyListener;
       
    79 	    iKeyListener = NULL;
       
    80 	    }
       
    81 
       
    82 	if(iRepositoryListener)
       
    83 	    {
       
    84 	    delete iRepositoryListener;
       
    85 	    iRepositoryListener = NULL;
       
    86 	    }
       
    87 	}
       
    88 
       
    89 void CSvgtPlugin::PrepareToExitL()
       
    90 	{
       
    91 	if (iPluginAdapter)
       
    92 		iPluginAdapter->PluginFinishedL();
       
    93 	}
       
    94 
       
    95 void CSvgtPlugin::ConstructL(NPP anInstance)
       
    96 	{
       
    97   	iInstance=anInstance;
       
    98   	iRenderBuffer = new ( ELeave ) CFbsBitmap();
       
    99 	
       
   100 	iObjectWidth = 0;
       
   101 	iObjectHeight = 0;
       
   102 	// By default obj height is not in percentage
       
   103 	iObjHeightInPercentage = EFalse; 
       
   104 	// By default obj width is not in percentage
       
   105 	iObjWidthInPercentage = EFalse; 
       
   106 	iExpectedDefaultSize = EFalse;
       
   107 	
       
   108 	//While parsing are object width height are specified or not
       
   109 	iObjectWidthSpecified = EFalse;
       
   110 	iObjectHeightSpecified = EFalse;
       
   111 	TFontSpec lFontSpec;
       
   112 	iSvgModule = CSvgEngineInterfaceImpl::NewL( iRenderBuffer, this, lFontSpec );
       
   113 
       
   114   	// Clear background white
       
   115 	iSvgModule->SetBackgroundColor(0xffffffff);
       
   116     iSvgModule->AddHyperlinkListener( this );
       
   117     iAdjusted = EFalse;
       
   118 
       
   119     if (FeatureManager::FeatureSupported(KFeatureIdSideVolumeKeys))
       
   120         {
       
   121         User::InfoPrint(_L("Volume Key supported"));
       
   122         iKeyListener = CVolumeKeyListener::NewL(this);
       
   123    	    }
       
   124    	else
       
   125    	    {
       
   126    	    User::InfoPrint(_L("Key not supported"));
       
   127    	    iRepositoryListener = CRepositoryVolumeListener::NewL(this);
       
   128    	    }
       
   129 	}
       
   130 
       
   131 void CSvgtPlugin::SetWindowL(const NPWindow *aWindow,const TRect& aRect)
       
   132     {
       
   133     iCurrentWindow.x = aWindow->x;
       
   134     iCurrentWindow.y = aWindow->y;
       
   135     iCurrentWindow.window = aWindow->window;
       
   136     iCurrentWindow.clipRect = aWindow->clipRect;
       
   137     iCurrentWindow.type = aWindow->type;
       
   138     iCurrentWindow.width = aWindow->width;
       
   139     iCurrentWindow.height = aWindow->height;
       
   140 
       
   141     iPluginAdapter = static_cast<MPluginAdapter*>(aWindow->window);
       
   142     iParentControl = iPluginAdapter->GetParentControl();
       
   143     if (iControl == NULL)
       
   144         {
       
   145         iControl = new (ELeave) CSvgtPluginControl;
       
   146         iControl->ConstructL(this,iParentControl);
       
   147         iPluginAdapter->PluginConstructedL(iControl);
       
   148         iPluginAdapter->SetPluginNotifier(iControl);
       
   149         }
       
   150 
       
   151 	if ( !iControl || !iSvgModule || aRect.Width() <= 0 || aRect.Height() <= 0 )
       
   152     	{
       
   153 		  return;
       
   154 		  }
       
   155 	iSetWindowCalled = ETrue;
       
   156 	
       
   157 	    iControl->SetRect(aRect);
       
   158 	
       
   159 	if ( iRenderWidth != aRect.Width() ||
       
   160 	     iRenderHeight != aRect.Height() )
       
   161 		{
       
   162 		iRenderWidth = aRect.Width();
       
   163 		iRenderHeight = aRect.Height();
       
   164 		
       
   165 		// Browser initially sends width/height as zero 
       
   166 		// if width/height are not specified
       
   167 		// Later if svg is available to us we call resize after adjustDimention
       
   168 		// But if we dont do adjustDimention quick enough
       
   169 		// Browser sends default width/Height as 300x150
       
   170 		
       
   171 		// To Ensure that we are setting the object width/height and 
       
   172 		// browser is not setting default width/height ahead of us doing resize
       
   173 		
       
   174 		// In adjustDimention if width/height are specified at the browser level
       
   175 		// iAdjusted is set to false, the second condition is to ensure that
       
   176 		// if the browser does a resize at a later point it should be allowed
       
   177 		if(iAdjusted || (iObjectWidthSpecified && iObjectHeightSpecified))
       
   178 		    {
       
   179 		    iObjectWidth  = iRenderWidth;
       
   180             iObjectHeight = iRenderHeight;
       
   181 		    }
       
   182 		iSvgModule->Pause(); //fix for CGSR-7CN7T7
       
   183 		
       
   184 		User::LeaveIfError( iRenderBuffer->Create(
       
   185 							TSize( iRenderWidth, iRenderHeight ), EColor64K ) );
       
   186 		iSvgModule->SetFrameBuffer( iRenderBuffer );
       
   187 		iSvgModule->Resume(); // fix for CGSR-7CN7T7
       
   188 		}
       
   189 
       
   190 
       
   191 		if ( iExpectedDefaultSize )
       
   192 			{
       
   193 			iExpectedDefaultSize = EFalse;
       
   194             AdjustDimention(ETrue,ETrue);
       
   195 			}
       
   196 
       
   197     	if(iControlSize != aRect.Size())
       
   198     		{
       
   199             iRenderWidth = aRect.Width();
       
   200             iRenderHeight = aRect.Height();
       
   201 	    	CFbsBitmap * lTempRenderBuffer = new (ELeave) CFbsBitmap();
       
   202             CleanupStack::PushL(lTempRenderBuffer);
       
   203             User::LeaveIfError( lTempRenderBuffer->Create( TSize(iRenderWidth,iRenderHeight), EColor64K ));
       
   204 			iSvgModule->SetFrameBuffer(lTempRenderBuffer);
       
   205 
       
   206 			delete	iRenderBuffer;
       
   207 			iRenderBuffer = lTempRenderBuffer;
       
   208 			CleanupStack::Pop(lTempRenderBuffer);
       
   209 			lTempRenderBuffer = NULL;
       
   210 			iControlSize = aRect.Size();
       
   211 			iControl->iContentDimension = iSvgModule->ContentDimensions();
       
   212 			}
       
   213         // For autoloading feature.
       
   214             if ( iControl->IsAsFileCalled() && iControl->GetFilename().Length() > 0 &&
       
   215                  !iStartCalled )
       
   216             {
       
   217 
       
   218                     TBool widthInPercentage;
       
   219                     TBool heightInPercentage;
       
   220                     
       
   221 	                iControl->iContentDimension = iSvgModule->ContentDimensionsInPercentage();
       
   222 	                if(iControl->iContentDimension.iWidth == -1 )
       
   223 	                {
       
   224 	                    widthInPercentage = EFalse;
       
   225 	                    if(iSvgModule->SvgDocument())
       
   226 	                    {
       
   227 	                        iControl->iContentDimension.iWidth = iSvgModule->GetViewportWidth(iSvgModule->SvgDocument());    
       
   228 	                    }
       
   229 	                    else
       
   230 	                    {
       
   231 	                        return;
       
   232 	                    }
       
   233 	                    
       
   234 	                }
       
   235 	                else 
       
   236                     {
       
   237 	                    widthInPercentage = ETrue;
       
   238                     }
       
   239                     
       
   240                     if(iControl->iContentDimension.iHeight == -1)
       
   241                     {
       
   242                         heightInPercentage = EFalse;
       
   243                         if(iSvgModule->SvgDocument())
       
   244 	                    {
       
   245 	                        iControl->iContentDimension.iHeight = iSvgModule->GetViewportHeight(iSvgModule->SvgDocument());
       
   246 	                    }
       
   247 	                    else
       
   248 	                    {
       
   249 	                        return;
       
   250 	                    }
       
   251                     }
       
   252                     else
       
   253                     {
       
   254                         heightInPercentage = ETrue;
       
   255                     }
       
   256                     // After loading the content, the width & height will be visible to plugin.
       
   257                     // It is time to adjust the size if needed.
       
   258                     if ( AdjustDimention(widthInPercentage,heightInPercentage) )
       
   259                         {
       
   260                         // dimention change is needed so return and notify Browser.
       
   261                         return;
       
   262                         }
       
   263                     iSvgModule->Start();
       
   264                     		iStartCalled = ETrue;
       
   265             } 
       
   266            
       
   267 	}
       
   268 
       
   269 
       
   270 CSvgtPluginControl* CSvgtPlugin::Control()
       
   271     {
       
   272     return iControl;
       
   273     }
       
   274 
       
   275 NPP CSvgtPlugin::Instance()
       
   276     {
       
   277     return iInstance;
       
   278     }
       
   279 
       
   280 void  CSvgtPlugin::GetSizeOfRenderBuffer(TSize& aSize)
       
   281 	{
       
   282 	if ( iRenderBuffer )
       
   283 		{
       
   284 		aSize = iRenderBuffer->SizeInPixels();
       
   285 		}
       
   286 	else
       
   287 		{
       
   288 		aSize = TSize ( 0, 0 );
       
   289 		}
       
   290 	}
       
   291 
       
   292 
       
   293 
       
   294 /**********************************************************************/
       
   295 //					implements MSvgRequestObserver
       
   296 /**********************************************************************/
       
   297 
       
   298 void CSvgtPlugin::UpdateScreen()
       
   299 	{
       
   300 	iControl->DrawNow();
       
   301 	}
       
   302 
       
   303 
       
   304 TBool CSvgtPlugin::ScriptCall( const TDesC& /*aScript*/,
       
   305                                   CSvgElementImpl* /*aCallerElement*/ )
       
   306 	{
       
   307     return EFalse;
       
   308 	}
       
   309 
       
   310 TBool CSvgtPlugin::LinkEntered( const TDesC& /* aUri */ )
       
   311 {
       
   312     // update mouse pointer here
       
   313     return ETrue;
       
   314 }
       
   315 
       
   316 TBool CSvgtPlugin::LinkExited( const TDesC& /* aUri */ )
       
   317 {
       
   318     // update mouse pointer here
       
   319     return ETrue;
       
   320 }
       
   321 TBool CSvgtPlugin::LinkActivated( const TDesC& aUrl )
       
   322 	{
       
   323 	CSvgtPluginEcomMain* lSvgtPluginEcomMain = (CSvgtPluginEcomMain*) Dll :: Tls ();
       
   324 	NPNetscapeFuncs* lNetscapeFuncs = lSvgtPluginEcomMain->Funcs();
       
   325 	if(lNetscapeFuncs)
       
   326 		{
       
   327         TPtrC lTarget('\0',0);
       
   328         lTarget.Set(_L("_parent"));
       
   329         lNetscapeFuncs->geturl(iInstance,aUrl,&lTarget);
       
   330    		}
       
   331 	return ETrue;
       
   332 	}
       
   333 
       
   334 void CSvgtPlugin::VolumeChanged(TInt aNewValue)
       
   335     {
       
   336    	RDebug::Print(_L("Volume level: %d"), aNewValue);    
       
   337     aNewValue *= 10; //to make the volume in percentage
       
   338     iSvgModule->SetAudioVolume( aNewValue );
       
   339     }
       
   340     
       
   341 TInt CSvgtPlugin::FetchImage(const TDesC&  aUri,  RFs& /*aSession*/, RFile& /*aFileHandle*/ )
       
   342 {
       
   343     TRAPD(err,FetchImageL(aUri));
       
   344     
       
   345     return err;
       
   346     
       
   347 }
       
   348     
       
   349 void CSvgtPlugin::FetchImageL(const TDesC&  aUri)    
       
   350     {
       
   351         TInt    lCount     = iImageUrlInfoList.Count();
       
   352         HBufC*  lListItem  = NULL;
       
   353         HBufC*  lUrl       = NULL;
       
   354                   
       
   355         //checks whether the request is already made for same Uri.        
       
   356         for(TInt i = 0; i < lCount; i++)
       
   357         {
       
   358             lListItem = HBufC::NewLC(iImageUrlInfoList[i]->Length());
       
   359             lUrl      = aUri.AllocLC();
       
   360                  
       
   361             *lListItem = *iImageUrlInfoList[i];
       
   362             
       
   363             // Convert the List Item to Lower case
       
   364             TPtr lListItemPtr = lListItem->Des();
       
   365             lListItemPtr.LowerCase();
       
   366             
       
   367             // Convert the Url to Lower case
       
   368             TPtr lUrlPtr = lUrl->Des();
       
   369             lUrlPtr.LowerCase();
       
   370             
       
   371             if( lListItemPtr.Compare(lUrlPtr) == 0 )       	
       
   372             {
       
   373                 CleanupStack::PopAndDestroy(2);
       
   374                 
       
   375                 lListItem = NULL;
       
   376                 lUrl      = NULL;
       
   377                	// Same Url is already requested in the past, no need to continue.
       
   378               	User::Leave(KErrAlreadyExists); // Indicates the download is pending
       
   379             }
       
   380             
       
   381             CleanupStack::PopAndDestroy(2);
       
   382             
       
   383             lListItem = NULL;
       
   384             lUrl      = NULL;
       
   385         }
       
   386         
       
   387          
       
   388         // --------------------------------------
       
   389 		// Request file from browser
       
   390 		// --------------------------------------
       
   391 		CSvgtPluginEcomMain* lSvgtPluginEcomMain = (CSvgtPluginEcomMain*) Dll :: Tls ();
       
   392 		NPNetscapeFuncs* lNetscapeFuncs = lSvgtPluginEcomMain->Funcs();
       
   393 		if(lNetscapeFuncs)
       
   394 		{
       
   395 			TPtrC lTarget('\0',0);
       
   396 			
       
   397 			lUrl = aUri.AllocL();
       
   398 			
       
   399 			// Current count is used as a context data.
       
   400 			void* contextptr = (void*)(lCount);   
       
   401 			NPError error = lNetscapeFuncs->geturlnotify(iInstance,aUri,NULL,contextptr);		
       
   402 			    
       
   403 			// Add the Url and RequestID to the List
       
   404 			iImageUrlInfoList.Append(lUrl);
       
   405 			    
       
   406 			if ( error != 0 )
       
   407     		{
       
   408                 #ifdef _DEBUG
       
   409                 		lNetscapeFuncs->status(iInstance,_L("Image failed"));
       
   410                 #endif
       
   411                 
       
   412                 User::LeaveIfError(error);
       
   413     		}
       
   414 			#ifdef _DEBUG
       
   415             lNetscapeFuncs->status(iInstance,_L("Downloading Image"));
       
   416             #endif
       
   417 		}
       
   418 	
       
   419         
       
   420         
       
   421         User::Leave(KRequestPending); // Indicate the download is pending
       
   422     }
       
   423 
       
   424 TInt CSvgtPlugin::FetchFont( const TDesC& /* aUri */,  RFs& /* aSession */, RFile&  /* aFileHandle */)
       
   425     {
       
   426 	// Fix for ANAE-775B7E. There is a limitaiton. For rendering text with 
       
   427 	// external font synchronous fetching of the file is needed. But the 
       
   428 	// external font file is fetched asynchronously by browser when we say 
       
   429 	// geturlnotify(). There is no API to pass the font data after fetching
       
   430 	// asynchronously. Hence the code here is removed by returning an error.
       
   431 	return KErrNotFound;
       
   432     }
       
   433 
       
   434 
       
   435 TBool CSvgtPlugin::LinkActivatedWithShow(const TDesC& aUri,const TDesC& /*aShow*/)
       
   436 	{
       
   437 	CSvgtPluginEcomMain* lSvgtPluginEcomMain = (CSvgtPluginEcomMain*) Dll :: Tls ();
       
   438 	NPNetscapeFuncs* lNetscapeFuncs = lSvgtPluginEcomMain->Funcs();
       
   439 	if(lNetscapeFuncs)
       
   440 		{
       
   441         TPtrC lTarget('\0',0);
       
   442         lTarget.Set(_L("_parent"));
       
   443 		lNetscapeFuncs->geturl(iInstance,aUri,&lTarget);
       
   444 		}
       
   445 	return ETrue;
       
   446 	}
       
   447 
       
   448 void CSvgtPlugin::GetSmilFitValue(TDes16 &aSmilValue)
       
   449     {
       
   450     aSmilValue.Copy(_L("meet"));
       
   451     }
       
   452 
       
   453 void CSvgtPlugin::UpdatePresentation(const TInt32&  aNoOfAnimation)
       
   454 	{
       
   455  	if (iTotalNumerOfAnimation < 0)
       
   456   		{
       
   457  		if (aNoOfAnimation != 0)
       
   458 			{
       
   459 			iStaticContent = EFalse;
       
   460 			iTotalNumerOfAnimation = aNoOfAnimation;
       
   461 			}
       
   462 		else
       
   463 			{
       
   464 			iStaticContent = ETrue;
       
   465 			}
       
   466 		}
       
   467  	else
       
   468 		{
       
   469 		iTotalNumerOfAnimation--;
       
   470 		}
       
   471 	}
       
   472 
       
   473 void CSvgtPlugin::GetViewPort(TInt /*getWidth*/, TInt /*getHeight*/, TBool /*isWidthInPer*/, TBool /*isHeightInPer*/, TInt &setWidth, TInt &setHeight)
       
   474 {
       
   475    
       
   476     setWidth = iRenderWidth;    
       
   477     setHeight = iRenderHeight;    
       
   478     
       
   479     iViewPortWidth = setWidth;
       
   480     iViewPortHeight = setHeight;
       
   481 }
       
   482 // ---------------------------------------------------------------------------
       
   483 // This function extracts attributes from the list that is passed from Browser.
       
   484 // Use to check if width & height are defined in XHTML tag
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 NPError CSvgtPlugin::SvgPluginNew(NPMIMEType /*pluginType*/, NPP instance,
       
   488     uint16 /*mode*/, CDesC16Array* argn, CDesC16Array* argv, NPSavedData* )
       
   489     {
       
   490     if (instance->pdata != this)
       
   491         {
       
   492         return NPERR_INVALID_INSTANCE_ERROR;
       
   493         }
       
   494 
       
   495     for (TInt i = 0; i < argn->Count(); i++)
       
   496         {
       
   497         TPtrC16 namePtr((*argn)[i]);
       
   498         TPtrC16 valPtr((*argv)[i]);
       
   499 
       
   500         if (KWidth().FindF(namePtr) == 0)
       
   501             {
       
   502             TLex lString( valPtr );
       
   503             lString.SkipSpace();
       
   504             TInt result = lString.Val(iRenderWidth);
       
   505             // Check if object width was specified as
       
   506             // percentage value.
       
   507             if ( valPtr.Locate( '%' ) != KErrNotFound )
       
   508                 {
       
   509                 // Do not store the value, browser takes
       
   510                 // care of computing the width
       
   511             	iObjWidthInPercentage = ETrue; 
       
   512                 }
       
   513             if (( result != KErrNone) || (iRenderWidth < 0))
       
   514                 {
       
   515                 iObjectWidth = 0;
       
   516                 }
       
   517             else
       
   518             	{
       
   519 	            iObjectWidth = iRenderWidth;
       
   520             	}
       
   521             iObjectWidthSpecified = ETrue;
       
   522             }
       
   523         else if (KHeight().FindF(namePtr) == 0)
       
   524             {
       
   525             TLex lString( valPtr );
       
   526             lString.SkipSpace();
       
   527             TInt result = lString.Val(iRenderHeight);
       
   528             // Check if object height was specified as a
       
   529             // percentage value.
       
   530             if ( valPtr.Locate( '%' ) != KErrNotFound )
       
   531                 {
       
   532                 // Do not store the value, browser takes
       
   533                 // care of computing the height                
       
   534             	iObjHeightInPercentage = ETrue; 
       
   535                 }
       
   536             if (( result != KErrNone) || ( iRenderHeight < 0 ))
       
   537                 {
       
   538                 iObjectHeight = 0;
       
   539                 }
       
   540             else
       
   541            		{
       
   542 	            iObjectHeight = iRenderHeight;
       
   543            		}
       
   544            	iObjectHeightSpecified = ETrue ;
       
   545             }
       
   546         }
       
   547 
       
   548     return NPERR_NO_ERROR;
       
   549     }
       
   550 
       
   551 
       
   552 // ---------------------------------------------------------------------------
       
   553 // ResizeWindow() This function is to notify that a new set of dimention value
       
   554 // should be taken into consideration. The new w&h is determined from
       
   555 // AdjustDimention().
       
   556 //
       
   557 // ---------------------------------------------------------------------------
       
   558 //
       
   559 void CSvgtPlugin::ResizeWindow(TInt aWidth, TInt aHeight)
       
   560     {
       
   561     NPPVariable variable;
       
   562 	CSvgtPluginEcomMain* lSvgtPluginEcomMain = (CSvgtPluginEcomMain*) Dll::Tls();
       
   563 	NPNetscapeFuncs* lNetscapeFuncs = lSvgtPluginEcomMain->Funcs();
       
   564 	NPWindow newWindow;
       
   565     variable = NPPVpluginWindowSize;
       
   566     newWindow.x = iCurrentWindow.x;
       
   567     newWindow.y = iCurrentWindow.y;
       
   568     newWindow.window = iCurrentWindow.window;
       
   569     newWindow.clipRect = iCurrentWindow.clipRect;
       
   570     newWindow.type = iCurrentWindow.type;
       
   571     newWindow.width = aWidth;
       
   572     newWindow.height = aHeight;
       
   573     TInt err = lNetscapeFuncs->setvalue(iInstance, variable, (void*)&newWindow);
       
   574     }
       
   575 
       
   576 
       
   577 // ---------------------------------------------------------------------------
       
   578 // AdjustDimention() This function does the logic to check if width & height
       
   579 // is needed to be adjusted
       
   580 // ---------------------------------------------------------------------------
       
   581 //
       
   582 TBool CSvgtPlugin::AdjustDimention( TBool aWidthInPercentage, TBool aHeightInPercentage)
       
   583     {
       
   584     iSvgModule->AddListener( static_cast < MSvgViewPortListener*>(this), ESvgViewPortListener );
       
   585     if ( iAdjusted )
       
   586     	return EFalse;
       
   587     
       
   588     // we set the width height in all cases except when width/height has been
       
   589     // explicitly specified in the browser hence its set here for all cases
       
   590     iAdjusted = ETrue;
       
   591    // html provides absolute width, no height
       
   592    // svg provides absolute width and absolute height
       
   593    if (
       
   594    ( iObjectWidthSpecified && !iObjWidthInPercentage && !iObjectHeightSpecified ) 
       
   595    && ( !aWidthInPercentage && !aHeightInPercentage)
       
   596    )
       
   597         {
       
   598         // only iObjectWidth is valid
       
   599         // Adjust missing object value as per aspect ratio of 
       
   600         // svg's viewport
       
   601         if(iControl->iContentDimension.iWidth)
       
   602         {
       
   603             TReal newHeight = (TInt)((TReal32)iObjectWidth *
       
   604             ( (TReal32)iControl->iContentDimension.iHeight /
       
   605                 (TReal32)iControl->iContentDimension.iWidth));
       
   606             
       
   607             ResizeWindow(iObjectWidth, newHeight);
       
   608         
       
   609         }
       
   610         return ETrue;
       
   611         }
       
   612     
       
   613    // html provides no width and absolute height
       
   614    // svg provides absolute width and absolute height
       
   615    else if (
       
   616     ( !iObjectWidthSpecified && iObjectHeightSpecified && !iObjHeightInPercentage ) 
       
   617     && ( !aWidthInPercentage && !aHeightInPercentage)
       
   618     )
       
   619         {
       
   620         // only iObjectHeight is valid
       
   621         // Adjust missing object value as per aspect ratio of 
       
   622         // svg's viewport
       
   623         if(iControl->iContentDimension.iHeight)
       
   624         {
       
   625             TInt newWidth = (TInt)((TReal32)iObjectHeight *
       
   626             ( (TReal32)iControl->iContentDimension.iWidth /
       
   627                 (TReal32)iControl->iContentDimension.iHeight));
       
   628             ResizeWindow(newWidth, iObjectHeight);
       
   629             
       
   630         }
       
   631         return ETrue;
       
   632         }
       
   633    // html provides no width and no height
       
   634    // svg provides absolute width and absolute height
       
   635    else if(
       
   636     (!iObjectWidthSpecified && !iObjectHeightSpecified)
       
   637      && ( !aWidthInPercentage && !aHeightInPercentage)
       
   638      )
       
   639         {
       
   640         ResizeWindow(iControl->iContentDimension.iWidth, iControl->iContentDimension.iHeight);
       
   641         return ETrue;
       
   642         }
       
   643    // html provides width and height be it percentages or absolute values
       
   644    else if(iObjectWidthSpecified && iObjectHeightSpecified)
       
   645         {
       
   646         iAdjusted = EFalse;
       
   647         return EFalse;
       
   648         }
       
   649     else
       
   650         {
       
   651         TReal newWidth = 0.0f;
       
   652         TReal newHeight = 0.0f;
       
   653         CEikonEnv* lEnv = STATIC_CAST( CEikonEnv*, iControl->ControlEnv() );
       
   654         
       
   655         TRect lClientRect = TRect( TPoint( 0,0 ), lEnv->EikAppUi()->ClientRect().Size());
       
   656        
       
   657        // if the browser has specified a valid absolute value width
       
   658         if ( !iObjWidthInPercentage && iObjectWidthSpecified)
       
   659             {
       
   660             newWidth = iObjectWidth; 
       
   661             }
       
   662         // if the browser has specified a valid percentage value width
       
   663         else if (iObjWidthInPercentage && iObjectWidthSpecified )
       
   664             {
       
   665             // Compute the new dimension by scaling clientRect dimension
       
   666             newWidth = lClientRect.Width() * iObjectWidth / 100;
       
   667             }
       
   668         // if the browser has specified a valid absolute value height
       
   669         if ( !iObjHeightInPercentage && iObjectHeightSpecified)
       
   670             {
       
   671             newHeight = iObjectHeight;
       
   672             }
       
   673         // if the browser has specified a valid percentage value Height
       
   674         else if(iObjHeightInPercentage && iObjectHeightSpecified)
       
   675             {
       
   676             // Compute the new dimension by scaling clientRect dimension
       
   677             newHeight = lClientRect.Height() * iObjectHeight / 100;
       
   678             }
       
   679             
       
   680         // if the browser has not specified the width
       
   681         if(!iObjectWidthSpecified)
       
   682             {
       
   683             if(aWidthInPercentage)
       
   684                 {
       
   685                 newWidth = lClientRect.Width() * iControl->iContentDimension.iWidth / 100;
       
   686                 }
       
   687             else
       
   688                 {
       
   689                 newWidth = iControl->iContentDimension.iWidth;
       
   690                 }
       
   691             }
       
   692         // if the browser has not specified the height
       
   693         if(!iObjectHeightSpecified)
       
   694             {
       
   695             if(aHeightInPercentage)
       
   696                 {
       
   697                 newHeight = lClientRect.Height() * iControl->iContentDimension.iHeight / 100;
       
   698                 }
       
   699             else
       
   700                 {
       
   701                 newHeight = iControl->iContentDimension.iHeight;
       
   702                 }
       
   703             }
       
   704         ResizeWindow(newWidth, newHeight);
       
   705         return ETrue;   
       
   706         }
       
   707     }
       
   708 
       
   709 TBool CSvgtPlugin::LoadSvgFile( const TDesC& aFilename )
       
   710 	{
       
   711 	if ( !iSvgModule )
       
   712 		{
       
   713 		return EFalse;
       
   714 		}
       
   715 	MSvgError* error = iSvgModule->Load( aFilename );
       
   716 	if ( !error )
       
   717 		{
       
   718 		return EFalse;
       
   719 		}
       
   720 	
       
   721 	// Loading error
       
   722     if ( error->HasError() && !error->IsWarning() )
       
   723         {
       
   724     	return EFalse;
       
   725         }
       
   726     TInt currentVolume;
       
   727     if (FeatureManager::FeatureSupported(KFeatureIdSideVolumeKeys))
       
   728         {
       
   729         currentVolume = iKeyListener->GetCurrentVolume();
       
   730    	    }
       
   731    	else
       
   732    	    {
       
   733         currentVolume = iRepositoryListener->GetCurrentVolume();
       
   734    	    }
       
   735    	    
       
   736    	VolumeChanged(currentVolume );
       
   737     iTotalNumerOfAnimation = -1;
       
   738     return ETrue;
       
   739 	}
       
   740