|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <apmrec.h> |
|
20 #include <apmstd.h> |
|
21 #include <f32file.h> |
|
22 |
|
23 #include <implementationproxy.h> |
|
24 |
|
25 #include "SvgRecognizer.h" |
|
26 |
|
27 // -------------------------------------------------------------------------- |
|
28 // CSvgRecognizer::CSvgRecognizer() : CApaDataRecognizerType( KUidMimeSvgRecognizer, |
|
29 // --------------------------------------------------------------------------- |
|
30 CSvgRecognizer::CSvgRecognizer() : CApaDataRecognizerType( KUidMimeSvgRecognizer, |
|
31 CApaDataRecognizerType::ELow ) |
|
32 { |
|
33 iCountDataTypes = 1; |
|
34 } |
|
35 |
|
36 // -------------------------------------------------------------------------- |
|
37 // TUint CSvgRecognizer::PreferredBufSize() |
|
38 // --------------------------------------------------------------------------- |
|
39 TUint CSvgRecognizer::PreferredBufSize() |
|
40 { |
|
41 return KMaxBufferLength; |
|
42 } |
|
43 |
|
44 // -------------------------------------------------------------------------- |
|
45 // TDataType CSvgRecognizer::SupportedDataTypeL( TInt /*aIndex */) const |
|
46 // --------------------------------------------------------------------------- |
|
47 TDataType CSvgRecognizer::SupportedDataTypeL( TInt /*aIndex */) const |
|
48 { |
|
49 return TDataType( KDataTypeImageSvg ); |
|
50 } |
|
51 |
|
52 // -------------------------------------------------------------------------- |
|
53 // void CSvgRecognizer::DoRecognizeL( const TDesC& aName, |
|
54 // --------------------------------------------------------------------------- |
|
55 void CSvgRecognizer::DoRecognizeL( const TDesC& aName, |
|
56 const TDesC8& /*aBuffer */) |
|
57 { |
|
58 iConfidence = ENotRecognized; |
|
59 |
|
60 const TInt positionOfLastDot = aName.LocateReverse( '.' ); |
|
61 |
|
62 if ( positionOfLastDot >= 0 ) |
|
63 { //check the extension |
|
64 const TPtrC ext = aName.Mid( positionOfLastDot ); |
|
65 /* SVGEngine suppported file extensions */ |
|
66 _LIT(KSvgExt1, ".svg"); |
|
67 _LIT(KSvgExt2, ".svgz"); |
|
68 _LIT(KSvgExt3, ".svgb"); |
|
69 |
|
70 if ( ext.CompareF( KSvgExt1 ) == 0 || |
|
71 ext.CompareF( KSvgExt2 ) == 0 || |
|
72 ext.CompareF( KSvgExt3 ) == 0 ) |
|
73 { |
|
74 iConfidence = ECertain; |
|
75 iDataType = TDataType( KDataTypeImageSvg ); |
|
76 } |
|
77 } |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 // CApaDataRecognizerType* CSvgRecognizer::CreateRecognizerL() |
|
82 // --------------------------------------------------------------------------- |
|
83 CApaDataRecognizerType* CSvgRecognizer::CreateRecognizerL() |
|
84 { |
|
85 CApaDataRecognizerType* lSvgDataRecogType = NULL; |
|
86 lSvgDataRecogType = new (ELeave) CSvgRecognizer(); |
|
87 return lSvgDataRecogType; // NULL if new failed |
|
88 } |
|
89 |
|
90 // -------------------------------------------------------------------------- |
|
91 // const TImplementationProxy SvgRecogImplTable[] = |
|
92 // --------------------------------------------------------------------------- |
|
93 const TImplementationProxy SvgRecogImplTable[] = |
|
94 { |
|
95 IMPLEMENTATION_PROXY_ENTRY(KImplementationValue, CSvgRecognizer::CreateRecognizerL) |
|
96 }; |
|
97 |
|
98 // -------------------------------------------------------------------------- |
|
99 // EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aImplTableCount) |
|
100 // --------------------------------------------------------------------------- |
|
101 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aImplTableCount) |
|
102 { |
|
103 aImplTableCount = sizeof(SvgRecogImplTable) / sizeof(TImplementationProxy); |
|
104 return SvgRecogImplTable; |
|
105 } |