|
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 TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute); |
|
1262 if(lSvgAttrId != KSvgUnknownAttribute) |
|
1263 { |
|
1264 |
|
1265 lValue = SvgEnumerationMappingJSRtoSVG(lSvgAttrId , (TInt)aValue); |
|
1266 |
|
1267 if ( lValue == KErrNotFound && aValue == ATTRIBUTE_INHERIT ) |
|
1268 lValue = KSVGAttributeInherit; |
|
1269 if(lSvgAttrId == KCSS_ATTR_FONTSIZE) |
|
1270 { |
|
1271 if(lValue != KErrNotFound) |
|
1272 { |
|
1273 // font is internally considered to be a float. |
|
1274 |
|
1275 SetElementFloatAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId, (TReal32)lValue); |
|
1276 return; |
|
1277 } |
|
1278 return; |
|
1279 } |
|
1280 if(lValue == KErrNotFound) |
|
1281 { |
|
1282 TBuf<40> lValueDes; |
|
1283 TInt lResult = SvgEnumerationtoStringMappingJSRtoSVG(lSvgAttrId , aValue ,lValueDes); |
|
1284 if(lResult == KErrNotFound) |
|
1285 { |
|
1286 // this is not valid Attribute. |
|
1287 return; |
|
1288 } |
|
1289 else |
|
1290 { |
|
1291 SetElementDesAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId,lValueDes ); |
|
1292 return; |
|
1293 } |
|
1294 // Call for the string Attribute. |
|
1295 } |
|
1296 SetEnumAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId,lValue); |
|
1297 } |
|
1298 } |
|
1299 } |
|
1300 |
|
1301 /** |
|
1302 * Get enum attribute value. |
|
1303 */ |
|
1304 EXPORT_C short CSvgJavaInterfaceImpl::SvgElementGetEnumAttribute( SvgElementHandle aElementHandle, |
|
1305 SvgAttrType aAttribute ) |
|
1306 { |
|
1307 if(aElementHandle) |
|
1308 { |
|
1309 TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aAttribute); |
|
1310 if(lSvgAttrId != KSvgUnknownAttribute) |
|
1311 { |
|
1312 // following swicth is for all the attributes for which constants |
|
1313 // are specified in Svgjsrconstants.h |
|
1314 TInt32 lValue = KErrNone; |
|
1315 if( lSvgAttrId == KCSS_ATTR_FILLRULE || |
|
1316 lSvgAttrId == KCSS_ATTR_STROKE_LINECAP || |
|
1317 lSvgAttrId == KCSS_ATTR_STROKE_LINEJOIN ) |
|
1318 { |
|
1319 TPtrC16 lValue; |
|
1320 GetElementDesAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId,lValue); |
|
1321 TInt lResult = SvgStringtoEnumerationMappingSVGtoJSR(lSvgAttrId , lValue ); |
|
1322 return ( short )lResult; |
|
1323 } |
|
1324 else |
|
1325 { |
|
1326 if(lSvgAttrId == KCSS_ATTR_FONTSIZE) |
|
1327 { |
|
1328 if(lValue != KErrNotFound) |
|
1329 { |
|
1330 // font is internally considered to be a float. |
|
1331 TReal32 lValue = GetElementFloatAttribute((CSvgElementImpl*)aElementHandle,lSvgAttrId); |
|
1332 return short (lValue) ; |
|
1333 } |
|
1334 return KInvalidEnumAttribute; |
|
1335 } |
|
1336 TInt lResult = GetEnumAttribute((CSvgElementImpl*)aElementHandle, lSvgAttrId , lValue); |
|
1337 if(lResult == KErrNotFound) |
|
1338 { |
|
1339 return KInvalidEnumAttribute; |
|
1340 } |
|
1341 else |
|
1342 { |
|
1343 TInt value = SvgEnumerationMappingSVGtoJSR(lSvgAttrId , lValue); |
|
1344 return (short) value; |
|
1345 } |
|
1346 } |
|
1347 } |
|
1348 } |
|
1349 return 0; |
|
1350 } |
|
1351 |
|
1352 /** |
|
1353 * Get the rectangle attribute value. |
|
1354 */ |
|
1355 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetRectAttribute( SvgElementHandle aElementHandle, |
|
1356 SvgAttrType /*aRectAttribute*/, |
|
1357 TReal32* aX, TReal32* aY, TReal32* aWidth, TReal32* aHeight ) __SOFTFP |
|
1358 { |
|
1359 if ( aElementHandle ) |
|
1360 { |
|
1361 if (!GetRectAttribute( (CXmlElementImpl*) aElementHandle, aX, |
|
1362 aY, aWidth, aHeight )) |
|
1363 { |
|
1364 return -1; |
|
1365 } |
|
1366 |
|
1367 if ( aX != NULL ) |
|
1368 { |
|
1369 return 1; |
|
1370 } |
|
1371 } |
|
1372 return -1; |
|
1373 } |
|
1374 |
|
1375 /** |
|
1376 * Set the rectangle attribute value. |
|
1377 */ |
|
1378 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetRectAttribute( SvgElementHandle aElementHandle, |
|
1379 SvgAttrType /*aRectAttribute*/, |
|
1380 TReal32 aX, TReal32 aY, TReal32 aWidth, TReal32 aHeight ) __SOFTFP |
|
1381 { |
|
1382 if ( aElementHandle ) SetRectAttribute( (CXmlElementImpl*) aElementHandle, aX, |
|
1383 aY, aWidth, aHeight ); |
|
1384 } |
|
1385 |
|
1386 /** |
|
1387 * Get the matrix attribute value. |
|
1388 */ |
|
1389 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetMatrixAttribute( SvgElementHandle aElementHandle, |
|
1390 SvgAttrType aMatrixAttribute, |
|
1391 TReal32* aAVal, TReal32* aBVal, TReal32* aCVal, |
|
1392 TReal32* aDVal, TReal32* aEVal, TReal32* aFVal ) __SOFTFP |
|
1393 { |
|
1394 if ( aElementHandle == NULL ) |
|
1395 { |
|
1396 return -1; |
|
1397 } |
|
1398 |
|
1399 if( aMatrixAttribute == AT_TRANSFORM) // request to get transform for the element |
|
1400 { |
|
1401 aMatrixAttribute = SvgGetAttributeTypeMappingJSRtoSVG(aMatrixAttribute); |
|
1402 GetMatrixAttribute( (CXmlElementImpl*) aElementHandle, aMatrixAttribute, aAVal, |
|
1403 aBVal, aCVal, aDVal, aEVal, aFVal ); |
|
1404 } |
|
1405 else // request for CTM |
|
1406 { |
|
1407 GetMatrixAttribute( (CXmlElementImpl*) aElementHandle, aAVal, |
|
1408 aBVal, aCVal, aDVal, aEVal, aFVal ); |
|
1409 } |
|
1410 |
|
1411 |
|
1412 return 0; |
|
1413 } |
|
1414 |
|
1415 /** |
|
1416 * Set the matrix attribute value. |
|
1417 */ |
|
1418 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetMatrixAttribute( SvgElementHandle aElementHandle, |
|
1419 SvgAttrType /*aMatrixAttribute*/, |
|
1420 TReal32 aAVal, TReal32 aBVal, TReal32 aCVal, |
|
1421 TReal32 aDVal, TReal32 aEVal, TReal32 aFVal ) __SOFTFP |
|
1422 { |
|
1423 if ( aElementHandle ) SetMatrixAttribute( (CXmlElementImpl*) aElementHandle, aAVal, |
|
1424 aBVal, aCVal, aDVal, aEVal, aFVal ); |
|
1425 } |
|
1426 |
|
1427 /** |
|
1428 * Get the path attribute value. |
|
1429 */ |
|
1430 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetPathAttribute( SvgElementHandle aElementHandle, |
|
1431 SvgAttrType aPathAttribute ) |
|
1432 { |
|
1433 // The attributeId must be one of the following. |
|
1434 // KAtrD, KAtrTo, KAtrFrom, KAtrBy, KAtrPath |
|
1435 TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aPathAttribute); |
|
1436 |
|
1437 return (TInt)GetPathAttribute((CXmlElementImpl*) aElementHandle, lSvgAttrId); |
|
1438 } |
|
1439 |
|
1440 /** |
|
1441 * Get the bounding box rectangle attribute value. |
|
1442 */ |
|
1443 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementGetBBox( SvgElementHandle aElementHandle, |
|
1444 SvgAttrType /*aAttributeType*/, |
|
1445 TReal32* aX, TReal32* aY, TReal32* aWidth, TReal32* aHeight ) __SOFTFP |
|
1446 { |
|
1447 if(aElementHandle) |
|
1448 { |
|
1449 TReal32 lX ,lY,lWidth,lHeight; |
|
1450 GetElementUnScaledBoundingBox((CSvgElementImpl*)aElementHandle,lX ,lY,lWidth,lHeight); |
|
1451 *aX = lX; |
|
1452 *aY = lY; |
|
1453 *aWidth = lWidth; |
|
1454 *aHeight = lHeight; |
|
1455 } |
|
1456 } |
|
1457 |
|
1458 /** |
|
1459 * Add event listener to the given element. |
|
1460 * Note: need to replace void* with specific class |
|
1461 */ |
|
1462 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementAddEventListener( SvgElementHandle aElementHandle, |
|
1463 TInt /*aListener*/, SvgAttrType /*aType*/ ) |
|
1464 { |
|
1465 if(aElementHandle) |
|
1466 { |
|
1467 // by default we have added the KEventExternalUI as the mask type. |
|
1468 |
|
1469 // aListener how do you convert this to the SVGEngien's event Mask. |
|
1470 const TUint8 aEventMask = KSvgEventMaskExternalUI; |
|
1471 AddToEventReceiverList((CXmlElementImpl*) aElementHandle, aEventMask); |
|
1472 } |
|
1473 } |
|
1474 |
|
1475 /** |
|
1476 * Remove event listener from the given element. |
|
1477 * Note: need to replace void* with specific class |
|
1478 */ |
|
1479 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementRemoveEventListener( SvgElementHandle aElementHandle, |
|
1480 TInt /*aListener*/, SvgAttrType /*aType*/ ) |
|
1481 { |
|
1482 if(aElementHandle) |
|
1483 { |
|
1484 RemoveFromEventReceiverList((CXmlElementImpl*)aElementHandle); |
|
1485 } |
|
1486 } |
|
1487 |
|
1488 /** |
|
1489 * Check if element is active. |
|
1490 */ |
|
1491 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementIsActive( SvgElementHandle aElementHandle ) |
|
1492 { |
|
1493 CSvgElementImpl* hElement = (CSvgElementImpl*)aElementHandle; |
|
1494 |
|
1495 return (IsElementActive( hElement )); |
|
1496 } |
|
1497 |
|
1498 /** |
|
1499 * Check removable element. |
|
1500 * any element that doesnt have an id and its children dont have ids |
|
1501 */ |
|
1502 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementCheckRemoveable( SvgElementHandle aElementHandle ) |
|
1503 { |
|
1504 CSvgElementImpl* hElement = (CSvgElementImpl*)aElementHandle; |
|
1505 |
|
1506 return (IsRemoveable(hElement)); |
|
1507 } |
|
1508 |
|
1509 // *********************************************************************** |
|
1510 // SVG Path |
|
1511 // *********************************************************************** |
|
1512 |
|
1513 /** |
|
1514 * Create an empty path |
|
1515 */ |
|
1516 EXPORT_C SvgPathHandle CSvgJavaInterfaceImpl::SvgPathCreate() |
|
1517 { |
|
1518 return (SvgPathHandle) SvgCreatePath(); |
|
1519 } |
|
1520 |
|
1521 /** |
|
1522 * Destroy the specified path path |
|
1523 */ |
|
1524 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathDestroy( SvgPathHandle aPathHandle ) |
|
1525 { |
|
1526 if(aPathHandle) |
|
1527 { |
|
1528 SvgDestroyPath((CGfxGeneralPath*)aPathHandle); |
|
1529 } |
|
1530 } |
|
1531 |
|
1532 /** |
|
1533 * Get the segment count for the given path. |
|
1534 */ |
|
1535 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgPathGetSegmentCount( SvgPathHandle aPathHandle ) |
|
1536 { |
|
1537 if(aPathHandle) |
|
1538 { |
|
1539 return GetSegmentCount((CGfxGeneralPath*)aPathHandle); |
|
1540 } |
|
1541 return 0; |
|
1542 } |
|
1543 |
|
1544 /** |
|
1545 * Get the segment type for the given path. |
|
1546 */ |
|
1547 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgPathGetSegmentType(SvgPathHandle aPathHandle, TInt aSegmentIndex ) |
|
1548 { |
|
1549 if(aPathHandle) |
|
1550 { |
|
1551 |
|
1552 TInt segmenttype = GetSegmentType((CGfxGeneralPath*)aPathHandle, aSegmentIndex + 1); |
|
1553 // map this to the corressponding segment type for the jsr. |
|
1554 |
|
1555 return MapSegmentType(segmenttype ); |
|
1556 } |
|
1557 return 0; |
|
1558 } |
|
1559 |
|
1560 /** |
|
1561 * Get the segment parameter for the given path. |
|
1562 */ |
|
1563 EXPORT_C TReal32 CSvgJavaInterfaceImpl::SvgPathGetSegmentParameter( SvgPathHandle aPathHandle, |
|
1564 TInt aSegmentIndex, |
|
1565 TInt aSegmentParameterIndex ) __SOFTFP |
|
1566 { |
|
1567 if(aPathHandle) |
|
1568 { |
|
1569 return (TReal32)GetSegmentParameter((CGfxGeneralPath*)aPathHandle,aSegmentIndex + 1,aSegmentParameterIndex + 1); |
|
1570 } |
|
1571 return 0; |
|
1572 } |
|
1573 |
|
1574 /** |
|
1575 * Add a move-to command to the given path. |
|
1576 */ |
|
1577 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddMoveTo( SvgPathHandle aPathHandle, TReal32 aX, TReal32 aY ) __SOFTFP |
|
1578 { |
|
1579 if(aPathHandle) |
|
1580 { |
|
1581 ADDMoveTo((CGfxGeneralPath*)aPathHandle,aX,aY); |
|
1582 } |
|
1583 } |
|
1584 |
|
1585 /** |
|
1586 * Add a line-to command to the given path. |
|
1587 */ |
|
1588 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddLineTo( SvgPathHandle aPathHandle, TReal32 aX, TReal32 aY ) __SOFTFP |
|
1589 { |
|
1590 if(aPathHandle) |
|
1591 { |
|
1592 ADDLineTo((CGfxGeneralPath*)aPathHandle, aX, aY); |
|
1593 } |
|
1594 } |
|
1595 |
|
1596 /** |
|
1597 * Add a quad-to command to the given path. |
|
1598 */ |
|
1599 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddQuadTo( SvgPathHandle aPathHandle, |
|
1600 TReal32 aX1, TReal32 aY1, |
|
1601 TReal32 aX2, TReal32 aY2) __SOFTFP |
|
1602 { |
|
1603 if(aPathHandle) |
|
1604 { |
|
1605 ADDQuadTo((CGfxGeneralPath*)aPathHandle, aX1, aY1, aX2, aY2); |
|
1606 } |
|
1607 } |
|
1608 |
|
1609 /** |
|
1610 * Add a curve-to command to the given path. |
|
1611 */ |
|
1612 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddCurveTo( SvgPathHandle aPathHandle, |
|
1613 TReal32 aX1, TReal32 aY1, |
|
1614 TReal32 aX2, TReal32 aY2, |
|
1615 TReal32 aX3, TReal32 aY3 ) __SOFTFP |
|
1616 { |
|
1617 if(aPathHandle) |
|
1618 { |
|
1619 ADDCurveTo((CGfxGeneralPath*)aPathHandle, aX1, aY1, aX2, aY2, aX3, aY3); |
|
1620 } |
|
1621 } |
|
1622 |
|
1623 /** |
|
1624 * Send a close-path command to the given path. |
|
1625 */ |
|
1626 EXPORT_C void CSvgJavaInterfaceImpl::SvgPathAddClose( SvgPathHandle aPathHandle ) |
|
1627 { |
|
1628 ADDCloseTo((CGfxGeneralPath*)aPathHandle); |
|
1629 } |
|
1630 |
|
1631 /** |
|
1632 * Update path info. |
|
1633 */ |
|
1634 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementUpdatePath( SvgElementHandle aElementHandle, SvgPathHandle aPathHandle ) |
|
1635 { |
|
1636 //this element handle may not be necessary |
|
1637 CSvgElementImpl* myPathElement = (CSvgElementImpl*)aElementHandle; |
|
1638 |
|
1639 UpdatePath(aPathHandle, myPathElement); |
|
1640 } |
|
1641 |
|
1642 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementElementInDOM ( TInt hDocument, TInt |
|
1643 hElement ) |
|
1644 { |
|
1645 if(hDocument && hElement) |
|
1646 { |
|
1647 TBool aresult= SVGElementInDom((CSvgDocumentImpl*)hDocument, (CXmlElementImpl*)hElement); |
|
1648 |
|
1649 if(aresult) |
|
1650 { |
|
1651 return 1; |
|
1652 } |
|
1653 } |
|
1654 |
|
1655 return 0; |
|
1656 } |
|
1657 |
|
1658 /* |
|
1659 * This functions checks if the element is child of a useElement. |
|
1660 * |
|
1661 */ |
|
1662 |
|
1663 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementIsUsed ( TInt hElement ) |
|
1664 { |
|
1665 if(hElement) |
|
1666 { |
|
1667 if( GetElementType( GetParentElement( (CXmlElementImpl*) hElement )) == KSvgUseElement) |
|
1668 { |
|
1669 return 1; |
|
1670 } |
|
1671 return 0; |
|
1672 } |
|
1673 else |
|
1674 { |
|
1675 return 0; |
|
1676 } |
|
1677 } |
|
1678 |
|
1679 /* |
|
1680 * This functions returns the pointer to the element which uses the current element. |
|
1681 * |
|
1682 */ |
|
1683 EXPORT_C TInt CSvgJavaInterfaceImpl::SvgElementGetUsedFromElement ( TInt hElement ) |
|
1684 { |
|
1685 // this function gets the actual element which was cloned so that it can |
|
1686 // be used in a use element. |
|
1687 if(hElement) |
|
1688 { |
|
1689 // get the parent <use> elements xlink:href |
|
1690 return (int) SVGElementGetUsedElement((CXmlElementImpl*)hElement); |
|
1691 } |
|
1692 return 0; |
|
1693 } |
|
1694 /* |
|
1695 * This functions returns the pointer to the element which uses the current element. |
|
1696 * |
|
1697 */ |
|
1698 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementGetScreenBBox( TInt aElementHandle, TReal32* x, |
|
1699 TReal32* y, TReal32* w, TReal32* h ) __SOFTFP |
|
1700 { |
|
1701 if(aElementHandle) |
|
1702 { |
|
1703 TReal32 lX ,lY,lWidth,lHeight; |
|
1704 GetElementBoundingbox((CSvgElementImpl*)aElementHandle,lX ,lY,lWidth,lHeight); |
|
1705 *x = lX; |
|
1706 *y = lY; |
|
1707 *w = lWidth; |
|
1708 *h = lHeight; |
|
1709 } |
|
1710 } |
|
1711 |
|
1712 EXPORT_C void CSvgJavaInterfaceImpl::SvgElementSetPathAttribute( SvgElementHandle aElementHandle, |
|
1713 SvgAttrType aPathAttribute , SvgPathHandle aPathHandle) |
|
1714 { |
|
1715 if(aElementHandle) |
|
1716 { |
|
1717 if(aPathHandle) |
|
1718 { |
|
1719 TInt lSvgAttrId = SvgGetAttributeTypeMappingJSRtoSVG(aPathAttribute); |
|
1720 SetPathAttribute((CSvgElementImpl*)(CXmlElementImpl*)aElementHandle, lSvgAttrId, (CGfxGeneralPath*)aPathHandle); |
|
1721 } |
|
1722 } |
|
1723 } |
|
1724 |
|
1725 TBool CSvgJavaInterfaceImpl::MouseEntered( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ ) |
|
1726 { |
|
1727 return ETrue; |
|
1728 } |
|
1729 |
|
1730 TBool CSvgJavaInterfaceImpl::MouseExited( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ ) |
|
1731 { |
|
1732 return ETrue; |
|
1733 } |
|
1734 |
|
1735 TBool CSvgJavaInterfaceImpl::MouseMoved( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ ) |
|
1736 { |
|
1737 return ETrue; |
|
1738 } |
|
1739 |
|
1740 TBool CSvgJavaInterfaceImpl::MousePressed( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ ) |
|
1741 { |
|
1742 return ETrue; |
|
1743 } |
|
1744 |
|
1745 TBool CSvgJavaInterfaceImpl::MouseReleased( RPointerArray<CSvgElementImpl>& /*aElements*/, TInt /*aX*/, TInt /*aY*/ ) |
|
1746 { |
|
1747 return ETrue; |
|
1748 } |
|
1749 |
|
1750 /** |
|
1751 * This maps the element ids form JSR specific to SVG specific |
|
1752 */ |
|
1753 TInt CSvgJavaInterfaceImpl::SvgGetElementTypeMappingJSRtoSVG( SvgAttrType aType ) |
|
1754 { |
|
1755 |
|
1756 switch(aType) |
|
1757 { |
|
1758 case 0: return KSvgAElement; |
|
1759 |
|
1760 case 1: return KSvgAnimateElement; |
|
1761 |
|
1762 case 2: return KSvgAnimateColorElement; |
|
1763 |
|
1764 case 3: return KSvgAnimateMotionElement; |
|
1765 |
|
1766 case 4: return KSvgAnimateTransformElement; |
|
1767 |
|
1768 case 5: return KSvgCircleElement; |
|
1769 |
|
1770 case 6: return KSvgDefsElement; |
|
1771 |
|
1772 case 7: return KSvgDescElement; |
|
1773 |
|
1774 case 8: return KSvgEllipseElement; |
|
1775 |
|
1776 case 9: return KSvgFontElement; |
|
1777 |
|
1778 case 10: return KSvgFontfaceElement; |
|
1779 |
|
1780 case 11: return KSvgFontfacenameElement; |
|
1781 |
|
1782 case 12: return KSvgFontfacesrcElement; |
|
1783 |
|
1784 case 13: return KSvgForeignObjectElement; |
|
1785 |
|
1786 case 14: return KSvgGElement; |
|
1787 |
|
1788 case 15: return KSvgGlyphElement; |
|
1789 |
|
1790 case 16: return KSvgHkernElement; |
|
1791 |
|
1792 case 17: return KSvgImageElement; |
|
1793 |
|
1794 case 18: return KSvgLineElement; |
|
1795 |
|
1796 case 19: return KSvgMetadataElement; |
|
1797 |
|
1798 case 20: return KSvgMissingglyphElement; |
|
1799 |
|
1800 case 21: return KSvgMpathElement; |
|
1801 |
|
1802 case 22: return KSvgPathElement; |
|
1803 |
|
1804 case 23: return KSvgPolygonElement; |
|
1805 |
|
1806 case 24: return KSvgPolylineElement; |
|
1807 |
|
1808 case 25: return KSvgRectElement; |
|
1809 |
|
1810 case 26: return KSvgSetElement; |
|
1811 |
|
1812 case 27: return KSvgSvgElement; |
|
1813 |
|
1814 case 28: return KSvgSwitchElement; |
|
1815 |
|
1816 case 29: return KSvgTextElement; |
|
1817 |
|
1818 case 30: return KSvgTitleElement; |
|
1819 |
|
1820 case 31: return KSvgUseElement; |
|
1821 |
|
1822 default: return KSvgUnknownElement; |
|
1823 } |
|
1824 } |
|
1825 |
|
1826 /** |
|
1827 * Tells if the element id is an animation or not. |
|
1828 */ |
|
1829 TBool CSvgJavaInterfaceImpl::IsAnimationElemId( const TInt aElementId ) |
|
1830 { |
|
1831 if ( aElementId == KSvgAnimateElement || |
|
1832 aElementId == KSvgAnimateColorElement || |
|
1833 aElementId == KSvgAnimateMotionElement || |
|
1834 aElementId == KSvgAnimateTransformElement) |
|
1835 { |
|
1836 return ETrue; |
|
1837 } |
|
1838 |
|
1839 return EFalse; |
|
1840 } |
|
1841 |
|
1842 /** |
|
1843 * This maps the element ids form SVG specific to JSR specific |
|
1844 */ |
|
1845 SvgAttrType CSvgJavaInterfaceImpl::SvgGetElementTypeMappingSVGtoJSR( const TInt aElementId) |
|
1846 { |
|
1847 switch(aElementId) |
|
1848 { |
|
1849 case KSvgAElement: return 0; |
|
1850 |
|
1851 case KSvgAnimateElement: return 1; |
|
1852 |
|
1853 case KSvgAnimateColorElement: return 2; |
|
1854 |
|
1855 case KSvgAnimateMotionElement: return 3; |
|
1856 |
|
1857 case KSvgAnimateTransformElement: return 4; |
|
1858 |
|
1859 case KSvgCircleElement: return 5; |
|
1860 |
|
1861 case KSvgDefsElement: return 6; |
|
1862 |
|
1863 case KSvgDescElement: return 7; |
|
1864 |
|
1865 case KSvgEllipseElement: return 8; |
|
1866 |
|
1867 case KSvgFontElement: return 9; |
|
1868 |
|
1869 case KSvgFontfaceElement: return 10; |
|
1870 |
|
1871 case KSvgFontfacenameElement: return 11; |
|
1872 |
|
1873 case KSvgFontfacesrcElement: return 12; |
|
1874 |
|
1875 case KSvgForeignObjectElement: return 13; |
|
1876 |
|
1877 case KSvgGElement: return 14; |
|
1878 |
|
1879 case KSvgGlyphElement: return 15; |
|
1880 |
|
1881 case KSvgHkernElement: return 16; |
|
1882 |
|
1883 case KSvgImageElement: return 17; |
|
1884 |
|
1885 case KSvgLineElement: return 18; |
|
1886 |
|
1887 case KSvgMetadataElement: return 19; |
|
1888 |
|
1889 case KSvgMissingglyphElement: return 20; |
|
1890 |
|
1891 case KSvgMpathElement: return 21; |
|
1892 |
|
1893 case KSvgPathElement: return 22; |
|
1894 |
|
1895 case KSvgPolygonElement: return 23; |
|
1896 |
|
1897 case KSvgPolylineElement: return 24; |
|
1898 |
|
1899 case KSvgRectElement: return 25; |
|
1900 |
|
1901 case KSvgSetElement: return 26; |
|
1902 |
|
1903 case KSvgSvgElement: return 27; |
|
1904 |
|
1905 case KSvgSwitchElement: return 28; |
|
1906 |
|
1907 case KSvgTextElement: return 29; |
|
1908 |
|
1909 case KSvgTitleElement: return 30; |
|
1910 |
|
1911 case KSvgUseElement: return 31; |
|
1912 |
|
1913 default: return KSvgUnknownElement; |
|
1914 } |
|
1915 } |
|
1916 |
|
1917 /** |
|
1918 * This maps the Attribute ids form SVG specific to JSR specific |
|
1919 */ |
|
1920 |
|
1921 SvgAttrType CSvgJavaInterfaceImpl::SvgGetAttributeTypeMappingSVGtoJSR( const TInt aElementId) |
|
1922 { |
|
1923 switch(aElementId) |
|
1924 { |
|
1925 case KAtrAccumulate:return AT_ACCUMULATE; |
|
1926 case KAtrAdditive:return AT_ADDITIVE; |
|
1927 case KAtrAlphabetic:return AT_ALPHABETIC; |
|
1928 case KAtrAscent:return AT_ASCENT; |
|
1929 case KAtrAttributeName:return AT_ATTRIBUTENAME; |
|
1930 case KAtrBaseProfile:return AT_BASEPROFILE; |
|
1931 case KAtrBegin:return AT_BEGIN; |
|
1932 case KAtrBy:return AT_BY; |
|
1933 case KAtrCalcMode:return AT_CALCMODE; |
|
1934 case KCSS_ATTR_COLOR:return AT_COLOR; |
|
1935 case KCSS_ATTR_COLORRENDERING:return AT_COLORRENDERING; |
|
1936 case KAtrCx:return AT_CX; |
|
1937 case KAtrCy:return AT_CY; |
|
1938 case KAtrD:return AT_D; |
|
1939 case KAtrDescent:return AT_DESCENT ; |
|
1940 case KCSS_ATTR_DISPLAY:return AT_DISPLAY; |
|
1941 case KAtrDur:return AT_DUR; |
|
1942 case KAtrEnd:return AT_END; |
|
1943 case KCSS_ATTR_FILL:return AT_FILL; |
|
1944 case KCSS_ATTR_FILLRULE:return AT_FILLRULE; |
|
1945 case KCSS_ATTR_FONTFAMILY:return AT_FONTFAMILY; |
|
1946 case KCSS_ATTR_FONTSIZE:return AT_FONTSIZE; |
|
1947 case KCSS_ATTR_FONTSTYLE:return AT_FONTSTYLE; |
|
1948 case KCSS_ATTR_FONTWEIGHT:return AT_FONTWEIGHT; |
|
1949 case KAtrFrom:return AT_FROM; |
|
1950 case KAtrG1:return AT_G1; |
|
1951 case KAtrG2:return AT_G2; |
|
1952 case KAtrGlyphName:return AT_GLYPHNAME; |
|
1953 case KAtrHeight:return AT_HEIGHT; |
|
1954 case KAtrHorizAdvX:return AT_HORIZADVX; |
|
1955 case KAtrHorizOriginX:return AT_HORIZORIGINX; |
|
1956 case KAtrId:return AT_ID; |
|
1957 case KAtrK:return AT_K; |
|
1958 case KAtrKeySplines:return AT_KEYSPLINES; |
|
1959 case KAtrKeyTimes:return AT_KEYTIMES; |
|
1960 case KAtrLang:return AT_LANG; |
|
1961 case KAtrOverlinePosition:return AT_OVERLINEPOSITION; |
|
1962 case KAtrOverlineThickness:return AT_OVERLINETHICKNESS; |
|
1963 case KAtrPath:return AT_PATH; |
|
1964 case KAtrPathLength:return AT_PATHLENGTH; |
|
1965 case KAtrPoints:return AT_POINTS; |
|
1966 case KAtrPreserveAspectRatio:return AT_PRESERVEASPECTRATIO; |
|
1967 case KAtrR:return AT_R; |
|
1968 case KAtrRepeatCount:return AT_REPEATCOUNT; |
|
1969 case KAtrRepeatDur:return AT_REPEATDUR; |
|
1970 case KAtrRequiredExtensions:return AT_REQUIREDEXTENSIONS; |
|
1971 case KAtrRequiredFeatures:return AT_REQUIREDFEATURES; |
|
1972 case KAtrRestart:return AT_RESTART; |
|
1973 case KAtrRotate:return AT_ROTATE; |
|
1974 case KAtrRx :return AT_RX; |
|
1975 case KAtrRy:return AT_RY; |
|
1976 case KAtrStrikethroughPosition:return AT_STRIKETHROUGHPOSITION; |
|
1977 case KAtrStrikethroughThickness:return AT_STRIKETHROUGHTHICKNESS; |
|
1978 case KCSS_ATTR_STROKE:return AT_STROKE; |
|
1979 case KCSS_ATTR_STROKE_DASHARRAY:return AT_STROKEDASHARRAY; |
|
1980 case KCSS_ATTR_STROKE_DASHOFFSET:return AT_STROKEDASHOFFSET; |
|
1981 case KCSS_ATTR_STROKE_LINECAP:return AT_STROKELINECAP; |
|
1982 case KCSS_ATTR_STROKE_LINEJOIN:return AT_STROKELINEJOIN; |
|
1983 case KCSS_ATTR_STROKE_MITERLIMIT:return AT_STROKEMITERLIMIT; |
|
1984 case KCSS_ATTR_STROKEWIDTH:return AT_STROKEWIDTH; |
|
1985 case KAtrStyle:return AT_STYLE; |
|
1986 case KAtrCdata:return AT_STRING; |
|
1987 case KAtrSystemLanguage:return AT_SYSTEMLANGUAGE; |
|
1988 case KCSS_ATTR_TEXTANCHOR:return AT_TEXTANCHOR; |
|
1989 case KCSS_ATTR_TEXTDECORATION:return AT_TEXTDECORATION; |
|
1990 case KAtrTo:return AT_TO; |
|
1991 case KAtrTransform :return AT_TRANSFORM; |
|
1992 case KAtrType: return AT_TYPE; |
|
1993 case KAtrU1:return AT_U1; |
|
1994 case KAtrU2:return AT_U2; |
|
1995 case KAtrUnderlinePosition:return AT_UNDERLINEPOSITION; |
|
1996 case KAtrUnderlineThickness:return AT_UNDERLINETHICKNESS; |
|
1997 case KAtrUnicode:return AT_UNICODE; |
|
1998 case KAtrUnicodeRange:return AT_UNICODERANGE; |
|
1999 case KAtrUnitsPerEm:return AT_UNITSPEREM; |
|
2000 case KAtrValues:return AT_VALUES; |
|
2001 case KAtrVersion:return AT_VERSION; |
|
2002 case KAtrViewBox:return AT_VIEWBOX; |
|
2003 case KCSS_ATTR_VISIBILITY:return AT_VISIBILITY; |
|
2004 case KAtrWidth: return AT_WIDTH; |
|
2005 case KAtrX: return AT_X; |
|
2006 case KAtrX1:return AT_X1; |
|
2007 case KAtrX2:return AT_X2; |
|
2008 case KAtrXlinkactuate:return AT_XLINKACTUATE; |
|
2009 case KAtrXlinkarcrole:return AT_XLINKARCROLE; |
|
2010 case KAtrXlinkhref: return AT_XLINKHREF; |
|
2011 case KAtrXlinkrole: return AT_XLINKROLE; |
|
2012 case KAtrXlinkshow: return AT_XLINKSHOW; |
|
2013 case KAtrXlinktitle:return AT_XLINKTITLE; |
|
2014 case KAtrXlinktype:return AT_XLINKTYPE; |
|
2015 case KAtrXmlLang: return AT_XMLLANG; |
|
2016 case KAtrXmlBase: return AT_XMLBASE; |
|
2017 case KAtrXmlSpace:return AT_XMLSPACE; |
|
2018 case KAtrY: return AT_Y; |
|
2019 case KAtrY1:return AT_Y1; |
|
2020 case KAtrY2:return AT_Y2; |
|
2021 case KAtrZoomAndPan: return AT_ZOOMANDPAN; |
|
2022 default: return KSvgUnknownAttribute; |
|
2023 } |
|
2024 } |
|
2025 |
|
2026 /** |
|
2027 * This maps the Attribute ids form JSR specific to SVG specific |
|
2028 */ |
|
2029 TInt CSvgJavaInterfaceImpl::SvgGetAttributeTypeMappingJSRtoSVG( SvgAttrType aType ) |
|
2030 { |
|
2031 switch(aType) |
|
2032 { |
|
2033 case AT_ACCENTHEIGHT: return KSvgUnknownAttribute; |
|
2034 |
|
2035 case AT_ACCUMULATE: return KAtrAccumulate; |
|
2036 |
|
2037 case AT_ADDITIVE: return KAtrAdditive; |
|
2038 |
|
2039 case AT_ALPHABETIC: return KAtrAlphabetic; |
|
2040 |
|
2041 case AT_ARABICFORM: return KSvgUnknownAttribute; |
|
2042 |
|
2043 case AT_ASCENT: return KAtrAscent; |
|
2044 |
|
2045 case AT_ATTRIBUTENAME: return KAtrAttributeName; |
|
2046 |
|
2047 case AT_ATTRIBUTETYPE: return KSvgUnknownAttribute; |
|
2048 |
|
2049 case AT_BASEPROFILE: return KAtrBaseProfile; |
|
2050 |
|
2051 case AT_BBOX: return KSvgUnknownAttribute; |
|
2052 |
|
2053 case AT_BEGIN: return KAtrBegin; |
|
2054 |
|
2055 case AT_BY: return KAtrBy; |
|
2056 |
|
2057 case AT_CALCMODE: return KAtrCalcMode; |
|
2058 |
|
2059 case AT_CAPHEIGHT: return KSvgUnknownAttribute; |
|
2060 |
|
2061 case AT_COLOR: return KCSS_ATTR_COLOR; |
|
2062 |
|
2063 case AT_COLORRENDERING: return KCSS_ATTR_COLORRENDERING; |
|
2064 |
|
2065 case AT_CX: return KAtrCx; |
|
2066 |
|
2067 case AT_CY: return KAtrCy; |
|
2068 |
|
2069 case AT_D: return KAtrD; |
|
2070 |
|
2071 case AT_DESCENT: return KAtrDescent; |
|
2072 |
|
2073 case AT_DISPLAY: return KCSS_ATTR_DISPLAY; |
|
2074 |
|
2075 case AT_DUR: return KAtrDur; |
|
2076 |
|
2077 case AT_END: return KAtrEnd; |
|
2078 |
|
2079 // it can be the fill corressponding to animation how to handle that. |
|
2080 case AT_FILL: return KCSS_ATTR_FILL; |
|
2081 |
|
2082 case AT_FILLRULE: return KCSS_ATTR_FILLRULE; |
|
2083 |
|
2084 case AT_FONTFAMILY: return KCSS_ATTR_FONTFAMILY; |
|
2085 |
|
2086 case AT_FONTSIZE: return KCSS_ATTR_FONTSIZE; |
|
2087 |
|
2088 case AT_FONTSTRETCH: return KSvgUnknownAttribute; |
|
2089 |
|
2090 case AT_FONTSTYLE: return KCSS_ATTR_FONTSTYLE; |
|
2091 |
|
2092 case AT_FONTVARIANT: return KSvgUnknownAttribute; |
|
2093 |
|
2094 case AT_FONTWEIGHT: return KCSS_ATTR_FONTWEIGHT; |
|
2095 |
|
2096 case AT_FROM: return KAtrFrom; |
|
2097 |
|
2098 case AT_G1: return KAtrG1; |
|
2099 |
|
2100 case AT_G2: return KAtrG2; |
|
2101 |
|
2102 case AT_GLYPHNAME: return KAtrGlyphName; |
|
2103 |
|
2104 case AT_HANGING: return KSvgUnknownAttribute; |
|
2105 |
|
2106 case AT_HEIGHT: return KAtrHeight; |
|
2107 |
|
2108 case AT_HORIZADVX: return KAtrHorizAdvX; |
|
2109 |
|
2110 case AT_HORIZORIGINX: return KAtrHorizOriginX; |
|
2111 |
|
2112 case AT_ID: return KAtrId; |
|
2113 |
|
2114 case AT_IDEOGRAPHIC: return KSvgUnknownAttribute; |
|
2115 |
|
2116 case AT_K: return KAtrK; |
|
2117 |
|
2118 case AT_KEYPOINTS: return KSvgUnknownAttribute; |
|
2119 |
|
2120 case AT_KEYSPLINES: return KAtrKeySplines; |
|
2121 |
|
2122 case AT_KEYTIMES: return KAtrKeyTimes; |
|
2123 |
|
2124 case AT_LANG: return KAtrLang; |
|
2125 |
|
2126 case AT_MATHEMATICAL: return KSvgUnknownAttribute; |
|
2127 |
|
2128 case AT_MAX: return KSvgUnknownAttribute; |
|
2129 |
|
2130 case AT_MIN: return KSvgUnknownAttribute; |
|
2131 |
|
2132 case AT_NAME: return KSvgUnknownAttribute; |
|
2133 |
|
2134 case AT_ORIGIN: return KSvgUnknownAttribute; |
|
2135 |
|
2136 case AT_OVERLINEPOSITION: return KAtrOverlinePosition; |
|
2137 |
|
2138 case AT_OVERLINETHICKNESS: return KAtrOverlineThickness; |
|
2139 |
|
2140 case AT_PANOSE1: return KSvgUnknownAttribute; |
|
2141 |
|
2142 case AT_PATH: return KAtrPath; |
|
2143 |
|
2144 case AT_PATHLENGTH: return KAtrPathLength; |
|
2145 |
|
2146 case AT_POINTS: return KAtrPoints; |
|
2147 |
|
2148 case AT_PRESERVEASPECTRATIO: return KAtrPreserveAspectRatio; |
|
2149 |
|
2150 case AT_R: return KAtrR; |
|
2151 |
|
2152 case AT_REPEATCOUNT: return KAtrRepeatCount; |
|
2153 |
|
2154 case AT_REPEATDUR:return KAtrRepeatDur; |
|
2155 |
|
2156 case AT_REQUIREDEXTENSIONS: return KAtrRequiredExtensions; |
|
2157 |
|
2158 case AT_REQUIREDFEATURES: return KAtrRequiredFeatures; |
|
2159 |
|
2160 case AT_RESTART: return KAtrRestart; |
|
2161 |
|
2162 case AT_ROTATE: return KAtrRotate; |
|
2163 |
|
2164 case AT_RX: return KAtrRx; |
|
2165 |
|
2166 case AT_RY: return KAtrRy; |
|
2167 |
|
2168 case AT_SLOPE: return KSvgUnknownAttribute; |
|
2169 |
|
2170 case AT_STEMH: return KSvgUnknownAttribute; |
|
2171 |
|
2172 case AT_STEMV: return KSvgUnknownAttribute; |
|
2173 |
|
2174 case AT_STRIKETHROUGHPOSITION: return KAtrStrikethroughPosition; |
|
2175 |
|
2176 case AT_STRIKETHROUGHTHICKNESS: return KAtrStrikethroughThickness; |
|
2177 |
|
2178 case AT_STROKE: return KCSS_ATTR_STROKE; |
|
2179 |
|
2180 case AT_STROKEDASHARRAY: return KCSS_ATTR_STROKE_DASHARRAY; |
|
2181 |
|
2182 case AT_STROKEDASHOFFSET: return KCSS_ATTR_STROKE_DASHOFFSET; |
|
2183 |
|
2184 case AT_STROKELINECAP: return KCSS_ATTR_STROKE_LINECAP; |
|
2185 |
|
2186 case AT_STROKELINEJOIN: return KCSS_ATTR_STROKE_LINEJOIN; |
|
2187 |
|
2188 case AT_STROKEMITERLIMIT: return KCSS_ATTR_STROKE_MITERLIMIT; |
|
2189 |
|
2190 case AT_STROKEWIDTH: return KCSS_ATTR_STROKEWIDTH; |
|
2191 |
|
2192 case AT_STYLE: return KAtrStyle; |
|
2193 |
|
2194 case AT_STRING: return KAtrCdata; |
|
2195 |
|
2196 case AT_SYSTEMLANGUAGE: return KAtrSystemLanguage; |
|
2197 |
|
2198 case AT_TARGET: return KAtrTarget; |
|
2199 |
|
2200 case AT_TEXTANCHOR: return KCSS_ATTR_TEXTANCHOR; |
|
2201 case AT_TEXTDECORATION: return KCSS_ATTR_TEXTDECORATION; |
|
2202 case AT_TO: return KAtrTo; |
|
2203 |
|
2204 case AT_TRANSFORM: return KAtrTransform; |
|
2205 |
|
2206 case AT_TYPE: return KAtrType; |
|
2207 |
|
2208 case AT_U1: return KAtrU1; |
|
2209 |
|
2210 case AT_U2: return KAtrU2; |
|
2211 |
|
2212 case AT_UNDERLINEPOSITION: return KAtrUnderlinePosition; |
|
2213 |
|
2214 case AT_UNDERLINETHICKNESS: return KAtrUnderlineThickness; |
|
2215 |
|
2216 case AT_UNICODE: return KAtrUnicode; |
|
2217 |
|
2218 case AT_UNICODERANGE:return KAtrUnicodeRange; |
|
2219 |
|
2220 case AT_UNITSPEREM: return KAtrUnitsPerEm; |
|
2221 |
|
2222 case AT_VALUES: return KAtrValues; |
|
2223 |
|
2224 case AT_VERSION: return KAtrVersion; |
|
2225 |
|
2226 case AT_VIEWBOX: return KAtrViewBox; |
|
2227 |
|
2228 case AT_VISIBILITY: return KCSS_ATTR_VISIBILITY; |
|
2229 |
|
2230 case AT_WIDTH: return KAtrWidth; |
|
2231 |
|
2232 case AT_WIDTHS: return KSvgUnknownAttribute; |
|
2233 |
|
2234 case AT_X: return KAtrX; |
|
2235 |
|
2236 case AT_XHEIGHT: return KSvgUnknownAttribute; |
|
2237 |
|
2238 case AT_X1: return KAtrX1; |
|
2239 |
|
2240 case AT_X2:return KAtrX2; |
|
2241 |
|
2242 case AT_XLINKACTUATE: return KAtrXlinkactuate; |
|
2243 |
|
2244 case AT_XLINKARCROLE: return KAtrXlinkarcrole; |
|
2245 |
|
2246 case AT_XLINKHREF: return KAtrXlinkhref; |
|
2247 |
|
2248 case AT_XLINKROLE: return KAtrXlinkrole; |
|
2249 |
|
2250 case AT_XLINKSHOW: return KAtrXlinkshow; |
|
2251 |
|
2252 case AT_XLINKTITLE: return KAtrXlinktitle; |
|
2253 |
|
2254 case AT_XLINKTYPE: return KAtrXlinktype; |
|
2255 |
|
2256 case AT_XMLLANG: return KAtrXmlLang; |
|
2257 |
|
2258 case AT_XMLBASE: return KAtrXmlBase; |
|
2259 |
|
2260 case AT_XMLSPACE: return KAtrXmlSpace; |
|
2261 |
|
2262 case AT_Y: return KAtrY; |
|
2263 |
|
2264 case AT_Y1: return KAtrY1; |
|
2265 |
|
2266 case AT_Y2: return KAtrY2; |
|
2267 |
|
2268 case AT_ZOOMANDPAN: return KAtrZoomAndPan; |
|
2269 |
|
2270 default: return KSvgUnknownAttribute; |
|
2271 } |
|
2272 } |
|
2273 /** |
|
2274 * This maps the Enumeration Mapping form JSR specific to SVG specific |
|
2275 */ |
|
2276 TInt CSvgJavaInterfaceImpl::SvgEnumerationMappingJSRtoSVG(const TInt aAttributeId, const TInt aJsrEnumValue) |
|
2277 { |
|
2278 // Most of these are style properties. |
|
2279 // COLOR_Rendering. this is not supported. |
|
2280 switch(aAttributeId) |
|
2281 { |
|
2282 // Text Anchor |
|
2283 case KAtrRotate: |
|
2284 { |
|
2285 switch(aJsrEnumValue) |
|
2286 { |
|
2287 // these are defined in animateMotion.cpp |
|
2288 case ROTATE_AUTO: return -100; |
|
2289 case ROTATE_AUTOREVERSE: return -200; |
|
2290 default: |
|
2291 return KErrNotFound; |
|
2292 } |
|
2293 } |
|
2294 |
|
2295 case KAtrType: |
|
2296 { |
|
2297 switch(aJsrEnumValue) |
|
2298 { |
|
2299 // these are defined in SchemaData.cpp |
|
2300 case TYPE_TRANSLATE: return KSvgTypeTranslate; |
|
2301 case TYPE_SCALE: return KSvgTypeScale; |
|
2302 case TYPE_ROTATE:return KSvgTypeRotate; |
|
2303 case TYPE_SKEWX:return KSvgTypeSkewX; |
|
2304 case TYPE_SKEWY: return KSvgTypeSkewY; |
|
2305 default: |
|
2306 return KErrNotFound; |
|
2307 } |
|
2308 } |
|
2309 |
|
2310 case KCSS_ATTR_FONTSIZE: |
|
2311 { |
|
2312 switch(aJsrEnumValue) |
|
2313 { |
|
2314 case FONT_SIZE_XXSMALL: return 2; |
|
2315 case FONT_SIZE_XSMALL: return 4; |
|
2316 case FONT_SIZE_SMALL:return 6; |
|
2317 case FONT_SIZE_MEDIUM:return 10; |
|
2318 case FONT_SIZE_LARGE: return 16; |
|
2319 case FONT_SIZE_XLARGE:return 20; |
|
2320 case FONT_SIZE_XXLARGE:return 24; |
|
2321 default: |
|
2322 return KErrNotFound; |
|
2323 } |
|
2324 } |
|
2325 |
|
2326 case KCSS_ATTR_TEXTANCHOR: |
|
2327 { |
|
2328 switch(aJsrEnumValue) |
|
2329 { |
|
2330 case TEXT_ANCHOR_START: |
|
2331 // these constants are taken from schemaData.cpp any change will need |
|
2332 // to be propagated to here |
|
2333 return 0; |
|
2334 case TEXT_ANCHOR_MIDDLE: |
|
2335 return 1; |
|
2336 case TEXT_ANCHOR_END: |
|
2337 return 2; |
|
2338 default: |
|
2339 return KErrNotFound; |
|
2340 } |
|
2341 |
|
2342 } |
|
2343 // Font Weight |
|
2344 case KCSS_ATTR_FONTWEIGHT: |
|
2345 { |
|
2346 switch(aJsrEnumValue) |
|
2347 { |
|
2348 case FONT_NORMAL: |
|
2349 return 0; |
|
2350 case FONT_WEIGHT_BOLD: |
|
2351 return 1; |
|
2352 case FONT_WEIGHT_BOLDER: |
|
2353 return 2; |
|
2354 case FONT_WEIGHT_LIGHTER: |
|
2355 return 3; |
|
2356 case FONT_WEIGHT_100: |
|
2357 return 4; |
|
2358 case FONT_WEIGHT_200: |
|
2359 return 5; |
|
2360 case FONT_WEIGHT_300: |
|
2361 return 6; |
|
2362 case FONT_WEIGHT_400: |
|
2363 return 7; |
|
2364 case FONT_WEIGHT_500: |
|
2365 return 8; |
|
2366 case FONT_WEIGHT_600: |
|
2367 return 9; |
|
2368 case FONT_WEIGHT_700: |
|
2369 return 10; |
|
2370 case FONT_WEIGHT_800: |
|
2371 return 11; |
|
2372 case FONT_WEIGHT_900: |
|
2373 return 12; |
|
2374 default: |
|
2375 return KErrNotFound; |
|
2376 } |
|
2377 |
|
2378 } |
|
2379 // Font Style |
|
2380 case KCSS_ATTR_FONTSTYLE: |
|
2381 { |
|
2382 switch(aJsrEnumValue) |
|
2383 { |
|
2384 case FONT_NORMAL: |
|
2385 return 0; |
|
2386 case FONT_STYLE_ITALIC : |
|
2387 return 1; |
|
2388 case FONT_STYLE_OBLIQUE : |
|
2389 return 2; |
|
2390 default: |
|
2391 return KErrNotFound; |
|
2392 } |
|
2393 |
|
2394 } |
|
2395 // Spread Method not given in defines.h so probably spreadmethod won't be used. |
|
2396 case KAtrPreserveAspectRatio: |
|
2397 |
|
2398 { |
|
2399 switch(aJsrEnumValue) |
|
2400 { |
|
2401 case PAR_NONE: |
|
2402 return 0; |
|
2403 case PAR_XMIDYMID: |
|
2404 return 6; |
|
2405 default: |
|
2406 return KErrNotFound; |
|
2407 |
|
2408 } |
|
2409 |
|
2410 } |
|
2411 // TextDecoration |
|
2412 case KAtrZoomAndPan: |
|
2413 { |
|
2414 switch(aJsrEnumValue) |
|
2415 { |
|
2416 case ZPN_MAGNIFY: |
|
2417 return 1; |
|
2418 |
|
2419 case ZPN_DISABLE: |
|
2420 return 0; |
|
2421 default: |
|
2422 return KErrNotFound; |
|
2423 } |
|
2424 |
|
2425 } |
|
2426 // Display |
|
2427 case KCSS_ATTR_DISPLAY: |
|
2428 { |
|
2429 switch(aJsrEnumValue) |
|
2430 { |
|
2431 case DISPLAY_NONE: |
|
2432 return 16; |
|
2433 |
|
2434 case DISPLAY_OTHER: |
|
2435 return 0; |
|
2436 |
|
2437 default: |
|
2438 return KErrNotFound; |
|
2439 |
|
2440 } |
|
2441 |
|
2442 } |
|
2443 // VIsibility |
|
2444 case KCSS_ATTR_VISIBILITY: |
|
2445 { |
|
2446 switch(aJsrEnumValue) |
|
2447 { |
|
2448 case VISIBILITY_VISIBLE: |
|
2449 return 0; |
|
2450 case VISIBILITY_OTHER: |
|
2451 return 1; |
|
2452 default: |
|
2453 return KErrNotFound; |
|
2454 |
|
2455 } |
|
2456 |
|
2457 } |
|
2458 case KAtrAdditive: |
|
2459 { |
|
2460 switch(aJsrEnumValue) |
|
2461 { |
|
2462 case ADDITIVE_REPLACE: |
|
2463 return 0; |
|
2464 case ADDITIVE_SUM: |
|
2465 return 1; |
|
2466 default : return KErrNotFound; |
|
2467 |
|
2468 } |
|
2469 |
|
2470 } |
|
2471 case KAtrAccumulate: |
|
2472 { |
|
2473 switch(aJsrEnumValue) |
|
2474 { |
|
2475 case ACCUMULATE_NONE: |
|
2476 return 0; |
|
2477 case ACCUMULATE_SUM: |
|
2478 return 1; |
|
2479 default : return KErrNotFound; |
|
2480 |
|
2481 } |
|
2482 |
|
2483 } |
|
2484 case KAtrCalcMode: |
|
2485 { |
|
2486 switch(aJsrEnumValue) |
|
2487 { |
|
2488 case CALC_MODE_DISCRETE: |
|
2489 return 0; |
|
2490 case CALC_MODE_LINEAR: |
|
2491 return 1; |
|
2492 case CALC_MODE_PACED: |
|
2493 return 2; |
|
2494 case CALC_MODE_SPLINE: |
|
2495 return 3; |
|
2496 default: return KErrNotFound; |
|
2497 |
|
2498 } |
|
2499 |
|
2500 } |
|
2501 // it can not be this attribute. |
|
2502 // This fill corresponds to animation. |
|
2503 case KCSS_ATTR_FILL: |
|
2504 { |
|
2505 switch(aJsrEnumValue) |
|
2506 { |
|
2507 // these are for animation |
|
2508 case FILL_REMOVE: |
|
2509 return 0; |
|
2510 case FILL_FREEZE: |
|
2511 return 1; |
|
2512 // following is the attribute value for fill "color" |
|
2513 // these are for fill - style attributes. |
|
2514 case PAINT_NONE: |
|
2515 return KSVGColorNone; |
|
2516 case PAINT_CURRENT: |
|
2517 return KSVGCurrentColor; |
|
2518 case PAINT_INHERIT: |
|
2519 return KSVGColorInherit; |
|
2520 default: return KErrNotFound; |
|
2521 } |
|
2522 |
|
2523 } |
|
2524 case KCSS_ATTR_STROKE: |
|
2525 { |
|
2526 switch(aJsrEnumValue) |
|
2527 { |
|
2528 // following is the attribute value for fill "color" |
|
2529 // these are for fill - style attributes. |
|
2530 case PAINT_NONE: |
|
2531 return KSVGColorNone; |
|
2532 case PAINT_CURRENT: |
|
2533 return KSVGCurrentColor; |
|
2534 case PAINT_INHERIT: |
|
2535 return KSVGColorInherit; |
|
2536 default: return KErrNotFound; |
|
2537 } |
|
2538 |
|
2539 } |
|
2540 case KAtrRestart: |
|
2541 { |
|
2542 switch(aJsrEnumValue) |
|
2543 { |
|
2544 case RESTART_ALWAYS: |
|
2545 return 0; |
|
2546 case RESTART_NEVER: |
|
2547 return 2; |
|
2548 case RESTART_WHENNOTACTIVE: |
|
2549 return 1; |
|
2550 default : |
|
2551 return KErrNotFound; |
|
2552 } |
|
2553 |
|
2554 } |
|
2555 case KCSS_ATTR_TEXTDECORATION: |
|
2556 { |
|
2557 switch(aJsrEnumValue) |
|
2558 { |
|
2559 case TEXT_UNDER_LINE: |
|
2560 return 1; |
|
2561 case TEXT_OVER_LINE: |
|
2562 return 2; |
|
2563 case TEXT_LINE_THROUGH: |
|
2564 return 3; |
|
2565 default: |
|
2566 return KErrNotFound; |
|
2567 } |
|
2568 |
|
2569 } |
|
2570 default: |
|
2571 return KErrNotFound; |
|
2572 |
|
2573 } |
|
2574 } |
|
2575 |
|
2576 /** |
|
2577 * This maps the Enumeration from JSR to SVG. SVG enumerated value here is string type. |
|
2578 */ |
|
2579 TInt CSvgJavaInterfaceImpl::SvgEnumerationtoStringMappingJSRtoSVG(const TInt aAttributeId, short aJsrEnumValue, TDes& aValue) |
|
2580 { |
|
2581 // all of these are style properties. |
|
2582 switch(aAttributeId) |
|
2583 { |
|
2584 case KCSS_ATTR_FILLRULE: |
|
2585 switch(aJsrEnumValue) |
|
2586 { |
|
2587 case FILL_RULE_EVENODD: |
|
2588 { |
|
2589 aValue = _L("evenodd"); |
|
2590 } |
|
2591 break; |
|
2592 case FILL_RULE_NONZERO: |
|
2593 { |
|
2594 aValue = _L("nonzero"); |
|
2595 } |
|
2596 break; |
|
2597 default: |
|
2598 return KErrNotFound; |
|
2599 |
|
2600 } |
|
2601 break; |
|
2602 case KCSS_ATTR_STROKE_LINECAP: |
|
2603 switch(aJsrEnumValue) |
|
2604 { |
|
2605 case STROKE_LINECAP_BUTT: |
|
2606 { |
|
2607 aValue = _L("butt"); |
|
2608 } |
|
2609 break; |
|
2610 case STROKE_LINECAP_ROUND: |
|
2611 { |
|
2612 aValue = _L("round"); |
|
2613 } |
|
2614 break; |
|
2615 case STROKE_LINECAP_SQUARE: |
|
2616 { |
|
2617 aValue = _L("square"); |
|
2618 } |
|
2619 break; |
|
2620 default : return KErrNotFound; |
|
2621 } |
|
2622 break; |
|
2623 case KCSS_ATTR_STROKE_LINEJOIN: |
|
2624 switch(aJsrEnumValue) |
|
2625 { |
|
2626 case STROKE_LINEJOIN_MITER: |
|
2627 { |
|
2628 aValue = _L("miter"); |
|
2629 } |
|
2630 break; |
|
2631 case STROKE_LINEJOIN_ROUND: |
|
2632 { |
|
2633 aValue = _L("round"); |
|
2634 } |
|
2635 break; |
|
2636 case STROKE_LINEJOIN_BEVEL: |
|
2637 { |
|
2638 aValue = _L("bevel"); |
|
2639 } |
|
2640 break; |
|
2641 default : return KErrNotFound; |
|
2642 } |
|
2643 break; |
|
2644 default: return KErrNotFound; |
|
2645 |
|
2646 } |
|
2647 return KErrNone; |
|
2648 } |
|
2649 /** |
|
2650 * This maps the Enumeration from SVG to JSR. SVG enumerated value here is string type. |
|
2651 */ |
|
2652 TInt CSvgJavaInterfaceImpl::SvgStringtoEnumerationMappingSVGtoJSR(const TInt aAttributeId , TPtrC16 aValue) |
|
2653 { |
|
2654 switch(aAttributeId) |
|
2655 { |
|
2656 case KCSS_ATTR_FILLRULE: |
|
2657 { |
|
2658 if(aValue == _L("evenodd")) |
|
2659 return FILL_RULE_EVENODD; |
|
2660 if(aValue == _L("nonzero")) |
|
2661 return FILL_RULE_NONZERO; |
|
2662 } |
|
2663 case KCSS_ATTR_STROKE_LINECAP: |
|
2664 { |
|
2665 if(aValue == _L("butt")) |
|
2666 return STROKE_LINECAP_BUTT; |
|
2667 if(aValue == _L("round")) |
|
2668 return STROKE_LINECAP_ROUND; |
|
2669 if(aValue == _L("square")) |
|
2670 return STROKE_LINECAP_SQUARE; |
|
2671 } |
|
2672 |
|
2673 case KCSS_ATTR_STROKE_LINEJOIN: |
|
2674 |
|
2675 { |
|
2676 if(aValue == _L("miter")) |
|
2677 return STROKE_LINEJOIN_MITER; |
|
2678 if(aValue == _L("round")) |
|
2679 return STROKE_LINEJOIN_ROUND; |
|
2680 if(aValue == _L("bevel")) |
|
2681 return STROKE_LINEJOIN_BEVEL; |
|
2682 } |
|
2683 default: return KErrNotFound; |
|
2684 } |
|
2685 } |
|
2686 /** |
|
2687 * This maps the Enumeration from SVG to JSR. |
|
2688 */ |
|
2689 TInt CSvgJavaInterfaceImpl::SvgEnumerationMappingSVGtoJSR(const TInt aAttributeId, TInt32 aSvgEnumValue) |
|
2690 { |
|
2691 switch(aAttributeId) |
|
2692 { |
|
2693 |
|
2694 case KAtrRotate: |
|
2695 { |
|
2696 switch(aSvgEnumValue) |
|
2697 { |
|
2698 case -100: return ROTATE_AUTO; |
|
2699 case -200: return ROTATE_AUTOREVERSE; |
|
2700 default: |
|
2701 return KErrNotFound; |
|
2702 } |
|
2703 } |
|
2704 |
|
2705 case KAtrType: |
|
2706 { |
|
2707 switch(aSvgEnumValue) |
|
2708 { |
|
2709 case KSvgTypeTranslate: return TYPE_TRANSLATE; |
|
2710 case KSvgTypeScale: return TYPE_SCALE; |
|
2711 case KSvgTypeRotate:return TYPE_ROTATE; |
|
2712 case KSvgTypeSkewX:return TYPE_SKEWX; |
|
2713 case KSvgTypeSkewY: return TYPE_SKEWY; |
|
2714 default: |
|
2715 return KErrNotFound; |
|
2716 } |
|
2717 } |
|
2718 |
|
2719 case KCSS_ATTR_TEXTANCHOR: |
|
2720 { |
|
2721 switch(aSvgEnumValue) |
|
2722 { |
|
2723 case 0: |
|
2724 // these constants are taken from schemaData.cpp any change will need |
|
2725 // to be propagated to here |
|
2726 return TEXT_ANCHOR_START; |
|
2727 case 1: |
|
2728 return TEXT_ANCHOR_MIDDLE; |
|
2729 case 2: |
|
2730 return TEXT_ANCHOR_END; |
|
2731 default: |
|
2732 return KErrNotFound; |
|
2733 } |
|
2734 |
|
2735 } |
|
2736 // Font Weight |
|
2737 case KCSS_ATTR_FONTWEIGHT: |
|
2738 { |
|
2739 switch(aSvgEnumValue) |
|
2740 { |
|
2741 case 0: |
|
2742 return FONT_NORMAL; |
|
2743 case 1: |
|
2744 return FONT_WEIGHT_BOLD; |
|
2745 case 2: |
|
2746 return FONT_WEIGHT_BOLDER; |
|
2747 case 3: |
|
2748 return FONT_WEIGHT_LIGHTER; |
|
2749 case 4: |
|
2750 return FONT_WEIGHT_100; |
|
2751 case 5: |
|
2752 return FONT_WEIGHT_200; |
|
2753 case 6: |
|
2754 return FONT_WEIGHT_300; |
|
2755 case 7: |
|
2756 return FONT_WEIGHT_400; |
|
2757 case 8: |
|
2758 return FONT_WEIGHT_500; |
|
2759 case 9: |
|
2760 return FONT_WEIGHT_600; |
|
2761 case 10: |
|
2762 return FONT_WEIGHT_700; |
|
2763 case 11: |
|
2764 return FONT_WEIGHT_800; |
|
2765 case 12: |
|
2766 return FONT_WEIGHT_900; |
|
2767 default: |
|
2768 return KErrNotFound; |
|
2769 } |
|
2770 |
|
2771 } |
|
2772 // Font Style |
|
2773 case KCSS_ATTR_FONTSTYLE: |
|
2774 { |
|
2775 switch(aSvgEnumValue) |
|
2776 { |
|
2777 case 0: |
|
2778 return FONT_NORMAL; |
|
2779 case 1: |
|
2780 return FONT_STYLE_ITALIC; |
|
2781 case 2: |
|
2782 return FONT_STYLE_OBLIQUE ; |
|
2783 default: |
|
2784 return KErrNotFound; |
|
2785 } |
|
2786 |
|
2787 } |
|
2788 // preserve aspect ratio |
|
2789 case KAtrPreserveAspectRatio: |
|
2790 |
|
2791 { |
|
2792 switch(aSvgEnumValue) |
|
2793 { |
|
2794 case 0: |
|
2795 return PAR_NONE; |
|
2796 case 6: |
|
2797 return PAR_XMIDYMID; |
|
2798 } |
|
2799 |
|
2800 } |
|
2801 // Zoom and Pan |
|
2802 case KAtrZoomAndPan: |
|
2803 { |
|
2804 switch(aSvgEnumValue) |
|
2805 { |
|
2806 case 1: |
|
2807 return ZPN_MAGNIFY; |
|
2808 |
|
2809 case 0: |
|
2810 return ZPN_DISABLE; |
|
2811 } |
|
2812 |
|
2813 } |
|
2814 // Display |
|
2815 case KCSS_ATTR_DISPLAY: |
|
2816 { |
|
2817 switch(aSvgEnumValue) |
|
2818 { |
|
2819 case 16: |
|
2820 return DISPLAY_NONE; |
|
2821 |
|
2822 case 0: |
|
2823 return DISPLAY_OTHER; |
|
2824 |
|
2825 default: |
|
2826 return KErrNotFound; |
|
2827 |
|
2828 } |
|
2829 |
|
2830 } |
|
2831 // VIsibility |
|
2832 case KCSS_ATTR_VISIBILITY: |
|
2833 { |
|
2834 switch(aSvgEnumValue) |
|
2835 { |
|
2836 case 0: |
|
2837 return VISIBILITY_VISIBLE; |
|
2838 case 1: |
|
2839 return VISIBILITY_OTHER; |
|
2840 default: |
|
2841 return KErrNotFound; |
|
2842 |
|
2843 } |
|
2844 |
|
2845 } |
|
2846 // additive |
|
2847 case KAtrAdditive: |
|
2848 { |
|
2849 switch(aSvgEnumValue) |
|
2850 { |
|
2851 case 1: |
|
2852 return ADDITIVE_SUM; |
|
2853 default : return ADDITIVE_REPLACE; |
|
2854 |
|
2855 } |
|
2856 |
|
2857 } |
|
2858 // accumulate |
|
2859 case KAtrAccumulate: |
|
2860 { |
|
2861 switch(aSvgEnumValue) |
|
2862 { |
|
2863 case 0: |
|
2864 return ACCUMULATE_NONE; |
|
2865 case 1: |
|
2866 return ACCUMULATE_SUM; |
|
2867 default : return KErrNotFound; |
|
2868 |
|
2869 } |
|
2870 |
|
2871 } |
|
2872 // calc-mode |
|
2873 case KAtrCalcMode: |
|
2874 { |
|
2875 switch(aSvgEnumValue) |
|
2876 { |
|
2877 case 0: |
|
2878 return CALC_MODE_DISCRETE; |
|
2879 case 1: |
|
2880 return CALC_MODE_LINEAR; |
|
2881 case 2: |
|
2882 return CALC_MODE_PACED; |
|
2883 case 3: |
|
2884 return CALC_MODE_SPLINE; |
|
2885 default: return KErrNotFound; |
|
2886 |
|
2887 } |
|
2888 |
|
2889 } |
|
2890 // it can not be this attribute. |
|
2891 // This fill corresponds to animation. |
|
2892 // fill attribute |
|
2893 case KCSS_ATTR_FILL: |
|
2894 { |
|
2895 switch(aSvgEnumValue) |
|
2896 { |
|
2897 case 0: |
|
2898 return FILL_REMOVE; |
|
2899 case 1: |
|
2900 return FILL_FREEZE; |
|
2901 default: return KErrNotFound; |
|
2902 } |
|
2903 |
|
2904 } |
|
2905 // restart attribute. |
|
2906 case KAtrRestart: |
|
2907 { |
|
2908 switch(aSvgEnumValue) |
|
2909 { |
|
2910 case 0: |
|
2911 return RESTART_ALWAYS; |
|
2912 case 2: |
|
2913 return RESTART_NEVER; |
|
2914 case 1: |
|
2915 return RESTART_WHENNOTACTIVE; |
|
2916 default : |
|
2917 return KErrNotFound; |
|
2918 } |
|
2919 |
|
2920 } |
|
2921 // text decoration. |
|
2922 case KCSS_ATTR_TEXTDECORATION: |
|
2923 { |
|
2924 switch(aSvgEnumValue) |
|
2925 { |
|
2926 case 1: |
|
2927 return TEXT_UNDER_LINE; |
|
2928 case 2: |
|
2929 return TEXT_OVER_LINE; |
|
2930 case 3: |
|
2931 return TEXT_LINE_THROUGH; |
|
2932 default: |
|
2933 return KErrNotFound; |
|
2934 } |
|
2935 |
|
2936 } |
|
2937 default: |
|
2938 return KErrNotFound; |
|
2939 |
|
2940 } |
|
2941 } |
|
2942 |
|
2943 /* |
|
2944 * This functions checks if an element is in a specified document. |
|
2945 * |
|
2946 */ |
|
2947 |
|
2948 TInt CSvgJavaInterfaceImpl::MapSegmentType(TInt aSvgSegmentType) |
|
2949 { |
|
2950 // the following is a limitation since in GFx2d.dll we do not store the |
|
2951 // relative or absolute nature of a command. |
|
2952 // currently we return the absolute. |
|
2953 |
|
2954 switch(aSvgSegmentType) |
|
2955 { |
|
2956 case KSvgSegClose: |
|
2957 { |
|
2958 return PATH_COMMAND_Z; |
|
2959 } |
|
2960 case KSvgSegLineTo: |
|
2961 { |
|
2962 return PATH_COMMAND_L; |
|
2963 } |
|
2964 case KSvgSegQuadTo: |
|
2965 { |
|
2966 return PATH_COMMAND_Q; |
|
2967 } |
|
2968 case KSvgSegCubicTo: |
|
2969 { |
|
2970 return PATH_COMMAND_C; |
|
2971 } |
|
2972 case KSvgSegMoveTo: |
|
2973 { |
|
2974 return PATH_COMMAND_M; |
|
2975 } |
|
2976 case KSvgVertical: |
|
2977 { |
|
2978 return PATH_COMMAND_V; |
|
2979 } |
|
2980 case KSvgHorizontal: |
|
2981 { |
|
2982 return PATH_COMMAND_H; |
|
2983 } |
|
2984 default : |
|
2985 return 0; |
|
2986 } |
|
2987 } |