46
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: SVG Implementation source file
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#if !defined(__E32BASE_H__)
|
|
20 |
#include <e32base.h>
|
|
21 |
#endif
|
|
22 |
|
|
23 |
#include "SVGElementImpl.h"
|
|
24 |
#include "SVGXmlElementImpl.h"
|
|
25 |
|
|
26 |
#include "GfxAffineTransform.h"
|
|
27 |
|
|
28 |
#include "SVGClrCssValueImpl.h"
|
|
29 |
#include "SVGPaintCssValueImpl.h"
|
|
30 |
#include "SVGIntCssValueImpl.h"
|
|
31 |
#include "SVGFloatCssValueImpl.h"
|
|
32 |
#include "SVGStrCssValueImpl.h"
|
|
33 |
#include "SVGVectorCssValueImpl.h"
|
|
34 |
|
|
35 |
#include "SVGSchemaData.h"
|
|
36 |
#include "SVGAnimationBase.h"
|
|
37 |
#include "SVGLineElementImpl.h"
|
|
38 |
#include "SVGRectElementImpl.h"
|
|
39 |
#include "SVGCircleElementImpl.h"
|
|
40 |
#include "SVGMpathElementImpl.h"
|
|
41 |
|
|
42 |
#include "SVGFontFaceElementImpl.h"
|
|
43 |
|
|
44 |
#include "SVGDocumentImpl.h"
|
|
45 |
#include "SVGStringTokenizer.h"
|
|
46 |
|
|
47 |
#include "SVGEngineImpl.h"
|
|
48 |
#include "SVGUseElementImpl.h"
|
|
49 |
#include "SVGAnimationElementImpl.h"
|
|
50 |
#include "SVGTokenizer.h"
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
CSvgElementImpl::~CSvgElementImpl()
|
|
56 |
{
|
|
57 |
if ( iId )
|
|
58 |
{
|
|
59 |
delete iId;
|
|
60 |
iId = NULL;
|
|
61 |
}
|
|
62 |
|
|
63 |
//need to remove from event list if it was an animation
|
|
64 |
|
|
65 |
CSvgDocumentImpl* thisDocument = ( CSvgDocumentImpl* ) OwnerDocument();
|
|
66 |
|
|
67 |
if (thisDocument != NULL)
|
|
68 |
{
|
|
69 |
thisDocument->RemoveFromEventReceiverList(this);
|
|
70 |
}
|
|
71 |
|
|
72 |
if ( iSvgTests )
|
|
73 |
{
|
|
74 |
delete iSvgTests;
|
|
75 |
iSvgTests = NULL;
|
|
76 |
}
|
|
77 |
|
|
78 |
if( iSvgLangSpace )
|
|
79 |
{
|
|
80 |
delete iSvgLangSpace;
|
|
81 |
iSvgLangSpace = NULL;
|
|
82 |
}
|
|
83 |
|
|
84 |
if ( iSvgTransformable )
|
|
85 |
{
|
|
86 |
delete iSvgTransformable;
|
|
87 |
iSvgTransformable = NULL;
|
|
88 |
}
|
|
89 |
ResetReferenceAttrSet();
|
|
90 |
}
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
TBool CSvgElementImpl::StyleInParent(CSvgElementImpl* aElement, TInt aAttrIndex)
|
|
98 |
{
|
|
99 |
if(aElement != NULL)
|
|
100 |
{
|
|
101 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)aElement->ParentNode ();
|
|
102 |
while(lParentElement && (lParentElement->iSvgStyleProperties != NULL))
|
|
103 |
{
|
|
104 |
if(!lParentElement)
|
|
105 |
return EFalse;
|
|
106 |
if (aElement->iSvgStyleProperties->operator[](aAttrIndex) ==
|
|
107 |
lParentElement->iSvgStyleProperties->operator[](aAttrIndex))
|
|
108 |
{
|
|
109 |
return ETrue;
|
|
110 |
}
|
|
111 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
112 |
}
|
|
113 |
}
|
|
114 |
return EFalse;
|
|
115 |
}
|
|
116 |
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
CSvgElementImpl::CSvgElementImpl() : iAnimateTransformMatrixIndex(-1),
|
|
121 |
iSvgStyleProperties(NULL),
|
|
122 |
iAnimateMotionMatrixIndex( -1 )
|
|
123 |
|
|
124 |
{
|
|
125 |
SetAllAttributesAdded( ETrue );
|
|
126 |
}
|
|
127 |
|
|
128 |
void CSvgElementImpl::InitializeL( TUint8 aElemID)
|
|
129 |
{
|
|
130 |
CXmlElementImpl::InitializeL( aElemID );
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
TBool CSvgElementImpl::IsDrawable()
|
|
138 |
{
|
|
139 |
return ETrue;
|
|
140 |
}
|
|
141 |
|
|
142 |
//*****************************************************
|
|
143 |
//
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
void CSvgElementImpl::DrawShapeL( CGfx2dGc* aGc,
|
|
148 |
MGfxShape& aShape,
|
|
149 |
CSvgElementImpl* /*aElement */)
|
|
150 |
{
|
|
151 |
if ( !AreAllAttributesAdded() )
|
|
152 |
{
|
|
153 |
return;
|
|
154 |
}
|
|
155 |
|
|
156 |
// Paint is a special case.
|
|
157 |
// Paint must be reset locally
|
|
158 |
|
|
159 |
SetGCL( aGc/*, aElement */);
|
|
160 |
|
|
161 |
if( iSvgTransformable )
|
|
162 |
{
|
|
163 |
aGc->SetTransform( GetCTM() );
|
|
164 |
}
|
|
165 |
|
|
166 |
aGc->DrawL( &aShape );
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
void CSvgElementImpl::DrawShapeL( CGfx2dGc* aGc, CSvgElementImpl* /*aElement*/ )
|
|
173 |
{
|
|
174 |
|
|
175 |
SetGCL( aGc/*, aElement */);
|
|
176 |
|
|
177 |
if(iSvgTransformable )
|
|
178 |
{
|
|
179 |
aGc->SetTransform( GetCTM() );
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
TBool CSvgElementImpl::DrawL( CGfx2dGc* /* aGc */,
|
|
187 |
CSvgElementImpl* /* aElement */ )
|
|
188 |
{
|
|
189 |
return ETrue;
|
|
190 |
}
|
|
191 |
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
// ---------------------------------------------------------------------------
|
|
195 |
const TDesC* CSvgElementImpl::Id()
|
|
196 |
{
|
|
197 |
return iId;
|
|
198 |
}
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
TInt CSvgElementImpl::SetIdandXmlbaseL( const TDesC& aPropertyName,
|
|
204 |
const TDesC& aValue )
|
|
205 |
{
|
|
206 |
_LIT( KId, "id" );
|
|
207 |
if ( aPropertyName == KId)
|
|
208 |
{
|
|
209 |
delete iId;
|
|
210 |
iId = NULL;
|
|
211 |
iId = aValue.AllocL();
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
return EFalse;
|
|
216 |
}
|
|
217 |
return ETrue;
|
|
218 |
}
|
|
219 |
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
// This method might leave with KErrNoMemory.
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
MXmlElement* CSvgElementImpl::AppendChildL( MXmlElement* aNewChild, TBool aIsJSR226Element )
|
|
225 |
{
|
|
226 |
|
|
227 |
CXmlElementImpl::AppendChildL( aNewChild );
|
|
228 |
|
|
229 |
if ( aNewChild && (((CSvgElementImpl *)aNewChild)->ElemID() != KSvgSvgElement) )
|
|
230 |
{
|
|
231 |
TInt err = KErrNone;
|
|
232 |
|
|
233 |
if (!aIsJSR226Element)
|
|
234 |
{
|
|
235 |
err = ((CSvgElementImpl *)aNewChild)->InitSvgStyleProperties();
|
|
236 |
}
|
|
237 |
else
|
|
238 |
{
|
|
239 |
// Error return needs to be checked
|
|
240 |
((CSvgElementImpl*)aNewChild)->InitAllSvgStyleProperties((CSvgElementImpl*)aNewChild);
|
|
241 |
}
|
|
242 |
if (err != KErrNone)
|
|
243 |
#ifdef _Debug
|
|
244 |
RDebug::Print(_L("CSvgElementImpl::AppendChildL[%x]: memory when append child"), this);
|
|
245 |
#endif //_Debug
|
|
246 |
User::Leave(err);
|
|
247 |
}
|
|
248 |
|
|
249 |
|
|
250 |
return aNewChild;
|
|
251 |
}
|
|
252 |
|
|
253 |
// ---------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
|
|
257 |
TInt CSvgElementImpl::SetAttributeL( const TDesC& aName ,
|
|
258 |
const TDesC& aValue )
|
|
259 |
{
|
|
260 |
|
|
261 |
|
|
262 |
if ( SetTransform( aName, aValue ) ||
|
|
263 |
SetIdandXmlbaseL( aName, aValue ) ||
|
|
264 |
SetLangSpaceAttributeL( aName, aValue ) ||
|
|
265 |
SetTestAttributeL( aName, aValue )
|
|
266 |
)
|
|
267 |
{
|
|
268 |
return KErrNone;
|
|
269 |
}
|
|
270 |
|
|
271 |
return KErrNone;
|
|
272 |
}
|
|
273 |
|
|
274 |
// ---------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
TInt CSvgElementImpl::RemoveAttribute( const TInt aAttrId )
|
|
278 |
{
|
|
279 |
if( iSvgStyleProperties && aAttrId < iSvgStyleProperties->Count() )
|
|
280 |
{
|
|
281 |
CCssValue *lCurrentCssPointer = iSvgStyleProperties->operator[](aAttrId);
|
|
282 |
CCssValue *lParentCssPointer = NULL ;
|
|
283 |
|
|
284 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)iParentNode;
|
|
285 |
while(lParentElement && (lParentElement->iSvgStyleProperties == NULL))
|
|
286 |
{
|
|
287 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
288 |
}
|
|
289 |
|
|
290 |
if ( lParentElement )
|
|
291 |
{
|
|
292 |
FindProperty( (TInt8)aAttrId, lParentCssPointer, ( CSvgElementImpl * )lParentElement );
|
|
293 |
}
|
|
294 |
|
|
295 |
iSvgStyleProperties->operator[](aAttrId) = lParentCssPointer;
|
|
296 |
PropagateToChildren( lCurrentCssPointer,lParentCssPointer, aAttrId );
|
|
297 |
}
|
|
298 |
return KErrNone;
|
|
299 |
|
|
300 |
}
|
|
301 |
|
|
302 |
// ---------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
|
|
306 |
void CSvgElementImpl::SetPresentationAttribute( const TInt8 aPropertyId,
|
|
307 |
CCssValue*& aCssValue )
|
|
308 |
|
|
309 |
{
|
|
310 |
if( iSvgStyleProperties && aPropertyId < iSvgStyleProperties->Count() )
|
|
311 |
{
|
|
312 |
iSvgStyleProperties->operator[](aPropertyId) = aCssValue;
|
|
313 |
}
|
|
314 |
|
|
315 |
}
|
|
316 |
|
|
317 |
// ---------------------------------------------------------------------------
|
|
318 |
// This method sets a property value that takes a float
|
|
319 |
// The switch statement can be expanded to add more attributes
|
|
320 |
// ---------------------------------------------------------------------------
|
|
321 |
TBool CSvgElementImpl::SetPropertyFloatL( const TInt& aAttrId,
|
|
322 |
TReal32 aValue)
|
|
323 |
{
|
|
324 |
CSvgDocumentImpl* doc = ( CSvgDocumentImpl* ) OwnerDocument();
|
|
325 |
|
|
326 |
if (!doc)
|
|
327 |
{
|
|
328 |
return EFalse;
|
|
329 |
}
|
|
330 |
|
|
331 |
TInt position = aAttrId;
|
|
332 |
|
|
333 |
|
|
334 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)iParentNode;
|
|
335 |
while(lParentElement && (lParentElement->iSvgStyleProperties == NULL))
|
|
336 |
{
|
|
337 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
338 |
}
|
|
339 |
|
|
340 |
switch ( position )
|
|
341 |
{
|
|
342 |
case KCSS_ATTR_STROKE_OPACITY:
|
|
343 |
case KCSS_ATTR_FILL_OPACITY:
|
|
344 |
case KCSS_ATTR_GROUP_OPACITY:
|
|
345 |
{
|
|
346 |
TFloatFixPt KZero;
|
|
347 |
TFloatFixPt KOne( KFloatFixOne );
|
|
348 |
TFloatFixPt opacityValue = aValue;
|
|
349 |
if (opacityValue < KZero)
|
|
350 |
{
|
|
351 |
opacityValue = KZero;
|
|
352 |
}
|
|
353 |
else if (opacityValue > KOne)
|
|
354 |
{
|
|
355 |
opacityValue = KOne;
|
|
356 |
}
|
|
357 |
CFloatCssValueImpl* tParentValue = NULL;
|
|
358 |
CFloatCssValueImpl* tValue = (CFloatCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
359 |
|
|
360 |
if( this != doc->RootElement() && lParentElement )
|
|
361 |
{
|
|
362 |
tParentValue = (CFloatCssValueImpl *)
|
|
363 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
364 |
}
|
|
365 |
if (tParentValue == tValue || tValue == NULL)
|
|
366 |
{
|
|
367 |
tValue = doc->iMemoryManager->GetCssFloatObjectL( opacityValue );
|
|
368 |
|
|
369 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
370 |
}
|
|
371 |
else
|
|
372 |
{
|
|
373 |
tValue->SetValueL( opacityValue );
|
|
374 |
}
|
|
375 |
}
|
|
376 |
break;
|
|
377 |
default:
|
|
378 |
return EFalse;
|
|
379 |
|
|
380 |
}
|
|
381 |
|
|
382 |
return ETrue;
|
|
383 |
|
|
384 |
}
|
|
385 |
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
// ---------------------------------------------------------------------------
|
|
389 |
|
|
390 |
TBool CSvgElementImpl::SetPropertyL( const TInt& aAttrId,
|
|
391 |
const TDesC& aValue)
|
|
392 |
{
|
|
393 |
_LIT( KInherit, "inherit" );
|
|
394 |
|
|
395 |
CSvgDocumentImpl* doc = ( CSvgDocumentImpl* ) OwnerDocument();
|
|
396 |
|
|
397 |
if (!doc)
|
|
398 |
{
|
|
399 |
return EFalse;
|
|
400 |
}
|
|
401 |
|
|
402 |
CSvgSchemaData* lSchemaData = doc->SchemaData();
|
|
403 |
|
|
404 |
TInt position = aAttrId;
|
|
405 |
|
|
406 |
|
|
407 |
if( (aValue == KInherit) || (iSvgStyleProperties == NULL))
|
|
408 |
{
|
|
409 |
return ETrue;
|
|
410 |
}
|
|
411 |
|
|
412 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)iParentNode;
|
|
413 |
while(lParentElement && (lParentElement->iSvgStyleProperties == NULL))
|
|
414 |
{
|
|
415 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
416 |
}
|
|
417 |
|
|
418 |
|
|
419 |
switch ( position )
|
|
420 |
{
|
|
421 |
|
|
422 |
case KCSS_ATTR_FILL:
|
|
423 |
//fill
|
|
424 |
{
|
|
425 |
CPaintCssValueImpl* tParentValue = NULL;
|
|
426 |
CPaintCssValueImpl* tValue = (CPaintCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
427 |
if( this != doc->RootElement() && lParentElement)
|
|
428 |
{
|
|
429 |
tParentValue = (CPaintCssValueImpl *)
|
|
430 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
431 |
}
|
|
432 |
if (tParentValue == tValue || tValue == NULL)
|
|
433 |
{
|
|
434 |
tValue = doc->iMemoryManager->GetCssPaintObjectL(aValue, this);
|
|
435 |
|
|
436 |
|
|
437 |
if ( tValue->IsDefaultSet() )
|
|
438 |
{
|
|
439 |
// if default color is set, check see if parent has one
|
|
440 |
if ( lParentElement )
|
|
441 |
{
|
|
442 |
tParentValue = (CPaintCssValueImpl *)
|
|
443 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
444 |
}
|
|
445 |
|
|
446 |
if ( tParentValue != NULL )
|
|
447 |
{
|
|
448 |
iSvgStyleProperties->operator[](position) = tParentValue;
|
|
449 |
break;
|
|
450 |
}
|
|
451 |
|
|
452 |
}
|
|
453 |
else
|
|
454 |
{
|
|
455 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
456 |
}
|
|
457 |
}
|
|
458 |
else
|
|
459 |
{
|
|
460 |
tValue->SetValueL( aValue );
|
|
461 |
}
|
|
462 |
|
|
463 |
break;
|
|
464 |
|
|
465 |
}
|
|
466 |
case KCSS_ATTR_STROKE_OPACITY:
|
|
467 |
case KCSS_ATTR_FILL_OPACITY:
|
|
468 |
case KCSS_ATTR_GROUP_OPACITY:
|
|
469 |
{
|
|
470 |
TFloatFixPt KZero;
|
|
471 |
TFloatFixPt KOne( KFloatFixOne );
|
|
472 |
TFloatFixPt opacityValue;
|
|
473 |
if ( TFloatFixPt::ConvertString( aValue, opacityValue ) == KErrNone )
|
|
474 |
{
|
|
475 |
if (aValue.Locate('%') != KErrNotFound)
|
|
476 |
{
|
|
477 |
//if a percentage
|
|
478 |
opacityValue = opacityValue / TFloatFixPt(100);
|
|
479 |
}
|
|
480 |
}
|
|
481 |
else
|
|
482 |
{
|
|
483 |
opacityValue = KOne;
|
|
484 |
}
|
|
485 |
|
|
486 |
if (opacityValue < KZero)
|
|
487 |
opacityValue = KZero;
|
|
488 |
else if (opacityValue > KOne)
|
|
489 |
opacityValue = KOne;
|
|
490 |
|
|
491 |
CFloatCssValueImpl* tParentValue = NULL;
|
|
492 |
CFloatCssValueImpl* tValue = (CFloatCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
493 |
|
|
494 |
if( this != doc->RootElement() && lParentElement )
|
|
495 |
{
|
|
496 |
tParentValue = (CFloatCssValueImpl *)
|
|
497 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
498 |
}
|
|
499 |
if (tParentValue == tValue || tValue == NULL)
|
|
500 |
{
|
|
501 |
tValue = doc->iMemoryManager->GetCssFloatObjectL(opacityValue);
|
|
502 |
|
|
503 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
tValue->SetValueL( opacityValue );
|
|
508 |
}
|
|
509 |
}
|
|
510 |
break;
|
|
511 |
|
|
512 |
case KCSS_ATTR_STROKE:
|
|
513 |
case KCSS_ATTR_COLOR:
|
|
514 |
{
|
|
515 |
|
|
516 |
CClrCssValueImpl* tParentValue = NULL;
|
|
517 |
CClrCssValueImpl* tValue = (CClrCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
518 |
if( this != doc->RootElement() && lParentElement )
|
|
519 |
{
|
|
520 |
tParentValue = (CClrCssValueImpl *)
|
|
521 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
522 |
}
|
|
523 |
if (tParentValue == tValue || tValue == NULL)
|
|
524 |
{
|
|
525 |
tValue = doc->iMemoryManager->GetCssClrObjectL( aValue );
|
|
526 |
|
|
527 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
tValue->SetValueL( aValue );
|
|
532 |
}
|
|
533 |
|
|
534 |
break;
|
|
535 |
|
|
536 |
}
|
|
537 |
case KCSS_ATTR_VISIBILITY:
|
|
538 |
// visibility
|
|
539 |
{
|
|
540 |
TPtrC lVal;
|
|
541 |
if ( aValue == _L( "visible" ) )
|
|
542 |
{
|
|
543 |
lVal.Set( _L( "0" ) );
|
|
544 |
}
|
|
545 |
else if ( aValue == _L( "hidden" ) )
|
|
546 |
{
|
|
547 |
lVal.Set( _L( "1" ) );
|
|
548 |
}
|
|
549 |
else if ( aValue == _L( "collapse" ) )
|
|
550 |
{
|
|
551 |
lVal.Set( _L( "3" ) );
|
|
552 |
}
|
|
553 |
|
|
554 |
CIntCssValueImpl* tParentValue = NULL;
|
|
555 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
556 |
if( this != doc->RootElement() && lParentElement )
|
|
557 |
{
|
|
558 |
tParentValue = (CIntCssValueImpl *)
|
|
559 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
560 |
}
|
|
561 |
if (tParentValue == tValue || tValue == NULL)
|
|
562 |
{
|
|
563 |
tValue = doc->iMemoryManager->GetCssIntObjectL( lVal );
|
|
564 |
|
|
565 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
566 |
}
|
|
567 |
else
|
|
568 |
{
|
|
569 |
tValue->SetValueL( lVal );
|
|
570 |
}
|
|
571 |
}
|
|
572 |
break;
|
|
573 |
|
|
574 |
case KCSS_ATTR_DISPLAY:
|
|
575 |
// display
|
|
576 |
{
|
|
577 |
|
|
578 |
TPtrC lVal;
|
|
579 |
if ( aValue == _L( "inline" ) )
|
|
580 |
{
|
|
581 |
lVal.Set( _L( "0" ) );
|
|
582 |
}
|
|
583 |
else if ( aValue == _L( "none" ) )
|
|
584 |
{
|
|
585 |
lVal.Set( _L( "16" ) );
|
|
586 |
}
|
|
587 |
|
|
588 |
CIntCssValueImpl* tParentValue = NULL;
|
|
589 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
590 |
if( this != doc->RootElement() && lParentElement)
|
|
591 |
{
|
|
592 |
tParentValue = (CIntCssValueImpl *)
|
|
593 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
594 |
}
|
|
595 |
if (tParentValue == tValue || tValue == NULL)
|
|
596 |
{
|
|
597 |
tValue = doc->iMemoryManager->GetCssIntObjectL( lVal );
|
|
598 |
|
|
599 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
600 |
}
|
|
601 |
else
|
|
602 |
{
|
|
603 |
tValue->SetValueL( lVal );
|
|
604 |
}
|
|
605 |
|
|
606 |
break;
|
|
607 |
}
|
|
608 |
case KCSS_ATTR_FONTSTYLE:
|
|
609 |
// font-style
|
|
610 |
{
|
|
611 |
TInt i;
|
|
612 |
|
|
613 |
i = lSchemaData->FindFontStyle(aValue);
|
|
614 |
|
|
615 |
TBufC<12> buf;
|
|
616 |
TPtr lVal ( buf.Des() );
|
|
617 |
_LIT( KFixptFormat, "%d" );
|
|
618 |
lVal.Format( KFixptFormat, i );
|
|
619 |
|
|
620 |
CIntCssValueImpl* tParentValue = NULL;
|
|
621 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
622 |
if( this != doc->RootElement() && lParentElement )
|
|
623 |
{
|
|
624 |
tParentValue = (CIntCssValueImpl *)
|
|
625 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
626 |
}
|
|
627 |
if (tParentValue == tValue || tValue == NULL)
|
|
628 |
{
|
|
629 |
tValue = doc->iMemoryManager->GetCssIntObjectL( lVal );
|
|
630 |
|
|
631 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
632 |
}
|
|
633 |
else
|
|
634 |
{
|
|
635 |
tValue->SetValueL( lVal );
|
|
636 |
}
|
|
637 |
}
|
|
638 |
break;
|
|
639 |
case KCSS_ATTR_FONTWEIGHT:
|
|
640 |
// font-weight
|
|
641 |
{
|
|
642 |
|
|
643 |
TInt i;
|
|
644 |
i = lSchemaData->FindFontWeightEnum(aValue);
|
|
645 |
TBufC<12> buf;
|
|
646 |
TPtr lVal ( buf.Des() );
|
|
647 |
_LIT( KFixptFormat, "%d" );
|
|
648 |
lVal.Format( KFixptFormat, i );
|
|
649 |
|
|
650 |
CIntCssValueImpl* tParentValue = NULL;
|
|
651 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
652 |
if( this != doc->RootElement() && lParentElement)
|
|
653 |
{
|
|
654 |
tParentValue = (CIntCssValueImpl *)
|
|
655 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
656 |
}
|
|
657 |
if (tParentValue == tValue || tValue == NULL)
|
|
658 |
{
|
|
659 |
|
|
660 |
tValue = doc->iMemoryManager->GetCssIntObjectL( lVal );
|
|
661 |
|
|
662 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
663 |
}
|
|
664 |
else
|
|
665 |
{
|
|
666 |
tValue->SetValueL( lVal );
|
|
667 |
}
|
|
668 |
}
|
|
669 |
break;
|
|
670 |
|
|
671 |
case KCSS_ATTR_FONTFAMILY:
|
|
672 |
if( ElemID() == KSvgFontfaceElement )
|
|
673 |
{
|
|
674 |
((CSvgFontFaceElementImpl *)this)->SetFontFamilyL(aValue);
|
|
675 |
}
|
|
676 |
|
|
677 |
case KCSS_ATTR_STROKE_LINECAP:
|
|
678 |
case KCSS_ATTR_STROKE_LINEJOIN:
|
|
679 |
case KCSS_ATTR_FILLRULE:
|
|
680 |
{
|
|
681 |
CStrCssValueImpl* tParentValue = NULL;
|
|
682 |
CStrCssValueImpl* tValue = (CStrCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
683 |
if( this != doc->RootElement() && lParentElement )
|
|
684 |
{
|
|
685 |
tParentValue = (CStrCssValueImpl *)
|
|
686 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
687 |
}
|
|
688 |
if (tParentValue == tValue || tValue == NULL)
|
|
689 |
{
|
|
690 |
tValue = doc->iMemoryManager->GetCssStrObjectL( aValue );
|
|
691 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
692 |
}
|
|
693 |
else
|
|
694 |
{
|
|
695 |
tValue->SetValueL( aValue );
|
|
696 |
}
|
|
697 |
}
|
|
698 |
break;
|
|
699 |
case KCSS_ATTR_STROKE_DASHARRAY:
|
|
700 |
{
|
|
701 |
|
|
702 |
CVectorCssValueImpl* tParentValue = NULL;
|
|
703 |
CVectorCssValueImpl* tValue = (CVectorCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
704 |
if( this != doc->RootElement() && lParentElement)
|
|
705 |
{
|
|
706 |
tParentValue = (CVectorCssValueImpl *)
|
|
707 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
708 |
}
|
|
709 |
if (tParentValue == tValue || tValue == NULL)
|
|
710 |
{
|
|
711 |
tValue = doc->iMemoryManager->GetCssVectorObjectL( aValue );
|
|
712 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
713 |
}
|
|
714 |
else
|
|
715 |
{
|
|
716 |
tValue->SetValueL( aValue );
|
|
717 |
}
|
|
718 |
|
|
719 |
if(tValue)
|
|
720 |
{
|
|
721 |
CArrayFix<TFloatFixPt>* lDashArray = tValue->Value();
|
|
722 |
TFloatFixPt lSum( 0 );
|
|
723 |
TUint numElem = lDashArray->Count();
|
|
724 |
// Iterate through the array to check whether the sum of elements
|
|
725 |
// of the dash array is non-zero.
|
|
726 |
for (TUint arrCount = 0; arrCount < numElem; arrCount++)
|
|
727 |
{
|
|
728 |
lSum = lSum + lDashArray->At(arrCount);
|
|
729 |
}
|
|
730 |
// If the sum is zero then, the behaviour should be similar to "none" i.e. no dashing applied.
|
|
731 |
if ( lSum == TFloatFixPt( 0 ) )
|
|
732 |
{
|
|
733 |
iSvgStyleProperties->operator[](position)= NULL;
|
|
734 |
|
|
735 |
|
|
736 |
// Not deleting the tValue as this would be freed in the
|
|
737 |
// destructor of CSvgMemoryManager
|
|
738 |
}
|
|
739 |
}
|
|
740 |
|
|
741 |
}
|
|
742 |
break;
|
|
743 |
case KCSS_ATTR_STROKEWIDTH:
|
|
744 |
{
|
|
745 |
// stroke-width can not be negative
|
|
746 |
TReal32 strokeWidth;
|
|
747 |
TPtrC remainder;
|
|
748 |
TBool validValue = TTokenizer::ParseDecimal( aValue, strokeWidth, remainder );
|
|
749 |
|
|
750 |
// Check for valid number characters and no characters following
|
|
751 |
// and must be non-negative
|
|
752 |
if ( !validValue || strokeWidth < 0.0f )
|
|
753 |
{
|
|
754 |
strokeWidth = 1.0f;
|
|
755 |
}
|
|
756 |
/*
|
|
757 |
"1pt" equals "1.25px" (and therefore 1.25 user units)
|
|
758 |
"1pc" equals "15px" (and therefore 15 user units)
|
|
759 |
"1mm" would be "3.543307px" (3.543307 user units)
|
|
760 |
"1cm" equals "35.43307px" (and therefore 35.43307 user units)
|
|
761 |
"1in" equals "90px" (and therefore 90 user units)
|
|
762 |
*/
|
|
763 |
else if ( remainder.Length() > 0 )
|
|
764 |
{
|
|
765 |
if ( remainder == _L("px") )
|
|
766 |
{
|
|
767 |
// do nothing
|
|
768 |
}
|
|
769 |
if ( remainder == _L("pt") )
|
|
770 |
{
|
|
771 |
strokeWidth *= 1.25f;
|
|
772 |
}
|
|
773 |
else if ( remainder == _L("pc") )
|
|
774 |
{
|
|
775 |
strokeWidth *= 15.0f;
|
|
776 |
}
|
|
777 |
else if ( remainder == _L("mm") )
|
|
778 |
{
|
|
779 |
strokeWidth *= 3.543307f;
|
|
780 |
}
|
|
781 |
else if ( remainder == _L("cm") )
|
|
782 |
{
|
|
783 |
strokeWidth *= 35.43307f;
|
|
784 |
}
|
|
785 |
else if ( remainder == _L("in") )
|
|
786 |
{
|
|
787 |
strokeWidth *= 90.0f;
|
|
788 |
}
|
|
789 |
else
|
|
790 |
{
|
|
791 |
strokeWidth = 1.0f;
|
|
792 |
}
|
|
793 |
}
|
|
794 |
|
|
795 |
CFloatCssValueImpl* tParentValue = NULL;
|
|
796 |
CFloatCssValueImpl* tValue = (CFloatCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
797 |
if( this != doc->RootElement() && lParentElement)
|
|
798 |
{
|
|
799 |
tParentValue = (CFloatCssValueImpl *)
|
|
800 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
801 |
}
|
|
802 |
if (tParentValue == tValue || tValue == NULL)
|
|
803 |
{
|
|
804 |
tValue = doc->iMemoryManager->GetCssFloatObjectL( strokeWidth );
|
|
805 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
806 |
}
|
|
807 |
else
|
|
808 |
{
|
|
809 |
tValue->SetValueL( strokeWidth );
|
|
810 |
}
|
|
811 |
}
|
|
812 |
break;
|
|
813 |
|
|
814 |
case KCSS_ATTR_FONTSIZE:
|
|
815 |
case KCSS_ATTR_STROKE_DASHOFFSET:
|
|
816 |
case KCSS_ATTR_STROKE_MITERLIMIT:
|
|
817 |
{
|
|
818 |
CFloatCssValueImpl* tParentValue = NULL;
|
|
819 |
CFloatCssValueImpl* tValue = (CFloatCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
820 |
if( this != doc->RootElement() && lParentElement )
|
|
821 |
{
|
|
822 |
tParentValue = (CFloatCssValueImpl *)
|
|
823 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
824 |
}
|
|
825 |
if (tParentValue == tValue || tValue == NULL)
|
|
826 |
{
|
|
827 |
tValue = doc->iMemoryManager->GetCssFloatObjectL(aValue);
|
|
828 |
|
|
829 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
830 |
}
|
|
831 |
else
|
|
832 |
{
|
|
833 |
tValue->SetValueL( aValue );
|
|
834 |
}
|
|
835 |
}
|
|
836 |
break;
|
|
837 |
case KCSS_ATTR_TEXTANCHOR:
|
|
838 |
//text-anchor
|
|
839 |
{
|
|
840 |
|
|
841 |
TInt i;
|
|
842 |
|
|
843 |
i = lSchemaData->FindTextAnchorEnum(aValue);
|
|
844 |
|
|
845 |
TBufC<12> buf;
|
|
846 |
TPtr lVal ( buf.Des() );
|
|
847 |
_LIT( KFixptFormat, "%d" );
|
|
848 |
lVal.Format( KFixptFormat, i );
|
|
849 |
|
|
850 |
CIntCssValueImpl* tParentValue = NULL;
|
|
851 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
852 |
if( this != doc->RootElement() && lParentElement )
|
|
853 |
{
|
|
854 |
tParentValue = (CIntCssValueImpl *)
|
|
855 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
856 |
}
|
|
857 |
if (tParentValue == tValue || tValue == NULL)
|
|
858 |
{
|
|
859 |
tValue = doc->iMemoryManager->GetCssIntObjectL( lVal );
|
|
860 |
|
|
861 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
862 |
}
|
|
863 |
else
|
|
864 |
{
|
|
865 |
tValue->SetValueL( lVal );
|
|
866 |
}
|
|
867 |
}
|
|
868 |
break;
|
|
869 |
case KCSS_ATTR_TEXTDECORATION:
|
|
870 |
//text-decoration
|
|
871 |
{
|
|
872 |
|
|
873 |
TInt i;
|
|
874 |
i = lSchemaData->FindTextDecorationEnum(aValue);
|
|
875 |
TBufC<12> buf;
|
|
876 |
TPtr lVal ( buf.Des() );
|
|
877 |
_LIT( KFixptFormat, "%d" );
|
|
878 |
lVal.Format( KFixptFormat, i );
|
|
879 |
|
|
880 |
CIntCssValueImpl* tParentValue = NULL;
|
|
881 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](position));
|
|
882 |
if( this != doc->RootElement() && lParentElement)
|
|
883 |
{
|
|
884 |
tParentValue = (CIntCssValueImpl *)
|
|
885 |
(lParentElement->iSvgStyleProperties->operator[](position));
|
|
886 |
}
|
|
887 |
if (tParentValue == tValue || tValue == NULL)
|
|
888 |
{
|
|
889 |
tValue = doc->iMemoryManager->GetCssIntObjectL(lVal);
|
|
890 |
|
|
891 |
iSvgStyleProperties->operator[](position) = tValue;
|
|
892 |
}
|
|
893 |
else
|
|
894 |
{
|
|
895 |
tValue->SetValueL( lVal );
|
|
896 |
}
|
|
897 |
}
|
|
898 |
break;
|
|
899 |
|
|
900 |
default:
|
|
901 |
return EFalse;
|
|
902 |
|
|
903 |
}
|
|
904 |
|
|
905 |
return ETrue;
|
|
906 |
|
|
907 |
}
|
|
908 |
|
|
909 |
|
|
910 |
|
|
911 |
// ---------------------------------------------------------------------------
|
|
912 |
//
|
|
913 |
// ---------------------------------------------------------------------------
|
|
914 |
TBool CSvgElementImpl::SetTransform( const TDesC& aAttributeName,
|
|
915 |
const TDesC& aValue )
|
|
916 |
{
|
|
917 |
|
|
918 |
if( iSvgTransformable == NULL )
|
|
919 |
{
|
|
920 |
return EFalse;
|
|
921 |
}
|
|
922 |
|
|
923 |
// If this attribute is not transform attribute, return immediately.
|
|
924 |
_LIT( KTransform, "transform" );
|
|
925 |
if ( aAttributeName != KTransform )
|
|
926 |
return EFalse;
|
|
927 |
|
|
928 |
TLex input ( aValue );
|
|
929 |
TReal32 M00, M10, M01, M11, M02, M12;
|
|
930 |
TGfxAffineTransform tempTransform;
|
|
931 |
MSvgTransformList* trList;
|
|
932 |
|
|
933 |
iSvgTransformable->GetTransform( trList );
|
|
934 |
TGfxAffineTransform originalTransform = trList->GetItem( 0 );
|
|
935 |
|
|
936 |
_LIT( KMatrixP, "matrix(" );
|
|
937 |
_LIT( KTranslateP, "translate(" );
|
|
938 |
_LIT( KScaleP, "scale(" );
|
|
939 |
_LIT( KRotateP, "rotate(" );
|
|
940 |
_LIT( KSkewxP, "skewX(" );
|
|
941 |
_LIT( KSkewyP, "skewY(" );
|
|
942 |
|
|
943 |
while ( !( input.Eos() ) )
|
|
944 |
{
|
|
945 |
input.Mark();
|
|
946 |
input.SkipCharacters();
|
|
947 |
TPtrC token = input.MarkedToken(); // then extract token
|
|
948 |
|
|
949 |
if ( token == KMatrixP )
|
|
950 |
{
|
|
951 |
input.SkipSpace(); if ( input.Val( M00, '.' ) != KErrNone ) return EFalse;
|
|
952 |
input.SkipSpace(); if ( input.Val( M10, '.' ) != KErrNone ) return EFalse;
|
|
953 |
input.SkipSpace(); if ( input.Val( M01, '.' ) != KErrNone ) return EFalse;
|
|
954 |
input.SkipSpace(); if ( input.Val( M11, '.' ) != KErrNone ) return EFalse;
|
|
955 |
input.SkipSpace(); if ( input.Val( M02, '.' ) != KErrNone ) return EFalse;
|
|
956 |
input.SkipSpace(); if ( input.Val( M12, '.' ) != KErrNone ) return EFalse;
|
|
957 |
|
|
958 |
//check to make sure the user isn't setting in scale of 0 because that can never be undone
|
|
959 |
//they probably just mean that they don't want to scale
|
|
960 |
/* if (M00 == 0)
|
|
961 |
{
|
|
962 |
M00 = 1;
|
|
963 |
}
|
|
964 |
if (M11 == 0)
|
|
965 |
{
|
|
966 |
M11 = 1;
|
|
967 |
}*/
|
|
968 |
|
|
969 |
tempTransform.SetTransform( M00, M10, M01, M11, M02, M12 );
|
|
970 |
originalTransform.Concatenate( tempTransform );
|
|
971 |
trList->ReplaceItem( originalTransform, 0 );
|
|
972 |
}
|
|
973 |
else if ( token == KTranslateP )
|
|
974 |
{
|
|
975 |
// parse tx
|
|
976 |
input.SkipSpace();
|
|
977 |
if ( input.Val( M00, '.' ) != KErrNone ) return EFalse;
|
|
978 |
|
|
979 |
// parse ty
|
|
980 |
input.SkipSpace();
|
|
981 |
if ( input.Val( M10, '.' ) != KErrNone ) M10 = 0.0;
|
|
982 |
|
|
983 |
// set translate
|
|
984 |
TFloatFixPt fixM00 ( M00 );
|
|
985 |
TFloatFixPt fixM10 ( M10 );
|
|
986 |
originalTransform.Translate( fixM00, fixM10 );
|
|
987 |
trList->ReplaceItem( originalTransform, 0 );
|
|
988 |
}
|
|
989 |
else if ( token == KScaleP )
|
|
990 |
{
|
|
991 |
input.SkipSpace();
|
|
992 |
if(input.Peek().IsDigit() || (input.Peek() == '-') || (input.Peek() == '.'))
|
|
993 |
{
|
|
994 |
if ( input.Val( M00, TChar('.') ) != KErrNone )
|
|
995 |
return EFalse;
|
|
996 |
}
|
|
997 |
else
|
|
998 |
{
|
|
999 |
M00 = 1.0;
|
|
1000 |
}
|
|
1001 |
input.SkipSpace();
|
|
1002 |
// If only one value is given then both scale values are set to that value
|
|
1003 |
if ( input.Eos() || input.Peek() == ')' )
|
|
1004 |
{
|
|
1005 |
M11 = M00;
|
|
1006 |
}
|
|
1007 |
else
|
|
1008 |
{
|
|
1009 |
if(input.Peek().IsDigit() || (input.Peek() == '-') || (input.Peek() == '.'))
|
|
1010 |
{
|
|
1011 |
if ( input.Val( M11, TChar('.')) != KErrNone )
|
|
1012 |
return EFalse;
|
|
1013 |
}
|
|
1014 |
else
|
|
1015 |
{
|
|
1016 |
M11 = 1.0;
|
|
1017 |
}
|
|
1018 |
}
|
|
1019 |
originalTransform.Scale( M00, M11 );
|
|
1020 |
trList->ReplaceItem( originalTransform, 0 );
|
|
1021 |
}
|
|
1022 |
else if ( token == KRotateP )
|
|
1023 |
{
|
|
1024 |
// parse r
|
|
1025 |
input.SkipSpace();
|
|
1026 |
if ( input.Val( M00, '.' ) != KErrNone ) return EFalse;
|
|
1027 |
// parse cx
|
|
1028 |
input.SkipSpace();
|
|
1029 |
if ( input.Val( M01, '.' ) == KErrNone )
|
|
1030 |
{
|
|
1031 |
// parse cy
|
|
1032 |
input.SkipSpace();
|
|
1033 |
if ( input.Val( M10, '.' ) != KErrNone ) return EFalse;
|
|
1034 |
M00 = M00 * KGradiansPerDegree; // Convert to Radians
|
|
1035 |
originalTransform.Rotate( M00, TFloatFixPt(M01), TFloatFixPt(M10) );
|
|
1036 |
trList->ReplaceItem( originalTransform, 0 );
|
|
1037 |
}
|
|
1038 |
else
|
|
1039 |
{
|
|
1040 |
M00 = M00 * KGradiansPerDegree; // Convert to Radians
|
|
1041 |
originalTransform.Rotate( M00 );
|
|
1042 |
trList->ReplaceItem( originalTransform, 0 );
|
|
1043 |
}
|
|
1044 |
}
|
|
1045 |
else if ( token == KSkewxP )
|
|
1046 |
{
|
|
1047 |
input.SkipSpace(); if ( input.Val( M00, '.' ) != KErrNone ) return EFalse;
|
|
1048 |
M00 = M00 * KGradiansPerDegree; // Convert to Radians
|
|
1049 |
originalTransform.Shear( M00, 0.0f );
|
|
1050 |
trList->ReplaceItem( originalTransform, 0 );
|
|
1051 |
}
|
|
1052 |
else if ( token == KSkewyP )
|
|
1053 |
{
|
|
1054 |
input.SkipSpace(); if ( input.Val( M00, '.' ) != KErrNone ) return EFalse;
|
|
1055 |
M00 = M00 * KGradiansPerDegree; // Convert to Radians
|
|
1056 |
originalTransform.Shear( 0.0f, M00 );
|
|
1057 |
trList->ReplaceItem( originalTransform, 0 );
|
|
1058 |
}
|
|
1059 |
|
|
1060 |
// Skip close paranthesis
|
|
1061 |
input.SkipSpace();
|
|
1062 |
input.Mark();
|
|
1063 |
input.MarkedToken(); // then extract token
|
|
1064 |
}
|
|
1065 |
return ETrue;
|
|
1066 |
}
|
|
1067 |
|
|
1068 |
|
|
1069 |
// ---------------------------------------------------------------------------
|
|
1070 |
//
|
|
1071 |
// ---------------------------------------------------------------------------
|
|
1072 |
TSvgColor* CSvgElementImpl::CurrentColor()
|
|
1073 |
{
|
|
1074 |
|
|
1075 |
|
|
1076 |
if( iSvgStyleProperties )
|
|
1077 |
{
|
|
1078 |
CCssValue* lColorValue = NULL;
|
|
1079 |
lColorValue = iSvgStyleProperties->operator[](KCSS_ATTR_COLOR);
|
|
1080 |
|
|
1081 |
if ( lColorValue &&
|
|
1082 |
( ( CClrCssValueImpl * ) lColorValue )->Value() &&
|
|
1083 |
( ( TSvgColor*)(( CClrCssValueImpl * ) lColorValue )->Value())->GetColor() != KSvgCurrentColor
|
|
1084 |
)
|
|
1085 |
{
|
|
1086 |
// current color found and useful, return it
|
|
1087 |
return ( TSvgColor*)(( CClrCssValueImpl * ) lColorValue )->Value();
|
|
1088 |
}
|
|
1089 |
else
|
|
1090 |
{
|
|
1091 |
// current color found, but it is "currentColor"
|
|
1092 |
// find the real color from searching parents
|
|
1093 |
|
|
1094 |
if ( iParentNode )
|
|
1095 |
{
|
|
1096 |
return ( ( CSvgElementImpl * ) iParentNode )->CurrentColor();
|
|
1097 |
}
|
|
1098 |
}
|
|
1099 |
}
|
|
1100 |
else
|
|
1101 |
{
|
|
1102 |
if ( iParentNode )
|
|
1103 |
{
|
|
1104 |
return ( ( CSvgElementImpl * ) iParentNode )->CurrentColor();
|
|
1105 |
}
|
|
1106 |
}
|
|
1107 |
return NULL;
|
|
1108 |
}
|
|
1109 |
|
|
1110 |
void CSvgElementImpl::InitAllSvgStyleProperties(CSvgElementImpl* aElement)
|
|
1111 |
{
|
|
1112 |
if (aElement && aElement->ParentNode())
|
|
1113 |
{
|
|
1114 |
aElement->InitSvgJSRStyleProperties((CSvgElementImpl*)aElement->ParentNode());
|
|
1115 |
}
|
|
1116 |
|
|
1117 |
if (aElement && aElement->iSvgStyleProperties && aElement->iSvgStyleProperties->Count() == KCSS_MAX_ATTR)
|
|
1118 |
{
|
|
1119 |
CSvgElementImpl* lChildElement = (CSvgElementImpl*)aElement->FirstChild();
|
|
1120 |
|
|
1121 |
if ( lChildElement )
|
|
1122 |
{
|
|
1123 |
InitAllSvgStyleProperties( lChildElement );
|
|
1124 |
}
|
|
1125 |
|
|
1126 |
CSvgElementImpl* lSiblingElement = (CSvgElementImpl*)aElement->NextSibling();
|
|
1127 |
|
|
1128 |
if ( lSiblingElement )
|
|
1129 |
{
|
|
1130 |
InitAllSvgStyleProperties( lSiblingElement );
|
|
1131 |
}
|
|
1132 |
}
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
void CSvgElementImpl::InitSvgJSRStyleProperties(CSvgElementImpl* aParentElement)
|
|
1136 |
{
|
|
1137 |
if ( iSvgStyleProperties && iSvgStyleProperties->Count() == KCSS_MAX_ATTR )
|
|
1138 |
{
|
|
1139 |
//JSR226 ELEMENT CREATION WILL COME TO THIS
|
|
1140 |
// any non NULL values in the iSvgStyleProperties array should be kept and
|
|
1141 |
// the NULL ones should be replaced by the parent values
|
|
1142 |
|
|
1143 |
if( aParentElement && aParentElement->iSvgStyleProperties)
|
|
1144 |
{
|
|
1145 |
TInt count = aParentElement->iSvgStyleProperties->Count();
|
|
1146 |
for ( TInt i = 0; i < count; i++ )
|
|
1147 |
{
|
|
1148 |
CCssValue* lCssValue = aParentElement->iSvgStyleProperties->operator[]( i );
|
|
1149 |
CCssValue* thisCssValue = this->iSvgStyleProperties->operator[]( i );
|
|
1150 |
|
|
1151 |
if( lCssValue && !thisCssValue )
|
|
1152 |
{
|
|
1153 |
// the parent had a property but we just had NULL, so lets inherit the parent property
|
|
1154 |
(*iSvgStyleProperties)[i] = lCssValue;
|
|
1155 |
}
|
|
1156 |
else
|
|
1157 |
{
|
|
1158 |
//this element must have a new value of its own in it so leave it alone
|
|
1159 |
}
|
|
1160 |
}
|
|
1161 |
}
|
|
1162 |
}
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
TInt CSvgElementImpl::InitSvgStyleProperties( )
|
|
1166 |
{
|
|
1167 |
// all styles from all elements for the normal engine
|
|
1168 |
// flow will be setup in this function
|
|
1169 |
|
|
1170 |
TInt err(KErrNone);
|
|
1171 |
|
|
1172 |
if( iSvgStyleProperties && iSvgStyleProperties->Count() == 0 )
|
|
1173 |
{
|
|
1174 |
//NORMAL ENGINE ELEMENT CREATION...
|
|
1175 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)iParentNode;
|
|
1176 |
while(lParentElement && ((lParentElement->iSvgStyleProperties == NULL) || (lParentElement->iSvgStyleProperties->Count() == 0)) )
|
|
1177 |
{
|
|
1178 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
if( lParentElement )
|
|
1182 |
{
|
|
1183 |
TInt count = lParentElement->iSvgStyleProperties->Count();
|
|
1184 |
for ( TInt i = 0; i < count; i++ )
|
|
1185 |
{
|
|
1186 |
CCssValue* lCssValue = lParentElement->iSvgStyleProperties->operator[]( i );
|
|
1187 |
err = iSvgStyleProperties->Insert(lCssValue,i);
|
|
1188 |
if (err)
|
|
1189 |
return err;
|
|
1190 |
}
|
|
1191 |
}
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
return err;
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
// ---------------------------------------------------------------------------
|
|
1198 |
//
|
|
1199 |
// ---------------------------------------------------------------------------
|
|
1200 |
|
|
1201 |
void CSvgElementImpl::FindProperty( const TInt8 aPropertyId,
|
|
1202 |
CCssValue*& aCssValue,
|
|
1203 |
CSvgElementImpl* aElement )
|
|
1204 |
|
|
1205 |
{
|
|
1206 |
if (aElement != NULL)
|
|
1207 |
aElement->FindProperty(aPropertyId, aCssValue);
|
|
1208 |
else
|
|
1209 |
FindProperty(aPropertyId, aCssValue);
|
|
1210 |
}
|
|
1211 |
|
|
1212 |
void CSvgElementImpl::FindProperty( const TInt8 aPropertyId,
|
|
1213 |
CCssValue*& aCssValue)
|
|
1214 |
|
|
1215 |
{
|
|
1216 |
if( iSvgStyleProperties && iSvgStyleProperties->Count() > aPropertyId)
|
|
1217 |
{
|
|
1218 |
aCssValue = iSvgStyleProperties->operator[](aPropertyId);
|
|
1219 |
}
|
|
1220 |
}
|
|
1221 |
|
|
1222 |
|
|
1223 |
// ---------------------------------------------------------------------------
|
|
1224 |
//
|
|
1225 |
// ---------------------------------------------------------------------------
|
|
1226 |
void CSvgElementImpl::SetTransform( MSvgTransformList*& aTransformList )
|
|
1227 |
{
|
|
1228 |
if( !iSvgTransformable )
|
|
1229 |
{
|
|
1230 |
// iSvgTransformable should not be NULL (created by subclass)
|
|
1231 |
TRAP_IGNORE( iSvgTransformable = CSvgTransformableImpl::NewL() );
|
|
1232 |
}
|
|
1233 |
|
|
1234 |
if( iSvgTransformable )
|
|
1235 |
{
|
|
1236 |
iSvgTransformable->SetTransform( aTransformList );
|
|
1237 |
}
|
|
1238 |
}
|
|
1239 |
|
|
1240 |
|
|
1241 |
// ---------------------------------------------------------------------------
|
|
1242 |
//
|
|
1243 |
// ---------------------------------------------------------------------------
|
|
1244 |
void CSvgElementImpl::GetTransform( MSvgTransformList*& aTransformList )
|
|
1245 |
{
|
|
1246 |
if( !iSvgTransformable )
|
|
1247 |
{
|
|
1248 |
// iSvgTransformable should not be NULL (created by subclass)
|
|
1249 |
TRAP_IGNORE( iSvgTransformable = CSvgTransformableImpl::NewL() );
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
if( iSvgTransformable )
|
|
1253 |
{
|
|
1254 |
iSvgTransformable->GetTransform( aTransformList );
|
|
1255 |
}
|
|
1256 |
}
|
|
1257 |
|
|
1258 |
// ---------------------------------------------------------------------------
|
|
1259 |
//
|
|
1260 |
// ---------------------------------------------------------------------------
|
|
1261 |
const TGfxAffineTransform& CSvgElementImpl::GetCTM()
|
|
1262 |
{
|
|
1263 |
if( !iSvgTransformable )
|
|
1264 |
{
|
|
1265 |
// iSvgTransformable should not be NULL (created by subclass)
|
|
1266 |
TRAP_IGNORE( iSvgTransformable = CSvgTransformableImpl::NewL() );
|
|
1267 |
}
|
|
1268 |
return( iSvgTransformable->GetCTM() );
|
|
1269 |
}
|
|
1270 |
|
|
1271 |
// ---------------------------------------------------------------------------
|
|
1272 |
//
|
|
1273 |
// ---------------------------------------------------------------------------
|
|
1274 |
void CSvgElementImpl::SetCTM( TGfxAffineTransform& aTr )
|
|
1275 |
{
|
|
1276 |
if( !iSvgTransformable )
|
|
1277 |
{
|
|
1278 |
// iSvgTransformable should not be NULL (created by subclass)
|
|
1279 |
TRAP_IGNORE( iSvgTransformable = CSvgTransformableImpl::NewL() );
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
if( iSvgTransformable )
|
|
1283 |
{
|
|
1284 |
iSvgTransformable->SetCTM( aTr );
|
|
1285 |
}
|
|
1286 |
else
|
|
1287 |
{
|
|
1288 |
#ifdef _DEBUG
|
|
1289 |
RDebug::Printf("CSvgElementImpl::SetCTM element %d wasnt transformable CTM not set", this->ElemID());
|
|
1290 |
#endif
|
|
1291 |
}
|
|
1292 |
}
|
|
1293 |
|
|
1294 |
// ---------------------------------------------------------------------------
|
|
1295 |
//
|
|
1296 |
// ---------------------------------------------------------------------------
|
|
1297 |
void CSvgElementImpl::SetGCL( CGfx2dGc* aGc)
|
|
1298 |
{
|
|
1299 |
|
|
1300 |
|
|
1301 |
TSvgColor* lStroke = NULL;
|
|
1302 |
MGfxPaint* lFill = NULL;
|
|
1303 |
TGfxStroke lStrokeC;
|
|
1304 |
TFloatFixPt lStrokeWidth = 1;
|
|
1305 |
TPtrC lFillRule; // Should be a defined constant for nonzero
|
|
1306 |
TPtrC lSLinecap; // Should be a defined constant for linecap
|
|
1307 |
TPtrC lSLinejoin; // Should be a defined constant for linejoin
|
|
1308 |
TInt lFontStyle = -1; // Should be a defined constant for fontstyle
|
|
1309 |
TFloatFixPt lFontSize = 10; // Should be a defined constant for fontstyle
|
|
1310 |
TInt lFontWeight = -1; // Should be a defined constant for fontweight
|
|
1311 |
TInt lTextanchor = -1;
|
|
1312 |
TInt lTextDecoration = -1;
|
|
1313 |
TFloatFixPt lDashOffset = 0;
|
|
1314 |
TFloatFixPt lSMiterlimit; // Should be a defined constant for strokemiterlimit
|
|
1315 |
CArrayFix<TFloatFixPt>* lDasharray = NULL;
|
|
1316 |
|
|
1317 |
CCssValue* lCssValue = NULL;
|
|
1318 |
|
|
1319 |
// Get fill color
|
|
1320 |
|
|
1321 |
FindProperty( KCSS_ATTR_FILL, lCssValue);
|
|
1322 |
if ( lCssValue )
|
|
1323 |
{
|
|
1324 |
// Currently only TSvgColor is represented by PaintCssValue
|
|
1325 |
// It will be extended to handle CGfxTexturePaint and CGfxGradientPaint
|
|
1326 |
lFill = ( ( CPaintCssValueImpl * ) lCssValue )->Value();
|
|
1327 |
// Set fill color
|
|
1328 |
if(lFill)
|
|
1329 |
{
|
|
1330 |
if (lFill->GetColor() == KSvgCurrentColor )
|
|
1331 |
{
|
|
1332 |
|
|
1333 |
lFill = CurrentColor();
|
|
1334 |
if (lFill && lFill->GetColor() != KGfxColorNull )
|
|
1335 |
{
|
|
1336 |
aGc->SetPaint( lFill );
|
|
1337 |
|
|
1338 |
}
|
|
1339 |
else
|
|
1340 |
{
|
|
1341 |
aGc->SetPaint( NULL );
|
|
1342 |
}
|
|
1343 |
}
|
|
1344 |
else if (lFill->GetColor() != KGfxColorNull )
|
|
1345 |
{
|
|
1346 |
aGc->SetPaint( lFill );
|
|
1347 |
}
|
|
1348 |
else
|
|
1349 |
{
|
|
1350 |
aGc->SetPaint( NULL );
|
|
1351 |
}
|
|
1352 |
}
|
|
1353 |
else
|
|
1354 |
{
|
|
1355 |
aGc->SetPaint( NULL );
|
|
1356 |
}
|
|
1357 |
}
|
|
1358 |
else
|
|
1359 |
{
|
|
1360 |
TSvgColor black ( 0 );
|
|
1361 |
aGc->SetPaint( &black );
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
// this is just regular opacity which needs to be an entire elements opacity
|
|
1365 |
// Opacity set using stroke and fill opacity
|
|
1366 |
CCssValue* lOpacityCssValue = NULL;
|
|
1367 |
FindProperty( KCSS_ATTR_GROUP_OPACITY, lOpacityCssValue);
|
|
1368 |
if ( lOpacityCssValue && ( ((CFloatCssValueImpl*)lOpacityCssValue)->Value() < TFloatFixPt(1) ) )
|
|
1369 |
{
|
|
1370 |
aGc->SetStrokeOpacity( ( ( CFloatCssValueImpl * ) lOpacityCssValue )->Value() );
|
|
1371 |
aGc->SetFillOpacity( ( ( CFloatCssValueImpl * ) lOpacityCssValue )->Value() );
|
|
1372 |
}
|
|
1373 |
|
|
1374 |
lCssValue = NULL;
|
|
1375 |
FindProperty( KCSS_ATTR_STROKE_OPACITY, lCssValue);
|
|
1376 |
if ( lCssValue )
|
|
1377 |
{
|
|
1378 |
TFloatFixPt lValue = ( ( CFloatCssValueImpl * ) lCssValue )->Value();
|
|
1379 |
aGc->SetStrokeOpacity( lValue );
|
|
1380 |
}
|
|
1381 |
else
|
|
1382 |
{
|
|
1383 |
aGc->SetStrokeOpacity(1);
|
|
1384 |
}
|
|
1385 |
|
|
1386 |
lCssValue = NULL;
|
|
1387 |
FindProperty( KCSS_ATTR_FILL_OPACITY, lCssValue);
|
|
1388 |
if ( lCssValue )
|
|
1389 |
{
|
|
1390 |
TFloatFixPt lValue = ( ( CFloatCssValueImpl * ) lCssValue )->Value();
|
|
1391 |
aGc->SetFillOpacity( lValue );
|
|
1392 |
}
|
|
1393 |
else
|
|
1394 |
{
|
|
1395 |
aGc->SetFillOpacity(1);
|
|
1396 |
}
|
|
1397 |
|
|
1398 |
// Get stroke color
|
|
1399 |
lCssValue = NULL;
|
|
1400 |
FindProperty( KCSS_ATTR_STROKE, lCssValue);
|
|
1401 |
|
|
1402 |
if ( lCssValue )
|
|
1403 |
{
|
|
1404 |
lStroke = ( ( CClrCssValueImpl * ) lCssValue )->Value();
|
|
1405 |
// Set stroke color
|
|
1406 |
if ( lStroke && lStroke->GetColor () == KSvgCurrentColor )
|
|
1407 |
{
|
|
1408 |
lStroke = CurrentColor();
|
|
1409 |
if(lStroke)
|
|
1410 |
{
|
|
1411 |
aGc->SetForegroundColor( *lStroke );
|
|
1412 |
}
|
|
1413 |
}
|
|
1414 |
else if ( lStroke )
|
|
1415 |
{
|
|
1416 |
aGc->SetForegroundColor( *lStroke );
|
|
1417 |
}
|
|
1418 |
}
|
|
1419 |
|
|
1420 |
// Get stroke-width
|
|
1421 |
lCssValue = NULL;
|
|
1422 |
FindProperty( KCSS_ATTR_STROKEWIDTH, lCssValue);
|
|
1423 |
|
|
1424 |
if ( lCssValue )
|
|
1425 |
{
|
|
1426 |
lStrokeWidth = ( ( CFloatCssValueImpl * ) lCssValue )->Value();
|
|
1427 |
if (lStrokeWidth <= TFloatFixPt(0))
|
|
1428 |
{
|
|
1429 |
lStrokeC.SetStrokeWidth( TFloatFixPt(0) );
|
|
1430 |
}
|
|
1431 |
else
|
|
1432 |
{
|
|
1433 |
// Set stroke-width
|
|
1434 |
lStrokeC.SetStrokeWidth( lStrokeWidth );
|
|
1435 |
}
|
|
1436 |
}
|
|
1437 |
|
|
1438 |
// Get and set fill-rule
|
|
1439 |
lCssValue = NULL;
|
|
1440 |
FindProperty( KCSS_ATTR_FILLRULE, lCssValue);
|
|
1441 |
|
|
1442 |
if ( lCssValue )
|
|
1443 |
{
|
|
1444 |
lFillRule.Set( ( ( CStrCssValueImpl * ) lCssValue )->Value() );
|
|
1445 |
if ( lFillRule == _L("evenodd" ) )// evenodd
|
|
1446 |
{
|
|
1447 |
aGc->SetWindingRule( EGfxWindEvenOdd );
|
|
1448 |
}
|
|
1449 |
else if ( lFillRule == _L("nonzero") )
|
|
1450 |
{
|
|
1451 |
aGc->SetWindingRule( EGfxWindNonZero );
|
|
1452 |
}
|
|
1453 |
}
|
|
1454 |
|
|
1455 |
// Get and set stroke-linecap
|
|
1456 |
lCssValue = NULL;
|
|
1457 |
FindProperty( KCSS_ATTR_STROKE_LINECAP, lCssValue);
|
|
1458 |
|
|
1459 |
if ( lCssValue )
|
|
1460 |
{
|
|
1461 |
lSLinecap.Set( ( ( CStrCssValueImpl * ) lCssValue )->Value() );
|
|
1462 |
|
|
1463 |
if (lSLinecap == _L("butt"))
|
|
1464 |
{
|
|
1465 |
lStrokeC.SetCapType( EGfxCapButt );
|
|
1466 |
}
|
|
1467 |
else if (lSLinecap == _L("round"))
|
|
1468 |
{
|
|
1469 |
lStrokeC.SetCapType( EGfxCapRound );
|
|
1470 |
}
|
|
1471 |
else if (lSLinecap == _L("square"))
|
|
1472 |
{
|
|
1473 |
lStrokeC.SetCapType( EGfxCapSquare );
|
|
1474 |
}
|
|
1475 |
}
|
|
1476 |
|
|
1477 |
lCssValue = NULL;
|
|
1478 |
FindProperty( KCSS_ATTR_STROKE_LINEJOIN, lCssValue);
|
|
1479 |
|
|
1480 |
if ( lCssValue )
|
|
1481 |
{
|
|
1482 |
lSLinejoin.Set( ( ( CStrCssValueImpl * ) lCssValue )->Value() );
|
|
1483 |
|
|
1484 |
if (lSLinejoin == _L("miter"))
|
|
1485 |
{
|
|
1486 |
lStrokeC.SetJoinType( EGfxJoinMiter );
|
|
1487 |
}
|
|
1488 |
else if (lSLinejoin == _L("round"))
|
|
1489 |
{
|
|
1490 |
lStrokeC.SetJoinType( EGfxJoinRound );
|
|
1491 |
}
|
|
1492 |
else if (lSLinejoin == _L("bevel"))
|
|
1493 |
{
|
|
1494 |
lStrokeC.SetJoinType( EGfxJoinBevel );
|
|
1495 |
}
|
|
1496 |
}
|
|
1497 |
|
|
1498 |
|
|
1499 |
lCssValue = NULL;
|
|
1500 |
|
|
1501 |
FindProperty( KCSS_ATTR_STROKE_DASHOFFSET, lCssValue);
|
|
1502 |
if ( lCssValue )
|
|
1503 |
{
|
|
1504 |
lDashOffset = ( ( CFloatCssValueImpl * ) lCssValue )->Value();
|
|
1505 |
// Set dashoffset into GC
|
|
1506 |
aGc->SetDashOffset( lDashOffset );
|
|
1507 |
}
|
|
1508 |
|
|
1509 |
// Get and set stroke-dasharray
|
|
1510 |
lCssValue = NULL;
|
|
1511 |
FindProperty( KCSS_ATTR_STROKE_DASHARRAY, lCssValue);
|
|
1512 |
if ( lCssValue )
|
|
1513 |
{
|
|
1514 |
( ( CVectorCssValueImpl * ) lCssValue )->Value( lDasharray );
|
|
1515 |
// Set stroke-dasharray into GC
|
|
1516 |
aGc->SetDashArrayL( lDasharray );
|
|
1517 |
}
|
|
1518 |
|
|
1519 |
// get and set stroke-miterlimit
|
|
1520 |
lCssValue = NULL;
|
|
1521 |
FindProperty( KCSS_ATTR_STROKE_MITERLIMIT, lCssValue);
|
|
1522 |
|
|
1523 |
if ( lCssValue )
|
|
1524 |
{
|
|
1525 |
lSMiterlimit = ( ( CFloatCssValueImpl * ) lCssValue )->Value();
|
|
1526 |
|
|
1527 |
lStrokeC.SetMiterLimit(lSMiterlimit);
|
|
1528 |
}
|
|
1529 |
|
|
1530 |
if( iElemID == KSvgTextAreaElement || iElemID == KSvgTextElement)
|
|
1531 |
{
|
|
1532 |
lCssValue = NULL;
|
|
1533 |
FindProperty( KCSS_ATTR_FONTSIZE, lCssValue);
|
|
1534 |
|
|
1535 |
if ( lCssValue )
|
|
1536 |
{
|
|
1537 |
lFontSize = ( ( CFloatCssValueImpl * ) lCssValue )->Value();
|
|
1538 |
|
|
1539 |
#ifdef SVG_FLOAT_BUILD
|
|
1540 |
if(lFontSize <= TFloatFixPt ( 0 ) )
|
|
1541 |
{
|
|
1542 |
lFontSize = TFloatFixPt ( 10 );
|
|
1543 |
}
|
|
1544 |
#else
|
|
1545 |
if(lFontSize <= TFloatFixPt ( 0,ETrue ) )
|
|
1546 |
lFontSize = TFloatFixPt ( 10 );
|
|
1547 |
#endif
|
|
1548 |
aGc->SetFontSize( lFontSize );
|
|
1549 |
}
|
|
1550 |
|
|
1551 |
lCssValue = NULL;
|
|
1552 |
FindProperty( KCSS_ATTR_FONTSTYLE, lCssValue);
|
|
1553 |
|
|
1554 |
if ( lCssValue )
|
|
1555 |
{
|
|
1556 |
lFontStyle = ( ( CIntCssValueImpl * ) lCssValue )->Value();
|
|
1557 |
aGc->SetFontStyle( lFontStyle );
|
|
1558 |
}
|
|
1559 |
|
|
1560 |
// Get and set font-weight
|
|
1561 |
lCssValue = NULL;
|
|
1562 |
FindProperty( KCSS_ATTR_FONTWEIGHT, lCssValue);
|
|
1563 |
|
|
1564 |
if ( lCssValue )
|
|
1565 |
{
|
|
1566 |
lFontWeight = ( ( CIntCssValueImpl * ) lCssValue )->Value();
|
|
1567 |
aGc->SetFontWeight( lFontWeight );
|
|
1568 |
}
|
|
1569 |
|
|
1570 |
// Get and set text-anchor
|
|
1571 |
lCssValue = NULL;
|
|
1572 |
FindProperty( KCSS_ATTR_TEXTANCHOR, lCssValue);
|
|
1573 |
|
|
1574 |
if ( lCssValue )
|
|
1575 |
{
|
|
1576 |
lTextanchor = ( ( CIntCssValueImpl * ) lCssValue )->Value();
|
|
1577 |
aGc->SetTextanchor( lTextanchor );
|
|
1578 |
}
|
|
1579 |
|
|
1580 |
// Get and set text-decoration
|
|
1581 |
lCssValue = NULL;
|
|
1582 |
FindProperty( KCSS_ATTR_TEXTDECORATION, lCssValue);
|
|
1583 |
|
|
1584 |
if ( lCssValue )
|
|
1585 |
{
|
|
1586 |
lTextDecoration = ( ( CIntCssValueImpl * ) lCssValue )->Value();
|
|
1587 |
aGc->SetTextDecoration( lTextDecoration );
|
|
1588 |
}
|
|
1589 |
}
|
|
1590 |
// Sset the stroke into the graphics library now that we are done
|
|
1591 |
aGc->SetStroke( lStrokeC );
|
|
1592 |
|
|
1593 |
}
|
|
1594 |
|
|
1595 |
// ---------------------------------------------------------------------------
|
|
1596 |
//
|
|
1597 |
// ---------------------------------------------------------------------------
|
|
1598 |
void CSvgElementImpl::UpdateCTM( )
|
|
1599 |
{
|
|
1600 |
CSvgDocumentImpl* lDocument = (CSvgDocumentImpl*)(this->OwnerDocument());
|
|
1601 |
|
|
1602 |
if ( !lDocument )
|
|
1603 |
{
|
|
1604 |
return;
|
|
1605 |
}
|
|
1606 |
|
|
1607 |
TInt lElementId = this->ElemID();
|
|
1608 |
if( this->IsTransformable() )
|
|
1609 |
{
|
|
1610 |
MSvgTransformList* trList;
|
|
1611 |
|
|
1612 |
// Current delta transformation due to animation, etc.
|
|
1613 |
TGfxAffineTransform localUserSpace;
|
|
1614 |
// Element's CTM
|
|
1615 |
TGfxAffineTransform lCurrentTM;
|
|
1616 |
|
|
1617 |
|
|
1618 |
// we do not need this for the radial and linear Gradient Element.
|
|
1619 |
//
|
|
1620 |
if ( this != lDocument->RootElement()
|
|
1621 |
&& !(lElementId == KSvgLinearGradientElement
|
|
1622 |
|| lElementId == KSvgRadialGradientElement ))
|
|
1623 |
|
|
1624 |
{
|
|
1625 |
CSvgElementImpl* lParentEl = ( CSvgElementImpl* )this->ParentNode();
|
|
1626 |
while (lParentEl && !(lParentEl->IsTransformable()) )
|
|
1627 |
{
|
|
1628 |
lParentEl = ( CSvgElementImpl* )lParentEl->ParentNode();
|
|
1629 |
}
|
|
1630 |
if( lParentEl )
|
|
1631 |
{
|
|
1632 |
lCurrentTM = lParentEl->GetCTM();
|
|
1633 |
}
|
|
1634 |
}
|
|
1635 |
|
|
1636 |
this->GetTransform( trList );
|
|
1637 |
localUserSpace = trList->Consolidate( IsOverwriteTransforms() );
|
|
1638 |
lCurrentTM.Concatenate( localUserSpace );
|
|
1639 |
|
|
1640 |
if(lElementId == KSvgUseElement)
|
|
1641 |
{
|
|
1642 |
lCurrentTM.Translate(((CSvgUseElementImpl *)this)->X(),((CSvgUseElementImpl *)this)->Y() );
|
|
1643 |
}
|
|
1644 |
/* else if(lElementId == KSvgAnimationElement)
|
|
1645 |
{
|
|
1646 |
lCurrentTM.Translate(((CSvgAnimationElementImpl *)this)->X(),((CSvgAnimationElementImpl *)this)->Y() );
|
|
1647 |
}*/
|
|
1648 |
else if ( lElementId == KSvgSvgElement )
|
|
1649 |
{
|
|
1650 |
// Viewbox
|
|
1651 |
CSvgSvgElementImpl* tmpSvgEl = ( CSvgSvgElementImpl* )
|
|
1652 |
this;
|
|
1653 |
TGfxRectangle2D tmpRect ( tmpSvgEl->X(),
|
|
1654 |
tmpSvgEl->Y(),
|
|
1655 |
tmpSvgEl->Width(),
|
|
1656 |
tmpSvgEl->Height() );
|
|
1657 |
|
|
1658 |
// Add stop for bogus viewports being set if the SVG element hasn't been set
|
|
1659 |
// from the Java side.
|
|
1660 |
if (tmpRect.iWidth >= TFloatFixPt(0) && tmpRect.iHeight >= TFloatFixPt(0))
|
|
1661 |
{
|
|
1662 |
tmpSvgEl->SetWindowViewportTrans( tmpRect, lCurrentTM );
|
|
1663 |
}
|
|
1664 |
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
this->SetCTM( lCurrentTM );
|
|
1668 |
}
|
|
1669 |
|
|
1670 |
CSvgElementImpl*lNewElement = ( CSvgElementImpl* )
|
|
1671 |
this->FirstChild();
|
|
1672 |
while ( lNewElement != NULL )
|
|
1673 |
{
|
|
1674 |
lNewElement->UpdateCTM();
|
|
1675 |
lNewElement = ( CSvgElementImpl * ) lNewElement->NextSibling();
|
|
1676 |
}
|
|
1677 |
}
|
|
1678 |
|
|
1679 |
|
|
1680 |
|
|
1681 |
|
|
1682 |
|
|
1683 |
// *******************************************************
|
|
1684 |
|
|
1685 |
// ---------------------------------------------------------------------------
|
|
1686 |
// From MSvgTests
|
|
1687 |
// ---------------------------------------------------------------------------
|
|
1688 |
void CSvgElementImpl::GetRequiredFeatures( const CDesCArrayFlat*& aRequiredFeatures )
|
|
1689 |
{
|
|
1690 |
if( iSvgTests )
|
|
1691 |
{
|
|
1692 |
iSvgTests->GetRequiredFeatures( aRequiredFeatures );
|
|
1693 |
}
|
|
1694 |
}
|
|
1695 |
|
|
1696 |
// ---------------------------------------------------------------------------
|
|
1697 |
//
|
|
1698 |
// ---------------------------------------------------------------------------
|
|
1699 |
void CSvgElementImpl::GetRequiredExtensions( const CDesCArrayFlat*& aRequiredExtensions )
|
|
1700 |
{
|
|
1701 |
if( iSvgTests )
|
|
1702 |
{
|
|
1703 |
iSvgTests->GetRequiredExtensions( aRequiredExtensions );
|
|
1704 |
}
|
|
1705 |
}
|
|
1706 |
|
|
1707 |
// ---------------------------------------------------------------------------
|
|
1708 |
// returns false if system language was empty string
|
|
1709 |
// ---------------------------------------------------------------------------
|
|
1710 |
TBool CSvgElementImpl::GetSystemLanguage( const CDesCArrayFlat*& aSystemLanguage )
|
|
1711 |
{
|
|
1712 |
if( iSvgTests )
|
|
1713 |
{
|
|
1714 |
return (iSvgTests->GetSystemLanguage( aSystemLanguage ));
|
|
1715 |
}
|
|
1716 |
|
|
1717 |
return ETrue;
|
|
1718 |
}
|
|
1719 |
|
|
1720 |
// ---------------------------------------------------------------------------
|
|
1721 |
//
|
|
1722 |
// ---------------------------------------------------------------------------
|
|
1723 |
TBool CSvgElementImpl::HasExtension( const TDesC& aExtension )
|
|
1724 |
{
|
|
1725 |
if( iSvgTests )
|
|
1726 |
{
|
|
1727 |
return iSvgTests->HasExtension( aExtension );
|
|
1728 |
}
|
|
1729 |
return EFalse;
|
|
1730 |
}
|
|
1731 |
|
|
1732 |
// ---------------------------------------------------------------------------
|
|
1733 |
//
|
|
1734 |
// ---------------------------------------------------------------------------
|
|
1735 |
TBool CSvgElementImpl::HasAnyTests( )
|
|
1736 |
{
|
|
1737 |
if( iSvgTests )
|
|
1738 |
{
|
|
1739 |
return iSvgTests->HasAnyTests( );
|
|
1740 |
}
|
|
1741 |
return EFalse;
|
|
1742 |
}
|
|
1743 |
|
|
1744 |
// ---------------------------------------------------------------------------
|
|
1745 |
//
|
|
1746 |
// ---------------------------------------------------------------------------
|
|
1747 |
TBool CSvgElementImpl::HasFeature( const TDesC& aFeature )
|
|
1748 |
{
|
|
1749 |
if( iSvgTests )
|
|
1750 |
{
|
|
1751 |
return iSvgTests->HasFeature( aFeature );
|
|
1752 |
}
|
|
1753 |
return EFalse;
|
|
1754 |
}
|
|
1755 |
|
|
1756 |
// ---------------------------------------------------------------------------
|
|
1757 |
//
|
|
1758 |
// ---------------------------------------------------------------------------
|
|
1759 |
TBool CSvgElementImpl::SetTestAttributeL( const TDesC& aPropertyName,
|
|
1760 |
const TDesC& aValue )
|
|
1761 |
{
|
|
1762 |
|
|
1763 |
_LIT( KRequiredFeatures, "requiredFeatures" );
|
|
1764 |
_LIT( KRequiredExtensions, "requiredExtensions" );
|
|
1765 |
_LIT( KSystemLanguage, "systemLanguage" );
|
|
1766 |
|
|
1767 |
if (aPropertyName == KRequiredFeatures || aPropertyName == KRequiredExtensions || aPropertyName == KSystemLanguage)
|
|
1768 |
{
|
|
1769 |
if (!iSvgTests)
|
|
1770 |
{
|
|
1771 |
iSvgTests = CSvgTestsImpl::NewL();
|
|
1772 |
}
|
|
1773 |
|
|
1774 |
return iSvgTests->SetTestAttributeL( aPropertyName, aValue );
|
|
1775 |
}
|
|
1776 |
|
|
1777 |
return EFalse;
|
|
1778 |
}
|
|
1779 |
|
|
1780 |
// ---------------------------------------------------------------------------
|
|
1781 |
//
|
|
1782 |
// ---------------------------------------------------------------------------
|
|
1783 |
void CSvgElementImpl::CreateSvgTestL(const TUint16 aAttrName)
|
|
1784 |
{
|
|
1785 |
if (aAttrName == KAtrRequiredFeatures || aAttrName == KAtrRequiredExtensions || aAttrName == KAtrSystemLanguage)
|
|
1786 |
{
|
|
1787 |
if (!iSvgTests)
|
|
1788 |
{
|
|
1789 |
iSvgTests = CSvgTestsImpl::NewL();
|
|
1790 |
}
|
|
1791 |
}
|
|
1792 |
}
|
|
1793 |
// *******************************************************
|
|
1794 |
// ---------------------------------------------------------------------------
|
|
1795 |
// From MSvgLangSpace.h
|
|
1796 |
// ---------------------------------------------------------------------------
|
|
1797 |
const TDesC& CSvgElementImpl::XMLLang()
|
|
1798 |
{
|
|
1799 |
if( iSvgLangSpace )
|
|
1800 |
{
|
|
1801 |
return iSvgLangSpace->XMLLang();
|
|
1802 |
}
|
|
1803 |
else
|
|
1804 |
{
|
|
1805 |
return KNullDesC;
|
|
1806 |
}
|
|
1807 |
}
|
|
1808 |
|
|
1809 |
// ---------------------------------------------------------------------------
|
|
1810 |
//
|
|
1811 |
// ---------------------------------------------------------------------------
|
|
1812 |
TInt CSvgElementImpl::SetXMLLangL( const TDesC& aXMLLang )
|
|
1813 |
{
|
|
1814 |
if( iSvgLangSpace )
|
|
1815 |
{
|
|
1816 |
iSvgLangSpace->SetXMLLangL( aXMLLang );
|
|
1817 |
}
|
|
1818 |
return KErrNone;
|
|
1819 |
}
|
|
1820 |
|
|
1821 |
// ---------------------------------------------------------------------------
|
|
1822 |
//
|
|
1823 |
// ---------------------------------------------------------------------------
|
|
1824 |
const TDesC& CSvgElementImpl::XMLSpace()
|
|
1825 |
{
|
|
1826 |
if( iSvgLangSpace )
|
|
1827 |
{
|
|
1828 |
return iSvgLangSpace->XMLSpace();
|
|
1829 |
}
|
|
1830 |
else
|
|
1831 |
{
|
|
1832 |
return KNullDesC;
|
|
1833 |
}
|
|
1834 |
|
|
1835 |
}
|
|
1836 |
|
|
1837 |
// ---------------------------------------------------------------------------
|
|
1838 |
//
|
|
1839 |
// ---------------------------------------------------------------------------
|
|
1840 |
TInt CSvgElementImpl::SetXMLSpaceL( const TDesC& aXMLSpace )
|
|
1841 |
{
|
|
1842 |
if( iSvgLangSpace )
|
|
1843 |
{
|
|
1844 |
iSvgLangSpace->SetXMLSpaceL( aXMLSpace );
|
|
1845 |
}
|
|
1846 |
return KErrNone;
|
|
1847 |
}
|
|
1848 |
|
|
1849 |
// ---------------------------------------------------------------------------
|
|
1850 |
//
|
|
1851 |
// ---------------------------------------------------------------------------
|
|
1852 |
TBool CSvgElementImpl::SetLangSpaceAttributeL( const TDesC& aPropertyName,
|
|
1853 |
const TDesC& aValue )
|
|
1854 |
{
|
|
1855 |
_LIT( KXMLLang, "xml:lang" );
|
|
1856 |
_LIT( KXMLSpace, "xml:space" );
|
|
1857 |
|
|
1858 |
if (aPropertyName == KXMLLang || aPropertyName == KXMLSpace)
|
|
1859 |
{
|
|
1860 |
if (!iSvgLangSpace)
|
|
1861 |
{
|
|
1862 |
iSvgLangSpace = CSvgLangSpaceImpl::NewL();
|
|
1863 |
}
|
|
1864 |
|
|
1865 |
return iSvgLangSpace->SetLangSpaceAttributeL( aPropertyName, aValue );
|
|
1866 |
}
|
|
1867 |
else
|
|
1868 |
{
|
|
1869 |
return EFalse;
|
|
1870 |
}
|
|
1871 |
}
|
|
1872 |
|
|
1873 |
// ---------------------------------------------------------------------------
|
|
1874 |
//
|
|
1875 |
// ---------------------------------------------------------------------------
|
|
1876 |
TBool CSvgElementImpl::SetXlinkAttributeL( const TDesC& aPropertyName,
|
|
1877 |
const TDesC& aValue )
|
|
1878 |
{
|
|
1879 |
if( iSvgUriReferenceImpl )
|
|
1880 |
{
|
|
1881 |
return iSvgUriReferenceImpl->SetXlinkAttributeL( aPropertyName, aValue );
|
|
1882 |
}
|
|
1883 |
else
|
|
1884 |
{
|
|
1885 |
return EFalse;
|
|
1886 |
}
|
|
1887 |
}
|
|
1888 |
|
|
1889 |
// ---------------------------------------------------------------------------
|
|
1890 |
//
|
|
1891 |
// ---------------------------------------------------------------------------
|
|
1892 |
const TDesC& CSvgElementImpl::Href()
|
|
1893 |
{
|
|
1894 |
if( iSvgUriReferenceImpl )
|
|
1895 |
{
|
|
1896 |
return iSvgUriReferenceImpl->Href();
|
|
1897 |
}
|
|
1898 |
return KNullDesC;
|
|
1899 |
|
|
1900 |
}
|
|
1901 |
|
|
1902 |
// ---------------------------------------------------------------------------
|
|
1903 |
//
|
|
1904 |
// ---------------------------------------------------------------------------
|
|
1905 |
TDesC* CSvgElementImpl::HrefPointer()
|
|
1906 |
{
|
|
1907 |
if( iSvgUriReferenceImpl )
|
|
1908 |
{
|
|
1909 |
return iSvgUriReferenceImpl->HrefPointer();
|
|
1910 |
}
|
|
1911 |
return NULL;
|
|
1912 |
}
|
|
1913 |
|
|
1914 |
// ---------------------------------------------------------------------------
|
|
1915 |
//
|
|
1916 |
// ---------------------------------------------------------------------------
|
|
1917 |
|
|
1918 |
const TDesC& CSvgElementImpl::XlinkShow()
|
|
1919 |
{
|
|
1920 |
if(iSvgUriReferenceImpl )
|
|
1921 |
{
|
|
1922 |
return iSvgUriReferenceImpl->XlinkShow();
|
|
1923 |
}
|
|
1924 |
return KNullDesC;
|
|
1925 |
}
|
|
1926 |
|
|
1927 |
|
|
1928 |
// *******************************************************
|
|
1929 |
// From MSvgEventReceiver
|
|
1930 |
// ---------------------------------------------------------------------------
|
|
1931 |
//
|
|
1932 |
// ---------------------------------------------------------------------------
|
|
1933 |
TBool CSvgElementImpl::ReceiveEventL( MSvgEvent* aEvent, const TUint16 aSubEventMask )
|
|
1934 |
{
|
|
1935 |
CSvgEngineImpl* engine = ( ( CSvgDocumentImpl* ) OwnerDocument() )->Engine();
|
|
1936 |
|
|
1937 |
// Accepts Internal event and mouse events
|
|
1938 |
switch ( aEvent->EventType() )
|
|
1939 |
{
|
|
1940 |
case ESvgEngineInternalEvent:
|
|
1941 |
break;
|
|
1942 |
case ESvgEngineEventMouseDown:
|
|
1943 |
case ESvgEngineEventMouseUp:
|
|
1944 |
case ESvgEngineEventMouseMove:
|
|
1945 |
{
|
|
1946 |
// Check if pointer is inside of the element
|
|
1947 |
MSvgUiMouseEvent* mevent = ( MSvgUiMouseEvent* ) aEvent;
|
|
1948 |
//TGfxRectangle2D p(mevent->X(), mevent->Y(), 0,0);
|
|
1949 |
TGfxPoint2D p ( mevent->X(), mevent->Y() );
|
|
1950 |
TGfxRectangle2D bbox;
|
|
1951 |
TInt32 lVisible;
|
|
1952 |
TInt32 lDisplay;
|
|
1953 |
this->GetAttributeIntL(KCSS_ATTR_VISIBILITY,lVisible);
|
|
1954 |
this->GetAttributeIntL(KCSS_ATTR_DISPLAY,lDisplay);
|
|
1955 |
GetBBox( bbox );
|
|
1956 |
if ( bbox.Contains( p ) && lDisplay != 16 && lVisible == 0 )
|
|
1957 |
{
|
|
1958 |
// Invoke internal event
|
|
1959 |
switch ( aEvent->EventType() )
|
|
1960 |
{
|
|
1961 |
case ESvgEngineEventMouseDown:
|
|
1962 |
{
|
|
1963 |
TSvgInternalEvent evt ( ESvgEventMousedown,
|
|
1964 |
( CSvgElementImpl* )
|
|
1965 |
this );
|
|
1966 |
engine->ProcessEventL(
|
|
1967 |
( CSvgDocumentImpl* )OwnerDocument(), &evt );
|
|
1968 |
SetMouseDown( ETrue );
|
|
1969 |
}
|
|
1970 |
break;
|
|
1971 |
case ESvgEngineEventMouseUp:
|
|
1972 |
{
|
|
1973 |
TSvgInternalEvent evt ( ESvgEventMouseup,
|
|
1974 |
( CSvgElementImpl* )
|
|
1975 |
this );
|
|
1976 |
engine->ProcessEventL(
|
|
1977 |
( CSvgDocumentImpl* )OwnerDocument(), &evt );
|
|
1978 |
|
|
1979 |
if ( IsMouseDown() )
|
|
1980 |
{
|
|
1981 |
// Check the aSubEventMask to know which event
|
|
1982 |
// has occured
|
|
1983 |
if(CanGenerateInternalEvent(aSubEventMask,ESvgEventActivate))
|
|
1984 |
{
|
|
1985 |
|
|
1986 |
TSvgInternalEvent evt1 (
|
|
1987 |
ESvgEventActivate,
|
|
1988 |
( CSvgElementImpl* )this );
|
|
1989 |
|
|
1990 |
engine->ProcessEventL(
|
|
1991 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
1992 |
&evt1 );
|
|
1993 |
}
|
|
1994 |
if ( CanGenerateInternalEvent(aSubEventMask,ESvgEventClick))
|
|
1995 |
{
|
|
1996 |
|
|
1997 |
TSvgInternalEvent evt (
|
|
1998 |
ESvgEventClick,
|
|
1999 |
( CSvgElementImpl* )this );
|
|
2000 |
|
|
2001 |
engine->ProcessEventL(
|
|
2002 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
2003 |
&evt );
|
|
2004 |
|
|
2005 |
}
|
|
2006 |
}
|
|
2007 |
SetMouseDown( EFalse );
|
|
2008 |
}
|
|
2009 |
break;
|
|
2010 |
case ESvgEngineEventMouseMove:
|
|
2011 |
{
|
|
2012 |
|
|
2013 |
engine->NotifyElementActivatedLinkEntered(this);
|
|
2014 |
|
|
2015 |
if ( CanGenerateInternalEvent(aSubEventMask,ESvgEventMousemove) )
|
|
2016 |
{
|
|
2017 |
|
|
2018 |
TSvgInternalEvent evt1(
|
|
2019 |
ESvgEventMousemove,
|
|
2020 |
( CSvgElementImpl* )this );
|
|
2021 |
engine->ProcessEventL(
|
|
2022 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
2023 |
&evt1 );
|
|
2024 |
}
|
|
2025 |
|
|
2026 |
if ( !IsMouseIn() )
|
|
2027 |
{
|
|
2028 |
|
|
2029 |
engine->NotifyInteractiveElementEntered(this);
|
|
2030 |
|
|
2031 |
// Check the aSubEventMask to know which event
|
|
2032 |
// has occured
|
|
2033 |
if ( CanGenerateInternalEvent(aSubEventMask,ESvgEventMouseover) )
|
|
2034 |
{
|
|
2035 |
|
|
2036 |
TSvgInternalEvent evt (
|
|
2037 |
ESvgEventMouseover,
|
|
2038 |
( CSvgElementImpl* )this );
|
|
2039 |
engine->ProcessEventL(
|
|
2040 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
2041 |
&evt );
|
|
2042 |
}
|
|
2043 |
|
|
2044 |
if ( CanGenerateInternalEvent(aSubEventMask,ESvgEventFocusin) )
|
|
2045 |
{
|
|
2046 |
|
|
2047 |
TSvgInternalEvent evt2 (
|
|
2048 |
ESvgEventFocusin,
|
|
2049 |
( CSvgElementImpl* )this );
|
|
2050 |
|
|
2051 |
engine->ProcessEventL(
|
|
2052 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
2053 |
&evt2 );
|
|
2054 |
|
|
2055 |
}
|
|
2056 |
}
|
|
2057 |
SetMouseIn( ETrue );
|
|
2058 |
}
|
|
2059 |
break;
|
|
2060 |
default:
|
|
2061 |
break;
|
|
2062 |
}
|
|
2063 |
}
|
|
2064 |
else
|
|
2065 |
{
|
|
2066 |
engine->NotifyElementActivatedLinkExited(this);
|
|
2067 |
|
|
2068 |
|
|
2069 |
// if state was 'mouse down'then reset the state
|
|
2070 |
SetMouseDown( EFalse );
|
|
2071 |
|
|
2072 |
// if state was 'mouse in' and event is ESvgEngineEventMouseMove,
|
|
2073 |
// invoke mouseout event
|
|
2074 |
|
|
2075 |
//MouseMove: in case of scrolling over a element focusOut events must
|
|
2076 |
// be generated
|
|
2077 |
|
|
2078 |
//MouseDown: In touch cases, if you tap on a element and then tap outside
|
|
2079 |
// then a focusout event must be generated
|
|
2080 |
if ( IsMouseIn() &&
|
|
2081 |
(aEvent->EventType() == ESvgEngineEventMouseMove || aEvent->EventType() == ESvgEngineEventMouseDown )
|
|
2082 |
)
|
|
2083 |
{
|
|
2084 |
|
|
2085 |
// Check the aSubEventMask to know whether any valid bit
|
|
2086 |
// is set
|
|
2087 |
if(engine->Document()->IsValidSubEventMask(aSubEventMask))
|
|
2088 |
{
|
|
2089 |
engine->NotifyInteractiveElementExited(this);
|
|
2090 |
}
|
|
2091 |
if ( CanGenerateInternalEvent(
|
|
2092 |
aSubEventMask,ESvgEventMouseout ) )
|
|
2093 |
{
|
|
2094 |
TSvgInternalEvent mouseOutEvent (
|
|
2095 |
ESvgEventMouseout, this );
|
|
2096 |
engine->ProcessEventL(
|
|
2097 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
2098 |
&mouseOutEvent );
|
|
2099 |
}
|
|
2100 |
if ( CanGenerateInternalEvent(
|
|
2101 |
aSubEventMask,ESvgEventFocusout))
|
|
2102 |
{
|
|
2103 |
TSvgInternalEvent focusOutEvent (
|
|
2104 |
ESvgEventFocusout, this );
|
|
2105 |
engine->ProcessEventL(
|
|
2106 |
( CSvgDocumentImpl* ) OwnerDocument(),
|
|
2107 |
&focusOutEvent );
|
|
2108 |
}
|
|
2109 |
}
|
|
2110 |
SetMouseIn( EFalse );
|
|
2111 |
}
|
|
2112 |
}
|
|
2113 |
break;
|
|
2114 |
default:
|
|
2115 |
break;
|
|
2116 |
}
|
|
2117 |
|
|
2118 |
return EFalse;
|
|
2119 |
}
|
|
2120 |
|
|
2121 |
// *******************************************************
|
|
2122 |
// From MSvgEventReceiver
|
|
2123 |
// ---------------------------------------------------------------------------
|
|
2124 |
//
|
|
2125 |
// ---------------------------------------------------------------------------
|
|
2126 |
TBool CSvgElementImpl::ReceiveEventL( MSvgEvent* /*aEvent*/ )
|
|
2127 |
{
|
|
2128 |
// Dummy implementation
|
|
2129 |
return EFalse;
|
|
2130 |
}
|
|
2131 |
|
|
2132 |
|
|
2133 |
|
|
2134 |
|
|
2135 |
// *******************************************************
|
|
2136 |
// From MXmlElementOpt
|
|
2137 |
// ---------------------------------------------------------------------------
|
|
2138 |
//
|
|
2139 |
// ---------------------------------------------------------------------------
|
|
2140 |
TInt CSvgElementImpl::GetAttributeIntL( const TInt aNameId, TInt32& aValue )
|
|
2141 |
{
|
|
2142 |
|
|
2143 |
|
|
2144 |
CCssValue* lCssValue = NULL;
|
|
2145 |
|
|
2146 |
|
|
2147 |
if( aNameId == KAtrAnimMotionMatrixIndex )
|
|
2148 |
{
|
|
2149 |
aValue = AnimateMotionMatrixIndexL();
|
|
2150 |
}
|
|
2151 |
else if(aNameId== KAtrAnimTransformMatrixIndex)
|
|
2152 |
{
|
|
2153 |
aValue = AnimateTransformMatrixIndexL();
|
|
2154 |
}
|
|
2155 |
else
|
|
2156 |
{
|
|
2157 |
if( (aNameId >= KCSS_MAX_ATTR || aNameId < 0))
|
|
2158 |
{
|
|
2159 |
return KErrInvalidAttribute;
|
|
2160 |
}
|
|
2161 |
|
|
2162 |
if (iSvgStyleProperties == NULL )
|
|
2163 |
{
|
|
2164 |
//if the style properties havent been set then just get a default one to be safe
|
|
2165 |
GetDefaultAttributeL(aNameId, lCssValue);
|
|
2166 |
}
|
|
2167 |
else
|
|
2168 |
{
|
|
2169 |
lCssValue = iSvgStyleProperties->operator[](aNameId);
|
|
2170 |
}
|
|
2171 |
|
|
2172 |
if( lCssValue )
|
|
2173 |
{
|
|
2174 |
aValue = (( CIntCssValueImpl* )lCssValue)->Value();
|
|
2175 |
|
|
2176 |
if( aNameId == KCSS_ATTR_FILL )
|
|
2177 |
{
|
|
2178 |
|
|
2179 |
MGfxPaint* lPaintValue = (MGfxPaint *)((( CPaintCssValueImpl* )lCssValue)->Value());
|
|
2180 |
/*
|
|
2181 |
if(lPaintValue && lPaintValue->GetColor()== KSvgCurrentColor)
|
|
2182 |
{
|
|
2183 |
lPaintValue = CurrentColor();
|
|
2184 |
aValue = lPaintValue->GetColor();
|
|
2185 |
}
|
|
2186 |
else*/ if(lPaintValue)
|
|
2187 |
{
|
|
2188 |
aValue = lPaintValue->GetColor();
|
|
2189 |
}
|
|
2190 |
else
|
|
2191 |
{
|
|
2192 |
return KErrNoAttribute;
|
|
2193 |
}
|
|
2194 |
}
|
|
2195 |
else if(aNameId == KCSS_ATTR_STROKE || aNameId == KCSS_ATTR_COLOR)
|
|
2196 |
{
|
|
2197 |
TSvgColor *lColorValue = (( CClrCssValueImpl* )lCssValue)->Value();
|
|
2198 |
if(lColorValue)
|
|
2199 |
{
|
|
2200 |
aValue = lColorValue->GetColor();
|
|
2201 |
}
|
|
2202 |
else
|
|
2203 |
{
|
|
2204 |
return KErrNoAttribute;
|
|
2205 |
}
|
|
2206 |
}
|
|
2207 |
return KErrNone;
|
|
2208 |
}
|
|
2209 |
else
|
|
2210 |
{
|
|
2211 |
return KErrNoAttribute;
|
|
2212 |
}
|
|
2213 |
}
|
|
2214 |
return KErrNone;
|
|
2215 |
|
|
2216 |
}
|
|
2217 |
|
|
2218 |
// ---------------------------------------------------------------------------
|
|
2219 |
//
|
|
2220 |
// ---------------------------------------------------------------------------
|
|
2221 |
TInt CSvgElementImpl::SetAttributeIntL( const TInt aNameId,
|
|
2222 |
const TInt32 aValue )
|
|
2223 |
{
|
|
2224 |
|
|
2225 |
|
|
2226 |
CSvgDocumentImpl* doc = ( CSvgDocumentImpl* ) OwnerDocument();
|
|
2227 |
|
|
2228 |
if (!doc)
|
|
2229 |
{
|
|
2230 |
return KErrNoAttribute;
|
|
2231 |
}
|
|
2232 |
|
|
2233 |
if( aNameId >= KCSS_MAX_ATTR || (iSvgStyleProperties == NULL))
|
|
2234 |
{
|
|
2235 |
return KErrNoAttribute;
|
|
2236 |
}
|
|
2237 |
|
|
2238 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)ParentNode ();
|
|
2239 |
while(lParentElement && (lParentElement->iSvgStyleProperties == NULL))
|
|
2240 |
{
|
|
2241 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
2242 |
}
|
|
2243 |
switch(aNameId)
|
|
2244 |
{
|
|
2245 |
case KCSS_ATTR_FILL:
|
|
2246 |
{
|
|
2247 |
CPaintCssValueImpl* tValue = (CPaintCssValueImpl *)(iSvgStyleProperties->operator[](aNameId));
|
|
2248 |
CPaintCssValueImpl* tParentValue = NULL ;
|
|
2249 |
if( this != doc->RootElement() && lParentElement )
|
|
2250 |
{
|
|
2251 |
tParentValue = (CPaintCssValueImpl *)(lParentElement->iSvgStyleProperties->operator[](aNameId));
|
|
2252 |
}
|
|
2253 |
|
|
2254 |
if( tParentValue == tValue || tValue == NULL) //Not Yet set
|
|
2255 |
{
|
|
2256 |
tValue = doc->iMemoryManager->GetCssPaintObjectL();
|
|
2257 |
|
|
2258 |
CCssValue* oldValue = iSvgStyleProperties->operator[](aNameId);
|
|
2259 |
PropagateToChildren( oldValue, tValue, aNameId );
|
|
2260 |
iSvgStyleProperties->operator[](aNameId) = tValue;
|
|
2261 |
}
|
|
2262 |
tValue->SetValueL( aValue );
|
|
2263 |
|
|
2264 |
break;
|
|
2265 |
}
|
|
2266 |
case KCSS_ATTR_STROKE:
|
|
2267 |
case KCSS_ATTR_COLOR:
|
|
2268 |
{
|
|
2269 |
|
|
2270 |
CClrCssValueImpl* tValue = (CClrCssValueImpl *)(iSvgStyleProperties->operator[](aNameId));
|
|
2271 |
CClrCssValueImpl* tParentValue = NULL ;
|
|
2272 |
if( this != doc->RootElement() && lParentElement)
|
|
2273 |
{
|
|
2274 |
tParentValue = (CClrCssValueImpl *)(lParentElement->iSvgStyleProperties->operator[](aNameId));
|
|
2275 |
}
|
|
2276 |
|
|
2277 |
if( tParentValue == tValue || tValue == NULL) //Not Yet set
|
|
2278 |
{
|
|
2279 |
tValue = doc->iMemoryManager->GetCssClrObjectL();
|
|
2280 |
|
|
2281 |
CCssValue* oldValue = iSvgStyleProperties->operator[](aNameId);
|
|
2282 |
PropagateToChildren( oldValue, tValue, aNameId );
|
|
2283 |
iSvgStyleProperties->operator[](aNameId) = tValue;
|
|
2284 |
}
|
|
2285 |
tValue->SetValueL( aValue );
|
|
2286 |
|
|
2287 |
break;
|
|
2288 |
}
|
|
2289 |
default:
|
|
2290 |
{
|
|
2291 |
CIntCssValueImpl* tValue = (CIntCssValueImpl *)(iSvgStyleProperties->operator[](aNameId));
|
|
2292 |
if( tValue != NULL && tValue->Value() == aValue )
|
|
2293 |
{
|
|
2294 |
return KErrNone;
|
|
2295 |
}
|
|
2296 |
CIntCssValueImpl* tParentValue = NULL ;
|
|
2297 |
if( this != doc->RootElement() && lParentElement )
|
|
2298 |
{
|
|
2299 |
tParentValue = (CIntCssValueImpl *)(lParentElement->iSvgStyleProperties->operator[](aNameId));
|
|
2300 |
}
|
|
2301 |
|
|
2302 |
if( tParentValue == tValue || tValue == NULL) //Not Yet set
|
|
2303 |
{
|
|
2304 |
tValue = doc->iMemoryManager->GetCssIntObjectL();
|
|
2305 |
|
|
2306 |
CCssValue* oldValue = iSvgStyleProperties->operator[](aNameId);
|
|
2307 |
PropagateToChildren( oldValue, tValue, aNameId );
|
|
2308 |
iSvgStyleProperties->operator[](aNameId) = tValue;
|
|
2309 |
|
|
2310 |
}
|
|
2311 |
if( lParentElement && aValue == KInherit )
|
|
2312 |
{
|
|
2313 |
//tParentValue = (CIntCssValueImpl *)(lParentElement->iSvgStyleProperties->operator[](aNameId));
|
|
2314 |
//(*iSvgStyleProperties)[aNameId]= tParentValue;
|
|
2315 |
if(tParentValue)
|
|
2316 |
tValue->SetValueL(tParentValue->Value());
|
|
2317 |
}
|
|
2318 |
else
|
|
2319 |
{
|
|
2320 |
tValue->SetValueL( aValue );
|
|
2321 |
}
|
|
2322 |
|
|
2323 |
break;
|
|
2324 |
|
|
2325 |
}
|
|
2326 |
}
|
|
2327 |
return KErrNoAttribute;
|
|
2328 |
|
|
2329 |
|
|
2330 |
}
|
|
2331 |
|
|
2332 |
// ---------------------------------------------------------------------------
|
|
2333 |
//
|
|
2334 |
// ---------------------------------------------------------------------------
|
|
2335 |
TInt CSvgElementImpl::GetAttributeFloat( const TInt aNameId, TFloatFixPt& aValue )
|
|
2336 |
{
|
|
2337 |
|
|
2338 |
CCssValue* lCssValue = NULL;
|
|
2339 |
if((aNameId < KCSS_MAX_ATTR) && iSvgStyleProperties )
|
|
2340 |
{
|
|
2341 |
lCssValue = iSvgStyleProperties->operator[](aNameId);
|
|
2342 |
if( lCssValue )
|
|
2343 |
{
|
|
2344 |
aValue = (( CFloatCssValueImpl * )lCssValue)->Value();
|
|
2345 |
return KErrNone;
|
|
2346 |
}
|
|
2347 |
else
|
|
2348 |
{
|
|
2349 |
TRAPD(err, GetDefaultAttributeL(aNameId, lCssValue));
|
|
2350 |
if (err)
|
|
2351 |
{
|
|
2352 |
#ifdef _DEBUG
|
|
2353 |
RDebug::Printf("CSvgElementImpl::GetAttributeFloat: Error trapped=%d", err);
|
|
2354 |
#endif
|
|
2355 |
return KErrNoAttribute;
|
|
2356 |
}
|
|
2357 |
aValue = (( CFloatCssValueImpl * )lCssValue)->Value();
|
|
2358 |
return KErrNone;
|
|
2359 |
}
|
|
2360 |
}
|
|
2361 |
return KErrNoAttribute;
|
|
2362 |
|
|
2363 |
}
|
|
2364 |
|
|
2365 |
// ---------------------------------------------------------------------------
|
|
2366 |
//
|
|
2367 |
// ---------------------------------------------------------------------------
|
|
2368 |
TInt CSvgElementImpl::SetAttributeFloatL( const TInt aNameId,
|
|
2369 |
const TFloatFixPt aValue )
|
|
2370 |
{
|
|
2371 |
CSvgDocumentImpl* doc = ( CSvgDocumentImpl* ) OwnerDocument();
|
|
2372 |
|
|
2373 |
if (!doc)
|
|
2374 |
{
|
|
2375 |
return KErrNoAttribute;
|
|
2376 |
}
|
|
2377 |
|
|
2378 |
if(aNameId < KCSS_MAX_ATTR && iSvgStyleProperties)
|
|
2379 |
{
|
|
2380 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)ParentNode ();
|
|
2381 |
while(lParentElement && (lParentElement->iSvgStyleProperties == NULL))
|
|
2382 |
{
|
|
2383 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
2384 |
}
|
|
2385 |
|
|
2386 |
|
|
2387 |
CFloatCssValueImpl* tValue = (CFloatCssValueImpl *)(iSvgStyleProperties->operator[](aNameId));
|
|
2388 |
CFloatCssValueImpl* tParentValue = NULL ;
|
|
2389 |
if( this != doc->RootElement() && lParentElement)
|
|
2390 |
{
|
|
2391 |
tParentValue = (CFloatCssValueImpl *)(lParentElement->iSvgStyleProperties->operator[](aNameId));
|
|
2392 |
|
|
2393 |
}
|
|
2394 |
|
|
2395 |
if( tParentValue == tValue || tValue == NULL) //Not Yet set
|
|
2396 |
{
|
|
2397 |
tValue = doc->iMemoryManager->GetCssFloatObjectL();
|
|
2398 |
|
|
2399 |
|
|
2400 |
CCssValue* oldValue = iSvgStyleProperties->operator[](aNameId);
|
|
2401 |
PropagateToChildren( oldValue, tValue, aNameId );
|
|
2402 |
|
|
2403 |
iSvgStyleProperties->operator[](aNameId) = tValue;
|
|
2404 |
}
|
|
2405 |
return tValue->SetValueL( aValue );
|
|
2406 |
|
|
2407 |
}
|
|
2408 |
return KErrNoAttribute;
|
|
2409 |
|
|
2410 |
}
|
|
2411 |
|
|
2412 |
|
|
2413 |
void CSvgElementImpl::GetSvgStylePropertiesArray( RPointerArray<CCssValue>*& aSvgStyleProperties)
|
|
2414 |
{
|
|
2415 |
aSvgStyleProperties = iSvgStyleProperties;
|
|
2416 |
}
|
|
2417 |
|
|
2418 |
|
|
2419 |
// ---------------------------------------------------------------------------
|
|
2420 |
//
|
|
2421 |
// ---------------------------------------------------------------------------
|
|
2422 |
TInt CSvgElementImpl::GetAttributePath( const TInt /* aNameId */,
|
|
2423 |
CGfxGeneralPath*& /* aValue */ )
|
|
2424 |
{
|
|
2425 |
return KErrNoAttribute;
|
|
2426 |
}
|
|
2427 |
|
|
2428 |
// ---------------------------------------------------------------------------
|
|
2429 |
//
|
|
2430 |
// ---------------------------------------------------------------------------
|
|
2431 |
TInt CSvgElementImpl::SetAttributePathL( const TInt /*aNameId */,
|
|
2432 |
CGfxGeneralPath* /* aValue */ )
|
|
2433 |
{
|
|
2434 |
return KErrNoAttribute;
|
|
2435 |
}
|
|
2436 |
|
|
2437 |
// ---------------------------------------------------------------------------
|
|
2438 |
//
|
|
2439 |
// ---------------------------------------------------------------------------
|
|
2440 |
TInt CSvgElementImpl::SetAttributePathRef( const TInt /*aNameId */,
|
|
2441 |
CGfxGeneralPath*& /* aValue */ )
|
|
2442 |
{
|
|
2443 |
return KErrNoAttribute;
|
|
2444 |
}
|
|
2445 |
|
|
2446 |
// ---------------------------------------------------------------------------
|
|
2447 |
//
|
|
2448 |
// ---------------------------------------------------------------------------
|
|
2449 |
TInt CSvgElementImpl::GetAttributeDes( const TInt aNameId, TPtrC16& aValue )
|
|
2450 |
{
|
|
2451 |
CCssValue* lCssValue = NULL;
|
|
2452 |
|
|
2453 |
if(aNameId < KCSS_MAX_ATTR && iSvgStyleProperties)
|
|
2454 |
{
|
|
2455 |
lCssValue = iSvgStyleProperties->operator[](aNameId);
|
|
2456 |
if( lCssValue )
|
|
2457 |
{
|
|
2458 |
aValue.Set( (( CStrCssValueImpl * )lCssValue)->Value() );
|
|
2459 |
return KErrNone;
|
|
2460 |
|
|
2461 |
}
|
|
2462 |
else
|
|
2463 |
{
|
|
2464 |
TBool defaultAttr = EFalse;
|
|
2465 |
TRAPD(err, defaultAttr = GetDefaultAttributeL(aNameId, lCssValue));
|
|
2466 |
if (err)
|
|
2467 |
{
|
|
2468 |
#ifdef _DEBUG
|
|
2469 |
RDebug::Printf("CSvgElementImpl::GetAttributeDes: Error trapped=%d", err);
|
|
2470 |
#endif
|
|
2471 |
return KErrNoAttribute;
|
|
2472 |
}
|
|
2473 |
|
|
2474 |
if (defaultAttr && lCssValue)
|
|
2475 |
{
|
|
2476 |
aValue.Set( (( CStrCssValueImpl * )lCssValue)->Value() );
|
|
2477 |
return KErrNone;
|
|
2478 |
}
|
|
2479 |
return KErrNoAttribute;
|
|
2480 |
}
|
|
2481 |
}
|
|
2482 |
// This is added for JSR API's and this is helpful for testing of the JSR API's
|
|
2483 |
if(aNameId == KAtrId)
|
|
2484 |
{
|
|
2485 |
if( Id() )
|
|
2486 |
{
|
|
2487 |
aValue.Set( *Id() );
|
|
2488 |
return KErrNone;
|
|
2489 |
}
|
|
2490 |
}
|
|
2491 |
return KErrNoAttribute;
|
|
2492 |
|
|
2493 |
}
|
|
2494 |
|
|
2495 |
// ---------------------------------------------------------------------------
|
|
2496 |
//
|
|
2497 |
// ---------------------------------------------------------------------------
|
|
2498 |
TInt CSvgElementImpl::SetAttributeDesL( const TInt aNameId,
|
|
2499 |
const TDesC& aValue )
|
|
2500 |
{
|
|
2501 |
CSvgDocumentImpl* doc = ( CSvgDocumentImpl* ) OwnerDocument();
|
|
2502 |
|
|
2503 |
if (!doc)
|
|
2504 |
{
|
|
2505 |
return KErrNoAttribute;
|
|
2506 |
}
|
|
2507 |
|
|
2508 |
if(aNameId < KCSS_MAX_ATTR && iSvgStyleProperties)
|
|
2509 |
{
|
|
2510 |
|
|
2511 |
CSvgElementImpl* lParentElement = (CSvgElementImpl*)ParentNode ();
|
|
2512 |
while(lParentElement && (lParentElement->iSvgStyleProperties == NULL))
|
|
2513 |
{
|
|
2514 |
lParentElement = (CSvgElementImpl*)lParentElement->ParentNode ();
|
|
2515 |
}
|
|
2516 |
|
|
2517 |
CStrCssValueImpl* tValue = (CStrCssValueImpl *)(iSvgStyleProperties->operator[](aNameId));
|
|
2518 |
CStrCssValueImpl* tParentValue = NULL ;
|
|
2519 |
if( this != doc->RootElement() && lParentElement)
|
|
2520 |
{
|
|
2521 |
tParentValue = (CStrCssValueImpl *)(lParentElement->iSvgStyleProperties->operator[](aNameId));
|
|
2522 |
}
|
|
2523 |
|
|
2524 |
if( tParentValue == tValue || tValue == NULL) //Not Yet set
|
|
2525 |
{
|
|
2526 |
tValue = doc->iMemoryManager->GetCssStrObjectL(KNullDesC);
|
|
2527 |
|
|
2528 |
|
|
2529 |
CCssValue* oldValue = iSvgStyleProperties->operator[](aNameId);
|
|
2530 |
PropagateToChildren( oldValue, tValue, aNameId );
|
|
2531 |
|
|
2532 |
iSvgStyleProperties->operator[](aNameId) = tValue;
|
|
2533 |
|
|
2534 |
}
|
|
2535 |
return tValue->SetValueL( aValue );
|
|
2536 |
|
|
2537 |
}
|
|
2538 |
// the following code is added to modify the Id. This might be needed for the JSR API's
|
|
2539 |
if(aNameId == KAtrId)
|
|
2540 |
{
|
|
2541 |
delete iId;
|
|
2542 |
iId = NULL;
|
|
2543 |
iId = aValue.AllocL();
|
|
2544 |
return KErrNone;
|
|
2545 |
}
|
|
2546 |
return KErrNoAttribute;
|
|
2547 |
|
|
2548 |
|
|
2549 |
}
|
|
2550 |
|
|
2551 |
// ---------------------------------------------------------------------------
|
|
2552 |
// Internal public method (public but not exported)
|
|
2553 |
// ---------------------------------------------------------------------------
|
|
2554 |
TInt32 CSvgElementImpl::AnimateMotionMatrixIndexL()
|
|
2555 |
{
|
|
2556 |
if ( iAnimateMotionMatrixIndex < 0 && iSvgTransformable )
|
|
2557 |
{
|
|
2558 |
TGfxAffineTransform ident;
|
|
2559 |
MSvgTransformList* trList;
|
|
2560 |
this->GetTransform( trList );
|
|
2561 |
trList->AppendItemL( ident, ETrue, ETrue ); // Set identity transform
|
|
2562 |
iAnimateMotionMatrixIndex = ( TInt16 ) ( trList->NumberOfItems() - 1 );// Keep index in list for this anim element
|
|
2563 |
}
|
|
2564 |
|
|
2565 |
return iAnimateMotionMatrixIndex;
|
|
2566 |
}
|
|
2567 |
TInt32 CSvgElementImpl::AnimateTransformMatrixIndexL()
|
|
2568 |
{
|
|
2569 |
if ( iAnimateTransformMatrixIndex < 0 && iSvgTransformable )
|
|
2570 |
{
|
|
2571 |
TGfxAffineTransform ident;
|
|
2572 |
MSvgTransformList* trList;
|
|
2573 |
this->GetTransform( trList );
|
|
2574 |
trList->AppendItemL( ident, ETrue, 2); // Set identity transform
|
|
2575 |
iAnimateTransformMatrixIndex = trList->NumberOfItems() - 1;// Keep index in list for this anim element */
|
|
2576 |
}
|
|
2577 |
|
|
2578 |
return iAnimateTransformMatrixIndex;
|
|
2579 |
}
|
|
2580 |
// ---------------------------------------------------------------------------
|
|
2581 |
//
|
|
2582 |
// ---------------------------------------------------------------------------
|
|
2583 |
void CSvgElementImpl::GetBBox( TGfxRectangle2D& /*aBbox*/ )
|
|
2584 |
{
|
|
2585 |
}
|
|
2586 |
|
|
2587 |
// ---------------------------------------------------------------------------
|
|
2588 |
//
|
|
2589 |
// ---------------------------------------------------------------------------
|
|
2590 |
void CSvgElementImpl::GetUnscaledBBox( TGfxRectangle2D& /*aBbox*/ )
|
|
2591 |
{
|
|
2592 |
}
|
|
2593 |
|
|
2594 |
// ---------------------------------------------------------------------------
|
|
2595 |
//
|
|
2596 |
// ---------------------------------------------------------------------------
|
|
2597 |
void CSvgElementImpl::ResetReferenceElementL()
|
|
2598 |
{
|
|
2599 |
}
|
|
2600 |
|
|
2601 |
// ---------------------------------------------------------------------------
|
|
2602 |
// perform a deep clone of this object
|
|
2603 |
// ---------------------------------------------------------------------------
|
|
2604 |
MXmlElement* CSvgElementImpl::CloneL(MXmlElement*)
|
|
2605 |
{
|
|
2606 |
return NULL;
|
|
2607 |
}
|
|
2608 |
|
|
2609 |
// ---------------------------------------------------------------------------
|
|
2610 |
// copy the contents of this object to the passed object
|
|
2611 |
// this method assumes that the passed object has already been
|
|
2612 |
// created using the proper NewL method.
|
|
2613 |
// ---------------------------------------------------------------------------
|
|
2614 |
void CSvgElementImpl::CopyL( CSvgElementImpl* aDestElement )
|
|
2615 |
{
|
|
2616 |
|
|
2617 |
if(aDestElement)
|
|
2618 |
{
|
|
2619 |
|
|
2620 |
if( iSvgStyleProperties )
|
|
2621 |
{
|
|
2622 |
aDestElement->iSvgStyleProperties->Reset();
|
|
2623 |
|
|
2624 |
CloneSvgStylePropertiesL(aDestElement,(CSvgElementImpl *)(aDestElement->ParentNode()));
|
|
2625 |
}
|
|
2626 |
|
|
2627 |
|
|
2628 |
// copy iSvgTransformable (CSvgTransformableImpl)
|
|
2629 |
if( iSvgTransformable )
|
|
2630 |
{
|
|
2631 |
if ( aDestElement->iSvgTransformable != NULL )
|
|
2632 |
{
|
|
2633 |
delete aDestElement->iSvgTransformable;
|
|
2634 |
aDestElement->iSvgTransformable = NULL;
|
|
2635 |
}
|
|
2636 |
aDestElement->iSvgTransformable = this->iSvgTransformable->CloneL();
|
|
2637 |
}
|
|
2638 |
|
|
2639 |
// copy iSvgTests (CSvgTestImpl)
|
|
2640 |
if( iSvgTests )
|
|
2641 |
{
|
|
2642 |
if ( aDestElement->iSvgTests != NULL )
|
|
2643 |
{
|
|
2644 |
delete aDestElement->iSvgTests;
|
|
2645 |
aDestElement->iSvgTests = NULL;
|
|
2646 |
}
|
|
2647 |
aDestElement->iSvgTests = this->iSvgTests->CloneL();
|
|
2648 |
}
|
|
2649 |
|
|
2650 |
// copy iSvgUriReferenceImpl (CSvgUriReferenceImpl)
|
|
2651 |
if( iSvgUriReferenceImpl )
|
|
2652 |
{
|
|
2653 |
if ( aDestElement->iSvgUriReferenceImpl != NULL )
|
|
2654 |
{
|
|
2655 |
delete aDestElement->iSvgUriReferenceImpl;
|
|
2656 |
aDestElement->iSvgUriReferenceImpl = NULL;
|
|
2657 |
}
|
|
2658 |
aDestElement->iSvgUriReferenceImpl = this->iSvgUriReferenceImpl->CloneL();
|
|
2659 |
}
|
|
2660 |
|
|
2661 |
// copy iSvgLangSpace (CSvgLangSpaceImpl)
|
|
2662 |
if( iSvgLangSpace )
|
|
2663 |
{
|
|
2664 |
if ( aDestElement->iSvgLangSpace != NULL )
|
|
2665 |
{
|
|
2666 |
delete aDestElement->iSvgLangSpace;
|
|
2667 |
aDestElement->iSvgLangSpace = NULL;
|
|
2668 |
}
|
|
2669 |
aDestElement->iSvgLangSpace = this->iSvgLangSpace->CloneL();
|
|
2670 |
}
|
|
2671 |
|
|
2672 |
// copy Id (iId)
|
|
2673 |
if( iId )
|
|
2674 |
{
|
|
2675 |
aDestElement->SetAttributeDesL( KAtrId, *iId );
|
|
2676 |
}
|
|
2677 |
|
|
2678 |
// copy stuff from superclass
|
|
2679 |
this->CXmlElementImpl::CopyL(aDestElement);
|
|
2680 |
}
|
|
2681 |
|
|
2682 |
}
|
|
2683 |
|
|
2684 |
void CSvgElementImpl::PropagateToChildren( CCssValue *oldValue, CCssValue *newValue, const TInt aNameId )
|
|
2685 |
{
|
|
2686 |
CSvgElementImpl *lChild = (CSvgElementImpl *)FirstChild();
|
|
2687 |
|
|
2688 |
while(lChild)
|
|
2689 |
{
|
|
2690 |
if( lChild->iSvgStyleProperties )
|
|
2691 |
{
|
|
2692 |
if( lChild->iSvgStyleProperties->operator[](aNameId) == oldValue)
|
|
2693 |
{
|
|
2694 |
lChild->iSvgStyleProperties->operator[](aNameId) = newValue;
|
|
2695 |
if( lChild->FirstChild() )
|
|
2696 |
{
|
|
2697 |
lChild = (CSvgElementImpl *)lChild->FirstChild();
|
|
2698 |
continue;
|
|
2699 |
}
|
|
2700 |
|
|
2701 |
}
|
|
2702 |
}
|
|
2703 |
else
|
|
2704 |
{
|
|
2705 |
if( lChild->FirstChild() )
|
|
2706 |
{
|
|
2707 |
lChild = (CSvgElementImpl *)lChild->FirstChild();
|
|
2708 |
continue;
|
|
2709 |
}
|
|
2710 |
}
|
|
2711 |
|
|
2712 |
|
|
2713 |
if( lChild->NextSibling() )
|
|
2714 |
{
|
|
2715 |
lChild = (CSvgElementImpl *)lChild->NextSibling();
|
|
2716 |
}
|
|
2717 |
else
|
|
2718 |
{
|
|
2719 |
lChild = (CSvgElementImpl *)lChild->ParentNode();
|
|
2720 |
while( lChild != this && lChild->NextSibling() == NULL )
|
|
2721 |
{
|
|
2722 |
lChild = (CSvgElementImpl *)lChild->ParentNode();
|
|
2723 |
}
|
|
2724 |
if( lChild == this )
|
|
2725 |
{
|
|
2726 |
lChild = NULL ;
|
|
2727 |
}
|
|
2728 |
else
|
|
2729 |
{
|
|
2730 |
lChild = (CSvgElementImpl *)(lChild->NextSibling());
|
|
2731 |
}
|
|
2732 |
}
|
|
2733 |
}
|
|
2734 |
}
|
|
2735 |
|
|
2736 |
void CSvgElementImpl::CloneSvgStylePropertiesL( CSvgElementImpl* aNewChild, CSvgElementImpl* aParentElement)
|
|
2737 |
{
|
|
2738 |
|
|
2739 |
CSvgDocumentImpl* doc = (CSvgDocumentImpl*)OwnerDocument();
|
|
2740 |
|
|
2741 |
if (!doc)
|
|
2742 |
{
|
|
2743 |
return;
|
|
2744 |
}
|
|
2745 |
|
|
2746 |
if( iSvgStyleProperties )
|
|
2747 |
{
|
|
2748 |
TInt count = iSvgStyleProperties->Count();
|
|
2749 |
CSvgElementImpl* lTmpParent = (CSvgElementImpl*)ParentNode ();
|
|
2750 |
while(lTmpParent && (lTmpParent->iSvgStyleProperties == NULL))
|
|
2751 |
{
|
|
2752 |
lTmpParent = (CSvgElementImpl*)lTmpParent->ParentNode ();
|
|
2753 |
}
|
|
2754 |
|
|
2755 |
RPointerArray<CCssValue>*lSvgStyleProperties = NULL;
|
|
2756 |
|
|
2757 |
( ( CSvgElementImpl * ) aNewChild )->GetSvgStylePropertiesArray( lSvgStyleProperties );
|
|
2758 |
|
|
2759 |
CSvgElementImpl* lTmpCloneParent = aParentElement;
|
|
2760 |
while(lTmpCloneParent && (lTmpCloneParent->iSvgStyleProperties == NULL))
|
|
2761 |
{
|
|
2762 |
lTmpCloneParent = (CSvgElementImpl*)lTmpCloneParent->ParentNode ();
|
|
2763 |
}
|
|
2764 |
|
|
2765 |
for ( TInt i = 0; i < count; i++ )
|
|
2766 |
{
|
|
2767 |
if( lTmpParent && (lTmpParent->iSvgStyleProperties->operator[]( i ) == iSvgStyleProperties->operator[]( i )) )
|
|
2768 |
{
|
|
2769 |
CCssValue* lCssValue = NULL;
|
|
2770 |
if( lTmpCloneParent )
|
|
2771 |
{
|
|
2772 |
lCssValue = lTmpCloneParent->iSvgStyleProperties->operator[]( i );
|
|
2773 |
}
|
|
2774 |
lSvgStyleProperties->InsertL(lCssValue,i);
|
|
2775 |
}
|
|
2776 |
else
|
|
2777 |
{
|
|
2778 |
|
|
2779 |
CCssValue* lCssValue = (iSvgStyleProperties->operator[]( i ));
|
|
2780 |
|
|
2781 |
//CLONING VALUES THROUGH MEMORY MANAGER
|
|
2782 |
|
|
2783 |
CCssValue* lCssValueCloned = doc->iMemoryManager->CloneCssValueL(lCssValue);
|
|
2784 |
|
|
2785 |
lSvgStyleProperties->InsertL(lCssValueCloned,i);
|
|
2786 |
}
|
|
2787 |
}
|
|
2788 |
}
|
|
2789 |
}
|
|
2790 |
|
|
2791 |
void CSvgElementImpl::ResetReferenceAttrSet()
|
|
2792 |
{
|
|
2793 |
if( iAnimateAttrSet )
|
|
2794 |
{
|
|
2795 |
iAnimateAttrSet->Close();
|
|
2796 |
delete iAnimateAttrSet;
|
|
2797 |
iAnimateAttrSet = NULL ;
|
|
2798 |
}
|
|
2799 |
}
|
|
2800 |
|
|
2801 |
|
|
2802 |
// functions for encoding
|
|
2803 |
|
|
2804 |
void CSvgElementImpl::SetTransformList(TGfxAffineTransform& aTr)
|
|
2805 |
{
|
|
2806 |
if( iSvgTransformable )
|
|
2807 |
{
|
|
2808 |
iSvgTransformable->SetTransformList(aTr);
|
|
2809 |
}
|
|
2810 |
}
|
|
2811 |
|
|
2812 |
|
|
2813 |
void CSvgElementImpl::SetRequiredFeatures( CDesCArrayFlat*& aRequiredFeatures )
|
|
2814 |
{
|
|
2815 |
if( iSvgTests )
|
|
2816 |
{
|
|
2817 |
iSvgTests->SetRequiredFeatures (aRequiredFeatures);
|
|
2818 |
}
|
|
2819 |
}
|
|
2820 |
|
|
2821 |
void CSvgElementImpl::SetRequiredExtensions( CDesCArrayFlat*& aRequiredExtensions )
|
|
2822 |
{
|
|
2823 |
if( iSvgTests )
|
|
2824 |
{
|
|
2825 |
iSvgTests->SetRequiredExtensions (aRequiredExtensions);
|
|
2826 |
}
|
|
2827 |
}
|
|
2828 |
|
|
2829 |
void CSvgElementImpl::SetSystemLanguage( CDesCArrayFlat*& aSystemLanguage )
|
|
2830 |
{
|
|
2831 |
if( iSvgTests )
|
|
2832 |
{
|
|
2833 |
iSvgTests->SetSystemLanguage (aSystemLanguage);
|
|
2834 |
}
|
|
2835 |
}
|
|
2836 |
|
|
2837 |
TBool CSvgElementImpl::IsTransformable()
|
|
2838 |
{
|
|
2839 |
if( iSvgTransformable )
|
|
2840 |
return ETrue;
|
|
2841 |
else
|
|
2842 |
return EFalse;
|
|
2843 |
}
|
|
2844 |
TInt CSvgElementImpl::SetUriRefDesL( const TUint16 aNameId,
|
|
2845 |
const TDesC& aValue )
|
|
2846 |
{
|
|
2847 |
if( iSvgUriReferenceImpl )
|
|
2848 |
{
|
|
2849 |
return iSvgUriReferenceImpl->SetUriRefDesL(aNameId, aValue);
|
|
2850 |
}
|
|
2851 |
return (TInt) EFalse;
|
|
2852 |
}
|
|
2853 |
void CSvgElementImpl::Reset(MSvgEvent* /*aEvent*/)
|
|
2854 |
{
|
|
2855 |
|
|
2856 |
}
|
|
2857 |
|
|
2858 |
void CSvgElementImpl::ReInitializeAnimation()
|
|
2859 |
{
|
|
2860 |
|
|
2861 |
}
|
|
2862 |
|
|
2863 |
CGfxGeneralPath* CSvgElementImpl::GetPathAttribute(TInt /*aAttributeId*/)
|
|
2864 |
{
|
|
2865 |
return NULL;
|
|
2866 |
}
|
|
2867 |
void CSvgElementImpl::SetPathAttribute(TInt /*aSvgAttrId*/, CGfxGeneralPath* /*aPathHandle*/)
|
|
2868 |
{
|
|
2869 |
|
|
2870 |
}
|
|
2871 |
|
|
2872 |
//this element has an animation associated with it
|
|
2873 |
TBool CSvgElementImpl::HasAnimation()
|
|
2874 |
{
|
|
2875 |
if (iHasAnimationBase)
|
|
2876 |
{
|
|
2877 |
return ETrue;
|
|
2878 |
}
|
|
2879 |
|
|
2880 |
return EFalse;
|
|
2881 |
}
|
|
2882 |
|
|
2883 |
void CSvgElementImpl::SetIsAnimating( TBool aBool )
|
|
2884 |
{
|
|
2885 |
if ( aBool )
|
|
2886 |
{
|
|
2887 |
iBooleanFlags = iBooleanFlags | KAnimatingBit;
|
|
2888 |
}
|
|
2889 |
else
|
|
2890 |
{
|
|
2891 |
iBooleanFlags = iBooleanFlags & ~KAnimatingBit;
|
|
2892 |
}
|
|
2893 |
}
|
|
2894 |
|
|
2895 |
TBool CSvgElementImpl::IsAnimating()
|
|
2896 |
{
|
|
2897 |
return iBooleanFlags & KAnimatingBit;
|
|
2898 |
}
|
|
2899 |
|
|
2900 |
void CSvgElementImpl::SetTurnOff( TBool aBool )
|
|
2901 |
{
|
|
2902 |
if ( aBool )
|
|
2903 |
{
|
|
2904 |
iBooleanFlags = iBooleanFlags | KWasTurnedOffBit;
|
|
2905 |
}
|
|
2906 |
else
|
|
2907 |
{
|
|
2908 |
iBooleanFlags = iBooleanFlags & ~KWasTurnedOffBit;
|
|
2909 |
}
|
|
2910 |
}
|
|
2911 |
|
|
2912 |
TBool CSvgElementImpl::WasTurnedOff()
|
|
2913 |
{
|
|
2914 |
return iBooleanFlags & KWasTurnedOffBit;
|
|
2915 |
}
|
|
2916 |
|
|
2917 |
void CSvgElementImpl::SetOverwriteTransforms( TBool aBool )
|
|
2918 |
{
|
|
2919 |
if ( aBool )
|
|
2920 |
{
|
|
2921 |
iBooleanFlags = iBooleanFlags | KOverwriteTransformsBit;
|
|
2922 |
}
|
|
2923 |
else
|
|
2924 |
{
|
|
2925 |
iBooleanFlags = iBooleanFlags & ~KOverwriteTransformsBit;
|
|
2926 |
}
|
|
2927 |
}
|
|
2928 |
|
|
2929 |
TBool CSvgElementImpl::IsOverwriteTransforms()
|
|
2930 |
{
|
|
2931 |
return iBooleanFlags & KOverwriteTransformsBit;
|
|
2932 |
}
|
|
2933 |
|
|
2934 |
void CSvgElementImpl::SetAllAttributesAdded( TBool aBool )
|
|
2935 |
{
|
|
2936 |
if ( aBool )
|
|
2937 |
{
|
|
2938 |
iBooleanFlags = iBooleanFlags | KAllAttributesAddedBit;
|
|
2939 |
}
|
|
2940 |
else
|
|
2941 |
{
|
|
2942 |
iBooleanFlags = iBooleanFlags & ~KAllAttributesAddedBit;
|
|
2943 |
}
|
|
2944 |
}
|
|
2945 |
|
|
2946 |
TBool CSvgElementImpl::AreAllAttributesAdded()
|
|
2947 |
{
|
|
2948 |
return iBooleanFlags & KAllAttributesAddedBit;
|
|
2949 |
}
|
|
2950 |
|
|
2951 |
void CSvgElementImpl::SetMouseDown( TBool aBool )
|
|
2952 |
{
|
|
2953 |
if ( aBool )
|
|
2954 |
{
|
|
2955 |
iBooleanFlags = iBooleanFlags | KMouseDownBit;
|
|
2956 |
}
|
|
2957 |
else
|
|
2958 |
{
|
|
2959 |
iBooleanFlags = iBooleanFlags & ~KMouseDownBit;
|
|
2960 |
}
|
|
2961 |
}
|
|
2962 |
|
|
2963 |
TBool CSvgElementImpl::IsMouseDown()
|
|
2964 |
{
|
|
2965 |
return iBooleanFlags & KMouseDownBit;
|
|
2966 |
}
|
|
2967 |
|
|
2968 |
void CSvgElementImpl::SetMouseIn( TBool aBool )
|
|
2969 |
{
|
|
2970 |
if ( aBool )
|
|
2971 |
{
|
|
2972 |
iBooleanFlags = iBooleanFlags | KMouseInBit;
|
|
2973 |
}
|
|
2974 |
else
|
|
2975 |
{
|
|
2976 |
iBooleanFlags = iBooleanFlags & ~KMouseInBit;
|
|
2977 |
}
|
|
2978 |
}
|
|
2979 |
|
|
2980 |
TBool CSvgElementImpl::IsMouseIn()
|
|
2981 |
{
|
|
2982 |
return iBooleanFlags & KMouseInBit;
|
|
2983 |
}
|
|
2984 |
|
|
2985 |
void CSvgElementImpl::DeactivateAnimation()
|
|
2986 |
{
|
|
2987 |
}
|
|
2988 |
|
|
2989 |
TBool CSvgElementImpl::DoAnimProcL(MSvgEvent* /*aEvent*/)
|
|
2990 |
{
|
|
2991 |
return ETrue;
|
|
2992 |
}
|
|
2993 |
void CSvgElementImpl ::PointToParent(const TInt aAttrId)
|
|
2994 |
{
|
|
2995 |
//this method doesnt look too good to me.
|
|
2996 |
//especially since the OldPointer that is getting passed
|
|
2997 |
//to PropagateToChildren is NULL
|
|
2998 |
|
|
2999 |
if(aAttrId < KCSS_MAX_ATTR && iSvgStyleProperties)
|
|
3000 |
{
|
|
3001 |
CSvgElementImpl* lTmpParent = (CSvgElementImpl*)ParentNode ();
|
|
3002 |
if(lTmpParent)
|
|
3003 |
{
|
|
3004 |
if(iSvgStyleProperties->operator[]( aAttrId ) != lTmpParent->iSvgStyleProperties->operator[](aAttrId ))
|
|
3005 |
{
|
|
3006 |
|
|
3007 |
//store the old value.
|
|
3008 |
CCssValue *OldPointer = iSvgStyleProperties->operator[]( aAttrId );
|
|
3009 |
|
|
3010 |
//this deletion is no longer needed as the memory manager is in charge of this now
|
|
3011 |
|
|
3012 |
// set the pointer
|
|
3013 |
iSvgStyleProperties->operator[]( aAttrId ) = lTmpParent->iSvgStyleProperties->operator[](aAttrId );
|
|
3014 |
|
|
3015 |
// update the child pointers to the previous values.
|
|
3016 |
PropagateToChildren(OldPointer, lTmpParent->iSvgStyleProperties->operator[](aAttrId ), aAttrId );
|
|
3017 |
}
|
|
3018 |
}
|
|
3019 |
}
|
|
3020 |
}
|
|
3021 |
TBool CSvgElementImpl::IsInherited(const TInt aAttrId)
|
|
3022 |
{
|
|
3023 |
if(aAttrId < KCSS_MAX_ATTR && iSvgStyleProperties)
|
|
3024 |
{
|
|
3025 |
CSvgElementImpl* lTmpParent = (CSvgElementImpl*)ParentNode ();
|
|
3026 |
if(lTmpParent && lTmpParent->iSvgStyleProperties)
|
|
3027 |
{
|
|
3028 |
return (iSvgStyleProperties->operator[]( aAttrId ) == lTmpParent->iSvgStyleProperties->operator[](aAttrId ));
|
|
3029 |
}
|
|
3030 |
}
|
|
3031 |
return EFalse;
|
|
3032 |
}
|
|
3033 |
|
|
3034 |
//probably dont need this anymore
|
|
3035 |
void CSvgElementImpl::InitSvgStylePropertiesWithNullL()
|
|
3036 |
{
|
|
3037 |
for( int i=0; i < KCSS_MAX_ATTR; i++ )
|
|
3038 |
{
|
|
3039 |
User::LeaveIfError( iSvgStyleProperties->Append( NULL ) );
|
|
3040 |
}
|
|
3041 |
}
|
|
3042 |
|
|
3043 |
TBool CSvgElementImpl::IsVisible()
|
|
3044 |
{
|
|
3045 |
if ( !AreAllAttributesAdded() )
|
|
3046 |
{
|
|
3047 |
return EFalse;
|
|
3048 |
}
|
|
3049 |
|
|
3050 |
TInt32 visbilityValue = -1;
|
|
3051 |
TInt lReturnValue = KErrGeneral;
|
|
3052 |
TRAPD(err, lReturnValue = this->GetAttributeIntL( KCSS_ATTR_VISIBILITY, visbilityValue ));
|
|
3053 |
if (err)
|
|
3054 |
{
|
|
3055 |
#ifdef _DEBUG
|
|
3056 |
RDebug::Printf("CSvgElementImpl::IsVisible() GetAttributeIntL error");
|
|
3057 |
#endif
|
|
3058 |
}
|
|
3059 |
|
|
3060 |
return ( ( lReturnValue == KErrNone) && (visbilityValue == 0) );
|
|
3061 |
}
|
|
3062 |
|
|
3063 |
void CSvgElementImpl::PrintStyleProperties( )
|
|
3064 |
{
|
|
3065 |
//prints all of the style properties out that this element has ahold of
|
|
3066 |
|
|
3067 |
#ifdef _DEBUG
|
|
3068 |
if (!iSvgStyleProperties)
|
|
3069 |
{
|
|
3070 |
RDebug::Printf("CSvgElementImpl::PrintStyleProperties[%x]: NO STYLES FOUND", this);
|
|
3071 |
return;
|
|
3072 |
}
|
|
3073 |
|
|
3074 |
RDebug::Printf("----STYLES---");
|
|
3075 |
for (TInt i=0; i<iSvgStyleProperties->Count(); i++)
|
|
3076 |
{
|
|
3077 |
switch (i)
|
|
3078 |
{
|
|
3079 |
case 0:
|
|
3080 |
RDebug::Printf("fill=\"");
|
|
3081 |
break;
|
|
3082 |
case 22:
|
|
3083 |
RDebug::Printf("fill-opacity=\"");
|
|
3084 |
break;
|
|
3085 |
case 23:
|
|
3086 |
RDebug::Printf("stroke-opacity=\"");
|
|
3087 |
break;
|
|
3088 |
case 1:
|
|
3089 |
RDebug::Printf("stroke=\"");
|
|
3090 |
break;
|
|
3091 |
case 2:
|
|
3092 |
RDebug::Printf("stroke-width=\"");
|
|
3093 |
break;
|
|
3094 |
case 3:
|
|
3095 |
RDebug::Printf("visibility=\"");
|
|
3096 |
break;
|
|
3097 |
case 4:
|
|
3098 |
RDebug::Printf("font-family=\"");
|
|
3099 |
break;
|
|
3100 |
case 5:
|
|
3101 |
RDebug::Printf("font-size=\"");
|
|
3102 |
break;
|
|
3103 |
case 6:
|
|
3104 |
RDebug::Printf("font-style=\"");
|
|
3105 |
break;
|
|
3106 |
case 7:
|
|
3107 |
RDebug::Printf("font-weight=\"");
|
|
3108 |
break;
|
|
3109 |
case 8:
|
|
3110 |
RDebug::Printf("stroke-dasharray=\"");
|
|
3111 |
break;
|
|
3112 |
case 9:
|
|
3113 |
RDebug::Printf("display=\"");
|
|
3114 |
break;
|
|
3115 |
case 10:
|
|
3116 |
RDebug::Printf("fill-rule=\"");
|
|
3117 |
break;
|
|
3118 |
case 11:
|
|
3119 |
RDebug::Printf("stroke-linecap=\"");
|
|
3120 |
break;
|
|
3121 |
case 12:
|
|
3122 |
RDebug::Printf("stroke-linejoin=\"");
|
|
3123 |
break;
|
|
3124 |
case 13:
|
|
3125 |
RDebug::Printf("stroke-dashoffset=\"");
|
|
3126 |
break;
|
|
3127 |
case 14:
|
|
3128 |
RDebug::Printf("stroke-miterlimit=\"");
|
|
3129 |
break;
|
|
3130 |
case 15:
|
|
3131 |
RDebug::Printf("color=\"");
|
|
3132 |
break;
|
|
3133 |
case 16:
|
|
3134 |
RDebug::Printf("text-anchor=\"");
|
|
3135 |
break;
|
|
3136 |
case 17:
|
|
3137 |
RDebug::Printf("text-decoration=\"");
|
|
3138 |
break;
|
|
3139 |
case 18:
|
|
3140 |
RDebug::Printf("color-interpolation=\"");
|
|
3141 |
break;
|
|
3142 |
case 19:
|
|
3143 |
RDebug::Printf("color-rendering=\"");
|
|
3144 |
break;
|
|
3145 |
case 20:
|
|
3146 |
RDebug::Printf("letter-spacing=\"");
|
|
3147 |
break;
|
|
3148 |
case 21:
|
|
3149 |
RDebug::Printf("word-spacing=\"");
|
|
3150 |
break;
|
|
3151 |
case 24: //THIS SHOULD BE = KSS_MAX_ATTR
|
|
3152 |
RDebug::Printf("group-opacity=\"");
|
|
3153 |
break;
|
|
3154 |
default:
|
|
3155 |
RDebug::Printf("UNKNOWN STYLE FOUND!!");
|
|
3156 |
break;
|
|
3157 |
}
|
|
3158 |
|
|
3159 |
if ( iSvgStyleProperties->operator[]( i ) )
|
|
3160 |
{
|
|
3161 |
iSvgStyleProperties->operator[]( i )->Print();
|
|
3162 |
RDebug::Printf("\"");
|
|
3163 |
}
|
|
3164 |
else
|
|
3165 |
{
|
|
3166 |
//that style was empty
|
|
3167 |
RDebug::Printf("EMPTY!!\"", i);
|
|
3168 |
}
|
|
3169 |
}
|
|
3170 |
RDebug::Printf("---END OF STYLES---");
|
|
3171 |
|
|
3172 |
#endif
|
|
3173 |
|
|
3174 |
}
|
|
3175 |
|
|
3176 |
TBool CSvgElementImpl::GetDefaultAttributeL( const TInt aNameId, CCssValue*& aValue )
|
|
3177 |
{
|
|
3178 |
CSvgDocumentImpl* lDocument = (CSvgDocumentImpl*)OwnerDocument();
|
|
3179 |
|
|
3180 |
if (!lDocument)
|
|
3181 |
{
|
|
3182 |
return EFalse;
|
|
3183 |
}
|
|
3184 |
|
|
3185 |
CSvgElementImpl* lRootElement = (CSvgElementImpl*)(lDocument->RootElement());
|
|
3186 |
|
|
3187 |
if (lRootElement)
|
|
3188 |
{
|
|
3189 |
RPointerArray<CCssValue>*lSvgStyleProperties = NULL;
|
|
3190 |
|
|
3191 |
lRootElement->GetSvgStylePropertiesArray(lSvgStyleProperties);
|
|
3192 |
|
|
3193 |
if (lSvgStyleProperties && lSvgStyleProperties->operator[](aNameId) != NULL )
|
|
3194 |
{
|
|
3195 |
aValue = (CCssValue*)lSvgStyleProperties->operator[](aNameId);
|
|
3196 |
return ETrue;
|
|
3197 |
}
|
|
3198 |
}
|
|
3199 |
|
|
3200 |
switch( aNameId )
|
|
3201 |
{
|
|
3202 |
// Initilaise Svg Element with default values
|
|
3203 |
case KCSS_ATTR_FILL:
|
|
3204 |
{
|
|
3205 |
CPaintCssValueImpl* lPaintObject = lDocument->iMemoryManager->GetCssPaintObjectL(_L("black"),(CSvgElementImpl *)this);
|
|
3206 |
|
|
3207 |
iSvgStyleProperties->InsertL(lPaintObject, KCSS_ATTR_FILL );
|
|
3208 |
}
|
|
3209 |
case KCSS_ATTR_FILL_OPACITY:
|
|
3210 |
{
|
|
3211 |
CFloatCssValueImpl* lFloatObject5 = lDocument->iMemoryManager->GetCssFloatObjectL(_L("1"));
|
|
3212 |
|
|
3213 |
iSvgStyleProperties->InsertL(lFloatObject5,KCSS_ATTR_FILL_OPACITY);
|
|
3214 |
}
|
|
3215 |
break;
|
|
3216 |
|
|
3217 |
case KCSS_ATTR_STROKE_OPACITY:
|
|
3218 |
{
|
|
3219 |
CFloatCssValueImpl* lFloatObject6 = lDocument->iMemoryManager->GetCssFloatObjectL(_L("1"));
|
|
3220 |
|
|
3221 |
iSvgStyleProperties->InsertL(lFloatObject6,KCSS_ATTR_STROKE_OPACITY);
|
|
3222 |
}
|
|
3223 |
break;
|
|
3224 |
|
|
3225 |
case KCSS_ATTR_STROKE:
|
|
3226 |
{
|
|
3227 |
CClrCssValueImpl* lClrObject = lDocument->iMemoryManager->GetCssClrObjectL(_L("none"));
|
|
3228 |
|
|
3229 |
iSvgStyleProperties->InsertL(lClrObject, KCSS_ATTR_STROKE);
|
|
3230 |
}
|
|
3231 |
break;
|
|
3232 |
|
|
3233 |
case KCSS_ATTR_STROKEWIDTH:
|
|
3234 |
{
|
|
3235 |
CFloatCssValueImpl* lFloatObject = lDocument->iMemoryManager->GetCssFloatObjectL(_L("1"));
|
|
3236 |
|
|
3237 |
iSvgStyleProperties->InsertL(lFloatObject, KCSS_ATTR_STROKEWIDTH);
|
|
3238 |
}
|
|
3239 |
break;
|
|
3240 |
|
|
3241 |
case KCSS_ATTR_VISIBILITY:
|
|
3242 |
{
|
|
3243 |
CIntCssValueImpl* lIntObject = lDocument->iMemoryManager->GetCssIntObjectL(_L("0"));
|
|
3244 |
|
|
3245 |
iSvgStyleProperties->InsertL(lIntObject,KCSS_ATTR_VISIBILITY);
|
|
3246 |
}
|
|
3247 |
break;
|
|
3248 |
|
|
3249 |
case KCSS_ATTR_FONTFAMILY:
|
|
3250 |
{
|
|
3251 |
iSvgStyleProperties->InsertL(NULL,KCSS_ATTR_FONTFAMILY);
|
|
3252 |
}
|
|
3253 |
break;
|
|
3254 |
|
|
3255 |
case KCSS_ATTR_FONTSIZE:
|
|
3256 |
{
|
|
3257 |
CFloatCssValueImpl* lFloatObject2 = lDocument->iMemoryManager->GetCssFloatObjectL(_L("10"));
|
|
3258 |
|
|
3259 |
iSvgStyleProperties->InsertL(lFloatObject2 ,KCSS_ATTR_FONTSIZE);
|
|
3260 |
}
|
|
3261 |
break;
|
|
3262 |
|
|
3263 |
case KCSS_ATTR_FONTSTYLE:
|
|
3264 |
{
|
|
3265 |
CIntCssValueImpl* lIntObject2 = lDocument->iMemoryManager->GetCssIntObjectL(_L("0"));
|
|
3266 |
|
|
3267 |
iSvgStyleProperties->InsertL(lIntObject2,KCSS_ATTR_FONTSTYLE);
|
|
3268 |
}
|
|
3269 |
break;
|
|
3270 |
|
|
3271 |
case KCSS_ATTR_FONTWEIGHT:
|
|
3272 |
{
|
|
3273 |
CIntCssValueImpl* lIntObject3 = lDocument->iMemoryManager->GetCssIntObjectL(_L("0"));
|
|
3274 |
|
|
3275 |
iSvgStyleProperties->InsertL(lIntObject3,KCSS_ATTR_FONTWEIGHT);
|
|
3276 |
}
|
|
3277 |
break;
|
|
3278 |
|
|
3279 |
case KCSS_ATTR_STROKE_DASHARRAY:
|
|
3280 |
{
|
|
3281 |
iSvgStyleProperties->InsertL(NULL,KCSS_ATTR_STROKE_DASHARRAY);
|
|
3282 |
}
|
|
3283 |
break;
|
|
3284 |
|
|
3285 |
case KCSS_ATTR_DISPLAY:
|
|
3286 |
{
|
|
3287 |
//set default to inline
|
|
3288 |
CIntCssValueImpl* lIntObject4 = lDocument->iMemoryManager->GetCssIntObjectL(_L("0"));
|
|
3289 |
|
|
3290 |
iSvgStyleProperties->InsertL(lIntObject4,KCSS_ATTR_DISPLAY);
|
|
3291 |
}
|
|
3292 |
break;
|
|
3293 |
|
|
3294 |
case KCSS_ATTR_FILLRULE:
|
|
3295 |
{
|
|
3296 |
CStrCssValueImpl* lStrObject1 = lDocument->iMemoryManager->GetCssStrObjectL(_L("nonzero"));
|
|
3297 |
|
|
3298 |
iSvgStyleProperties->InsertL(lStrObject1,KCSS_ATTR_FILLRULE);
|
|
3299 |
}
|
|
3300 |
break;
|
|
3301 |
|
|
3302 |
case KCSS_ATTR_STROKE_LINECAP:
|
|
3303 |
{
|
|
3304 |
CStrCssValueImpl* lStrObject2 = lDocument->iMemoryManager->GetCssStrObjectL(_L("butt"));
|
|
3305 |
|
|
3306 |
iSvgStyleProperties->InsertL(lStrObject2,KCSS_ATTR_STROKE_LINECAP);
|
|
3307 |
}
|
|
3308 |
break;
|
|
3309 |
|
|
3310 |
case KCSS_ATTR_STROKE_LINEJOIN:
|
|
3311 |
{
|
|
3312 |
CStrCssValueImpl* lStrObject3 = lDocument->iMemoryManager->GetCssStrObjectL(_L("miter"));
|
|
3313 |
|
|
3314 |
iSvgStyleProperties->InsertL(lStrObject3,KCSS_ATTR_STROKE_LINEJOIN);
|
|
3315 |
}
|
|
3316 |
break;
|
|
3317 |
|
|
3318 |
case KCSS_ATTR_STROKE_DASHOFFSET:
|
|
3319 |
{
|
|
3320 |
CFloatCssValueImpl* lFloatObject3 = lDocument->iMemoryManager->GetCssFloatObjectL(_L("0"));
|
|
3321 |
|
|
3322 |
iSvgStyleProperties->InsertL(lFloatObject3,KCSS_ATTR_STROKE_DASHOFFSET);
|
|
3323 |
}
|
|
3324 |
break;
|
|
3325 |
|
|
3326 |
case KCSS_ATTR_STROKE_MITERLIMIT:
|
|
3327 |
{
|
|
3328 |
CFloatCssValueImpl* lFloatObject4 = lDocument->iMemoryManager->GetCssFloatObjectL(_L("4"));
|
|
3329 |
|
|
3330 |
iSvgStyleProperties->InsertL(lFloatObject4,KCSS_ATTR_STROKE_MITERLIMIT);
|
|
3331 |
}
|
|
3332 |
break;
|
|
3333 |
|
|
3334 |
case KCSS_ATTR_COLOR:
|
|
3335 |
{
|
|
3336 |
CClrCssValueImpl* lClrObject4 = lDocument->iMemoryManager->GetCssClrObjectL(_L("black"));
|
|
3337 |
|
|
3338 |
iSvgStyleProperties->InsertL(lClrObject4,KCSS_ATTR_COLOR);
|
|
3339 |
}
|
|
3340 |
break;
|
|
3341 |
|
|
3342 |
case KCSS_ATTR_TEXTANCHOR:
|
|
3343 |
{
|
|
3344 |
CIntCssValueImpl* lIntObject5 = lDocument->iMemoryManager->GetCssIntObjectL(_L("0"));
|
|
3345 |
|
|
3346 |
iSvgStyleProperties->InsertL(lIntObject5,KCSS_ATTR_TEXTANCHOR);
|
|
3347 |
}
|
|
3348 |
break;
|
|
3349 |
|
|
3350 |
case KCSS_ATTR_TEXTDECORATION:
|
|
3351 |
{
|
|
3352 |
CIntCssValueImpl* lIntObject6 = lDocument->iMemoryManager->GetCssIntObjectL(_L("-1"));
|
|
3353 |
|
|
3354 |
iSvgStyleProperties->InsertL(lIntObject6,KCSS_ATTR_TEXTDECORATION);
|
|
3355 |
}
|
|
3356 |
break;
|
|
3357 |
|
|
3358 |
case KCSS_ATTR_COLORINTERPOLATION:
|
|
3359 |
{
|
|
3360 |
iSvgStyleProperties->InsertL(NULL,KCSS_ATTR_COLORINTERPOLATION);
|
|
3361 |
}
|
|
3362 |
break;
|
|
3363 |
|
|
3364 |
case KCSS_ATTR_COLORRENDERING:
|
|
3365 |
{
|
|
3366 |
iSvgStyleProperties->InsertL(NULL,KCSS_ATTR_COLORRENDERING);
|
|
3367 |
}
|
|
3368 |
break;
|
|
3369 |
|
|
3370 |
case KCSS_ATTR_LETTERSPACING:
|
|
3371 |
{
|
|
3372 |
iSvgStyleProperties->InsertL(NULL,KCSS_ATTR_LETTERSPACING);
|
|
3373 |
}
|
|
3374 |
break;
|
|
3375 |
|
|
3376 |
case KCSS_ATTR_WORDSPACING:
|
|
3377 |
{
|
|
3378 |
iSvgStyleProperties->InsertL(NULL,KCSS_ATTR_WORDSPACING);
|
|
3379 |
}
|
|
3380 |
break;
|
|
3381 |
|
|
3382 |
case KCSS_ATTR_GROUP_OPACITY:
|
|
3383 |
{
|
|
3384 |
CFloatCssValueImpl* lFloatObject7 = lDocument->iMemoryManager->GetCssFloatObjectL(_L("1"));
|
|
3385 |
|
|
3386 |
iSvgStyleProperties->InsertL(lFloatObject7,KCSS_ATTR_GROUP_OPACITY);
|
|
3387 |
}
|
|
3388 |
break;
|
|
3389 |
|
|
3390 |
default:
|
|
3391 |
{
|
|
3392 |
//don't know the element
|
|
3393 |
return EFalse;
|
|
3394 |
}
|
|
3395 |
}
|
|
3396 |
|
|
3397 |
aValue = (CCssValue*)iSvgStyleProperties->operator[](aNameId);
|
|
3398 |
return ETrue;
|
|
3399 |
}
|
|
3400 |
|
|
3401 |
TFloatFixPt CSvgElementImpl::GetCurrentScale( )
|
|
3402 |
{
|
|
3403 |
const TGfxAffineTransform& ctm = GetCTM();
|
|
3404 |
//GET THE SCALE FACTOR FROM THE CURRENT ELEMENT
|
|
3405 |
TGfxPoint2D ep( 1, 0 ), org( 2, 0 );
|
|
3406 |
ctm.Transform( &ep, & ep, 1 );
|
|
3407 |
ctm.Transform( &org, & org, 1 );
|
|
3408 |
ep.iX -= org.iX;
|
|
3409 |
ep.iY -= org.iY;
|
|
3410 |
|
|
3411 |
TFloatFixPt scale = TFloatFixPt::Sqrt( ep.iX * ep.iX + ep.iY * ep.iY );
|
|
3412 |
// adjust for rounding error when rotated (and not scaled)
|
|
3413 |
if ( scale < TFloatFixPt(1.0f) && scale > TFloatFixPt(0.998f) )
|
|
3414 |
{
|
|
3415 |
scale = TFloatFixPt(1.0f);
|
|
3416 |
}
|
|
3417 |
|
|
3418 |
return scale;
|
|
3419 |
}
|
|
3420 |
|
|
3421 |
|
|
3422 |
//ALL animated element types must be listed here
|
|
3423 |
TBool CSvgElementImpl::IsAnimatedElement( )
|
|
3424 |
{
|
|
3425 |
return ( iElemID == KSvgAnimateElement ||
|
|
3426 |
iElemID == KSvgAnimateColorElement ||
|
|
3427 |
iElemID == KSvgAnimateMotionElement ||
|
|
3428 |
iElemID == KSvgAnimateTransformElement ||
|
|
3429 |
iElemID == KSvgSetElement ||
|
|
3430 |
//iElemID == KSvgDiscardElement || //discard has a begin but doesn't inherit from animationbase?
|
|
3431 |
iElemID == KSvgAudioElement ||
|
|
3432 |
iElemID == KSvgMediaAnimationElement );
|
|
3433 |
}
|
|
3434 |
|
|
3435 |
TBool CSvgElementImpl::CanGenerateInternalEvent(TUint16 aSubEventmask, TSvgEvent aEvent)
|
|
3436 |
{
|
|
3437 |
TUint16 tmp=aSubEventmask;
|
|
3438 |
switch(aEvent)
|
|
3439 |
{
|
|
3440 |
case ESvgEventActivate:
|
|
3441 |
tmp= tmp & ESvgInteractiveEventActivate;
|
|
3442 |
break;
|
|
3443 |
case ESvgEventClick:
|
|
3444 |
tmp = tmp & ESvgInteractiveEventClick;
|
|
3445 |
break;
|
|
3446 |
case ESvgEventMouseover:
|
|
3447 |
tmp = tmp & ESvgInteractiveEventMouseover;
|
|
3448 |
break;
|
|
3449 |
case ESvgEventMousemove:
|
|
3450 |
tmp = tmp & ESvgInteractiveEventMousemove;
|
|
3451 |
break;
|
|
3452 |
case ESvgEventFocusin:
|
|
3453 |
tmp = tmp & ESvgInteractiveEventFocusin;
|
|
3454 |
break;
|
|
3455 |
case ESvgEventMouseout:
|
|
3456 |
tmp = tmp & ESvgInteractiveEventMouseout;
|
|
3457 |
break;
|
|
3458 |
case ESvgEventFocusout:
|
|
3459 |
tmp = tmp & ESvgInteractiveEventFocusout;
|
|
3460 |
break;
|
|
3461 |
default:
|
|
3462 |
tmp=0;
|
|
3463 |
}
|
|
3464 |
if(tmp)
|
|
3465 |
{
|
|
3466 |
return ETrue;
|
|
3467 |
}
|
|
3468 |
else
|
|
3469 |
{
|
|
3470 |
return EFalse;
|
|
3471 |
}
|
|
3472 |
}
|
|
3473 |
TBool CSvgElementImpl::IsSVGEnginePaused()
|
|
3474 |
{
|
|
3475 |
CSvgEngineImpl* lEngine = ( ( CSvgDocumentImpl* ) OwnerDocument() )->Engine();
|
|
3476 |
return ( lEngine->IsSVGEnginePaused() );
|
|
3477 |
|
|
3478 |
}
|