|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32std.h> |
|
17 #include <ecom/implementationproxy.h> |
|
18 |
|
19 #include <xml/xmlframeworkerrors.h> |
|
20 #include <xml/plugins/dictionarycodepage.h> |
|
21 |
|
22 #include "emn1_0stringdict00.h" |
|
23 #include "emn1_0stringdict00tagtable.h" |
|
24 #include "emn1_0stringdict00attributetable.h" |
|
25 |
|
26 |
|
27 using namespace Xml; |
|
28 |
|
29 MStringDictionary* CEmn1_0StringDict00::NewL(TAny* aStringPool) |
|
30 { |
|
31 CEmn1_0StringDict00* self = new(ELeave) CEmn1_0StringDict00(reinterpret_cast<RStringPool*>(aStringPool)); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return (static_cast<MStringDictionary*>(self)); |
|
36 } |
|
37 |
|
38 |
|
39 |
|
40 CEmn1_0StringDict00::CEmn1_0StringDict00(RStringPool* aStringPool) |
|
41 : iStringPool(*aStringPool), |
|
42 iCodePage(0) |
|
43 { |
|
44 // do nothing; |
|
45 } |
|
46 |
|
47 |
|
48 |
|
49 void CEmn1_0StringDict00::ConstructL() |
|
50 { |
|
51 // we don't own this stringpool |
|
52 iStringPool.OpenL(Emn1_0StringDict00TagTable::Table); |
|
53 iStringPool.OpenL(Emn1_0StringDict00AttributeTable::Table); |
|
54 |
|
55 |
|
56 iCodepage00Table = CDictionaryCodePage::NewL( |
|
57 &Emn1_0StringDict00TagTable::Table, |
|
58 &Emn1_0StringDict00AttributeTable::Table, |
|
59 0,0); // codepage |
|
60 |
|
61 // Construct the correlation mapping |
|
62 iCodepage00Table->ConstructIndexMappingL(iTagCodePage00, CDictionaryCodePage::EStringTypeElement); |
|
63 iCodepage00Table->ConstructIndexMappingL(iAttributeCodePage00, CDictionaryCodePage::EStringTypeAttribute); |
|
64 } |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 void CEmn1_0StringDict00::Release() |
|
70 { |
|
71 delete (this); |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 CEmn1_0StringDict00::~CEmn1_0StringDict00() |
|
78 { |
|
79 if (iCodepage00Table) |
|
80 { |
|
81 delete iCodepage00Table; |
|
82 } |
|
83 } |
|
84 |
|
85 |
|
86 |
|
87 void CEmn1_0StringDict00::ElementL(TInt aToken, RString& aElement) const |
|
88 { |
|
89 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
90 aToken, CDictionaryCodePage::EStringTypeElement); |
|
91 |
|
92 if (index == KErrXmlStringPoolTableNotFound) |
|
93 { |
|
94 User::Leave(KErrXmlUnsupportedElement); |
|
95 } |
|
96 |
|
97 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
98 aElement = iStringPool.String( |
|
99 index, |
|
100 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 void CEmn1_0StringDict00::AttributeL(TInt aToken, RString& aAttribute) const |
|
106 { |
|
107 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
108 aToken, CDictionaryCodePage::EStringTypeAttribute); |
|
109 |
|
110 if (index == KErrXmlStringPoolTableNotFound) |
|
111 { |
|
112 User::Leave(KErrXmlUnsupportedAttribute); |
|
113 } |
|
114 |
|
115 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
116 aAttribute = iStringPool.String( |
|
117 index, |
|
118 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttribute))); |
|
119 }; |
|
120 |
|
121 |
|
122 |
|
123 void CEmn1_0StringDict00::AttributeValuePairL(TInt aToken, RString& aAttribute, RString& aValue) const |
|
124 { |
|
125 AttributeL(aToken, aAttribute); |
|
126 AttributeValueL(aToken, aValue); |
|
127 }; |
|
128 |
|
129 |
|
130 |
|
131 void CEmn1_0StringDict00::AttributeValueL(TInt /*aToken*/, RString& /*aValue*/) const |
|
132 { |
|
133 /* TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
134 aToken, CDictionaryCodePage::EStringTypeAttributeValue); |
|
135 |
|
136 if (index == KErrXmlStringPoolTableNotFound) |
|
137 { |
|
138 User::Leave(KErrXmlUnsupportedAttributeValue); |
|
139 } |
|
140 |
|
141 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
142 aValue = iStringPool.String( |
|
143 index, |
|
144 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttributeValue)));*/ |
|
145 }; |
|
146 |
|
147 |
|
148 |
|
149 TBool CEmn1_0StringDict00::CompareThisDictionary(const RString& aDictionaryDescription) const |
|
150 { |
|
151 // If this string dictionary has many codepages then all these comparisons should go here. |
|
152 // Remember, the string dictionary loads up all the RStringTables into its RStringPool |
|
153 // on construction. So if the comparison fails we do not have it. |
|
154 return ( |
|
155 (aDictionaryDescription == iStringPool.String(Emn1_0StringDict00TagTable::EUri, Emn1_0StringDict00TagTable::Table)) || |
|
156 (aDictionaryDescription == iStringPool.String(Emn1_0StringDict00TagTable::EPublicId, Emn1_0StringDict00TagTable::Table))|| |
|
157 (aDictionaryDescription == iStringPool.String(Emn1_0StringDict00TagTable::EFormalPublicId, Emn1_0StringDict00TagTable::Table))); |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 TInt CEmn1_0StringDict00::SwitchCodePage(TInt aCodePage) |
|
163 { |
|
164 // We only have one codepage sp can't switch |
|
165 if (aCodePage != iCodePage) |
|
166 { |
|
167 return KErrXmlMissingStringDictionary; |
|
168 } |
|
169 return iCodePage; |
|
170 } |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 /** |
|
177 This method obtains the public identifier from the StringTable. |
|
178 Either the formal or non formal public id will do. |
|
179 The stringDictionary .rss files must list both these as wbxml |
|
180 documents have one or the other. |
|
181 |
|
182 @param aPubId The public identifier for this string |
|
183 dictionary. |
|
184 */ |
|
185 |
|
186 void CEmn1_0StringDict00::PublicIdentifier(RString& aPubId) |
|
187 { |
|
188 aPubId = iStringPool.String( |
|
189 Emn1_0StringDict00TagTable::EFormalPublicId, |
|
190 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
191 } |
|
192 |
|
193 |
|
194 /** |
|
195 The element types in the Device Information DTD are defined within |
|
196 a namespace associated with the Uri/Urn available from the StringTable. |
|
197 The RString need not be closed, but closing is harmless. |
|
198 |
|
199 @param aUri The associated namespace for this string |
|
200 dictionary. |
|
201 */ |
|
202 |
|
203 void CEmn1_0StringDict00::NamespaceUri(RString& aUri) |
|
204 { |
|
205 aUri = iStringPool.String( |
|
206 Emn1_0StringDict00TagTable::EUri, |
|
207 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
208 } |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 // __________________________________________________________________________ |
|
214 // Exported proxy for instantiation method resolution |
|
215 // Define the interface UIDs |
|
216 const TImplementationProxy ImplementationTable[] = { |
|
217 IMPLEMENTATION_PROXY_ENTRY(0x20022C28,CEmn1_0StringDict00::NewL) |
|
218 }; |
|
219 |
|
220 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
221 { |
|
222 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
223 |
|
224 return ImplementationTable; |
|
225 } |
|
226 |