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 |
#include "SVGTestsImpl.h"
|
|
20 |
|
|
21 |
|
|
22 |
// ---------------------------------------------------------------------------
|
|
23 |
// Two phase construction:
|
|
24 |
// - Implements the SVGTests DOM interface.
|
|
25 |
// - Partially implemented, only those required
|
|
26 |
// for passing SVG Test Suite.
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
CSvgTestsImpl* CSvgTestsImpl::NewL()
|
|
29 |
{
|
|
30 |
CSvgTestsImpl* self = new ( ELeave ) CSvgTestsImpl();
|
|
31 |
CleanupStack::PushL( self );
|
|
32 |
self->ConstructL();
|
|
33 |
CleanupStack::Pop();
|
|
34 |
|
|
35 |
return self;
|
|
36 |
}
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
CSvgTestsImpl* CSvgTestsImpl::NewLC()
|
|
42 |
{
|
|
43 |
CSvgTestsImpl* self = new ( ELeave ) CSvgTestsImpl();
|
|
44 |
CleanupStack::PushL( self );
|
|
45 |
self->ConstructL();
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
CSvgTestsImpl::~CSvgTestsImpl()
|
|
53 |
{
|
|
54 |
if ( iRequiredFeatures )
|
|
55 |
{
|
|
56 |
delete iRequiredFeatures;
|
|
57 |
iRequiredFeatures = NULL;
|
|
58 |
}
|
|
59 |
if ( iRequiredExtensions )
|
|
60 |
{
|
|
61 |
delete iRequiredExtensions;
|
|
62 |
iRequiredExtensions = NULL;
|
|
63 |
}
|
|
64 |
if ( iSystemLanguage )
|
|
65 |
{
|
|
66 |
delete iSystemLanguage;
|
|
67 |
iSystemLanguage = NULL;
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
void CSvgTestsImpl::ConstructL()
|
|
76 |
{
|
|
77 |
iRequiredFeatures = new ( ELeave ) CDesCArrayFlat( 1 );
|
|
78 |
iRequiredFeatures->Reset();
|
|
79 |
iRequiredExtensions = new ( ELeave ) CDesCArrayFlat( 1 );
|
|
80 |
iRequiredExtensions->Reset();
|
|
81 |
iSystemLanguage = new ( ELeave ) CDesCArrayFlat( 1 );
|
|
82 |
iSystemLanguage->Reset();
|
|
83 |
|
|
84 |
iSystemLanguageEmpty = EFalse;
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
// From MSvgTests
|
|
89 |
|
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
void CSvgTestsImpl::GetRequiredFeatures( const CDesCArrayFlat*& aRequiredFeatures )
|
|
94 |
{
|
|
95 |
aRequiredFeatures = iRequiredFeatures;
|
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
// function for decoding
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
void CSvgTestsImpl::SetRequiredFeatures( CDesCArrayFlat*& aRequiredFeatures )
|
|
102 |
{
|
|
103 |
if(iRequiredFeatures)
|
|
104 |
{
|
|
105 |
iRequiredFeatures->Reset();
|
|
106 |
delete iRequiredFeatures;
|
|
107 |
iRequiredFeatures= NULL;
|
|
108 |
}
|
|
109 |
iRequiredFeatures= aRequiredFeatures;
|
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
void CSvgTestsImpl::GetRequiredExtensions( const CDesCArrayFlat*& aRequiredExtensions )
|
|
116 |
{
|
|
117 |
aRequiredExtensions = iRequiredExtensions;
|
|
118 |
}
|
|
119 |
|
|
120 |
// ---------------------------------------------------------------------------
|
|
121 |
// function for decoding
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
void CSvgTestsImpl::SetRequiredExtensions( CDesCArrayFlat*& aRequiredExtensions )
|
|
124 |
{
|
|
125 |
if(iRequiredExtensions)
|
|
126 |
{
|
|
127 |
iRequiredExtensions->Reset();
|
|
128 |
delete iRequiredExtensions;
|
|
129 |
iRequiredExtensions= NULL;
|
|
130 |
}
|
|
131 |
iRequiredExtensions= aRequiredExtensions;
|
|
132 |
}
|
|
133 |
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
// returns false if there was an empty string system language true otherwise
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
TBool CSvgTestsImpl::GetSystemLanguage( const CDesCArrayFlat*& aSystemLanguage )
|
|
138 |
{
|
|
139 |
aSystemLanguage = iSystemLanguage;
|
|
140 |
|
|
141 |
if (iSystemLanguageEmpty)
|
|
142 |
{
|
|
143 |
return EFalse;
|
|
144 |
}
|
|
145 |
|
|
146 |
return ETrue;
|
|
147 |
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// function for decoding
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
void CSvgTestsImpl::SetSystemLanguage( CDesCArrayFlat*& aSystemLanguage )
|
|
154 |
{
|
|
155 |
if(iSystemLanguage)
|
|
156 |
{
|
|
157 |
iSystemLanguage->Reset();
|
|
158 |
delete iSystemLanguage;
|
|
159 |
iSystemLanguage= NULL;
|
|
160 |
}
|
|
161 |
iSystemLanguage= aSystemLanguage;
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
TBool CSvgTestsImpl::HasExtension( const TDesC& /* aExtension */ )
|
|
168 |
{
|
|
169 |
return EFalse;
|
|
170 |
}
|
|
171 |
|
|
172 |
// For use in requiredFeatures
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
TBool CSvgTestsImpl::HasFeature( const TDesC& aFeature )
|
|
177 |
{
|
|
178 |
// SVG Tiny Feature List
|
|
179 |
_LIT( KTiny, "http://www.w3.org/TR/SVGMobile/Tiny/feature#" );
|
|
180 |
_LIT( KBase, "base" );
|
|
181 |
_LIT( KInteractivity, "interactivity" );
|
|
182 |
_LIT( KAll, "all" );
|
|
183 |
|
|
184 |
// SVG 1.1 Feature List
|
|
185 |
_LIT( KSVG11, "http://www.w3.org/TR/SVG11/feature#" );
|
|
186 |
_LIT( KCoreAttr, "CoreAttribute" );
|
|
187 |
_LIT( KBasicStr, "BasicStructure" );
|
|
188 |
_LIT( KStyle, "Style" );
|
|
189 |
_LIT( KPaintAttr, "PaintAttribute" );
|
|
190 |
_LIT( KGraphicsAttr, "BasicGraphicsAttribute" );
|
|
191 |
_LIT( KHyperlink, "Hyperlinking" );
|
|
192 |
_LIT( KXlinkAttr, "XlinkAttribute" );
|
|
193 |
_LIT( KCond, "ConditionalProcessing" );
|
|
194 |
_LIT( KShape, "Shape" );
|
|
195 |
_LIT( KImage, "Image" );
|
|
196 |
_LIT( KBasicTest, "BasicText" );
|
|
197 |
_LIT( KBasicFont, "BasicFont" );
|
|
198 |
_LIT( KDocAttr,"DocumentEventsAttribute" );
|
|
199 |
_LIT( KGraphEvt,"GraphicalEventsAttribute" );
|
|
200 |
_LIT( KAnimEvt,"AnimationEventsAttribute" );
|
|
201 |
_LIT( KScript, "Scripting" );
|
|
202 |
_LIT( KView, "View" );
|
|
203 |
_LIT( KAnim, "SVG-animation" );
|
|
204 |
_LIT( KExt, "Extensibility" );
|
|
205 |
|
|
206 |
_LIT( KSVG12, "http://www.w3.org/TR/SVG12/feature#" );
|
|
207 |
_LIT( KAudio, "Audio");
|
|
208 |
|
|
209 |
// SVG 1.2 Feature List
|
|
210 |
// SVG Feature List
|
|
211 |
_LIT( KStatic, "org.w3c.svg.static" );
|
|
212 |
_LIT( KDynamic, "org.w3c.svg.dynamic" );
|
|
213 |
|
|
214 |
TPtrC tinybase( KTiny );
|
|
215 |
if( (aFeature.Length()-tinybase.Length()) > 1 )
|
|
216 |
{
|
|
217 |
TPtrC rightTiny= aFeature.Right(aFeature.Length()-tinybase.Length() );
|
|
218 |
if ( rightTiny.Match(KBase) != KErrNotFound)
|
|
219 |
return ETrue;
|
|
220 |
if ( rightTiny.Match(KInteractivity) != KErrNotFound)
|
|
221 |
return ETrue;
|
|
222 |
if ( rightTiny.Match(KAll) != KErrNotFound )
|
|
223 |
return ETrue;
|
|
224 |
}
|
|
225 |
|
|
226 |
TPtrC svg11base( KSVG11 );
|
|
227 |
if( (aFeature.Length()-svg11base.Length()) > 1 )
|
|
228 |
{
|
|
229 |
TPtrC rightSvg11= aFeature.Right(aFeature.Length()-svg11base.Length() );
|
|
230 |
if ( rightSvg11.Match(KAnim) != KErrNotFound )
|
|
231 |
return ETrue;
|
|
232 |
if ( rightSvg11.Match(KCoreAttr) != KErrNotFound )
|
|
233 |
return ETrue;
|
|
234 |
if ( rightSvg11.Match(KBasicStr) != KErrNotFound )
|
|
235 |
return ETrue;
|
|
236 |
if ( rightSvg11.Match(KStyle) != KErrNotFound )
|
|
237 |
return ETrue;
|
|
238 |
if ( rightSvg11.Match(KPaintAttr) != KErrNotFound )
|
|
239 |
return ETrue;
|
|
240 |
if ( rightSvg11.Match(KGraphicsAttr) != KErrNotFound )
|
|
241 |
return ETrue;
|
|
242 |
if ( rightSvg11.Match(KHyperlink) != KErrNotFound )
|
|
243 |
return ETrue;
|
|
244 |
if ( rightSvg11.Match(KXlinkAttr) != KErrNotFound )
|
|
245 |
return ETrue;
|
|
246 |
if (rightSvg11.Match(KCond) != KErrNotFound )
|
|
247 |
return ETrue;
|
|
248 |
if ( rightSvg11.Match(KShape) != KErrNotFound )
|
|
249 |
return ETrue;
|
|
250 |
if ( rightSvg11.Match(KImage) != KErrNotFound )
|
|
251 |
return ETrue;
|
|
252 |
if ( rightSvg11.Match(KBasicTest) != KErrNotFound )
|
|
253 |
return ETrue;
|
|
254 |
if (rightSvg11.Match(KBasicFont) != KErrNotFound )
|
|
255 |
return ETrue;
|
|
256 |
if ( rightSvg11.Match(KDocAttr) != KErrNotFound )
|
|
257 |
return ETrue;
|
|
258 |
if ( rightSvg11.Match(KGraphEvt) != KErrNotFound )
|
|
259 |
return ETrue;
|
|
260 |
if ( rightSvg11.Match(KAnimEvt) != KErrNotFound )
|
|
261 |
return ETrue;
|
|
262 |
if ( rightSvg11.Match(KScript)!= KErrNotFound )
|
|
263 |
return EFalse; // Scripting is not supported.
|
|
264 |
if ( rightSvg11.Match(KView) != KErrNotFound )
|
|
265 |
return ETrue;
|
|
266 |
if ( rightSvg11.Match(KAnim) != KErrNotFound )
|
|
267 |
return ETrue;
|
|
268 |
if ( rightSvg11.Match(KExt) != KErrNotFound )
|
|
269 |
return ETrue;
|
|
270 |
}
|
|
271 |
|
|
272 |
TPtrC svg12base( KSVG12 );
|
|
273 |
if( (aFeature.Length()-svg12base.Length()) > 1 )
|
|
274 |
{
|
|
275 |
TPtrC rightSvg12= aFeature.Right(aFeature.Length()-svg12base.Length() );
|
|
276 |
if ( rightSvg12.Match(KAudio) != KErrNotFound )
|
|
277 |
{
|
|
278 |
return ETrue;
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
if ( aFeature == KStatic )
|
|
283 |
return ETrue;
|
|
284 |
if ( aFeature == KDynamic )
|
|
285 |
return EFalse;
|
|
286 |
else
|
|
287 |
return FALSE;
|
|
288 |
}
|
|
289 |
|
|
290 |
TBool CSvgTestsImpl::HasAnyTests()
|
|
291 |
{
|
|
292 |
const CDesCArrayFlat* tempTestArray = NULL;
|
|
293 |
|
|
294 |
GetRequiredFeatures(tempTestArray);
|
|
295 |
if (tempTestArray && tempTestArray->Count() > 0)
|
|
296 |
{
|
|
297 |
return ETrue;
|
|
298 |
}
|
|
299 |
|
|
300 |
GetSystemLanguage(tempTestArray);
|
|
301 |
if (tempTestArray && tempTestArray->Count() > 0)
|
|
302 |
{
|
|
303 |
return ETrue;
|
|
304 |
}
|
|
305 |
|
|
306 |
GetRequiredExtensions(tempTestArray);
|
|
307 |
if (tempTestArray && tempTestArray->Count() > 0)
|
|
308 |
{
|
|
309 |
return ETrue;
|
|
310 |
}
|
|
311 |
|
|
312 |
if (iSystemLanguageEmpty)
|
|
313 |
{
|
|
314 |
return ETrue;
|
|
315 |
}
|
|
316 |
|
|
317 |
return EFalse;
|
|
318 |
}
|
|
319 |
|
|
320 |
// Implementation
|
|
321 |
|
|
322 |
TBool CSvgTestsImpl::SetRequiredFeatureAttribute( const TDesC& aValue )
|
|
323 |
{
|
|
324 |
TLex input( aValue );
|
|
325 |
|
|
326 |
while ( !( input.Eos() ) )
|
|
327 |
{
|
|
328 |
input.SkipSpace();
|
|
329 |
input.Mark();
|
|
330 |
input.SkipCharacters();
|
|
331 |
TPtrC token = input.MarkedToken(); // then extract token
|
|
332 |
TRAPD(error,iRequiredFeatures->AppendL( token ));
|
|
333 |
|
|
334 |
if (error != KErrNone)
|
|
335 |
{
|
|
336 |
//Error Processing
|
|
337 |
return EFalse;
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
return ETrue;
|
|
342 |
}
|
|
343 |
|
|
344 |
TBool CSvgTestsImpl::SetRequiredExtensionAttribute( const TDesC& aValue )
|
|
345 |
{
|
|
346 |
TLex input( aValue );
|
|
347 |
|
|
348 |
if ( aValue.Length() == 0 )
|
|
349 |
{
|
|
350 |
TRAPD(error1,iRequiredExtensions->AppendL( aValue ));
|
|
351 |
|
|
352 |
if (error1 != KErrNone)
|
|
353 |
{
|
|
354 |
//Error Processing
|
|
355 |
return EFalse;
|
|
356 |
}
|
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
|
360 |
while ( !( input.Eos() ) )
|
|
361 |
{
|
|
362 |
input.SkipSpace();
|
|
363 |
input.Mark();
|
|
364 |
input.SkipCharacters();
|
|
365 |
TPtrC token = input.MarkedToken(); // then extract token
|
|
366 |
TRAPD(error,iRequiredExtensions->AppendL( token ));
|
|
367 |
|
|
368 |
if (error != KErrNone)
|
|
369 |
{
|
|
370 |
//Error Processing
|
|
371 |
return EFalse;
|
|
372 |
}
|
|
373 |
}
|
|
374 |
}
|
|
375 |
return ETrue;
|
|
376 |
}
|
|
377 |
|
|
378 |
TBool CSvgTestsImpl::SetSystemLanguageAttribute( const TDesC& aValue )
|
|
379 |
{
|
|
380 |
TLex input( aValue );
|
|
381 |
|
|
382 |
iSystemLanguageEmpty = EFalse;
|
|
383 |
|
|
384 |
if ( input.Eos() )
|
|
385 |
{
|
|
386 |
iSystemLanguageEmpty = ETrue;
|
|
387 |
}
|
|
388 |
else
|
|
389 |
{
|
|
390 |
while ( !( input.Eos() ) )
|
|
391 |
{
|
|
392 |
input.SkipSpace();
|
|
393 |
input.Mark();
|
|
394 |
input.SkipCharacters();
|
|
395 |
TPtrC token = input.MarkedToken(); // then extract token
|
|
396 |
TRAPD(error,iSystemLanguage->AppendL( token ));
|
|
397 |
|
|
398 |
if (error != KErrNone)
|
|
399 |
{
|
|
400 |
//Error Processing
|
|
401 |
return EFalse;
|
|
402 |
}
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
return ETrue;
|
|
407 |
|
|
408 |
}
|
|
409 |
|
|
410 |
// ---------------------------------------------------------------------------
|
|
411 |
//
|
|
412 |
// ---------------------------------------------------------------------------
|
|
413 |
TBool CSvgTestsImpl::SetTestAttributeL( const TDesC& aPropertyName,
|
|
414 |
const TDesC& aValue )
|
|
415 |
{
|
|
416 |
|
|
417 |
_LIT( KRequiredFeatures, "requiredFeatures" );
|
|
418 |
_LIT( KRequiredExtensions, "requiredExtensions" );
|
|
419 |
_LIT( KSystemLanguage, "systemLanguage" );
|
|
420 |
|
|
421 |
if (aPropertyName == KRequiredFeatures)
|
|
422 |
{
|
|
423 |
return SetRequiredFeatureAttribute(aValue);
|
|
424 |
}
|
|
425 |
else if (aPropertyName == KRequiredExtensions)
|
|
426 |
{
|
|
427 |
return SetRequiredExtensionAttribute(aValue);
|
|
428 |
}
|
|
429 |
else if (aPropertyName == KSystemLanguage)
|
|
430 |
{
|
|
431 |
return SetSystemLanguageAttribute(aValue);
|
|
432 |
}
|
|
433 |
else
|
|
434 |
{
|
|
435 |
return EFalse;
|
|
436 |
}
|
|
437 |
}
|
|
438 |
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
//
|
|
441 |
// ---------------------------------------------------------------------------
|
|
442 |
CSvgTestsImpl* CSvgTestsImpl::CloneL()
|
|
443 |
{
|
|
444 |
CSvgTestsImpl* retValue = CSvgTestsImpl::NewL();
|
|
445 |
|
|
446 |
CleanupStack::PushL(retValue);
|
|
447 |
// no need to call Reset() on any of these arrays because
|
|
448 |
// that already happened in the call to NewL above
|
|
449 |
int i;
|
|
450 |
|
|
451 |
// *** copy required features
|
|
452 |
TInt requiredFeaturesCnt = this->iRequiredFeatures->Count();
|
|
453 |
for (i=0; i< requiredFeaturesCnt; i++)
|
|
454 |
{
|
|
455 |
retValue->iRequiredFeatures->AppendL(this->iRequiredFeatures->operator[](i));
|
|
456 |
}
|
|
457 |
|
|
458 |
// *** copy required extensions
|
|
459 |
TInt requiredExtensionsCnt = this->iRequiredExtensions->Count();
|
|
460 |
for (i=0; i< requiredExtensionsCnt; i++)
|
|
461 |
{
|
|
462 |
retValue->iRequiredExtensions->AppendL(this->iRequiredExtensions->operator[](i));
|
|
463 |
}
|
|
464 |
|
|
465 |
// *** copy system language
|
|
466 |
TInt systemLanguageCnt = this->iSystemLanguage->Count();
|
|
467 |
for (i=0; i< systemLanguageCnt; i++)
|
|
468 |
{
|
|
469 |
retValue->iSystemLanguage->AppendL(this->iSystemLanguage->operator[](i));
|
|
470 |
}
|
|
471 |
CleanupStack::Pop();
|
|
472 |
return retValue;
|
|
473 |
}
|