svgtopt/SVGEngineJI/src/SvgJavaInterfaceImpl.cpp
changeset 46 88edb906c587
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2004 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 #include <SvgJavaInterfaceImpl.h>
       
    19 #include "SVGErrorImpl.h"
       
    20 #include "SVGjsrconstants.h"
       
    21 
       
    22 //utility classes only can be removed in final version
       
    23 #include <hal.h>
       
    24 #include <hal_data.h>
       
    25 #include <imageconversion.h>
       
    26 
       
    27 // ***********************************************************************
       
    28 // Java error
       
    29 // ***********************************************************************
       
    30 
       
    31 // ==========================================================================
       
    32 // Two-phase constructor
       
    33 // ==========================================================================
       
    34 TInt CJavaError::NewL( CSvgErrorImpl& aError )
       
    35     {
       
    36     CJavaError* self = new ( ELeave ) CJavaError();
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL( aError );
       
    39     CleanupStack::Pop();
       
    40     MJavaError* selfInterface = self;
       
    41 	return ( reinterpret_cast<TUint>( selfInterface ) >> 2 );
       
    42     }
       
    43 
       
    44 // ==========================================================================
       
    45 // Destructor
       
    46 // ==========================================================================
       
    47 CJavaError::~CJavaError()
       
    48     {
       
    49     if(iDescription)
       
    50 		{
       
    51 		delete iDescription;
       
    52 		iDescription = NULL;
       
    53 		}
       
    54     }
       
    55 
       
    56 // ==========================================================================
       
    57 // return Etrue if an error is indicated by this object.
       
    58 // ==========================================================================
       
    59 TBool CJavaError::HasError() const
       
    60 {
       
    61     return iErrorCode != KErrNone;
       
    62 }
       
    63 
       
    64 // ==========================================================================
       
    65 // return Etrue if the error indicated by this object is only a warning.
       
    66 // ==========================================================================
       
    67 TBool CJavaError::IsWarning() const
       
    68 {
       
    69     return iIsWarning;
       
    70 }
       
    71 
       
    72 // ==========================================================================
       
    73 // Get the error code.
       
    74 // ==========================================================================
       
    75 TInt CJavaError::ErrorCode() const
       
    76 {
       
    77     return iErrorCode;
       
    78 }
       
    79 
       
    80 // ==========================================================================
       
    81 // Get the error description.
       
    82 // ==========================================================================
       
    83 TDesC8& CJavaError::Description()
       
    84 {
       
    85     return *iDescription;
       
    86 }
       
    87 
       
    88 // ==========================================================================
       
    89 // Second phase of construction
       
    90 // ==========================================================================
       
    91 void CJavaError::ConstructL( CSvgErrorImpl& aError )
       
    92 {
       
    93 	// Error code
       
    94     switch( aError.ErrorCode() )
       
    95     	{
       
    96     	case ESvgInvalidAttributeValue:
       
    97 		case ESvgUnknown:
       
    98     		{
       
    99     		iErrorCode = KJavaIOException;
       
   100     		break;
       
   101 			}
       
   102     	case KErrNoMemory:
       
   103     		{
       
   104     		iErrorCode = KErrNoMemory;
       
   105     		break;
       
   106     		}
       
   107     	default: iErrorCode = KJavaIOException;
       
   108     	}
       
   109 	// Warning
       
   110 	iIsWarning = aError.IsWarning();
       
   111 	// Description
       
   112     iDescription = HBufC8::NewL( aError.Description().Length() + 1);
       
   113     TPtr8 ptr = iDescription->Des();
       
   114 	ptr.Copy( aError.Description() );
       
   115     ptr.ZeroTerminate();
       
   116 	}
       
   117 
       
   118 // ==========================================================================
       
   119 // Constructor
       
   120 // ==========================================================================
       
   121 CJavaError::CJavaError()
       
   122 : iErrorCode( KErrNone ),
       
   123   iIsWarning( EFalse ),
       
   124   iDescription( NULL )
       
   125 {
       
   126 }
       
   127 // ***********************************************************************
       
   128 // SVG Engine
       
   129 // ***********************************************************************
       
   130 
       
   131 EXPORT_C CSvgJavaInterfaceImpl::CSvgJavaInterfaceImpl(): iTempDoc( NULL )
       
   132 {
       
   133 }
       
   134 
       
   135 EXPORT_C CSvgJavaInterfaceImpl* CSvgJavaInterfaceImpl::NewL( TFontSpec& aFontSpec )
       
   136 {
       
   137     CSvgJavaInterfaceImpl* self = new ( ELeave ) CSvgJavaInterfaceImpl();
       
   138     CleanupStack::PushL( self );
       
   139     self->ConstructL(aFontSpec);
       
   140     CleanupStack::Pop();
       
   141     return self;
       
   142 }
       
   143 
       
   144 EXPORT_C CSvgJavaInterfaceImpl* CSvgJavaInterfaceImpl::NewL()
       
   145 {
       
   146     CSvgJavaInterfaceImpl* self = new ( ELeave ) CSvgJavaInterfaceImpl();
       
   147     CleanupStack::PushL( self );
       
   148     self->ConstructL();
       
   149     CleanupStack::Pop();
       
   150     return self;
       
   151 }
       
   152 
       
   153 void CSvgJavaInterfaceImpl::ConstructL( TFontSpec& aFontSpec )
       
   154 {
       
   155     CSvgEngineInterfaceImpl::ConstructL(aFontSpec);
       
   156     iTempDoc = (CSvgDocumentImpl*)SvgDocumentCreateEmpty();
       
   157 
       
   158     AddListener( (MSvgMouseListener*)this, ESvgMouseListener );
       
   159 
       
   160     //TO BE ADDED IN THE FUTURE FOR TEXT AREA AND PROGRESSIVE RENDERING
       
   161     //AddListener( (MSvgTextAreaListener*)this, ESvgTextAreaListener );
       
   162     //AddListener( (MSvgTextListener*)this, ESvgTextListener );
       
   163     //AddListener( (MSvgLoadingListener*)this, ESvgLoadingListener );
       
   164 }
       
   165 
       
   166 void CSvgJavaInterfaceImpl::ConstructL()
       
   167 {
       
   168     CSvgEngineInterfaceImpl::ConstructL();
       
   169     iTempDoc = (CSvgDocumentImpl*)SvgDocumentCreateEmpty();
       
   170 
       
   171     AddListener( (MSvgMouseListener*)this, ESvgMouseListener );
       
   172 
       
   173     //TO BE ADDED IN THE FUTURE FOR TEXT AREA AND PROGRESSIVE RENDERING
       
   174     //AddListener( (MSvgTextAreaListener*)this, ESvgTextAreaListener );
       
   175     //AddListener( (MSvgTextListener*)this, ESvgTextListener );
       
   176     //AddListener( (MSvgLoadingListener*)this, ESvgLoadingListener );
       
   177 }
       
   178 
       
   179 EXPORT_C CSvgJavaInterfaceImpl::~CSvgJavaInterfaceImpl()
       
   180 {
       
   181 	if (iTempDoc)
       
   182 	{
       
   183 		DestroyDocument( iTempDoc );
       
   184 		iTempDoc = NULL;
       
   185 	}
       
   186 }
       
   187 
       
   188 /**
       
   189  * Create an SvgEngine instance.
       
   190  */
       
   191 EXPORT_C SvgEngineHandle CSvgJavaInterfaceImpl::SvgEngineCreate()
       
   192 {
       
   193     CSvgEngineImpl *lSvgEngine = NULL;
       
   194     TRAPD(error,lSvgEngine = SvgEngineNewL());
       
   195     if(error == KErrNone)
       
   196         {
       
   197         return (SvgEngineHandle)lSvgEngine;
       
   198         }
       
   199     return 0;
       
   200 }
       
   201 /**
       
   202  * Request to set render quality.
       
   203  */
       
   204 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineSetRenderQuality( SvgEngineHandle aEngineHandle, TInt aQuality )
       
   205 {
       
   206 	SetRenderQuality( aQuality, aEngineHandle );	
       
   207 }
       
   208 
       
   209 /**
       
   210  * Request to render the SVG document.
       
   211  */
       
   212 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineRenderDocument( SvgEngineHandle aEngineHandle, SvgDocumentHandle aDocumentHandle, TInt aSurfaceHandle, TInt aSurfaceMaskHandle, TReal32 aCurrentTime )
       
   213 {
       
   214     CSvgEngineInterfaceImpl::iFileIsLoaded = ETrue;
       
   215 
       
   216     SetDocument( (CSvgEngineImpl*)aEngineHandle, (CSvgDocumentImpl*)aDocumentHandle );
       
   217 
       
   218     // GfxContext creation
       
   219     TRAPD(error, SetGdiContextL( (CSvgEngineImpl*)aEngineHandle, (CFbsBitmap*)aSurfaceHandle ) );
       
   220     if ( error != KErrNone )
       
   221        {
       
   222        // ignore trap error
       
   223        }
       
   224 
       
   225 	//this udpates things like Viewport with whatever preserveAspectRatio and widths are set
       
   226 	//InitializeEngine((CSvgEngineImpl*)aEngineHandle);
       
   227 
       
   228 	if ( ((CFbsBitmap*)aSurfaceMaskHandle) != NULL)
       
   229 	GenerateMask((CFbsBitmap*)aSurfaceMaskHandle);
       
   230 
       
   231     RenderFrame( (CSvgEngineImpl*)aEngineHandle, (TUint)(aCurrentTime * 1000) );
       
   232 
       
   233 	//utility functions   
       
   234     /*//TDisplayMode lDisplay = ((CFbsBitmap*)aSurfaceHandle)->DisplayMode();
       
   235     
       
   236    	//call it like this:
       
   237 	TBuf<KMaxName> myText;
       
   238 	myText.Copy(_L("Andrew's Test Bitmap"));
       
   239 
       
   240 	ConvertBitmapToFileL((CFbsBitmap*)aSurfaceHandle, myText);
       
   241 	*/
       
   242 }
       
   243 
       
   244 /**
       
   245  *
       
   246  */
       
   247 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineRenderDocumentL( 
       
   248 		SvgEngineHandle aEngineHandle, SvgDocumentHandle aDocumentHandle, 
       
   249 		TInt aSurfaceHandle, const TPoint& aAnchor, const TRect& aRenderArea, TReal32 aCurrentTime, TReal32 aAlpha ) __SOFTFP
       
   250 	{
       
   251     CSvgEngineInterfaceImpl::iFileIsLoaded = ETrue;
       
   252     SetDocument( (CSvgEngineImpl*)aEngineHandle, (CSvgDocumentImpl*)aDocumentHandle );
       
   253 
       
   254 	CFbsBitmap* target = reinterpret_cast<CFbsBitmap*>( aSurfaceHandle );	
       
   255 	CFbsBitmap* source = new ( ELeave ) CFbsBitmap();
       
   256 
       
   257 	User::LeaveIfError( source->Create( 
       
   258 		TSize( SvgDocumentGetViewportWidth( aDocumentHandle ), 
       
   259 		       SvgDocumentGetViewportHeight( aDocumentHandle ) ),
       
   260 			   EColor16MA ) ); 
       
   261 	
       
   262     // GfxContext creation
       
   263     TRAPD(error, SetGdiContextL( (CSvgEngineImpl*)aEngineHandle, source ) );
       
   264     if ( error != KErrNone )
       
   265        {
       
   266        // ignore trap error
       
   267        }
       
   268 
       
   269     RenderFrame( (CSvgEngineImpl*)aEngineHandle, (TUint)(aCurrentTime * 1000) );
       
   270 
       
   271 	source->LockHeap();
       
   272 	target->LockHeap();
       
   273 
       
   274 	// Source 
       
   275 	TUint32* sourceBuffer = source->DataAddress();
       
   276 	const TInt sourceBufferWidth( source->SizeInPixels().iWidth );
       
   277 	
       
   278 	// Target 
       
   279 	TUint32* targetBuffer = target->DataAddress();
       
   280 	const TInt targetBufferWidth( target->SizeInPixels().iWidth );
       
   281 
       
   282 	// Set source buffer x position
       
   283 	if( aAnchor.iX < aRenderArea.iTl.iX ) 
       
   284 		{ 
       
   285 		sourceBuffer += ( aRenderArea.iTl.iX - aAnchor.iX ); 
       
   286 		}
       
   287 	// Set source buffer y position
       
   288 	if( aAnchor.iY < aRenderArea.iTl.iY ) 
       
   289 		{ 
       
   290 		sourceBuffer += sourceBufferWidth * ( aAnchor.iY - aRenderArea.iTl.iY ); 
       
   291 		}
       
   292 
       
   293 	// Set target buffer x position
       
   294 	targetBuffer += aRenderArea.iTl.iX;
       
   295 	// Set target buffer y position
       
   296 	targetBuffer += targetBufferWidth * aRenderArea.iTl.iY;
       
   297 
       
   298 	TInt heightIndex = 0;
       
   299 	TInt widthIndex = 0;
       
   300 	// If fully opaque
       
   301 	if( aAlpha == 1.0f )
       
   302 		{
       
   303 		// Line loop
       
   304 		for( heightIndex = 0; heightIndex < aRenderArea.Height(); heightIndex++ )
       
   305 			{
       
   306 			// Pixel loop
       
   307 			for( widthIndex = 0; widthIndex < aRenderArea.Width(); widthIndex++ )
       
   308 				{
       
   309 				// If alpha channel is not zero then do pixel coping
       
   310 				if( ( 0xff000000 & *sourceBuffer ) != 0x0 ) 
       
   311 					{ 
       
   312 					*targetBuffer = *sourceBuffer;
       
   313 					// Set the alpha value 0xFF 	
       
   314 					*targetBuffer |= 0xff000000;
       
   315 					}
       
   316 				// Next pixel
       
   317 				sourceBuffer++;
       
   318 				targetBuffer++;
       
   319 				}
       
   320 			sourceBuffer = sourceBuffer - aRenderArea.Width() + sourceBufferWidth;
       
   321 			targetBuffer = targetBuffer - aRenderArea.Width() + targetBufferWidth;
       
   322 			}
       
   323 		}
       
   324 	// Partly opaque
       
   325 	else
       
   326 		{
       
   327 
       
   328 		TUint alpha = STATIC_CAST( TUint8, ( aAlpha * 255 ) );
       
   329 		TUint antiAlpha = 255 - alpha;
       
   330 
       
   331 		TUint8* sourcePtr = NULL;
       
   332 		TUint8* targetPtr = NULL;
       
   333 		for( heightIndex = 0; heightIndex < aRenderArea.Height(); heightIndex++ )
       
   334 			{
       
   335 			// Pixel loop
       
   336 			for( widthIndex = 0; widthIndex < aRenderArea.Width(); widthIndex++ )
       
   337 				{
       
   338 				// If alpha channel is not zero then do alpha plending
       
   339 				if( ( 0xff000000 & *sourceBuffer ) != 0x0 ) 
       
   340 					{ 
       
   341 					targetPtr = REINTERPRET_CAST( TUint8*, targetBuffer );
       
   342 					sourcePtr = REINTERPRET_CAST( TUint8*, sourceBuffer );
       
   343 					// Blue component
       
   344 					*targetPtr = ( TUint8 )( ( ( TUint )( *sourcePtr ) * alpha + 
       
   345 											   ( TUint )( *targetPtr ) * antiAlpha ) / 255 ); 
       
   346      				sourcePtr++;
       
   347 					targetPtr++;
       
   348 					// Green component
       
   349 					*targetPtr = ( TUint8 )( ( ( TUint )( *sourcePtr ) * alpha + 
       
   350 											   ( TUint )( *targetPtr ) * antiAlpha ) / 255 ); 
       
   351      				sourcePtr++;
       
   352 					targetPtr++;
       
   353 					// Red component
       
   354 					*targetPtr = ( TUint8 )( ( ( TUint )( *sourcePtr ) * alpha + 
       
   355 											   ( TUint )( *targetPtr ) * antiAlpha ) / 255 ); 
       
   356      				// Alpha component
       
   357 					sourcePtr++;
       
   358 					targetPtr++;
       
   359 					*targetPtr = *sourcePtr;
       
   360 					// Set the alpha value 0xFF	
       
   361 					*targetPtr |= 0xff000000;
       
   362 					}
       
   363 				// Next pixel
       
   364 				sourceBuffer++;
       
   365 				targetBuffer++;
       
   366 				}
       
   367 			// Next line
       
   368 			sourceBuffer = sourceBuffer - aRenderArea.Width() + sourceBufferWidth;
       
   369 			targetBuffer = targetBuffer - aRenderArea.Width() + targetBufferWidth;
       
   370 			}
       
   371 		}
       
   372 		source->UnlockHeap();
       
   373 		target->UnlockHeap();
       
   374 		delete source;
       
   375 
       
   376 	}
       
   377 
       
   378 /**
       
   379  * Request to destroy the given engine by handle.
       
   380  */
       
   381 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineDestroy( SvgEngineHandle aEngineHandle )
       
   382 
       
   383 {
       
   384     DestroyEngine( (CSvgEngineImpl *)aEngineHandle );
       
   385 }
       
   386 
       
   387 /*
       
   388 * Sets the animation back to time 0 and then starts the internal engine timer
       
   389 */
       
   390 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineStart( SvgEngineHandle aEngineHandle )
       
   391 {
       
   392 	Start((CSvgEngineImpl*)aEngineHandle);
       
   393 }
       
   394 
       
   395 /*
       
   396 * Stops the internal SVG engine timer
       
   397 */
       
   398 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineStop( SvgEngineHandle aEngineHandle )
       
   399 {
       
   400 	Stop((CSvgEngineImpl*)aEngineHandle);
       
   401 }
       
   402 
       
   403 /*
       
   404 * Resumes the internal SVG engine timer
       
   405 */
       
   406 EXPORT_C void CSvgJavaInterfaceImpl::SvgEngineResume( SvgEngineHandle aEngineHandle )
       
   407 {
       
   408 	Resume((CSvgEngineImpl*)aEngineHandle);
       
   409 }
       
   410 
       
   411 
       
   412 // *****************************************************************************
       
   413 // *** SVG Rendering Surface Functions
       
   414 // *****************************************************************************
       
   415 /**
       
   416  * Create a Svg Rendering Surface.
       
   417  */
       
   418 
       
   419  // SVG Engine creates the buffer for the surface according width and height. Currently, application gives us the buffer.
       
   420 
       
   421 EXPORT_C SvgSurfaceHandle CSvgJavaInterfaceImpl::SvgRenderingSurfaceCreate( TInt aWidth, TInt aHeight )
       
   422 {
       
   423     // First create the frame buffer with aWidth and aHeight
       
   424     TSize size(aWidth, aHeight);
       
   425 
       
   426     // Can't use ELeave because this function can't leave
       
   427     // Using ELeave but didn't handle (no trap or propagate to parents) causes more confusing.
       
   428     // Check for NULL is good enough.
       
   429     // Ignore CodeScanner error (Code Review Guide)
       
   430     CFbsBitmap *lFrameBuffer = new CFbsBitmap();
       
   431 
       
   432     // Has same effect as using ELeave
       
   433     if ( !lFrameBuffer )
       
   434         {
       
   435         return NULL;
       
   436         }
       
   437 
       
   438     TInt lErrorCode = KErrNone;
       
   439 	TInt displayColors = 256*256;
       
   440 	HAL::Get( HALData::EDisplayColors, displayColors );
       
   441 	if ( displayColors == 256*256*256 )
       
   442     	{
       
   443    		lErrorCode = lFrameBuffer->Create( size, EColor16MU );
       
   444 	    }
       
   445 	else
       
   446 	    {
       
   447    	 	lErrorCode = lFrameBuffer->Create( size, EColor64K );
       
   448 	    }
       
   449 
       
   450     if(lErrorCode != KErrNone)
       
   451         {
       
   452         return NULL;
       
   453         }
       
   454 
       
   455     return (SvgSurfaceHandle) lFrameBuffer;
       
   456 
       
   457 }
       
   458 /**
       
   459  * Destroy a Svg Rendering Surface.
       
   460  */
       
   461 
       
   462 EXPORT_C  void CSvgJavaInterfaceImpl::SvgRenderingSurfaceDestroy( SvgSurfaceHandle aSurface )
       
   463 {
       
   464     if(aSurface)
       
   465         {
       
   466         delete (CFbsBitmap*)aSurface;
       
   467         return;
       
   468         }
       
   469 }
       
   470 /**
       
   471  * Get a pointer to the Svg Rendering surface.
       
   472  */
       
   473 
       
   474 EXPORT_C TUint* CSvgJavaInterfaceImpl::SvgRenderingSurfaceGetBuffer( SvgSurfaceHandle aSurface )
       
   475 {
       
   476     return (TUint*)aSurface;
       
   477 }
       
   478 /**
       
   479  * Get the width of the Svg Rendering Surface.
       
   480  */
       
   481 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgRenderingSurfaceGetWidth( SvgSurfaceHandle aSurface )
       
   482 {
       
   483     if(aSurface)
       
   484         {
       
   485         return ((CFbsBitmap *)aSurface)->SizeInPixels().iWidth;
       
   486         }
       
   487     else
       
   488         {
       
   489         return 0;
       
   490         }
       
   491 }
       
   492 /**
       
   493  * Get the height of the Svg Rendering Surface
       
   494  */
       
   495 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgRenderingSurfaceGetHeight( SvgSurfaceHandle aSurface )
       
   496 {
       
   497     if(aSurface)
       
   498         {
       
   499         return ((CFbsBitmap *)aSurface)->SizeInPixels().iHeight;
       
   500         }
       
   501     else
       
   502         {
       
   503         return 0;
       
   504         }
       
   505 }
       
   506 
       
   507 // ***********************************************************************
       
   508 // SVG Document
       
   509 // ***********************************************************************
       
   510 
       
   511 /**
       
   512  * Create an empty svg document.
       
   513  */
       
   514 EXPORT_C SvgDocumentHandle CSvgJavaInterfaceImpl::SvgDocumentCreateEmpty()
       
   515 {
       
   516     CSvgDocumentImpl *lSvgDoc = NULL;
       
   517     TRAPD(error,lSvgDoc = SvgDocumentNewL());
       
   518     if(error == KErrNone)
       
   519         {
       
   520         }
       
   521 
       
   522      //sets up the root element
       
   523     InitRootElement(lSvgDoc);
       
   524 
       
   525     return ((SvgDocumentHandle)lSvgDoc);
       
   526 }
       
   527 
       
   528 /**
       
   529  * Create a svg document by parsing the given STRING (not file).
       
   530  */
       
   531 EXPORT_C SvgDocumentHandle CSvgJavaInterfaceImpl::SvgDocumentCreateL( const TPtrC16& aString )
       
   532 {
       
   533     CSvgDocumentImpl *lSvgDoc = NULL;
       
   534     TRAPD(error ,lSvgDoc = SvgDocumentNewL());
       
   535     if(error != KErrNone)
       
   536         {
       
   537         	#ifdef _DEBUG
       
   538         	RDebug::Printf("JavaInterfaceImpl: Document Failed to Create");
       
   539         	#endif
       
   540 
       
   541         return NULL;
       
   542         }
       
   543 
       
   544     TRAPD( error2, FillDocumentL( lSvgDoc, aString ) );
       
   545     if(error2 != KErrNone)
       
   546         {
       
   547         // error is set in iSvgError
       
   548         }
       
   549 
       
   550     if( iSvgError && iSvgError->HasError() )
       
   551     	{
       
   552     		if( lSvgDoc != NULL )
       
   553         	{
       
   554 				DestroyDocument(lSvgDoc);
       
   555 				lSvgDoc = NULL;
       
   556         	}
       
   557 
       
   558 		User::Leave( CJavaError::NewL( *iSvgError ) );
       
   559     	}
       
   560 
       
   561     return  ((SvgDocumentHandle)lSvgDoc);
       
   562 }
       
   563 
       
   564 /**
       
   565  * Destroy the given svg document (by handle).
       
   566  */
       
   567 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentDestroy( SvgDocumentHandle aDocumentHandle )
       
   568 {
       
   569     DestroyDocument( (CSvgDocumentImpl*)aDocumentHandle );
       
   570 }
       
   571 
       
   572 /**
       
   573  * Svg Document RequestCompleted
       
   574  */
       
   575  // Returns the data from a resource handler to be attached to
       
   576  // the elements with the corresponding uri
       
   577 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentRequestCompleted( SvgDocumentHandle aDocument, const TPtrC16& aUri, const TPtrC8& aData)
       
   578 {
       
   579     if ( aUri.Length() > 0 && aDocument != NULL)
       
   580     {
       
   581         AddExternalData((CSvgDocumentImpl*)aDocument, aUri, aData, ETrue, aData.Size());
       
   582        
       
   583         return 1;
       
   584     }
       
   585     return 0;
       
   586 }
       
   587 
       
   588 /**
       
   589  * Svg Document GetExternalListItem.
       
   590  */
       
   591  // Returns a character ptr to a URI for the element at (index) in
       
   592  // the external elements list (any item that has a uri or image link)
       
   593 
       
   594 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetExternalListItem(SvgDocumentHandle aDocumentHandle, TInt aIndex, TPtrC16& aItem)
       
   595 {
       
   596     //returns the uri associated with the element(at index) that is requires an external resource
       
   597 
       
   598     if (aIndex < GetExternalListSize( reinterpret_cast< CSvgDocumentImpl* >( aDocumentHandle ) ) )
       
   599     {
       
   600 	  TRAPD(error1, GetExternalListItemL( 
       
   601 				( reinterpret_cast< CSvgDocumentImpl* >( aDocumentHandle ) ), aIndex, aItem ));
       
   602 		
       
   603       return error1; 	    
       
   604     }
       
   605     
       
   606 	return KErrNotFound;		
       
   607 }
       
   608 
       
   609 /**
       
   610  * Svg Document get external list item.
       
   611  */
       
   612  // What is the purpose of this api
       
   613 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetExternalListSize( SvgDocumentHandle aDocumentHandle )
       
   614 {
       
   615     //the total number of external elements requested in the document i.e. the number of uris
       
   616 
       
   617     return (GetExternalListSize((CSvgDocumentImpl*)aDocumentHandle));
       
   618 }
       
   619 
       
   620 /**
       
   621  * Set Media time for the specified document.
       
   622  */
       
   623 EXPORT_C  void CSvgJavaInterfaceImpl::SvgDocumentSetMediaTime( SvgDocumentHandle aDocumentHandle, TReal32 seconds ) __SOFTFP
       
   624 {
       
   625     if(aDocumentHandle)
       
   626         {
       
   627         // this means that the current time for the document needs to be changed.
       
   628         TUint32 lTimeInMilliSeconds = (TUint32)(seconds * 1000);
       
   629         SvgSetMediaTime((CSvgDocumentImpl*)aDocumentHandle , lTimeInMilliSeconds);
       
   630         }
       
   631 }
       
   632 
       
   633 /**
       
   634  * Get Media time for the specified document.
       
   635  */
       
   636 EXPORT_C TReal32 CSvgJavaInterfaceImpl::SvgDocumentGetMediaTime( SvgDocumentHandle aDocumentHandle ) __SOFTFP
       
   637 {
       
   638     if(aDocumentHandle)
       
   639         {
       
   640         TReal32 ltime = SvgGetMediaTime((CSvgDocumentImpl*) aDocumentHandle );
       
   641         // convert in to seconds.
       
   642         if(ltime)
       
   643             {
       
   644             return (ltime / 1000);
       
   645             }
       
   646          // media time is 0
       
   647         }
       
   648     return 0;
       
   649 }
       
   650 
       
   651 /**
       
   652  * Get the viewport width for the given document.
       
   653  */
       
   654 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetViewportWidth( SvgDocumentHandle aDocumentHandle)
       
   655 {
       
   656     return ( aDocumentHandle) ? GetViewportWidth( (CSvgDocumentImpl*)aDocumentHandle ) : 0;
       
   657 }
       
   658 
       
   659 /**
       
   660  * Get the viewport height for the given document.
       
   661  */
       
   662 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetViewportHeight( SvgDocumentHandle aDocumentHandle )
       
   663 {
       
   664     return ( aDocumentHandle) ? GetViewportHeight( (CSvgDocumentImpl*)aDocumentHandle ) : 0;
       
   665 }
       
   666 
       
   667 /**
       
   668  * Set the viewport width for the given document.
       
   669  */
       
   670 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentSetViewportWidth( SvgDocumentHandle aDocumentHandle, TInt aWidth )
       
   671 {
       
   672     if ( aDocumentHandle ) SetViewportWidth( (CSvgDocumentImpl*)aDocumentHandle, aWidth );
       
   673 }
       
   674 
       
   675 /**
       
   676  * Set the viewport height for the given document.
       
   677  */
       
   678 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentSetViewportHeight( SvgDocumentHandle aDocumentHandle, TInt aHeight )
       
   679 {
       
   680     if ( aDocumentHandle ) SetViewportHeight( (CSvgDocumentImpl*)aDocumentHandle, aHeight );
       
   681 }
       
   682 
       
   683 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentViewportInit( SvgDocumentHandle aDocumentHandle )
       
   684 {
       
   685     if ( aDocumentHandle ) ViewportInit( (CSvgDocumentImpl*)aDocumentHandle );
       
   686 }
       
   687 
       
   688 /**
       
   689  * Get the viewport width units for the given document.
       
   690  */
       
   691 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetViewportWidthUnits( SvgDocumentHandle aDocumentHandle )
       
   692 {
       
   693    return ( aDocumentHandle ) ? GetViewportUnits( (CSvgDocumentImpl*)aDocumentHandle ) : 0;
       
   694 }
       
   695 
       
   696 /**
       
   697  * Get the viewport height units for the given document.
       
   698  */
       
   699 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetViewportHeightUnits( SvgDocumentHandle aDocumentHandle)
       
   700 {
       
   701     return ( aDocumentHandle) ? GetViewportUnits( (CSvgDocumentImpl*)aDocumentHandle ) : 0;
       
   702 }
       
   703 
       
   704 /**
       
   705  * Get the root element for the given document.
       
   706  */
       
   707 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgDocumentGetRootElement( SvgDocumentHandle aDocumentHandle )
       
   708 {
       
   709     return (SvgElementHandle)GetRootElement( (CSvgDocumentImpl*)aDocumentHandle );
       
   710 }
       
   711 
       
   712 /**
       
   713  * Get the svg element identified by the given id-string.
       
   714  */
       
   715 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgDocumentGetElementById( SvgDocumentHandle aDocumentHandle, const TPtrC16& aID )
       
   716 {
       
   717     if ( aID.Length() > 0 )
       
   718     {
       
   719         SvgElementHandle elementHandle =
       
   720             (SvgElementHandle)GetElementById( (CSvgDocumentImpl*)aDocumentHandle, aID );
       
   721 
       
   722         return elementHandle;
       
   723     }
       
   724     else
       
   725     {
       
   726         return 0;
       
   727     }
       
   728 }
       
   729 
       
   730 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetNumberOfIds(SvgDocumentHandle aDocumentHandle )
       
   731 {
       
   732     return GetNumberOfIds((CSvgDocumentImpl*)aDocumentHandle);
       
   733 }
       
   734 
       
   735 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentGetId(SvgDocumentHandle aDocumentHandle, TInt index, TPtrC16& aId)
       
   736 {
       
   737     TDesC* myId = GetId((CSvgDocumentImpl*)aDocumentHandle, (TInt)index);
       
   738     if ( myId == NULL )
       
   739         return NULL;
       
   740     
       
   741     aId.Set( *myId );
       
   742 	
       
   743 	return KErrNone;
       
   744 }
       
   745 
       
   746 /**
       
   747  * Set the begin animation time for the given element.
       
   748  */
       
   749 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentBeginElementAt( SvgDocumentHandle aDocumentHandle,
       
   750                                     SvgElementHandle aElementHandle,
       
   751                                     TReal32 aOffsetTime ) __SOFTFP
       
   752 {
       
   753     if(aDocumentHandle)
       
   754         {
       
   755         if(aElementHandle)
       
   756             {
       
   757             // should their be any conversion between the time. ie possible
       
   758             // multiplication. The below conversion is done thinking that the
       
   759             // aOffsetTime value represents the time in seconds.
       
   760             TUint32 lTime = (TUint32)(aOffsetTime * 1000);
       
   761             SvgBeginElementAt( (CXmlElementImpl*)aElementHandle , lTime, (CSvgDocumentImpl*)aDocumentHandle );
       
   762             }
       
   763         }
       
   764 }
       
   765 /**
       
   766  * Set the end animation time for the given element.
       
   767  */
       
   768 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentEndElementAt( SvgDocumentHandle aDocumentHandle,
       
   769                                   SvgElementHandle aElementHandle,
       
   770                                   TReal32 aOffsetTime ) __SOFTFP
       
   771 {
       
   772     if(aDocumentHandle)
       
   773         {
       
   774         if(aElementHandle)
       
   775             {
       
   776             // should their be any conversion between the time. ie possible
       
   777             // multiplication. The below conversion is done thinking that the
       
   778             // aOffsetTime value represents the time in seconds.
       
   779             TUint32 lTime = (TUint32)(aOffsetTime * 1000);
       
   780             SvgEndElementAt((CXmlElementImpl*)aElementHandle , lTime, (CSvgDocumentImpl*)aDocumentHandle );
       
   781             }
       
   782         }
       
   783 }
       
   784 
       
   785 /**
       
   786  * Set the given element to have the focus.
       
   787  */
       
   788 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentFocusOn( SvgDocumentHandle aDocumentHandle,
       
   789                              SvgElementHandle aElementHandle )
       
   790  {
       
   791     if(aDocumentHandle && aElementHandle)
       
   792         {
       
   793         SetFocusElement((CXmlElementImpl*)aElementHandle,(CSvgDocumentImpl*)aDocumentHandle);
       
   794         DispatchFocusInEvent((CSvgDocumentImpl*)aDocumentHandle,(CSvgElementImpl *)aElementHandle);
       
   795         }
       
   796  }
       
   797  
       
   798  
       
   799  /**
       
   800  * Unset the focus from the given element passed as parameter.
       
   801  */
       
   802 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentFocusOut( SvgDocumentHandle aDocumentHandle,
       
   803                              SvgElementHandle aElementHandle)
       
   804  {
       
   805     if(aDocumentHandle && aElementHandle)
       
   806         {
       
   807        	DispatchFocusOutEvent((CSvgDocumentImpl*)aDocumentHandle,(CSvgElementImpl *)aElementHandle);
       
   808         }
       
   809  }
       
   810 
       
   811 /**
       
   812  * Get the element having the focus.
       
   813  */
       
   814 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgDocumentGetFocus( SvgDocumentHandle aDocumentHandle )
       
   815 {
       
   816     if(aDocumentHandle)
       
   817         {
       
   818         return (SvgElementHandle)GetFocusedElement((CSvgDocumentImpl*)aDocumentHandle);
       
   819         }
       
   820     else
       
   821         {
       
   822         return 0;
       
   823         }
       
   824 }
       
   825 
       
   826 /**
       
   827  * Activate the element that has the focus.
       
   828  */
       
   829 EXPORT_C void CSvgJavaInterfaceImpl::SvgDocumentActivate( SvgDocumentHandle aDocumentHandle )
       
   830 {
       
   831     if(aDocumentHandle)
       
   832         {
       
   833         SvgActivateAnimation((CSvgDocumentImpl*)aDocumentHandle);
       
   834         }
       
   835 }
       
   836 
       
   837 /**
       
   838  * Request a mouse event at the given coordinate.
       
   839  */
       
   840 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgDocumentDispatchMouseEvent( SvgDocumentHandle aDocumentHandle,
       
   841                                          TInt aMouseX, TInt aMouseY )
       
   842 {
       
   843     if(aDocumentHandle)
       
   844         {
       
   845         // Dispatch of all mouse events.
       
   846         return (DispatchMouseEventsAt((CSvgDocumentImpl*)aDocumentHandle, aMouseX, aMouseY, (MSvgMouseListener*)this));
       
   847         }
       
   848 
       
   849         return 0;
       
   850 }
       
   851 
       
   852 /**
       
   853  * Check if document has animation.
       
   854  */
       
   855 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgDocumentHasAnimation( SvgDocumentHandle aDocumentHandle )
       
   856 {
       
   857     if(aDocumentHandle)
       
   858         {
       
   859        	 	TBool lValue = SvgHasAnimation((CSvgDocumentImpl*)aDocumentHandle);
       
   860 
       
   861         	if(lValue)
       
   862         	{
       
   863         		return 1;
       
   864         	}
       
   865         }
       
   866         
       
   867     return 0;
       
   868 }
       
   869 
       
   870 /**
       
   871  * Check if element has animation.
       
   872  */
       
   873 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementHasAnimation( SvgElementHandle aElementHandle )
       
   874 {
       
   875     if(aElementHandle)
       
   876         {
       
   877        	 	SvgElementHandle aFirstChildElement = SvgElementGetFirstElementChild(aElementHandle);
       
   878 					
       
   879 					while (aFirstChildElement)
       
   880 					{
       
   881 						if ( IsAnimationElemId( GetElementType((CXmlElementImpl*)aFirstChildElement)) )
       
   882 						{
       
   883 							return 1;
       
   884 						}
       
   885 						
       
   886 						aFirstChildElement = SvgElementGetNextElementSibling( aFirstChildElement );
       
   887 					}
       
   888         }
       
   889 
       
   890     return 0;
       
   891 }
       
   892 
       
   893 // ***********************************************************************
       
   894 // SVG Element
       
   895 // ***********************************************************************
       
   896 
       
   897 /**
       
   898  * Create a new svg element of the given tag string and append to the given
       
   899  * svg element parent.
       
   900  */
       
   901 
       
   902 
       
   903 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgElementCreate( SvgAttrType aType )
       
   904 {
       
   905 	TInt lElementId = SvgGetElementTypeMappingJSRtoSVG(aType);
       
   906 
       
   907     CXmlElementImpl* newChild = NULL;
       
   908 
       
   909         TRAPD( error, newChild = CreateElementL( iTempDoc, lElementId ) );
       
   910         if(error != KErrNone)
       
   911         {
       
   912            return 0;
       
   913         }
       
   914 
       
   915         //AppendChild( GetRootElement( iTempDoc ), newChild);
       
   916         // Alan
       
   917         TRAPD(err3, InitSvgStylePropertiesWithNullL((CSvgElementImpl*)newChild));
       
   918         if ( err3 != KErrNone )
       
   919         {
       
   920            return NULL;
       
   921         }
       
   922 
       
   923         return (SvgElementHandle)newChild;
       
   924 }
       
   925 
       
   926 /**
       
   927  * Destroy svg element of the given handle.
       
   928  */
       
   929 EXPORT_C void  CSvgJavaInterfaceImpl::SvgElementDestroy( SvgElementHandle aElementHandle )
       
   930 {
       
   931 		if(aElementHandle )
       
   932     {
       
   933     CXmlElementImpl *lParentNode =
       
   934         (CXmlElementImpl*)GetParentElement( (CXmlElementImpl*)aElementHandle );
       
   935     if(lParentNode)
       
   936         {
       
   937         RemoveChild( (CXmlElementImpl*)lParentNode, (CXmlElementImpl*)aElementHandle );
       
   938         }
       
   939     DestroyElement( (CXmlElementImpl*)aElementHandle );
       
   940     }
       
   941 }
       
   942 
       
   943 /**
       
   944  * Get the parent element for the given svg element.
       
   945  */
       
   946 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgElementGetParent( SvgElementHandle aElementHandle )
       
   947 {
       
   948     return ( aElementHandle ) ? (SvgElementHandle)GetParentElement( (CXmlElementImpl*)aElementHandle ) : NULL;
       
   949 }
       
   950 /**
       
   951  * Get the first child element for the given svg element.
       
   952  */
       
   953 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgElementGetFirstElementChild( SvgElementHandle aElementHandle )
       
   954 {
       
   955     return ( aElementHandle ) ? (SvgElementHandle)GetFirstChild( (CXmlElementImpl*)aElementHandle ) : NULL;
       
   956 }
       
   957 
       
   958 /**
       
   959  * Get the next sibling element for the given svg element.
       
   960  */
       
   961 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgElementGetNextElementSibling( SvgElementHandle aElementHandle )
       
   962 {
       
   963     return ( aElementHandle ) ? (SvgElementHandle)GetNextSibling( (CXmlElementImpl*)aElementHandle ) : NULL;
       
   964 }
       
   965 
       
   966 /**
       
   967  * Append the given child element to the given svg element.
       
   968  */
       
   969 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementAppendChild( SvgElementHandle aElementHandle,
       
   970                              SvgElementHandle aChildElementHandle )
       
   971 {
       
   972     if ( aElementHandle )
       
   973         {
       
   974         AppendChild( (CXmlElementImpl*)aElementHandle,
       
   975                                   (CXmlElementImpl*)aChildElementHandle, ETrue );
       
   976         }
       
   977 }
       
   978 /**
       
   979  * Remove the given child element from the given svg element.
       
   980  */
       
   981 EXPORT_C SvgElementHandle CSvgJavaInterfaceImpl::SvgElementRemoveChild( SvgElementHandle aElementHandle,
       
   982                                  SvgElementHandle aChildElementHandle )
       
   983 {
       
   984     if(aElementHandle)
       
   985         {
       
   986         RemoveChild( (CXmlElementImpl*)aElementHandle,
       
   987                      (CXmlElementImpl*)aChildElementHandle );
       
   988         }
       
   989      return aChildElementHandle;
       
   990 }
       
   991 /**
       
   992  * Add the given child element to the given svg element, before
       
   993  * the given reference element.
       
   994  */
       
   995 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementInsertBefore( SvgElementHandle aElementHandle,
       
   996                               SvgElementHandle aChildElementHandle,
       
   997                               SvgElementHandle aReferenceElementHandle )
       
   998 {
       
   999     if ( aReferenceElementHandle )
       
  1000     {
       
  1001         CXmlElementImpl* lTempChild = GetFirstChild( (CXmlElementImpl*)aElementHandle );
       
  1002 
       
  1003     	if (lTempChild == (CXmlElementImpl*)aReferenceElementHandle)
       
  1004     	{
       
  1005     		//the first child happens to be the reference child to insert before
       
  1006 
       
  1007     		//set the parent up for the new child
       
  1008     		SetParentElement( (CXmlElementImpl*)aChildElementHandle,
       
  1009                               (CXmlElementImpl*)aElementHandle );
       
  1010 
       
  1011            	SetFirstChildElement( (CXmlElementImpl*)aChildElementHandle,
       
  1012            							(CXmlElementImpl*)aElementHandle );
       
  1013 
       
  1014            	//set the new child up in front of the reference sibling
       
  1015             SetNextSibling( (CXmlElementImpl*)aChildElementHandle, lTempChild  );
       
  1016 
       
  1017             return;
       
  1018     	}
       
  1019 
       
  1020         while ( lTempChild && GetNextSibling( lTempChild ) !=
       
  1021                 (CXmlElementImpl*)aReferenceElementHandle )
       
  1022         {
       
  1023             lTempChild = GetNextSibling( lTempChild );
       
  1024         }
       
  1025         if ( lTempChild != NULL )
       
  1026         {
       
  1027             SetParentElement( (CXmlElementImpl*)aChildElementHandle,
       
  1028                               (CXmlElementImpl*)aElementHandle );
       
  1029             SetNextSibling( lTempChild, (CXmlElementImpl*)aChildElementHandle );
       
  1030             SetNextSibling( (CXmlElementImpl*)aChildElementHandle,
       
  1031                             (CXmlElementImpl*)aReferenceElementHandle );
       
  1032         }
       
  1033     }
       
  1034 }
       
  1035 
       
  1036 /**
       
  1037  * Request element type.
       
  1038  */
       
  1039 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetType( SvgElementHandle aElementHandle )
       
  1040 {
       
  1041     return ( !aElementHandle ) ? 0 :
       
  1042         SvgGetElementTypeMappingSVGtoJSR( GetElementType( (CXmlElementImpl*)aElementHandle ) );
       
  1043 }
       
  1044 
       
  1045 /**
       
  1046  * Get a string attribute from the given element.
       
  1047  * returning 16 bit characters now instead of 8 bit ones that the original JSR used...
       
  1048  */
       
  1049 
       
  1050 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetStringAttribute( SvgElementHandle aElementHandle,
       
  1051                                         SvgAttrType aAttributeName, TPtrC16& aStrAttribute )
       
  1052 {
       
  1053 	 if(aElementHandle)
       
  1054    {
       
  1055 	   		TInt lSvgAttrId =
       
  1056 				SvgGetAttributeTypeMappingJSRtoSVG(aAttributeName);
       
  1057 	  		if(lSvgAttrId != KSvgUnknownAttribute)
       
  1058       		{
       
  1059 	        		return ( GetElementDesAttribute( ( CSvgElementImpl* )aElementHandle, lSvgAttrId, aStrAttribute ) );
       
  1060       		}
       
  1061 		}
       
  1062    	return KErrNotFound;
       
  1063 }
       
  1064 
       
  1065 /**
       
  1066  * Set a string attribute on the given element.
       
  1067  */
       
  1068 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetStringAttribute( SvgElementHandle aElementHandle,
       
  1069                                         SvgAttrType aAttributeName,
       
  1070                                         const TPtrC16& aAttributeValue )
       
  1071 {
       
  1072 
       
  1073 if(aElementHandle)
       
  1074     {
       
  1075     TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttributeName);
       
  1076     if(lSvgAttrId != KSvgUnknownAttribute)
       
  1077         {
       
  1078         // This will not work with the animation elements.
       
  1079             SetElementDesAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId, aAttributeValue);
       
  1080         }
       
  1081     }
       
  1082 return ;
       
  1083 }
       
  1084 
       
  1085 /**
       
  1086  * Get a color attribute from the given element.
       
  1087  * The values are copied into the color object given.
       
  1088  */
       
  1089 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetColorAttribute( SvgElementHandle aElementHandle,
       
  1090                                    SvgAttrType aAttribute,
       
  1091                                    TInt* aRedValue, TInt* aGreenValue, TInt* aBlueValue )
       
  1092 {
       
  1093     if(aElementHandle)
       
  1094     {
       
  1095         TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute);
       
  1096         // find if it is a valid attribute.
       
  1097         if(lSvgAttrId != KSvgUnknownAttribute)
       
  1098         {
       
  1099             TInt32 lColorValue;
       
  1100 
       
  1101             // now the rgb values need to be fused. for this we take the
       
  1102             // least significant 8 bits of each integer.
       
  1103 
       
  1104             lColorValue = GetElementColorAttribute((CSvgElementImpl*) aElementHandle,lSvgAttrId);
       
  1105 
       
  1106             // extract the 8-bits corressponding to the specific color attribute.
       
  1107             // the color is in BGR format so
       
  1108 
       
  1109 			//KGfxColorNull == 0x1ffffff
       
  1110             if (lColorValue == 0x1ffffff)
       
  1111             {
       
  1112             	  *aBlueValue = -1; //Initialize BGR values
       
  1113             	  *aGreenValue = -1;
       
  1114             	  *aRedValue = -1;
       
  1115             }
       
  1116 
       
  1117 			//KSvgCurrentColor = 0x2ffffff
       
  1118 						else if (lColorValue == 0x2ffffff)
       
  1119 						{
       
  1120 							*aBlueValue = 0; //Initialize BGR values
       
  1121             	*aGreenValue = 0;
       
  1122             	*aRedValue = 0;
       
  1123 						}
       
  1124 
       
  1125 			//KErrNoAttribute
       
  1126 			else if (lColorValue == -10 && (aAttribute == AT_FILL)  )
       
  1127 			{
       
  1128 				*aBlueValue = 0;
       
  1129 				*aGreenValue = 0;
       
  1130 				*aRedValue = 0;
       
  1131 			}
       
  1132 			else if (lColorValue == -10 && (aAttribute == AT_STROKE) )
       
  1133 			{
       
  1134 				*aBlueValue = -1;
       
  1135 				*aGreenValue = -1;
       
  1136 				*aRedValue = -1;
       
  1137 			}
       
  1138 
       
  1139 			else if (lColorValue == -10 && (aAttribute == AT_COLOR) )
       
  1140 			{
       
  1141 				*aBlueValue = 0;
       
  1142 				*aGreenValue = 0;
       
  1143 				*aRedValue = 0;
       
  1144 			}
       
  1145             else if (lColorValue != KInvalidEnumAttribute)
       
  1146             {
       
  1147                 *aRedValue = ( lColorValue >> 16 ) & 0x0000ff;
       
  1148                 *aGreenValue = ( lColorValue >> 8 ) & 0x0000ff;
       
  1149                 *aBlueValue = lColorValue & 0x0000ff;
       
  1150             }
       
  1151             return 0;
       
  1152         }
       
  1153     }
       
  1154     return -1;
       
  1155 }
       
  1156 
       
  1157 /**
       
  1158  * Set a color attribute for the given element.
       
  1159  */
       
  1160 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetColorAttribute( SvgElementHandle aElementHandle,
       
  1161                                    SvgAttrType aAttribute,
       
  1162                                    TInt aRedValue, TInt aGreenValue, TInt aBlueValue )
       
  1163 
       
  1164 {
       
  1165     if(aElementHandle)
       
  1166         {
       
  1167         TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute);
       
  1168         // find if it is a valid attribute.
       
  1169         if(lSvgAttrId != KSvgUnknownAttribute)
       
  1170             {
       
  1171             TInt32 lColorValue;
       
  1172 
       
  1173             // now the rgb values need to be fused. for this we take the
       
  1174             // least significant 8 bits of each integer.
       
  1175 
       
  1176             TInt32 red = aRedValue & 0x0000ff;
       
  1177             TInt32 green = aGreenValue & 0x0000ff;
       
  1178             TInt32 blue = aBlueValue & 0x0000ff;
       
  1179 
       
  1180             lColorValue = (((red << 16) | green << 8) | blue);
       
  1181 
       
  1182 
       
  1183             SetElementColorAttribute((CSvgElementImpl*) aElementHandle,lSvgAttrId,lColorValue);
       
  1184             }
       
  1185         }
       
  1186 }
       
  1187 
       
  1188 /**
       
  1189  * Get a float attribute value.
       
  1190  */
       
  1191 EXPORT_C TReal32 CSvgJavaInterfaceImpl::SvgElementGetFloatAttribute( SvgElementHandle aElementHandle,
       
  1192                                     SvgAttrType aAttribute ) __SOFTFP
       
  1193 
       
  1194 {
       
  1195 	if(aElementHandle)
       
  1196     {
       
  1197      TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute);
       
  1198      // The following function can not be called for the animation elements
       
  1199      		if(lSvgAttrId != KSvgUnknownAttribute)
       
  1200      		{
       
  1201         	TReal32 lValue = GetElementFloatAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId);
       
  1202 
       
  1203         	return lValue;
       
  1204       	}
       
  1205     }
       
  1206 	return KInvalidFloatAttribute;
       
  1207 }
       
  1208 
       
  1209 /**
       
  1210  * Set a float attribute value.
       
  1211  */
       
  1212 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetFloatAttribute( SvgElementHandle aElementHandle,
       
  1213                                    SvgAttrType aAttribute,
       
  1214                                    TReal32 aFloatValue ) __SOFTFP
       
  1215 {
       
  1216 	if(aElementHandle)
       
  1217     {
       
  1218      TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute);
       
  1219      // The following function can not be called for the animation elements
       
  1220      if(lSvgAttrId != KSvgUnknownAttribute)
       
  1221         {
       
  1222         SetElementFloatAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId, aFloatValue);
       
  1223         }
       
  1224     }
       
  1225 	return;
       
  1226 }
       
  1227 
       
  1228 /**
       
  1229  * Set enum attribute value.
       
  1230  */
       
  1231 EXPORT_C void  CSvgJavaInterfaceImpl::SvgElementSetEnumAttribute( SvgElementHandle aElementHandle,
       
  1232                                      SvgAttrType aAttribute, short aValue)
       
  1233 {
       
  1234    /**********************************************************
       
  1235     // this function needs mapping of the enumeration values.
       
  1236     // preserve aspect ratio
       
  1237     // Zoom And Pan
       
  1238     // Paint ? is it fill or stroke.
       
  1239     // Fonts
       
  1240     // Font_Style
       
  1241     // Font_weight
       
  1242     // Font_stretch
       
  1243     // Text_Anchor
       
  1244     // Font_Size
       
  1245     // Fill_Rule
       
  1246     // Display
       
  1247     // Visibility
       
  1248     // Color-rendering          // This is not supported in the SVGEngine.
       
  1249     // Strokes
       
  1250     // accumulate
       
  1251     // additive
       
  1252     // calc_mode
       
  1253     // fill
       
  1254     // restart
       
  1255     // type (animate Transform)
       
  1256     // attributeType
       
  1257     ********************************************************/
       
  1258     if(aElementHandle)
       
  1259         {
       
  1260         //TInt32 lValue = 0;
       
  1261         
       
  1262         TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute);
       
  1263         if(lSvgAttrId != KSvgUnknownAttribute)
       
  1264             {
       
  1265 			TInt lValue = SvgEnumerationMappingJSRtoSVG(lSvgAttrId , (TInt)aValue);
       
  1266 			/*
       
  1267             lValue = SvgEnumerationMappingJSRtoSVG(lSvgAttrId , (TInt)aValue);
       
  1268             
       
  1269             if ( lValue == KErrNotFound && aValue == ATTRIBUTE_INHERIT ) 
       
  1270                 lValue = KSVGAttributeInherit;*/
       
  1271             if(lSvgAttrId == KCSS_ATTR_FONTSIZE)
       
  1272                 {
       
  1273                 if(lValue != KErrNotFound)
       
  1274                     {
       
  1275                     // font is internally considered to be a float.
       
  1276 
       
  1277                     SetElementFloatAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId, (TReal32)lValue);
       
  1278                     return;
       
  1279                     }
       
  1280                 return;
       
  1281                 }
       
  1282             if(lValue == KErrNotFound)
       
  1283                 {
       
  1284                 TBuf<40> lValueDes;
       
  1285                 TInt lResult = SvgEnumerationtoStringMappingJSRtoSVG(lSvgAttrId , aValue ,lValueDes);
       
  1286                 if(lResult == KErrNotFound)
       
  1287                     {
       
  1288                     // this is not valid Attribute.
       
  1289                     return;
       
  1290                     }
       
  1291                 else
       
  1292                     {
       
  1293                     SetElementDesAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId,lValueDes );
       
  1294                     return;
       
  1295                     }
       
  1296                 // Call for the string Attribute.
       
  1297                 }
       
  1298             SetEnumAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId,lValue);
       
  1299             }
       
  1300         }
       
  1301 }
       
  1302 
       
  1303 /**
       
  1304  * Get enum attribute value.
       
  1305  */
       
  1306 EXPORT_C short CSvgJavaInterfaceImpl::SvgElementGetEnumAttribute( SvgElementHandle aElementHandle,
       
  1307                                      SvgAttrType aAttribute )
       
  1308 {
       
  1309         if(aElementHandle)
       
  1310         {
       
  1311         TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute);
       
  1312         if(lSvgAttrId != KSvgUnknownAttribute)
       
  1313             {
       
  1314             // following swicth is for all the attributes for which constants
       
  1315             // are specified in Svgjsrconstants.h
       
  1316             TInt32 lValue = KErrNone;
       
  1317             if( lSvgAttrId == KCSS_ATTR_FILLRULE ||
       
  1318             lSvgAttrId == KCSS_ATTR_STROKE_LINECAP ||
       
  1319             lSvgAttrId == KCSS_ATTR_STROKE_LINEJOIN )
       
  1320                 {
       
  1321                 TPtrC16 lValue;
       
  1322                 GetElementDesAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId,lValue);
       
  1323                 TInt lResult = SvgStringtoEnumerationMappingSVGtoJSR(lSvgAttrId , lValue );
       
  1324                 return ( short )lResult;
       
  1325                 }
       
  1326             else
       
  1327                 {
       
  1328                 if(lSvgAttrId == KCSS_ATTR_FONTSIZE)
       
  1329                     {
       
  1330                     if(lValue != KErrNotFound)
       
  1331                         {
       
  1332                         // font is internally considered to be a float.
       
  1333                         TReal32 lValue = GetElementFloatAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId);
       
  1334                         return short (lValue) ;
       
  1335                         }
       
  1336                     return KInvalidEnumAttribute;
       
  1337                     }
       
  1338                 TInt lResult = GetEnumAttribute((CSvgElementImpl*)aElementHandle, lSvgAttrId , lValue);
       
  1339                 if(lResult == KErrNotFound)
       
  1340                     {
       
  1341                     return KInvalidEnumAttribute;
       
  1342                     }
       
  1343                 else
       
  1344                     {
       
  1345                      TInt value = SvgEnumerationMappingSVGtoJSR(lSvgAttrId , lValue);
       
  1346                     return (short) value;
       
  1347                     }
       
  1348                 }
       
  1349             }
       
  1350         }
       
  1351         return 0;
       
  1352 }
       
  1353 
       
  1354 /**
       
  1355  * Get the rectangle attribute value.
       
  1356  */
       
  1357 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetRectAttribute( SvgElementHandle aElementHandle,
       
  1358                                   SvgAttrType /*aRectAttribute*/,
       
  1359                                   TReal32* aX, TReal32* aY, TReal32* aWidth, TReal32* aHeight ) __SOFTFP
       
  1360 {
       
  1361    if ( aElementHandle )
       
  1362    {
       
  1363         if (!GetRectAttribute( (CXmlElementImpl*) aElementHandle, aX,
       
  1364                                                     aY, aWidth, aHeight ))
       
  1365         {
       
  1366 					return -1;
       
  1367 				}
       
  1368 				
       
  1369         if ( aX != NULL )
       
  1370         {
       
  1371             return 1;
       
  1372         }
       
  1373     }
       
  1374    return -1;
       
  1375 }
       
  1376 
       
  1377 /**
       
  1378  * Set the rectangle attribute value.
       
  1379  */
       
  1380 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetRectAttribute( SvgElementHandle aElementHandle,
       
  1381                                   SvgAttrType /*aRectAttribute*/,
       
  1382                                   TReal32 aX, TReal32 aY, TReal32 aWidth, TReal32 aHeight ) __SOFTFP
       
  1383 {
       
  1384    if ( aElementHandle ) SetRectAttribute( (CXmlElementImpl*) aElementHandle, aX,
       
  1385                                                      aY, aWidth, aHeight );
       
  1386 }
       
  1387 
       
  1388 /**
       
  1389  * Get the matrix attribute value.
       
  1390  */
       
  1391 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetMatrixAttribute( SvgElementHandle aElementHandle,
       
  1392                                     SvgAttrType aMatrixAttribute,
       
  1393                                     TReal32* aAVal, TReal32* aBVal, TReal32* aCVal,
       
  1394                                     TReal32* aDVal, TReal32* aEVal, TReal32* aFVal ) __SOFTFP
       
  1395 {
       
  1396    if ( aElementHandle == NULL )
       
  1397    {
       
  1398        return -1;
       
  1399    }
       
  1400    
       
  1401    if( aMatrixAttribute == AT_TRANSFORM) // request to get transform for the element
       
  1402    {
       
  1403       aMatrixAttribute = SvgGetAttributeTypeMappingJSRtoSVG(aMatrixAttribute);
       
  1404    	  GetMatrixAttribute( (CXmlElementImpl*) aElementHandle, aMatrixAttribute, aAVal,
       
  1405                            aBVal, aCVal, aDVal, aEVal, aFVal );
       
  1406    }
       
  1407    else // request for CTM
       
  1408    {
       
  1409        GetMatrixAttribute( (CXmlElementImpl*) aElementHandle, aAVal,
       
  1410                            aBVal, aCVal, aDVal, aEVal, aFVal );
       
  1411    }
       
  1412    
       
  1413 
       
  1414    return 0;
       
  1415 }
       
  1416 
       
  1417 /**
       
  1418  * Set the matrix attribute value.
       
  1419  */
       
  1420 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetMatrixAttribute( SvgElementHandle aElementHandle,
       
  1421                                     SvgAttrType /*aMatrixAttribute*/,
       
  1422                                     TReal32 aAVal, TReal32 aBVal, TReal32 aCVal,
       
  1423                                     TReal32 aDVal, TReal32 aEVal, TReal32 aFVal ) __SOFTFP
       
  1424 {
       
  1425    if ( aElementHandle ) SetMatrixAttribute( (CXmlElementImpl*) aElementHandle, aAVal,
       
  1426                                                       aBVal, aCVal, aDVal, aEVal, aFVal );
       
  1427 }
       
  1428 
       
  1429 /**
       
  1430  * Get the path attribute value.
       
  1431  */
       
  1432 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetPathAttribute( SvgElementHandle aElementHandle,
       
  1433                                                         SvgAttrType aPathAttribute )
       
  1434 {
       
  1435     //  The attributeId must be one of the following.
       
  1436     //  KAtrD, KAtrTo, KAtrFrom, KAtrBy, KAtrPath
       
  1437     TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aPathAttribute);
       
  1438 
       
  1439     return (TInt)GetPathAttribute((CXmlElementImpl*) aElementHandle, lSvgAttrId);
       
  1440 }
       
  1441 
       
  1442 /**
       
  1443  * Get the bounding box rectangle attribute value.
       
  1444  */
       
  1445 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementGetBBox( SvgElementHandle aElementHandle,
       
  1446                             SvgAttrType /*aAttributeType*/,
       
  1447                             TReal32* aX, TReal32* aY, TReal32* aWidth, TReal32* aHeight ) __SOFTFP
       
  1448 {
       
  1449     if(aElementHandle)
       
  1450         {
       
  1451         TReal32 lX ,lY,lWidth,lHeight;
       
  1452         GetElementUnScaledBoundingBox((CSvgElementImpl*)aElementHandle,lX ,lY,lWidth,lHeight);
       
  1453         *aX = lX;
       
  1454         *aY = lY;
       
  1455         *aWidth = lWidth;
       
  1456         *aHeight = lHeight;
       
  1457         }
       
  1458 }
       
  1459 
       
  1460 /**
       
  1461  * Add event listener to the given element.
       
  1462  * Note: need to replace void* with specific class
       
  1463  */
       
  1464 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementAddEventListener( SvgElementHandle aElementHandle,
       
  1465                                         TInt /*aListener*/, SvgAttrType /*aType*/ )
       
  1466 {
       
  1467     if(aElementHandle)
       
  1468         {
       
  1469         // by default we have added the KEventExternalUI as the mask type.
       
  1470 
       
  1471         // aListener how do you convert this to the SVGEngien's event Mask.
       
  1472         const TUint8 aEventMask = KSvgEventMaskExternalUI;
       
  1473         AddToEventReceiverList((CXmlElementImpl*) aElementHandle, aEventMask);
       
  1474         }
       
  1475 }
       
  1476 
       
  1477 /**
       
  1478  * Remove event listener from the given element.
       
  1479  * Note: need to replace void* with specific class
       
  1480  */
       
  1481 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementRemoveEventListener( SvgElementHandle aElementHandle,
       
  1482                                         TInt /*aListener*/, SvgAttrType /*aType*/ )
       
  1483 {
       
  1484     if(aElementHandle)
       
  1485         {
       
  1486         RemoveFromEventReceiverList((CXmlElementImpl*)aElementHandle);
       
  1487         }
       
  1488 }
       
  1489 
       
  1490 /**
       
  1491  * Check if element is active.
       
  1492  */
       
  1493 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementIsActive( SvgElementHandle aElementHandle )
       
  1494 {
       
  1495     CSvgElementImpl* hElement = (CSvgElementImpl*)aElementHandle;
       
  1496 
       
  1497     return (IsElementActive( hElement ));
       
  1498 }
       
  1499 
       
  1500 /**
       
  1501  * Check removable element.
       
  1502  * any element that doesnt have an id and its children dont have ids
       
  1503 */
       
  1504 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementCheckRemoveable( SvgElementHandle aElementHandle )
       
  1505 {
       
  1506     CSvgElementImpl* hElement = (CSvgElementImpl*)aElementHandle;
       
  1507 
       
  1508     return (IsRemoveable(hElement));
       
  1509 }
       
  1510 
       
  1511 // ***********************************************************************
       
  1512 // SVG Path
       
  1513 // ***********************************************************************
       
  1514 
       
  1515 /**
       
  1516  * Create an empty path
       
  1517  */
       
  1518 EXPORT_C SvgPathHandle CSvgJavaInterfaceImpl::SvgPathCreate()
       
  1519 {
       
  1520     return (SvgPathHandle) SvgCreatePath();
       
  1521 }
       
  1522 
       
  1523 /**
       
  1524  * Destroy the specified path path
       
  1525  */
       
  1526 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathDestroy( SvgPathHandle aPathHandle )
       
  1527 {
       
  1528  	if(aPathHandle)
       
  1529     {
       
  1530     SvgDestroyPath((CGfxGeneralPath*)aPathHandle);
       
  1531     }
       
  1532 }
       
  1533 
       
  1534 /**
       
  1535  * Get the segment count for the given path.
       
  1536  */
       
  1537 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgPathGetSegmentCount( SvgPathHandle aPathHandle )
       
  1538 {
       
  1539     if(aPathHandle)
       
  1540         {
       
  1541         return GetSegmentCount((CGfxGeneralPath*)aPathHandle);
       
  1542         }
       
  1543     return 0;
       
  1544 }
       
  1545 
       
  1546 /**
       
  1547  * Get the segment type for the given path.
       
  1548  */
       
  1549 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgPathGetSegmentType(SvgPathHandle aPathHandle, TInt aSegmentIndex )
       
  1550 {
       
  1551     if(aPathHandle)
       
  1552         {
       
  1553 
       
  1554         TInt segmenttype = GetSegmentType((CGfxGeneralPath*)aPathHandle, aSegmentIndex + 1);
       
  1555         // map this to the corressponding segment type for the jsr.
       
  1556 
       
  1557         return MapSegmentType(segmenttype );
       
  1558         }
       
  1559     return 0;
       
  1560 }
       
  1561 
       
  1562 /**
       
  1563  * Get the segment parameter for the given path.
       
  1564  */
       
  1565 EXPORT_C TReal32 CSvgJavaInterfaceImpl::SvgPathGetSegmentParameter( SvgPathHandle aPathHandle,
       
  1566                                    TInt aSegmentIndex,
       
  1567                                    TInt aSegmentParameterIndex ) __SOFTFP
       
  1568 {
       
  1569     if(aPathHandle)
       
  1570         {
       
  1571         return (TReal32)GetSegmentParameter((CGfxGeneralPath*)aPathHandle,aSegmentIndex + 1,aSegmentParameterIndex + 1);
       
  1572         }
       
  1573     return 0;
       
  1574 }
       
  1575 
       
  1576  /**
       
  1577  * Add a move-to command to the given path.
       
  1578  */
       
  1579 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddMoveTo( SvgPathHandle aPathHandle, TReal32 aX, TReal32 aY ) __SOFTFP
       
  1580 {
       
  1581     if(aPathHandle)
       
  1582         {
       
  1583          ADDMoveTo((CGfxGeneralPath*)aPathHandle,aX,aY);
       
  1584         }
       
  1585 }
       
  1586 
       
  1587 /**
       
  1588  * Add a line-to command to the given path.
       
  1589  */
       
  1590 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddLineTo( SvgPathHandle aPathHandle, TReal32 aX, TReal32 aY ) __SOFTFP
       
  1591 {
       
  1592     if(aPathHandle)
       
  1593         {
       
  1594          ADDLineTo((CGfxGeneralPath*)aPathHandle, aX, aY);
       
  1595         }
       
  1596 }
       
  1597 
       
  1598 /**
       
  1599  * Add a quad-to command to the given path.
       
  1600  */
       
  1601 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddQuadTo( SvgPathHandle aPathHandle,
       
  1602                         TReal32 aX1, TReal32 aY1,
       
  1603                         TReal32 aX2, TReal32 aY2) __SOFTFP
       
  1604 {
       
  1605     if(aPathHandle)
       
  1606         {
       
  1607          ADDQuadTo((CGfxGeneralPath*)aPathHandle, aX1, aY1, aX2, aY2);
       
  1608         }
       
  1609 }
       
  1610 
       
  1611 /**
       
  1612  * Add a curve-to command to the given path.
       
  1613  */
       
  1614 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddCurveTo( SvgPathHandle aPathHandle,
       
  1615                         TReal32 aX1, TReal32 aY1,
       
  1616                         TReal32 aX2, TReal32 aY2,
       
  1617                         TReal32 aX3, TReal32 aY3 ) __SOFTFP
       
  1618 {
       
  1619   if(aPathHandle)
       
  1620         {
       
  1621          ADDCurveTo((CGfxGeneralPath*)aPathHandle, aX1, aY1, aX2, aY2, aX3, aY3);
       
  1622         }
       
  1623 }
       
  1624 
       
  1625 /**
       
  1626  * Send a close-path command to the given path.
       
  1627  */
       
  1628 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddClose( SvgPathHandle aPathHandle )
       
  1629 {
       
  1630     ADDCloseTo((CGfxGeneralPath*)aPathHandle);
       
  1631 }
       
  1632 
       
  1633 /**
       
  1634  * Update path info.
       
  1635  */
       
  1636 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementUpdatePath( SvgElementHandle aElementHandle, SvgPathHandle aPathHandle )
       
  1637 {
       
  1638     //this element handle may not be necessary
       
  1639     CSvgElementImpl* myPathElement = (CSvgElementImpl*)aElementHandle;
       
  1640 
       
  1641     UpdatePath(aPathHandle, myPathElement);
       
  1642 }
       
  1643 
       
  1644 EXPORT_C TInt  CSvgJavaInterfaceImpl::SvgElementElementInDOM ( TInt hDocument, TInt
       
  1645                                         hElement )
       
  1646 {
       
  1647 		if(hDocument && hElement)
       
  1648     {
       
  1649     	TBool aresult= SVGElementInDom((CSvgDocumentImpl*)hDocument, (CXmlElementImpl*)hElement);
       
  1650     
       
  1651     	if(aresult)
       
  1652         {
       
  1653         return 1;
       
  1654         }
       
  1655     }
       
  1656     
       
  1657 return 0;
       
  1658 }
       
  1659 
       
  1660 /*
       
  1661 * This functions checks if the element is  child of a useElement.
       
  1662 *
       
  1663 */
       
  1664 
       
  1665 EXPORT_C TInt  CSvgJavaInterfaceImpl::SvgElementIsUsed ( TInt hElement )
       
  1666 {
       
  1667     if(hElement)
       
  1668         {
       
  1669         if( GetElementType( GetParentElement( (CXmlElementImpl*) hElement )) == KSvgUseElement)
       
  1670             {
       
  1671             return 1;
       
  1672             }
       
  1673         return 0;
       
  1674         }
       
  1675     else
       
  1676         {
       
  1677         return 0;
       
  1678         }
       
  1679 }
       
  1680 
       
  1681 /*
       
  1682 * This functions returns the pointer to the element which uses the current element.
       
  1683 *
       
  1684 */
       
  1685 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetUsedFromElement ( TInt hElement )
       
  1686 {
       
  1687     // this function gets the actual element which was cloned so that it can
       
  1688     // be used in a use element.
       
  1689     if(hElement)
       
  1690         {
       
  1691         // get the parent <use> elements xlink:href
       
  1692         return (int) SVGElementGetUsedElement((CXmlElementImpl*)hElement);
       
  1693         }
       
  1694     return 0;
       
  1695 }
       
  1696 /*
       
  1697 * This functions returns the pointer to the element which uses the current element.
       
  1698 *
       
  1699 */
       
  1700 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementGetScreenBBox( TInt aElementHandle, TReal32* x,
       
  1701                                                             TReal32* y, TReal32* w, TReal32* h ) __SOFTFP
       
  1702     {
       
  1703     if(aElementHandle)
       
  1704         {
       
  1705         TReal32 lX ,lY,lWidth,lHeight;
       
  1706         GetElementBoundingbox((CSvgElementImpl*)aElementHandle,lX ,lY,lWidth,lHeight);
       
  1707         *x = lX;
       
  1708         *y = lY;
       
  1709         *w = lWidth;
       
  1710         *h = lHeight;
       
  1711         }
       
  1712     }
       
  1713 
       
  1714 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetPathAttribute( SvgElementHandle aElementHandle,
       
  1715                                       SvgAttrType aPathAttribute , SvgPathHandle aPathHandle)
       
  1716 {
       
  1717     if(aElementHandle)
       
  1718         {
       
  1719         if(aPathHandle)
       
  1720             {
       
  1721             TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aPathAttribute);
       
  1722             SetPathAttribute((CSvgElementImpl*)(CXmlElementImpl*)aElementHandle,  lSvgAttrId, (CGfxGeneralPath*)aPathHandle);
       
  1723             }
       
  1724         }
       
  1725 }
       
  1726 
       
  1727 TBool CSvgJavaInterfaceImpl::MouseEntered( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ )
       
  1728 {
       
  1729 	return ETrue;
       
  1730 }
       
  1731 
       
  1732 TBool CSvgJavaInterfaceImpl::MouseExited( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ )
       
  1733 {
       
  1734 	return ETrue;
       
  1735 }
       
  1736 
       
  1737 TBool CSvgJavaInterfaceImpl::MouseMoved( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ )
       
  1738 {
       
  1739 	return ETrue;
       
  1740 }
       
  1741 
       
  1742 TBool CSvgJavaInterfaceImpl::MousePressed( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ )
       
  1743 {
       
  1744 	return ETrue;
       
  1745 }
       
  1746 
       
  1747 TBool CSvgJavaInterfaceImpl::MouseReleased( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ )
       
  1748 {
       
  1749 	return ETrue;
       
  1750 }
       
  1751 
       
  1752 /**
       
  1753 * This maps the element ids form JSR specific to SVG specific
       
  1754 */
       
  1755 TInt CSvgJavaInterfaceImpl::SvgGetElementTypeMappingJSRtoSVG( SvgAttrType aType )
       
  1756 {
       
  1757 
       
  1758 switch(aType)
       
  1759     {
       
  1760     case 0: return KSvgAElement;
       
  1761 
       
  1762     case 1: return KSvgAnimateElement;
       
  1763 
       
  1764     case 2: return KSvgAnimateColorElement;
       
  1765 
       
  1766     case 3: return KSvgAnimateMotionElement;
       
  1767 
       
  1768     case 4: return KSvgAnimateTransformElement;
       
  1769 
       
  1770     case 5: return KSvgCircleElement;
       
  1771 
       
  1772     case 6: return KSvgDefsElement;
       
  1773 
       
  1774     case 7: return KSvgDescElement;
       
  1775 
       
  1776     case 8: return KSvgEllipseElement;
       
  1777 
       
  1778     case 9: return KSvgFontElement;
       
  1779 
       
  1780     case 10: return KSvgFontfaceElement;
       
  1781 
       
  1782     case 11: return KSvgFontfacenameElement;
       
  1783 
       
  1784     case 12: return KSvgFontfacesrcElement;
       
  1785 
       
  1786     case 13: return KSvgForeignObjectElement;
       
  1787 
       
  1788     case 14: return KSvgGElement;
       
  1789 
       
  1790     case 15: return KSvgGlyphElement;
       
  1791 
       
  1792     case 16: return KSvgHkernElement;
       
  1793 
       
  1794     case 17: return KSvgImageElement;
       
  1795 
       
  1796     case 18: return KSvgLineElement;
       
  1797 
       
  1798     case 19: return KSvgMetadataElement;
       
  1799 
       
  1800     case 20: return KSvgMissingglyphElement;
       
  1801 
       
  1802     case 21: return KSvgMpathElement;
       
  1803 
       
  1804     case 22: return KSvgPathElement;
       
  1805 
       
  1806     case 23: return KSvgPolygonElement;
       
  1807 
       
  1808     case 24: return KSvgPolylineElement;
       
  1809 
       
  1810     case 25: return KSvgRectElement;
       
  1811 
       
  1812     case 26: return KSvgSetElement;
       
  1813 
       
  1814     case 27: return KSvgSvgElement;
       
  1815 
       
  1816     case 28: return KSvgSwitchElement;
       
  1817 
       
  1818     case 29: return KSvgTextElement;
       
  1819 
       
  1820     case 30: return KSvgTitleElement;
       
  1821 
       
  1822     case 31: return KSvgUseElement;
       
  1823 
       
  1824     default: return KSvgUnknownElement;
       
  1825     }
       
  1826 }
       
  1827 
       
  1828 /**
       
  1829 * Tells if the element id is an animation or not.
       
  1830 */
       
  1831 TBool CSvgJavaInterfaceImpl::IsAnimationElemId( const TInt aElementId )
       
  1832 {
       
  1833 	if ( aElementId == KSvgAnimateElement || 
       
  1834 			 aElementId == KSvgAnimateColorElement ||
       
  1835 			 aElementId == KSvgAnimateMotionElement ||
       
  1836 			 aElementId == KSvgAnimateTransformElement)
       
  1837 	{
       
  1838 		return ETrue;
       
  1839 	}		 	
       
  1840 	
       
  1841 	return EFalse;
       
  1842 }
       
  1843 
       
  1844 /**
       
  1845 * This maps the element ids form SVG specific to JSR specific
       
  1846 */
       
  1847 SvgAttrType  CSvgJavaInterfaceImpl::SvgGetElementTypeMappingSVGtoJSR( const TInt aElementId)
       
  1848 {
       
  1849     switch(aElementId)
       
  1850     {
       
  1851     case KSvgAElement: return 0;
       
  1852 
       
  1853     case KSvgAnimateElement: return 1;
       
  1854 
       
  1855     case KSvgAnimateColorElement: return 2;
       
  1856 
       
  1857     case KSvgAnimateMotionElement: return 3;
       
  1858 
       
  1859     case KSvgAnimateTransformElement: return 4;
       
  1860 
       
  1861     case KSvgCircleElement: return 5;
       
  1862 
       
  1863     case KSvgDefsElement: return 6;
       
  1864 
       
  1865     case KSvgDescElement: return 7;
       
  1866 
       
  1867     case KSvgEllipseElement: return 8;
       
  1868 
       
  1869     case KSvgFontElement: return 9;
       
  1870 
       
  1871     case KSvgFontfaceElement: return 10;
       
  1872 
       
  1873     case KSvgFontfacenameElement: return 11;
       
  1874 
       
  1875     case KSvgFontfacesrcElement: return 12;
       
  1876 
       
  1877     case KSvgForeignObjectElement: return 13;
       
  1878 
       
  1879     case KSvgGElement: return 14;
       
  1880 
       
  1881     case KSvgGlyphElement: return 15;
       
  1882 
       
  1883     case KSvgHkernElement: return 16;
       
  1884 
       
  1885     case KSvgImageElement: return 17;
       
  1886 
       
  1887     case KSvgLineElement: return 18;
       
  1888 
       
  1889     case KSvgMetadataElement: return 19;
       
  1890 
       
  1891     case KSvgMissingglyphElement: return 20;
       
  1892 
       
  1893     case KSvgMpathElement: return 21;
       
  1894 
       
  1895     case KSvgPathElement: return 22;
       
  1896 
       
  1897     case KSvgPolygonElement: return 23;
       
  1898 
       
  1899     case KSvgPolylineElement: return 24;
       
  1900 
       
  1901     case KSvgRectElement: return 25;
       
  1902 
       
  1903     case KSvgSetElement: return 26;
       
  1904 
       
  1905     case KSvgSvgElement: return 27;
       
  1906 
       
  1907     case KSvgSwitchElement: return 28;
       
  1908 
       
  1909     case KSvgTextElement: return 29;
       
  1910 
       
  1911     case KSvgTitleElement: return 30;
       
  1912 
       
  1913     case KSvgUseElement: return 31;
       
  1914 
       
  1915     default: return KSvgUnknownElement;
       
  1916     }
       
  1917 }
       
  1918 
       
  1919 /**
       
  1920 * This maps the Attribute ids form SVG specific to JSR specific
       
  1921 */
       
  1922 
       
  1923 SvgAttrType  CSvgJavaInterfaceImpl::SvgGetAttributeTypeMappingSVGtoJSR( const TInt aElementId)
       
  1924 {
       
  1925     switch(aElementId)
       
  1926     {
       
  1927     case KAtrAccumulate:return AT_ACCUMULATE;
       
  1928     case KAtrAdditive:return AT_ADDITIVE;
       
  1929     case KAtrAlphabetic:return AT_ALPHABETIC;
       
  1930     case KAtrAscent:return AT_ASCENT;
       
  1931     case KAtrAttributeName:return AT_ATTRIBUTENAME;
       
  1932     case KAtrBaseProfile:return AT_BASEPROFILE;
       
  1933     case KAtrBegin:return AT_BEGIN;
       
  1934     case KAtrBy:return AT_BY;
       
  1935     case KAtrCalcMode:return AT_CALCMODE;
       
  1936     case KCSS_ATTR_COLOR:return AT_COLOR;
       
  1937     case KCSS_ATTR_COLORRENDERING:return AT_COLORRENDERING;
       
  1938     case KAtrCx:return AT_CX;
       
  1939     case KAtrCy:return AT_CY;
       
  1940     case KAtrD:return AT_D;
       
  1941     case KAtrDescent:return AT_DESCENT ;
       
  1942     case KCSS_ATTR_DISPLAY:return AT_DISPLAY;
       
  1943     case KAtrDur:return AT_DUR;
       
  1944     case KAtrEnd:return AT_END;
       
  1945     case KCSS_ATTR_FILL:return AT_FILL;
       
  1946     case KCSS_ATTR_FILLRULE:return AT_FILLRULE;
       
  1947     case KCSS_ATTR_FONTFAMILY:return AT_FONTFAMILY;
       
  1948     case KCSS_ATTR_FONTSIZE:return AT_FONTSIZE;
       
  1949     case KCSS_ATTR_FONTSTYLE:return AT_FONTSTYLE;
       
  1950     case KCSS_ATTR_FONTWEIGHT:return AT_FONTWEIGHT;
       
  1951     case KAtrFrom:return AT_FROM;
       
  1952     case KAtrG1:return AT_G1;
       
  1953     case KAtrG2:return AT_G2;
       
  1954     case KAtrGlyphName:return AT_GLYPHNAME;
       
  1955     case KAtrHeight:return AT_HEIGHT;
       
  1956     case KAtrHorizAdvX:return AT_HORIZADVX;
       
  1957     case KAtrHorizOriginX:return AT_HORIZORIGINX;
       
  1958     case KAtrId:return AT_ID;
       
  1959     case KAtrK:return AT_K;
       
  1960     case KAtrKeySplines:return AT_KEYSPLINES;
       
  1961     case KAtrKeyTimes:return AT_KEYTIMES;
       
  1962     case KAtrLang:return AT_LANG;
       
  1963     case KAtrOverlinePosition:return AT_OVERLINEPOSITION;
       
  1964     case KAtrOverlineThickness:return AT_OVERLINETHICKNESS;
       
  1965     case KAtrPath:return AT_PATH;
       
  1966     case KAtrPathLength:return AT_PATHLENGTH;
       
  1967     case KAtrPoints:return AT_POINTS;
       
  1968     case KAtrPreserveAspectRatio:return AT_PRESERVEASPECTRATIO;
       
  1969     case KAtrR:return AT_R;
       
  1970     case KAtrRepeatCount:return AT_REPEATCOUNT;
       
  1971     case KAtrRepeatDur:return AT_REPEATDUR;
       
  1972     case KAtrRequiredExtensions:return AT_REQUIREDEXTENSIONS;
       
  1973     case KAtrRequiredFeatures:return AT_REQUIREDFEATURES;
       
  1974     case KAtrRestart:return AT_RESTART;
       
  1975     case KAtrRotate:return AT_ROTATE;
       
  1976     case KAtrRx :return AT_RX;
       
  1977     case KAtrRy:return AT_RY;
       
  1978     case KAtrStrikethroughPosition:return AT_STRIKETHROUGHPOSITION;
       
  1979     case KAtrStrikethroughThickness:return AT_STRIKETHROUGHTHICKNESS;
       
  1980     case KCSS_ATTR_STROKE:return AT_STROKE;
       
  1981     case KCSS_ATTR_STROKE_DASHARRAY:return AT_STROKEDASHARRAY;
       
  1982     case KCSS_ATTR_STROKE_DASHOFFSET:return AT_STROKEDASHOFFSET;
       
  1983     case KCSS_ATTR_STROKE_LINECAP:return AT_STROKELINECAP;
       
  1984     case KCSS_ATTR_STROKE_LINEJOIN:return AT_STROKELINEJOIN;
       
  1985     case KCSS_ATTR_STROKE_MITERLIMIT:return AT_STROKEMITERLIMIT;
       
  1986     case KCSS_ATTR_STROKEWIDTH:return AT_STROKEWIDTH;
       
  1987     case KAtrStyle:return AT_STYLE;
       
  1988     case KAtrCdata:return AT_STRING;
       
  1989     case KAtrSystemLanguage:return AT_SYSTEMLANGUAGE;
       
  1990     case KCSS_ATTR_TEXTANCHOR:return AT_TEXTANCHOR;
       
  1991     case KCSS_ATTR_TEXTDECORATION:return AT_TEXTDECORATION;
       
  1992     case KAtrTo:return AT_TO;
       
  1993     case KAtrTransform :return AT_TRANSFORM;
       
  1994     case KAtrType: return AT_TYPE;
       
  1995     case KAtrU1:return AT_U1;
       
  1996     case KAtrU2:return AT_U2;
       
  1997     case KAtrUnderlinePosition:return AT_UNDERLINEPOSITION;
       
  1998     case KAtrUnderlineThickness:return AT_UNDERLINETHICKNESS;
       
  1999     case KAtrUnicode:return AT_UNICODE;
       
  2000     case KAtrUnicodeRange:return AT_UNICODERANGE;
       
  2001     case KAtrUnitsPerEm:return AT_UNITSPEREM;
       
  2002     case KAtrValues:return AT_VALUES;
       
  2003     case KAtrVersion:return AT_VERSION;
       
  2004     case KAtrViewBox:return AT_VIEWBOX;
       
  2005     case KCSS_ATTR_VISIBILITY:return  AT_VISIBILITY;
       
  2006     case KAtrWidth: return AT_WIDTH;
       
  2007     case KAtrX: return AT_X;
       
  2008     case KAtrX1:return AT_X1;
       
  2009     case KAtrX2:return AT_X2;
       
  2010     case KAtrXlinkactuate:return AT_XLINKACTUATE;
       
  2011     case KAtrXlinkarcrole:return AT_XLINKARCROLE;
       
  2012     case KAtrXlinkhref: return AT_XLINKHREF;
       
  2013     case KAtrXlinkrole: return AT_XLINKROLE;
       
  2014     case KAtrXlinkshow: return AT_XLINKSHOW;
       
  2015     case KAtrXlinktitle:return AT_XLINKTITLE;
       
  2016     case KAtrXlinktype:return AT_XLINKTYPE;
       
  2017     case KAtrXmlLang: return AT_XMLLANG;
       
  2018     case KAtrXmlBase: return AT_XMLBASE;
       
  2019     case KAtrXmlSpace:return AT_XMLSPACE;
       
  2020     case KAtrY: return AT_Y;
       
  2021     case KAtrY1:return AT_Y1;
       
  2022     case KAtrY2:return AT_Y2;
       
  2023     case KAtrZoomAndPan: return AT_ZOOMANDPAN;
       
  2024     default: return KSvgUnknownAttribute;
       
  2025     }
       
  2026 }
       
  2027 
       
  2028 /**
       
  2029 * This maps the Attribute ids form JSR specific to SVG specific
       
  2030 */
       
  2031 TInt CSvgJavaInterfaceImpl::SvgGetAttributeTypeMappingJSRtoSVG( SvgAttrType aType )
       
  2032 {
       
  2033     switch(aType)
       
  2034     {
       
  2035     case AT_ACCENTHEIGHT: return KSvgUnknownAttribute;
       
  2036 
       
  2037     case AT_ACCUMULATE: return KAtrAccumulate;
       
  2038 
       
  2039     case AT_ADDITIVE: return KAtrAdditive;
       
  2040 
       
  2041     case AT_ALPHABETIC: return KAtrAlphabetic;
       
  2042 
       
  2043     case AT_ARABICFORM: return KSvgUnknownAttribute;
       
  2044 
       
  2045     case AT_ASCENT: return KAtrAscent;
       
  2046 
       
  2047     case AT_ATTRIBUTENAME: return KAtrAttributeName;
       
  2048 
       
  2049     case AT_ATTRIBUTETYPE: return KSvgUnknownAttribute;
       
  2050 
       
  2051     case AT_BASEPROFILE: return KAtrBaseProfile;
       
  2052 
       
  2053     case AT_BBOX: return KSvgUnknownAttribute;
       
  2054 
       
  2055     case AT_BEGIN: return KAtrBegin;
       
  2056 
       
  2057     case AT_BY: return KAtrBy;
       
  2058 
       
  2059     case AT_CALCMODE: return KAtrCalcMode;
       
  2060 
       
  2061     case AT_CAPHEIGHT: return KSvgUnknownAttribute;
       
  2062 
       
  2063     case AT_COLOR: return KCSS_ATTR_COLOR;
       
  2064 
       
  2065     case AT_COLORRENDERING: return KCSS_ATTR_COLORRENDERING;
       
  2066 
       
  2067     case AT_CX: return KAtrCx;
       
  2068 
       
  2069     case AT_CY: return KAtrCy;
       
  2070 
       
  2071     case AT_D: return KAtrD;
       
  2072 
       
  2073     case AT_DESCENT: return KAtrDescent;
       
  2074 
       
  2075     case AT_DISPLAY: return KCSS_ATTR_DISPLAY;
       
  2076 
       
  2077     case AT_DUR: return KAtrDur;
       
  2078 
       
  2079     case AT_END: return KAtrEnd;
       
  2080 
       
  2081    // it can be the fill corressponding to animation how to handle that.
       
  2082     case AT_FILL: return KCSS_ATTR_FILL;
       
  2083 
       
  2084     case AT_FILLRULE: return KCSS_ATTR_FILLRULE;
       
  2085 
       
  2086     case AT_FONTFAMILY: return KCSS_ATTR_FONTFAMILY;
       
  2087 
       
  2088     case AT_FONTSIZE: return KCSS_ATTR_FONTSIZE;
       
  2089 
       
  2090     case AT_FONTSTRETCH: return KSvgUnknownAttribute;
       
  2091 
       
  2092     case AT_FONTSTYLE: return KCSS_ATTR_FONTSTYLE;
       
  2093 
       
  2094     case AT_FONTVARIANT: return KSvgUnknownAttribute;
       
  2095 
       
  2096     case AT_FONTWEIGHT: return KCSS_ATTR_FONTWEIGHT;
       
  2097 
       
  2098     case AT_FROM: return KAtrFrom;
       
  2099 
       
  2100     case AT_G1: return KAtrG1;
       
  2101 
       
  2102     case AT_G2: return KAtrG2;
       
  2103 
       
  2104     case AT_GLYPHNAME: return KAtrGlyphName;
       
  2105 
       
  2106     case AT_HANGING: return KSvgUnknownAttribute;
       
  2107 
       
  2108     case AT_HEIGHT: return KAtrHeight;
       
  2109 
       
  2110     case AT_HORIZADVX: return KAtrHorizAdvX;
       
  2111 
       
  2112     case AT_HORIZORIGINX: return KAtrHorizOriginX;
       
  2113 
       
  2114     case AT_ID: return KAtrId;
       
  2115 
       
  2116     case AT_IDEOGRAPHIC: return KSvgUnknownAttribute;
       
  2117 
       
  2118     case AT_K: return KAtrK;
       
  2119 
       
  2120     case AT_KEYPOINTS: return KSvgUnknownAttribute;
       
  2121 
       
  2122     case AT_KEYSPLINES: return KAtrKeySplines;
       
  2123 
       
  2124     case AT_KEYTIMES: return KAtrKeyTimes;
       
  2125 
       
  2126     case AT_LANG: return KAtrLang;
       
  2127 
       
  2128     case AT_MATHEMATICAL: return KSvgUnknownAttribute;
       
  2129 
       
  2130     case AT_MAX: return KSvgUnknownAttribute;
       
  2131 
       
  2132     case AT_MIN: return KSvgUnknownAttribute;
       
  2133 
       
  2134     case AT_NAME: return KSvgUnknownAttribute;
       
  2135 
       
  2136     case AT_ORIGIN: return KSvgUnknownAttribute;
       
  2137 
       
  2138     case AT_OVERLINEPOSITION: return KAtrOverlinePosition;
       
  2139 
       
  2140     case AT_OVERLINETHICKNESS: return KAtrOverlineThickness;
       
  2141 
       
  2142     case AT_PANOSE1: return KSvgUnknownAttribute;
       
  2143 
       
  2144     case AT_PATH: return KAtrPath;
       
  2145 
       
  2146     case AT_PATHLENGTH: return KAtrPathLength;
       
  2147 
       
  2148     case AT_POINTS: return KAtrPoints;
       
  2149 
       
  2150     case AT_PRESERVEASPECTRATIO: return KAtrPreserveAspectRatio;
       
  2151 
       
  2152     case AT_R: return KAtrR;
       
  2153 
       
  2154     case AT_REPEATCOUNT: return KAtrRepeatCount;
       
  2155 
       
  2156     case AT_REPEATDUR:return KAtrRepeatDur;
       
  2157 
       
  2158     case AT_REQUIREDEXTENSIONS: return KAtrRequiredExtensions;
       
  2159 
       
  2160     case AT_REQUIREDFEATURES: return KAtrRequiredFeatures;
       
  2161 
       
  2162     case AT_RESTART: return KAtrRestart;
       
  2163 
       
  2164     case AT_ROTATE: return KAtrRotate;
       
  2165 
       
  2166     case AT_RX: return KAtrRx;
       
  2167 
       
  2168     case AT_RY: return KAtrRy;
       
  2169 
       
  2170     case AT_SLOPE: return KSvgUnknownAttribute;
       
  2171 
       
  2172     case AT_STEMH: return KSvgUnknownAttribute;
       
  2173 
       
  2174     case AT_STEMV: return KSvgUnknownAttribute;
       
  2175 
       
  2176     case AT_STRIKETHROUGHPOSITION: return KAtrStrikethroughPosition;
       
  2177 
       
  2178     case AT_STRIKETHROUGHTHICKNESS: return KAtrStrikethroughThickness;
       
  2179 
       
  2180     case AT_STROKE: return KCSS_ATTR_STROKE;
       
  2181 
       
  2182     case AT_STROKEDASHARRAY: return KCSS_ATTR_STROKE_DASHARRAY;
       
  2183 
       
  2184     case AT_STROKEDASHOFFSET: return KCSS_ATTR_STROKE_DASHOFFSET;
       
  2185 
       
  2186     case AT_STROKELINECAP: return KCSS_ATTR_STROKE_LINECAP;
       
  2187 
       
  2188     case AT_STROKELINEJOIN: return KCSS_ATTR_STROKE_LINEJOIN;
       
  2189 
       
  2190     case AT_STROKEMITERLIMIT: return KCSS_ATTR_STROKE_MITERLIMIT;
       
  2191 
       
  2192     case AT_STROKEWIDTH: return KCSS_ATTR_STROKEWIDTH;
       
  2193 
       
  2194     case AT_STYLE: return KAtrStyle;
       
  2195 
       
  2196 		case AT_STRING: return KAtrCdata;
       
  2197 
       
  2198     case AT_SYSTEMLANGUAGE: return KAtrSystemLanguage;
       
  2199 
       
  2200     case AT_TARGET: return KAtrTarget;
       
  2201 
       
  2202     case AT_TEXTANCHOR: return KCSS_ATTR_TEXTANCHOR;
       
  2203     case AT_TEXTDECORATION: return KCSS_ATTR_TEXTDECORATION;
       
  2204     case AT_TO: return KAtrTo;
       
  2205 
       
  2206     case AT_TRANSFORM: return KAtrTransform;
       
  2207 
       
  2208     case AT_TYPE: return KAtrType;
       
  2209 
       
  2210     case AT_U1: return KAtrU1;
       
  2211 
       
  2212     case AT_U2: return KAtrU2;
       
  2213 
       
  2214     case AT_UNDERLINEPOSITION: return KAtrUnderlinePosition;
       
  2215 
       
  2216     case AT_UNDERLINETHICKNESS: return KAtrUnderlineThickness;
       
  2217 
       
  2218     case AT_UNICODE: return KAtrUnicode;
       
  2219 
       
  2220     case AT_UNICODERANGE:return KAtrUnicodeRange;
       
  2221 
       
  2222     case AT_UNITSPEREM: return KAtrUnitsPerEm;
       
  2223 
       
  2224     case AT_VALUES: return KAtrValues;
       
  2225 
       
  2226     case AT_VERSION: return KAtrVersion;
       
  2227 
       
  2228     case AT_VIEWBOX: return KAtrViewBox;
       
  2229 
       
  2230     case AT_VISIBILITY: return KCSS_ATTR_VISIBILITY;
       
  2231 
       
  2232     case AT_WIDTH: return KAtrWidth;
       
  2233 
       
  2234     case AT_WIDTHS: return KSvgUnknownAttribute;
       
  2235 
       
  2236     case AT_X: return KAtrX;
       
  2237 
       
  2238     case AT_XHEIGHT: return KSvgUnknownAttribute;
       
  2239 
       
  2240     case AT_X1: return KAtrX1;
       
  2241 
       
  2242     case AT_X2:return KAtrX2;
       
  2243 
       
  2244     case AT_XLINKACTUATE: return KAtrXlinkactuate;
       
  2245 
       
  2246     case AT_XLINKARCROLE: return KAtrXlinkarcrole;
       
  2247 
       
  2248     case AT_XLINKHREF: return KAtrXlinkhref;
       
  2249 
       
  2250     case AT_XLINKROLE: return KAtrXlinkrole;
       
  2251 
       
  2252     case AT_XLINKSHOW: return KAtrXlinkshow;
       
  2253 
       
  2254     case AT_XLINKTITLE: return KAtrXlinktitle;
       
  2255 
       
  2256     case AT_XLINKTYPE: return KAtrXlinktype;
       
  2257 
       
  2258     case AT_XMLLANG: return KAtrXmlLang;
       
  2259 
       
  2260     case AT_XMLBASE: return KAtrXmlBase;
       
  2261 
       
  2262     case AT_XMLSPACE: return KAtrXmlSpace;
       
  2263 
       
  2264     case AT_Y: return KAtrY;
       
  2265 
       
  2266     case AT_Y1: return KAtrY1;
       
  2267 
       
  2268     case AT_Y2: return KAtrY2;
       
  2269 
       
  2270     case AT_ZOOMANDPAN: return KAtrZoomAndPan;
       
  2271 
       
  2272     default: return KSvgUnknownAttribute;
       
  2273     }
       
  2274 }
       
  2275 /**
       
  2276 * This maps the Enumeration  Mapping form JSR specific to SVG specific
       
  2277 */
       
  2278 TInt  CSvgJavaInterfaceImpl::SvgEnumerationMappingJSRtoSVG(const TInt aAttributeId, const TInt aJsrEnumValue)
       
  2279 {
       
  2280     // Most of these are style properties.
       
  2281     // COLOR_Rendering. this is not supported.
       
  2282             switch(aAttributeId)
       
  2283                 {
       
  2284                     // Text Anchor
       
  2285                 case KAtrRotate:
       
  2286                     {
       
  2287                         switch(aJsrEnumValue)
       
  2288                         {
       
  2289                             // these are defined in animateMotion.cpp
       
  2290                         case ROTATE_AUTO: return -100;
       
  2291                         case ROTATE_AUTOREVERSE: return -200;
       
  2292                         default:
       
  2293                             return KErrNotFound;
       
  2294                         }
       
  2295                     }
       
  2296 
       
  2297                 case KAtrType:
       
  2298                     {
       
  2299                         switch(aJsrEnumValue)
       
  2300                         {
       
  2301                         // these are defined in SchemaData.cpp
       
  2302                         case TYPE_TRANSLATE: return KSvgTypeTranslate;
       
  2303                         case TYPE_SCALE: return KSvgTypeScale;
       
  2304                         case TYPE_ROTATE:return KSvgTypeRotate;
       
  2305                         case TYPE_SKEWX:return KSvgTypeSkewX;
       
  2306                         case TYPE_SKEWY: return KSvgTypeSkewY;
       
  2307                         default:
       
  2308                             return KErrNotFound;
       
  2309                         }
       
  2310                     }
       
  2311 
       
  2312                 case KCSS_ATTR_FONTSIZE:
       
  2313                     {
       
  2314                         switch(aJsrEnumValue)
       
  2315                         {
       
  2316                         case FONT_SIZE_XXSMALL: return 2;
       
  2317                         case FONT_SIZE_XSMALL: return 4;
       
  2318                         case FONT_SIZE_SMALL:return 6;
       
  2319                         case FONT_SIZE_MEDIUM:return 10;
       
  2320                         case FONT_SIZE_LARGE: return 16;
       
  2321                         case FONT_SIZE_XLARGE:return 20;
       
  2322                         case FONT_SIZE_XXLARGE:return 24;
       
  2323                         default:
       
  2324                             return KErrNotFound;
       
  2325                         }
       
  2326                     }
       
  2327 
       
  2328                 case KCSS_ATTR_TEXTANCHOR:
       
  2329                     {
       
  2330                         switch(aJsrEnumValue)
       
  2331                         {
       
  2332                         case TEXT_ANCHOR_START:
       
  2333                         // these constants are taken from schemaData.cpp any change will need
       
  2334                         // to be propagated to here
       
  2335                             return 0;
       
  2336                         case TEXT_ANCHOR_MIDDLE:
       
  2337                             return 1;
       
  2338                         case TEXT_ANCHOR_END:
       
  2339                             return 2;
       
  2340                         default:
       
  2341                          return KErrNotFound;
       
  2342                         }
       
  2343 
       
  2344                     }
       
  2345                     // Font Weight
       
  2346                 case KCSS_ATTR_FONTWEIGHT:
       
  2347                     {
       
  2348                         switch(aJsrEnumValue)
       
  2349                         {
       
  2350                         case FONT_NORMAL:
       
  2351                         return 0;
       
  2352                         case FONT_WEIGHT_BOLD:
       
  2353                         return 1;
       
  2354                         case FONT_WEIGHT_BOLDER:
       
  2355                         return 2;
       
  2356                         case FONT_WEIGHT_LIGHTER:
       
  2357                         return 3;
       
  2358                         case FONT_WEIGHT_100:
       
  2359                         return 4;
       
  2360                         case FONT_WEIGHT_200:
       
  2361                         return 5;
       
  2362                         case FONT_WEIGHT_300:
       
  2363                         return 6;
       
  2364                         case FONT_WEIGHT_400:
       
  2365                         return 7;
       
  2366                         case FONT_WEIGHT_500:
       
  2367                         return 8;
       
  2368                         case FONT_WEIGHT_600:
       
  2369                         return 9;
       
  2370                         case FONT_WEIGHT_700:
       
  2371                         return 10;
       
  2372                         case FONT_WEIGHT_800:
       
  2373                         return 11;
       
  2374                         case FONT_WEIGHT_900:
       
  2375                         return 12;
       
  2376                         default:
       
  2377                         return KErrNotFound;
       
  2378                         }
       
  2379 
       
  2380                     }
       
  2381                     // Font Style
       
  2382                 case KCSS_ATTR_FONTSTYLE:
       
  2383                         {
       
  2384                         switch(aJsrEnumValue)
       
  2385                             {
       
  2386                             case FONT_NORMAL:
       
  2387                             return 0;
       
  2388                             case FONT_STYLE_ITALIC  :
       
  2389                             return 1;
       
  2390                             case FONT_STYLE_OBLIQUE  :
       
  2391                             return 2;
       
  2392                             default:
       
  2393                             return KErrNotFound;
       
  2394                             }
       
  2395 
       
  2396                         }
       
  2397                     // Spread Method not given in defines.h so probably spreadmethod won't be used.
       
  2398                 case KAtrPreserveAspectRatio:
       
  2399 
       
  2400                         {
       
  2401                             switch(aJsrEnumValue)
       
  2402                             {
       
  2403                             case PAR_NONE:
       
  2404                             return 0;
       
  2405                             case PAR_XMIDYMID:
       
  2406                             return 6;
       
  2407                             default:
       
  2408                             return KErrNotFound;
       
  2409 
       
  2410                             }
       
  2411 
       
  2412                         }
       
  2413                     // TextDecoration
       
  2414                 case KAtrZoomAndPan:
       
  2415                     {
       
  2416                         switch(aJsrEnumValue)
       
  2417                         {
       
  2418                         case ZPN_MAGNIFY:
       
  2419                         return 1;
       
  2420 
       
  2421                         case ZPN_DISABLE:
       
  2422                         return 0;
       
  2423                         default:
       
  2424                             return KErrNotFound;
       
  2425                         }
       
  2426 
       
  2427                     }
       
  2428                     // Display
       
  2429                 case KCSS_ATTR_DISPLAY:
       
  2430                     {
       
  2431                         switch(aJsrEnumValue)
       
  2432                     {
       
  2433                     case DISPLAY_NONE:
       
  2434                     return 16;
       
  2435 
       
  2436                     case DISPLAY_OTHER:
       
  2437                     return 0;
       
  2438 
       
  2439                     default:
       
  2440                     return KErrNotFound;
       
  2441 
       
  2442                     }
       
  2443 
       
  2444                     }
       
  2445                     // VIsibility
       
  2446                 case KCSS_ATTR_VISIBILITY:
       
  2447                     {
       
  2448                         switch(aJsrEnumValue)
       
  2449                         {
       
  2450                         case VISIBILITY_VISIBLE:
       
  2451                         return 0;
       
  2452                         case VISIBILITY_OTHER:
       
  2453                         return 1;
       
  2454                         default:
       
  2455                         return KErrNotFound;
       
  2456 
       
  2457                         }
       
  2458 
       
  2459                     }
       
  2460                 case KAtrAdditive:
       
  2461                         {
       
  2462                         switch(aJsrEnumValue)
       
  2463                             {
       
  2464                         case ADDITIVE_REPLACE:
       
  2465                         return 0;
       
  2466                         case ADDITIVE_SUM:
       
  2467                         return 1;
       
  2468                         default : return KErrNotFound;
       
  2469 
       
  2470                             }
       
  2471 
       
  2472                         }
       
  2473                     case KAtrAccumulate:
       
  2474                         {
       
  2475                             switch(aJsrEnumValue)
       
  2476                             {
       
  2477                         case ACCUMULATE_NONE:
       
  2478                         return 0;
       
  2479                         case ACCUMULATE_SUM:
       
  2480                         return 1;
       
  2481                         default : return KErrNotFound;
       
  2482 
       
  2483                             }
       
  2484 
       
  2485                         }
       
  2486                     case KAtrCalcMode:
       
  2487                         {
       
  2488                             switch(aJsrEnumValue)
       
  2489                             {
       
  2490                         case CALC_MODE_DISCRETE:
       
  2491                         return 0;
       
  2492                         case CALC_MODE_LINEAR:
       
  2493                         return 1;
       
  2494                         case CALC_MODE_PACED:
       
  2495                         return 2;
       
  2496                         case CALC_MODE_SPLINE:
       
  2497                         return 3;
       
  2498                         default: return KErrNotFound;
       
  2499 
       
  2500                             }
       
  2501 
       
  2502                         }
       
  2503                         // it can not be this attribute.
       
  2504                         // This fill corresponds to animation.
       
  2505                     case KCSS_ATTR_FILL:
       
  2506                             {
       
  2507                             switch(aJsrEnumValue)
       
  2508                                 {
       
  2509                                 // these are for animation
       
  2510                                 case FILL_REMOVE:
       
  2511                                 return 0;
       
  2512                                 case FILL_FREEZE:
       
  2513                                 return 1;
       
  2514                                 // following is the attribute value for fill "color"
       
  2515                                 // these are for fill - style attributes.
       
  2516                                 case PAINT_NONE:
       
  2517                                 return KSVGColorNone;
       
  2518                                 case PAINT_CURRENT:
       
  2519                                 return KSVGCurrentColor;
       
  2520                                 case PAINT_INHERIT:
       
  2521                                 return KSVGColorInherit;
       
  2522                                 default: return KErrNotFound;
       
  2523                                 }
       
  2524 
       
  2525                         }
       
  2526                     case KCSS_ATTR_STROKE:
       
  2527                             {
       
  2528                             switch(aJsrEnumValue)
       
  2529                                 {
       
  2530                                 // following is the attribute value for fill "color"
       
  2531                                 // these are for fill - style attributes.
       
  2532                                 case PAINT_NONE:
       
  2533                                 return KSVGColorNone;
       
  2534                                 case PAINT_CURRENT:
       
  2535                                 return KSVGCurrentColor;
       
  2536                                 case PAINT_INHERIT:
       
  2537                                 return KSVGColorInherit;
       
  2538                                 default: return KErrNotFound;
       
  2539                                 }
       
  2540 
       
  2541                             }
       
  2542                     case KAtrRestart:
       
  2543                         {
       
  2544                         switch(aJsrEnumValue)
       
  2545                         {
       
  2546                         case RESTART_ALWAYS:
       
  2547                         return 0;
       
  2548                         case RESTART_NEVER:
       
  2549                         return 2;
       
  2550                         case RESTART_WHENNOTACTIVE:
       
  2551                         return 1;
       
  2552                         default :
       
  2553                         return KErrNotFound;
       
  2554                         }
       
  2555 
       
  2556                         }
       
  2557                     case KCSS_ATTR_TEXTDECORATION:
       
  2558                         {
       
  2559                         switch(aJsrEnumValue)
       
  2560                             {
       
  2561                         case TEXT_UNDER_LINE:
       
  2562                         return 1;
       
  2563                         case TEXT_OVER_LINE:
       
  2564                         return 2;
       
  2565                         case TEXT_LINE_THROUGH:
       
  2566                         return 3;
       
  2567                         default:
       
  2568                         return KErrNotFound;
       
  2569                             }
       
  2570 
       
  2571                         }
       
  2572                     default:
       
  2573                     return KErrNotFound;
       
  2574 
       
  2575                     }
       
  2576 }
       
  2577 
       
  2578 /**
       
  2579 * This maps the Enumeration from JSR to SVG. SVG enumerated value here is string type.
       
  2580 */
       
  2581 TInt  CSvgJavaInterfaceImpl::SvgEnumerationtoStringMappingJSRtoSVG(const TInt aAttributeId, short aJsrEnumValue, TDes& aValue)
       
  2582 {
       
  2583     // all of these are style properties.
       
  2584     switch(aAttributeId)
       
  2585     {
       
  2586     case KCSS_ATTR_FILLRULE:
       
  2587         switch(aJsrEnumValue)
       
  2588             {
       
  2589             case FILL_RULE_EVENODD:
       
  2590                 {
       
  2591                 aValue = _L("evenodd");
       
  2592                 }
       
  2593             break;
       
  2594             case FILL_RULE_NONZERO:
       
  2595                 {
       
  2596                     aValue = _L("nonzero");
       
  2597                 }
       
  2598             break;
       
  2599             default:
       
  2600                 return KErrNotFound;
       
  2601 
       
  2602             }
       
  2603         break;
       
  2604         case KCSS_ATTR_STROKE_LINECAP:
       
  2605             switch(aJsrEnumValue)
       
  2606             {
       
  2607             case STROKE_LINECAP_BUTT:
       
  2608                 {
       
  2609                     aValue = _L("butt");
       
  2610                 }
       
  2611                 break;
       
  2612             case STROKE_LINECAP_ROUND:
       
  2613                 {
       
  2614                     aValue = _L("round");
       
  2615                 }
       
  2616                 break;
       
  2617             case STROKE_LINECAP_SQUARE:
       
  2618                 {
       
  2619                     aValue = _L("square");
       
  2620                 }
       
  2621                 break;
       
  2622             default : return KErrNotFound;
       
  2623             }
       
  2624         break;
       
  2625         case KCSS_ATTR_STROKE_LINEJOIN:
       
  2626             switch(aJsrEnumValue)
       
  2627             {
       
  2628             case STROKE_LINEJOIN_MITER:
       
  2629                 {
       
  2630                     aValue = _L("miter");
       
  2631                 }
       
  2632                 break;
       
  2633             case STROKE_LINEJOIN_ROUND:
       
  2634                 {
       
  2635                     aValue = _L("round");
       
  2636                 }
       
  2637                 break;
       
  2638             case STROKE_LINEJOIN_BEVEL:
       
  2639                 {
       
  2640                     aValue = _L("bevel");
       
  2641                 }
       
  2642                 break;
       
  2643             default : return KErrNotFound;
       
  2644             }
       
  2645             break;
       
  2646             default: return KErrNotFound;
       
  2647 
       
  2648     }
       
  2649     return KErrNone;
       
  2650 }
       
  2651 /**
       
  2652 * This maps the Enumeration from SVG to JSR. SVG enumerated value here is string type.
       
  2653 */
       
  2654 TInt CSvgJavaInterfaceImpl::SvgStringtoEnumerationMappingSVGtoJSR(const TInt aAttributeId , TPtrC16 aValue)
       
  2655 {
       
  2656     switch(aAttributeId)
       
  2657     {
       
  2658     case KCSS_ATTR_FILLRULE:
       
  2659             {
       
  2660             if(aValue == _L("evenodd"))
       
  2661             return FILL_RULE_EVENODD;
       
  2662             if(aValue == _L("nonzero"))
       
  2663             return FILL_RULE_NONZERO;
       
  2664             }
       
  2665     case KCSS_ATTR_STROKE_LINECAP:
       
  2666             {
       
  2667             if(aValue == _L("butt"))
       
  2668             return STROKE_LINECAP_BUTT;
       
  2669             if(aValue == _L("round"))
       
  2670             return STROKE_LINECAP_ROUND;
       
  2671             if(aValue == _L("square"))
       
  2672             return STROKE_LINECAP_SQUARE;
       
  2673             }
       
  2674 
       
  2675         case KCSS_ATTR_STROKE_LINEJOIN:
       
  2676 
       
  2677             {
       
  2678             if(aValue == _L("miter"))
       
  2679             return STROKE_LINEJOIN_MITER;
       
  2680             if(aValue == _L("round"))
       
  2681             return STROKE_LINEJOIN_ROUND;
       
  2682             if(aValue == _L("bevel"))
       
  2683             return STROKE_LINEJOIN_BEVEL;
       
  2684             }
       
  2685         default: return KErrNotFound;
       
  2686     }
       
  2687 }
       
  2688 /**
       
  2689 * This maps the Enumeration from SVG to JSR.
       
  2690 */
       
  2691 TInt  CSvgJavaInterfaceImpl::SvgEnumerationMappingSVGtoJSR(const TInt aAttributeId, TInt32 aSvgEnumValue)
       
  2692 {
       
  2693             switch(aAttributeId)
       
  2694                 {
       
  2695 
       
  2696                 case KAtrRotate:
       
  2697                     {
       
  2698                         switch(aSvgEnumValue)
       
  2699                         {
       
  2700                         case -100: return ROTATE_AUTO;
       
  2701                         case -200: return ROTATE_AUTOREVERSE;
       
  2702                         default:
       
  2703                             return KErrNotFound;
       
  2704                         }
       
  2705                     }
       
  2706 
       
  2707                 case KAtrType:
       
  2708                     {
       
  2709                         switch(aSvgEnumValue)
       
  2710                 {
       
  2711                         case KSvgTypeTranslate: return TYPE_TRANSLATE;
       
  2712                         case KSvgTypeScale: return TYPE_SCALE;
       
  2713                         case KSvgTypeRotate:return TYPE_ROTATE;
       
  2714                         case KSvgTypeSkewX:return TYPE_SKEWX;
       
  2715                         case KSvgTypeSkewY: return TYPE_SKEWY;
       
  2716                         default:
       
  2717                             return KErrNotFound;
       
  2718                         }
       
  2719                     }
       
  2720 
       
  2721                 case KCSS_ATTR_TEXTANCHOR:
       
  2722                     {
       
  2723                         switch(aSvgEnumValue)
       
  2724                         {
       
  2725                         case 0:
       
  2726                         // these constants are taken from schemaData.cpp any change will need
       
  2727                         // to be propagated to here
       
  2728                         return TEXT_ANCHOR_START;
       
  2729                         case 1:
       
  2730                             return TEXT_ANCHOR_MIDDLE;
       
  2731                         case 2:
       
  2732                             return TEXT_ANCHOR_END;
       
  2733                         default:
       
  2734                          return KErrNotFound;
       
  2735                         }
       
  2736 
       
  2737                     }
       
  2738                     // Font Weight
       
  2739                 case KCSS_ATTR_FONTWEIGHT:
       
  2740                     {
       
  2741                         switch(aSvgEnumValue)
       
  2742                         {
       
  2743                         case 0:
       
  2744                         return FONT_NORMAL;
       
  2745                         case 1:
       
  2746                         return FONT_WEIGHT_BOLD;
       
  2747                         case 2:
       
  2748                         return FONT_WEIGHT_BOLDER;
       
  2749                         case 3:
       
  2750                         return FONT_WEIGHT_LIGHTER;
       
  2751                         case 4:
       
  2752                         return FONT_WEIGHT_100;
       
  2753                         case 5:
       
  2754                         return FONT_WEIGHT_200;
       
  2755                         case 6:
       
  2756                         return FONT_WEIGHT_300;
       
  2757                         case 7:
       
  2758                         return FONT_WEIGHT_400;
       
  2759                         case 8:
       
  2760                         return FONT_WEIGHT_500;
       
  2761                         case 9:
       
  2762                         return FONT_WEIGHT_600;
       
  2763                         case 10:
       
  2764                         return FONT_WEIGHT_700;
       
  2765                         case 11:
       
  2766                         return FONT_WEIGHT_800;
       
  2767                         case 12:
       
  2768                         return FONT_WEIGHT_900;
       
  2769                         default:
       
  2770                         return KErrNotFound;
       
  2771                         }
       
  2772 
       
  2773                     }
       
  2774                     // Font Style
       
  2775                 case KCSS_ATTR_FONTSTYLE:
       
  2776                     {
       
  2777                     switch(aSvgEnumValue)
       
  2778                         {
       
  2779                         case 0:
       
  2780                         return FONT_NORMAL;
       
  2781                         case 1:
       
  2782                         return FONT_STYLE_ITALIC;
       
  2783                         case 2:
       
  2784                         return FONT_STYLE_OBLIQUE  ;
       
  2785                         default:
       
  2786                         return KErrNotFound;
       
  2787                         }
       
  2788 
       
  2789                     }
       
  2790                 // preserve aspect ratio
       
  2791                 case KAtrPreserveAspectRatio:
       
  2792 
       
  2793                     {
       
  2794                         switch(aSvgEnumValue)
       
  2795                         {
       
  2796                         case 0:
       
  2797                         return PAR_NONE;
       
  2798                         case 6:
       
  2799                         return PAR_XMIDYMID;
       
  2800                         }
       
  2801 
       
  2802                     }
       
  2803                     // Zoom and Pan
       
  2804                 case KAtrZoomAndPan:
       
  2805                     {
       
  2806                         switch(aSvgEnumValue)
       
  2807                         {
       
  2808                         case 1:
       
  2809                         return ZPN_MAGNIFY;
       
  2810 
       
  2811                         case 0:
       
  2812                         return ZPN_DISABLE;
       
  2813                         }
       
  2814 
       
  2815                     }
       
  2816                     // Display
       
  2817                 case KCSS_ATTR_DISPLAY:
       
  2818                     {
       
  2819                         switch(aSvgEnumValue)
       
  2820                     {
       
  2821                     case 16:
       
  2822                     return DISPLAY_NONE;
       
  2823 
       
  2824                     case 0:
       
  2825                     return DISPLAY_OTHER;
       
  2826 
       
  2827                     default:
       
  2828                     return KErrNotFound;
       
  2829 
       
  2830                     }
       
  2831 
       
  2832                     }
       
  2833                     // VIsibility
       
  2834                 case KCSS_ATTR_VISIBILITY:
       
  2835                     {
       
  2836                         switch(aSvgEnumValue)
       
  2837                         {
       
  2838                         case 0:
       
  2839                         return VISIBILITY_VISIBLE;
       
  2840                         case 1:
       
  2841                         return VISIBILITY_OTHER;
       
  2842                         default:
       
  2843                         return KErrNotFound;
       
  2844 
       
  2845                         }
       
  2846 
       
  2847                     }
       
  2848                     // additive
       
  2849                 case KAtrAdditive:
       
  2850                         {
       
  2851                         switch(aSvgEnumValue)
       
  2852                             {
       
  2853                             case 1:
       
  2854                             return ADDITIVE_SUM;
       
  2855                                 default : return ADDITIVE_REPLACE;
       
  2856 
       
  2857                             }
       
  2858 
       
  2859                         }
       
  2860                     // accumulate
       
  2861                     case KAtrAccumulate:
       
  2862                         {
       
  2863                             switch(aSvgEnumValue)
       
  2864                             {
       
  2865                         case 0:
       
  2866                         return ACCUMULATE_NONE;
       
  2867                         case 1:
       
  2868                         return ACCUMULATE_SUM;
       
  2869                         default : return KErrNotFound;
       
  2870 
       
  2871                             }
       
  2872 
       
  2873                         }
       
  2874                 // calc-mode
       
  2875                     case KAtrCalcMode:
       
  2876                         {
       
  2877                             switch(aSvgEnumValue)
       
  2878                             {
       
  2879                         case 0:
       
  2880                         return CALC_MODE_DISCRETE;
       
  2881                         case 1:
       
  2882                         return CALC_MODE_LINEAR;
       
  2883                         case 2:
       
  2884                         return CALC_MODE_PACED;
       
  2885                         case 3:
       
  2886                         return CALC_MODE_SPLINE;
       
  2887                         default: return KErrNotFound;
       
  2888 
       
  2889                             }
       
  2890 
       
  2891                         }
       
  2892                         // it can not be this attribute.
       
  2893                         // This fill corresponds to animation.
       
  2894                 // fill attribute
       
  2895                     case KCSS_ATTR_FILL:
       
  2896                         {
       
  2897                             switch(aSvgEnumValue)
       
  2898                             {
       
  2899                         case 0:
       
  2900                         return FILL_REMOVE;
       
  2901                         case 1:
       
  2902                         return FILL_FREEZE;
       
  2903                         default: return KErrNotFound;
       
  2904                             }
       
  2905 
       
  2906                         }
       
  2907                 // restart attribute.
       
  2908                     case KAtrRestart:
       
  2909                         {
       
  2910                             switch(aSvgEnumValue)
       
  2911                             {
       
  2912                         case 0:
       
  2913                         return RESTART_ALWAYS;
       
  2914                         case 2:
       
  2915                         return RESTART_NEVER;
       
  2916                         case 1:
       
  2917                         return RESTART_WHENNOTACTIVE;
       
  2918                         default :
       
  2919                         return KErrNotFound;
       
  2920                             }
       
  2921 
       
  2922                         }
       
  2923                 // text decoration.
       
  2924                     case KCSS_ATTR_TEXTDECORATION:
       
  2925                         {
       
  2926                         switch(aSvgEnumValue)
       
  2927                             {
       
  2928                         case 1:
       
  2929                         return TEXT_UNDER_LINE;
       
  2930                         case 2:
       
  2931                         return TEXT_OVER_LINE;
       
  2932                         case 3:
       
  2933                         return TEXT_LINE_THROUGH;
       
  2934                         default:
       
  2935                         return KErrNotFound;
       
  2936                             }
       
  2937 
       
  2938                         }
       
  2939                     default:
       
  2940                     return KErrNotFound;
       
  2941 
       
  2942                     }
       
  2943 }
       
  2944 
       
  2945 /*
       
  2946 * This functions checks if an element is in a specified document.
       
  2947 *
       
  2948 */
       
  2949 
       
  2950 TInt CSvgJavaInterfaceImpl::MapSegmentType(TInt aSvgSegmentType)
       
  2951 {
       
  2952     // the following is a limitation since in GFx2d.dll we do not store the
       
  2953     // relative or absolute nature of a command.
       
  2954     // currently we return the absolute.
       
  2955 
       
  2956     switch(aSvgSegmentType)
       
  2957         {
       
  2958         case KSvgSegClose:
       
  2959                 {
       
  2960                 return PATH_COMMAND_Z;
       
  2961                 }
       
  2962         case KSvgSegLineTo:
       
  2963                 {
       
  2964                     return PATH_COMMAND_L;
       
  2965                 }
       
  2966         case KSvgSegQuadTo:
       
  2967                 {
       
  2968                     return PATH_COMMAND_Q;
       
  2969                 }
       
  2970         case KSvgSegCubicTo:
       
  2971                 {
       
  2972                     return PATH_COMMAND_C;
       
  2973                 }
       
  2974         case KSvgSegMoveTo:
       
  2975                 {
       
  2976                     return PATH_COMMAND_M;
       
  2977                 }
       
  2978         case KSvgVertical:
       
  2979                 {
       
  2980                     return PATH_COMMAND_V;
       
  2981                 }
       
  2982         case KSvgHorizontal:
       
  2983                 {
       
  2984                     return PATH_COMMAND_H;
       
  2985                 }
       
  2986         default :
       
  2987             return 0;
       
  2988         }
       
  2989 }