|
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 #include "SVGSetElementImpl.h" |
|
23 #include "SVGDocumentImpl.h" |
|
24 #include "SVGSchemaData.h" |
|
25 |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 // --------------------------------------------------------------------------- |
|
30 CSvgSetElementImpl* CSvgSetElementImpl::NewL( const TUint8 aElemID, |
|
31 CSvgDocumentImpl* aDoc ) |
|
32 { |
|
33 CSvgSetElementImpl* self = new ( ELeave ) CSvgSetElementImpl( aDoc ); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL( aElemID ); |
|
36 CleanupStack::Pop(); |
|
37 |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 // --------------------------------------------------------------------------- |
|
44 CSvgSetElementImpl* CSvgSetElementImpl::NewLC( const TUint8 aElemID, |
|
45 CSvgDocumentImpl* aDoc ) |
|
46 { |
|
47 CSvgSetElementImpl* self = new ( ELeave ) CSvgSetElementImpl( aDoc ); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL( aElemID ); |
|
50 |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 // --------------------------------------------------------------------------- |
|
58 void CSvgSetElementImpl::ConstructL( const TUint8 aElemID) |
|
59 { |
|
60 CSvgAnimationBase::ConstructL( aElemID ); |
|
61 iReqAttrFlag=KSVG_ANIMATE_ELEMFLAG; |
|
62 iIsInheritedAttribute = EFalse; |
|
63 } |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 // --------------------------------------------------------------------------- |
|
72 CSvgSetElementImpl::~CSvgSetElementImpl() |
|
73 { |
|
74 } |
|
75 |
|
76 // ******************************************************* |
|
77 // Private |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 // --------------------------------------------------------------------------- |
|
82 CSvgSetElementImpl::CSvgSetElementImpl( CSvgDocumentImpl* aDoc ) : CSvgAnimationBase( aDoc ) |
|
83 |
|
84 { |
|
85 } |
|
86 |
|
87 // ******************************************************* |
|
88 // From MSvgEventReceiver |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 // --------------------------------------------------------------------------- |
|
92 void CSvgSetElementImpl::ResetReferenceElementL() |
|
93 { |
|
94 if(iTargetElement != NULL ) |
|
95 { |
|
96 if( ((iTargetElement->iAnimateAttrSet == NULL) || (iTargetElement->iAnimateAttrSet->Find(iAttrId) == KErrNotFound) ) ) |
|
97 { |
|
98 if (iInitDone && iAnimStatus != KAnimNotActive) |
|
99 { |
|
100 iCheckFirstAnim= ETrue; |
|
101 SetToOriginalL(); |
|
102 if( !(iTargetElement->iAnimateAttrSet) ) |
|
103 { |
|
104 iTargetElement->iAnimateAttrSet = new (ELeave) RArray<TUint32>(1); |
|
105 } |
|
106 iTargetElement->iAnimateAttrSet->Append((TUint32)(iAttrId)); |
|
107 } |
|
108 } |
|
109 } |
|
110 } |
|
111 |
|
112 // ******************************************************* |
|
113 // From MSvgEventReceiver |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 // --------------------------------------------------------------------------- |
|
117 TBool CSvgSetElementImpl::ReceiveEventL( MSvgEvent* aEvent ) |
|
118 { |
|
119 return CSvgAnimationBase::ReceiveEventProcL( aEvent, this ); |
|
120 } |
|
121 |
|
122 // From CSvgAnimationBase |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 // --------------------------------------------------------------------------- |
|
126 TBool CSvgSetElementImpl::AnimProcL( MSvgTimerEvent* /* aEvent */) |
|
127 |
|
128 { |
|
129 |
|
130 if((iAnimStatus != KAnimActive) || iDoFreeze) |
|
131 { |
|
132 if(iFill== KAnimFillFreeze && !iDoFreeze && iAnimStatus == KAnimFinished) |
|
133 { |
|
134 } |
|
135 else |
|
136 { |
|
137 CSvgAnimationBase::CheckForEndTimesAndFreezeL(this ); |
|
138 return EFalse; |
|
139 } |
|
140 } |
|
141 // Set value |
|
142 switch ( iDataType ) |
|
143 { |
|
144 case KSvgTypeOpacity: |
|
145 case KSvgTypeLength: |
|
146 iEndFloat = iToFloat; |
|
147 iTargetElement->SetAttributeFloatL( iAttrId, iToFloat ); |
|
148 break; |
|
149 case KSvgTypeList: |
|
150 case KSvgTypePath: |
|
151 case KSvgTypeTransform: |
|
152 break; |
|
153 case KSvgTypeColor: |
|
154 iEndInt = iToInt; |
|
155 iTargetElement->SetAttributeIntL( iAttrId, iToInt ); |
|
156 break; |
|
157 case KSvgTypeTextAnchor: |
|
158 case KSvgTypeInteger: |
|
159 iEndInt = iToInt; |
|
160 iTargetElement->SetAttributeIntL( iAttrId, iToInt ); |
|
161 case KSvgTypeVisibility: |
|
162 iEndInt = iToInt; |
|
163 iTargetElement->SetAttributeIntL( iAttrId, iToInt ); |
|
164 case KSvgTypeDisplay: |
|
165 iEndInt = iToInt; |
|
166 iTargetElement->SetAttributeIntL( iAttrId, iToInt ); |
|
167 break; |
|
168 |
|
169 //viewBox |
|
170 case KSvgTypeViewBox: |
|
171 { |
|
172 if(iTargetElement->ElemID() == KSvgSvgElement) |
|
173 { |
|
174 iEndViewBox= iToViewBox; |
|
175 ((CSvgSvgElementImpl*)iTargetElement)->SetViewBoxL( iToViewBox ); |
|
176 } |
|
177 } |
|
178 break; |
|
179 |
|
180 default: |
|
181 break; |
|
182 } |
|
183 CSvgAnimationBase::CheckForEndTimesAndFreezeL(this ); |
|
184 return ETrue; //. |
|
185 } |
|
186 |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 // --------------------------------------------------------------------------- |
|
191 void CSvgSetElementImpl::ResetAnimationL() |
|
192 { |
|
193 } |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 // --------------------------------------------------------------------------- |
|
197 TInt CSvgSetElementImpl::SetAttributeIntL( const TInt aNameId, const TInt32 aValue) |
|
198 { |
|
199 return CSvgAnimationBase::SetAttributeIntL(aNameId,aValue); |
|
200 } |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 // --------------------------------------------------------------------------- |
|
204 TInt CSvgSetElementImpl::GetAttributeIntL( const TInt aNameId, TInt32& aValue ) |
|
205 { |
|
206 return CSvgAnimationBase::GetAttributeIntL(aNameId,aValue); |
|
207 } |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 // --------------------------------------------------------------------------- |
|
211 TInt CSvgSetElementImpl::SetAttributeFloatL(const TInt aNameId, TFloatFixPt aValue ) |
|
212 { |
|
213 return CSvgAnimationBase::SetAttributeFloatL(aNameId,aValue); |
|
214 } |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 // --------------------------------------------------------------------------- |
|
218 TInt CSvgSetElementImpl::GetAttributeFloat(const TInt aNameId, TFloatFixPt& aValue ) |
|
219 { |
|
220 return CSvgAnimationBase::GetAttributeFloat(aNameId,aValue); |
|
221 } |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 // --------------------------------------------------------------------------- |
|
225 void CSvgSetElementImpl::ReInitializeAnimation() |
|
226 { |
|
227 |
|
228 /* if( iCurrentRepeatCount > 1 && iAccumulate == KAccumSum ) |
|
229 {*/ |
|
230 |
|
231 if ( iAttrId == 0xffff ) |
|
232 return; |
|
233 |
|
234 CSvgAnimationBase::ReInitializeAnimation(); |
|
235 |
|
236 if(iCheckFirstAnim) |
|
237 { |
|
238 if(iIsInheritedAttribute) |
|
239 { |
|
240 iTargetElement->PointToParent(iAttrId); |
|
241 } |
|
242 else |
|
243 { |
|
244 TRAPD(error, SetToOriginalL()); |
|
245 if (error != KErrNone) |
|
246 { |
|
247 //non error condition needs to be handled |
|
248 } |
|
249 } |
|
250 |
|
251 } |
|
252 } |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 // --------------------------------------------------------------------------- |
|
256 CGfxGeneralPath* CSvgSetElementImpl::GetPathAttribute(TInt aAttributeId) |
|
257 { |
|
258 return CSvgAnimationBase::GetPathAttribute(aAttributeId); |
|
259 } |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 // --------------------------------------------------------------------------- |
|
263 void CSvgSetElementImpl::SetPathAttribute(TInt aAttributeId, CGfxGeneralPath* aPathHandle) |
|
264 { |
|
265 CSvgAnimationBase::SetPathAttribute( aAttributeId, aPathHandle); |
|
266 } |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 void CSvgSetElementImpl::Reset(MSvgEvent* aEvent) |
|
272 { |
|
273 iIsUserSeek = ETrue; |
|
274 // first call the animation base function. |
|
275 TSvgTimerEvent* timerEvent = ( TSvgTimerEvent* ) aEvent; |
|
276 |
|
277 if((TInt32)timerEvent->Time() < iAbsoluteBeginTime) |
|
278 { |
|
279 // let it come to initial position. |
|
280 ((CSvgDocumentImpl*)iOwnerDocument)->iInitialDrawFlag = ETrue; |
|
281 ReInitializeAnimation(); |
|
282 return; |
|
283 } |
|
284 |
|
285 TRAPD(error,CSvgAnimationBase::ResetL( aEvent, this)); |
|
286 |
|
287 if (error != KErrNone) |
|
288 { |
|
289 // Error Processing |
|
290 } |
|
291 |
|
292 } |
|
293 void CSvgSetElementImpl::DeactivateAnimation() |
|
294 { |
|
295 CSvgAnimationBase::DeactivateAnimation(this); |
|
296 } |
|
297 TBool CSvgSetElementImpl::DoAnimProcL(MSvgEvent* aEvent) |
|
298 { |
|
299 return this->AnimProcL((MSvgTimerEvent*)aEvent); |
|
300 } |
|
301 void CSvgSetElementImpl::InitAnimationL() |
|
302 { |
|
303 if(!iTargetElement) |
|
304 { |
|
305 // if target element is not found then remove it. |
|
306 ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this); |
|
307 ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1); |
|
308 return; |
|
309 } |
|
310 |
|
311 if (!iHaveValues) |
|
312 { |
|
313 if (!iHaveTo && !iHaveBy) |
|
314 { |
|
315 ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this ); |
|
316 ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1); |
|
317 } |
|
318 } |
|
319 |
|
320 iIsInheritedAttribute = iTargetElement->IsInherited(iAttrId); |
|
321 |
|
322 // this is to make sure that this is taken only once. |
|
323 |
|
324 CSvgAnimationBase::InitAnimationL(); |
|
325 SetFillValueL(); |
|
326 } |
|
327 |
|
328 void CSvgSetElementImpl::SetToOriginalL() |
|
329 { |
|
330 // this is to make sure the inherited style attributes are made point back to the parent. |
|
331 if(iIsInheritedAttribute && iAnimStatus == KAnimFinished) |
|
332 { |
|
333 // only if the animation has finished |
|
334 iTargetElement->PointToParent(iAttrId); |
|
335 } |
|
336 else |
|
337 { |
|
338 // set this to original values. |
|
339 CSvgAnimationBase::SetToOriginalL(); |
|
340 } |
|
341 } |
|
342 |
|
343 void CSvgSetElementImpl::Print( TBool aIsEncodeOn ) |
|
344 { |
|
345 if (!aIsEncodeOn) |
|
346 { |
|
347 #ifdef _DEBUG |
|
348 RDebug::Printf("<set to=\"hmm\"\\>",this); |
|
349 #endif |
|
350 } |
|
351 } |