|
1 /* |
|
2 * Copyright (c) 2002 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: COMAPushEMNStringDict00 |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <ecom/implementationproxy.h> |
|
22 |
|
23 #include <xml/plugins/dictionarycodepage.h> |
|
24 |
|
25 #include <xml/xmlframeworkerrors.h> |
|
26 |
|
27 #include "OMAPushEMNStringDict00.h" |
|
28 |
|
29 // These headers are automatically generated from \StringDictionaries\src\*.st |
|
30 // files. |
|
31 #include "omapushemntagtable.h" |
|
32 #include "omapushemnattributetable.h" |
|
33 #include "omapushemnattributevaluetable.h" |
|
34 |
|
35 using namespace Xml; |
|
36 |
|
37 //----------------------------------------------------------------------------- |
|
38 // COMAPushEMNStringDict00::NewL |
|
39 //----------------------------------------------------------------------------- |
|
40 MStringDictionary* COMAPushEMNStringDict00::NewL( TAny* aStringPool ) |
|
41 { |
|
42 COMAPushEMNStringDict00* self = |
|
43 new(ELeave) COMAPushEMNStringDict00( |
|
44 reinterpret_cast<RStringPool*>( aStringPool ) ); |
|
45 |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop( self ); |
|
49 return ( static_cast<MStringDictionary*>( self ) ); |
|
50 } |
|
51 |
|
52 //----------------------------------------------------------------------------- |
|
53 // COMAPushEMNStringDict00::COMAPushEMNStringDict00 |
|
54 //----------------------------------------------------------------------------- |
|
55 COMAPushEMNStringDict00::COMAPushEMNStringDict00( |
|
56 RStringPool* aStringPool ) : iStringPool(*aStringPool), iCodePage(0) |
|
57 { |
|
58 // do nothing; |
|
59 } |
|
60 |
|
61 //----------------------------------------------------------------------------- |
|
62 // COMAPushEMNStringDict00::ConstructL |
|
63 //----------------------------------------------------------------------------- |
|
64 void COMAPushEMNStringDict00::ConstructL() |
|
65 { |
|
66 // we don't own this stringpool |
|
67 iStringPool.OpenL(OMAPushEMNStringDict00TagTable::Table); |
|
68 iStringPool.OpenL(OMAPushEMNStringDict00AttributeTable::Table); |
|
69 iStringPool.OpenL(OMAPushEMNStringDict00AttributeValueTable::Table); |
|
70 |
|
71 iCodepage00Table = CDictionaryCodePage::NewL( |
|
72 &OMAPushEMNStringDict00TagTable::Table, |
|
73 &OMAPushEMNStringDict00AttributeTable::Table, |
|
74 &OMAPushEMNStringDict00AttributeValueTable::Table, |
|
75 0); // codepage |
|
76 |
|
77 // Construct the correlation mapping |
|
78 iCodepage00Table->ConstructIndexMappingL( |
|
79 iTagCodePage00, CDictionaryCodePage::EStringTypeElement ); |
|
80 iCodepage00Table->ConstructIndexMappingL( |
|
81 iAttributeCodePage00, CDictionaryCodePage::EStringTypeAttribute ); |
|
82 iCodepage00Table->ConstructIndexMappingL( |
|
83 iAttributeValueCodePage00, CDictionaryCodePage::EStringTypeAttributeValue ); |
|
84 } |
|
85 |
|
86 //----------------------------------------------------------------------------- |
|
87 // COMAPushEMNStringDict00::Release |
|
88 //----------------------------------------------------------------------------- |
|
89 void COMAPushEMNStringDict00::Release() |
|
90 { |
|
91 delete( this ); |
|
92 } |
|
93 |
|
94 //----------------------------------------------------------------------------- |
|
95 // COMAPushEMNStringDict00::~COMAPushEMNStringDict00 |
|
96 //----------------------------------------------------------------------------- |
|
97 COMAPushEMNStringDict00::~COMAPushEMNStringDict00() |
|
98 { |
|
99 if ( iCodepage00Table ) |
|
100 { |
|
101 delete iCodepage00Table; |
|
102 } |
|
103 } |
|
104 |
|
105 //----------------------------------------------------------------------------- |
|
106 // COMAPushEMNStringDict00::ElementL |
|
107 //----------------------------------------------------------------------------- |
|
108 void COMAPushEMNStringDict00::ElementL( |
|
109 TInt aToken, RString& aElement) const |
|
110 { |
|
111 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
112 aToken, CDictionaryCodePage::EStringTypeElement ); |
|
113 |
|
114 if ( index == KErrXmlStringPoolTableNotFound ) |
|
115 { |
|
116 User::Leave( KErrXmlUnsupportedElement ); |
|
117 } |
|
118 |
|
119 // when we have multiple codepages per string dictionary we'd do something |
|
120 // like iCodepageTable[n]->StringTable() |
|
121 aElement = iStringPool.String( |
|
122 index, |
|
123 *( iCodepage00Table->StringTable( |
|
124 CDictionaryCodePage::EStringTypeElement ) ) ); |
|
125 } |
|
126 |
|
127 //----------------------------------------------------------------------------- |
|
128 // COMAPushEMNStringDict00::AttributeL |
|
129 //----------------------------------------------------------------------------- |
|
130 void COMAPushEMNStringDict00::AttributeL( |
|
131 TInt aToken, RString& aAttribute ) const |
|
132 { |
|
133 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
134 aToken, CDictionaryCodePage::EStringTypeAttribute ); |
|
135 |
|
136 if ( index == KErrXmlStringPoolTableNotFound ) |
|
137 { |
|
138 User::Leave( KErrXmlUnsupportedAttribute ); |
|
139 } |
|
140 |
|
141 // when we have multiple codepages per string dictionary we'd do something |
|
142 // like iCodepageTable[n]->StringTable() |
|
143 aAttribute = iStringPool.String( |
|
144 index, |
|
145 *( iCodepage00Table->StringTable( |
|
146 CDictionaryCodePage::EStringTypeAttribute ) ) ); |
|
147 }; |
|
148 |
|
149 //----------------------------------------------------------------------------- |
|
150 // COMAPushEMNStringDict00::AttributeValuePairL |
|
151 //----------------------------------------------------------------------------- |
|
152 void COMAPushEMNStringDict00::AttributeValuePairL( |
|
153 TInt aToken, RString& aAttribute, RString& aValue ) const |
|
154 { |
|
155 AttributeL( aToken, aAttribute ); |
|
156 AttributeValueL( aToken, aValue ); |
|
157 }; |
|
158 |
|
159 //----------------------------------------------------------------------------- |
|
160 // COMAPushEMNStringDict00::AttributeValueL |
|
161 //----------------------------------------------------------------------------- |
|
162 void COMAPushEMNStringDict00::AttributeValueL( |
|
163 TInt aToken, RString& aValue ) const |
|
164 { |
|
165 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
166 aToken, CDictionaryCodePage::EStringTypeAttributeValue ); |
|
167 |
|
168 if ( index == KErrXmlStringPoolTableNotFound ) |
|
169 { |
|
170 User::Leave( KErrXmlUnsupportedAttributeValue ); |
|
171 } |
|
172 |
|
173 // when we have multiple codepages per string dictionary we'd do something |
|
174 // like iCodepageTable[n]->StringTable() |
|
175 aValue = iStringPool.String( |
|
176 index, |
|
177 *( iCodepage00Table->StringTable( |
|
178 CDictionaryCodePage::EStringTypeAttributeValue ) ) ); |
|
179 }; |
|
180 |
|
181 //----------------------------------------------------------------------------- |
|
182 // COMAPushEMNStringDict00::CompareThisDictionary |
|
183 //----------------------------------------------------------------------------- |
|
184 TBool COMAPushEMNStringDict00::CompareThisDictionary( |
|
185 const RString& aDictionaryDescription ) const |
|
186 { |
|
187 // If this string dictionary has many codepages then all these comparisons should go here. |
|
188 // Remember, the string dictionary loads up all the RStringTables into its RStringPool |
|
189 // on construction. So if the comparison fails we do not have it. |
|
190 return ( |
|
191 ( aDictionaryDescription == iStringPool.String( |
|
192 OMAPushEMNStringDict00TagTable::EUri, |
|
193 OMAPushEMNStringDict00TagTable::Table ) ) || |
|
194 ( aDictionaryDescription == iStringPool.String( |
|
195 OMAPushEMNStringDict00TagTable::EPublicId, |
|
196 OMAPushEMNStringDict00TagTable::Table ) ) || |
|
197 ( aDictionaryDescription == iStringPool.String( |
|
198 OMAPushEMNStringDict00TagTable::EFormalPublicId, |
|
199 OMAPushEMNStringDict00TagTable::Table ) ) ); |
|
200 } |
|
201 |
|
202 //----------------------------------------------------------------------------- |
|
203 // COMAPushEMNStringDict00::SwitchCodePage |
|
204 //----------------------------------------------------------------------------- |
|
205 TInt COMAPushEMNStringDict00::SwitchCodePage( TInt aCodePage ) |
|
206 { |
|
207 // We only have one codepage sp can't switch |
|
208 if ( aCodePage != iCodePage ) |
|
209 { |
|
210 return KErrXmlMissingStringDictionary; |
|
211 } |
|
212 return iCodePage; |
|
213 } |
|
214 |
|
215 //----------------------------------------------------------------------------- |
|
216 // COMAPushEMNStringDict00::PublicIdentifier |
|
217 //----------------------------------------------------------------------------- |
|
218 void COMAPushEMNStringDict00::PublicIdentifier( RString& aPubId ) |
|
219 { |
|
220 aPubId = iStringPool.String( |
|
221 OMAPushEMNStringDict00TagTable::EFormalPublicId, |
|
222 *( iCodepage00Table->StringTable( |
|
223 CDictionaryCodePage::EStringTypeElement ) ) ); |
|
224 } |
|
225 |
|
226 //----------------------------------------------------------------------------- |
|
227 // COMAPushEMNStringDict00::NamespaceUri |
|
228 //----------------------------------------------------------------------------- |
|
229 void COMAPushEMNStringDict00::NamespaceUri( RString& aUri ) |
|
230 { |
|
231 aUri = iStringPool.String( |
|
232 OMAPushEMNStringDict00TagTable::EUri, |
|
233 *( iCodepage00Table->StringTable( |
|
234 CDictionaryCodePage::EStringTypeElement ) ) ); |
|
235 } |
|
236 |
|
237 //----------------------------------------------------------------------------- |
|
238 // ECOM PLUGIN LOADING STUFF |
|
239 //----------------------------------------------------------------------------- |
|
240 const TImplementationProxy ImplementationTable[] = { |
|
241 IMPLEMENTATION_PROXY_ENTRY( 0x1027508B, COMAPushEMNStringDict00::NewL ) |
|
242 }; |
|
243 |
|
244 //----------------------------------------------------------------------------- |
|
245 // ImplementationGroupProxy |
|
246 //----------------------------------------------------------------------------- |
|
247 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
248 TInt& aTableCount ) |
|
249 { |
|
250 aTableCount = sizeof( ImplementationTable ) / |
|
251 sizeof( TImplementationProxy ); |
|
252 |
|
253 return ImplementationTable; |
|
254 } |
|
255 |