|
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 "si1_0stringdict00.h" |
|
23 #include "si1_0stringdict00tagtable.h" |
|
24 #include "si1_0stringdict00attributetable.h" |
|
25 #include "si1_0stringdict00attributevaluetable.h" |
|
26 |
|
27 using namespace Xml; |
|
28 |
|
29 MStringDictionary* CSi1_0StringDict00::NewL(TAny* aStringPool) |
|
30 { |
|
31 CSi1_0StringDict00* self = new(ELeave) CSi1_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 CSi1_0StringDict00::CSi1_0StringDict00(RStringPool* aStringPool) |
|
41 : iStringPool(*aStringPool), |
|
42 iCodePage(0) |
|
43 { |
|
44 // do nothing; |
|
45 } |
|
46 |
|
47 |
|
48 |
|
49 void CSi1_0StringDict00::ConstructL() |
|
50 { |
|
51 // we don't own this stringpool |
|
52 iStringPool.OpenL(Si1_0StringDict00TagTable::Table); |
|
53 iStringPool.OpenL(Si1_0StringDict00AttributeTable::Table); |
|
54 iStringPool.OpenL(Si1_0StringDict00AttributeValueTable::Table); |
|
55 |
|
56 iCodepage00Table = CDictionaryCodePage::NewL( |
|
57 &Si1_0StringDict00TagTable::Table, |
|
58 &Si1_0StringDict00AttributeTable::Table, |
|
59 &Si1_0StringDict00AttributeValueTable::Table, |
|
60 0); // codepage |
|
61 |
|
62 // Construct the correlation mapping |
|
63 iCodepage00Table->ConstructIndexMappingL(iTagCodePage00, CDictionaryCodePage::EStringTypeElement); |
|
64 iCodepage00Table->ConstructIndexMappingL(iAttributeCodePage00, CDictionaryCodePage::EStringTypeAttribute); |
|
65 iCodepage00Table->ConstructIndexMappingL(iAttributeValueCodePage00, CDictionaryCodePage::EStringTypeAttributeValue); |
|
66 } |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 void CSi1_0StringDict00::Release() |
|
72 { |
|
73 delete (this); |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 CSi1_0StringDict00::~CSi1_0StringDict00() |
|
80 { |
|
81 if (iCodepage00Table) |
|
82 { |
|
83 delete iCodepage00Table; |
|
84 } |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 void CSi1_0StringDict00::ElementL(TInt aToken, RString& aElement) const |
|
90 { |
|
91 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
92 aToken, CDictionaryCodePage::EStringTypeElement); |
|
93 |
|
94 if (index == KErrXmlStringPoolTableNotFound) |
|
95 { |
|
96 User::Leave(KErrXmlUnsupportedElement); |
|
97 } |
|
98 |
|
99 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
100 aElement = iStringPool.String( |
|
101 index, |
|
102 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
103 } |
|
104 |
|
105 |
|
106 |
|
107 void CSi1_0StringDict00::AttributeL(TInt aToken, RString& aAttribute) const |
|
108 { |
|
109 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
110 aToken, CDictionaryCodePage::EStringTypeAttribute); |
|
111 |
|
112 if (index == KErrXmlStringPoolTableNotFound) |
|
113 { |
|
114 User::Leave(KErrXmlUnsupportedAttribute); |
|
115 } |
|
116 |
|
117 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
118 aAttribute = iStringPool.String( |
|
119 index, |
|
120 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttribute))); |
|
121 }; |
|
122 |
|
123 |
|
124 |
|
125 void CSi1_0StringDict00::AttributeValuePairL(TInt aToken, RString& aAttribute, RString& aValue) const |
|
126 { |
|
127 AttributeL(aToken, aAttribute); |
|
128 AttributeValueL(aToken, aValue); |
|
129 }; |
|
130 |
|
131 |
|
132 |
|
133 void CSi1_0StringDict00::AttributeValueL(TInt aToken, RString& aValue) const |
|
134 { |
|
135 TInt index = iCodepage00Table->StringPoolIndexFromToken( |
|
136 aToken, CDictionaryCodePage::EStringTypeAttributeValue); |
|
137 |
|
138 if (index == KErrXmlStringPoolTableNotFound) |
|
139 { |
|
140 User::Leave(KErrXmlUnsupportedAttributeValue); |
|
141 } |
|
142 |
|
143 // when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable() |
|
144 aValue = iStringPool.String( |
|
145 index, |
|
146 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttributeValue))); |
|
147 }; |
|
148 |
|
149 |
|
150 |
|
151 TBool CSi1_0StringDict00::CompareThisDictionary(const RString& aDictionaryDescription) const |
|
152 { |
|
153 // If this string dictionary has many codepages then all these comparisons should go here. |
|
154 // Remember, the string dictionary loads up all the RStringTables into its RStringPool |
|
155 // on construction. So if the comparison fails we do not have it. |
|
156 return ( |
|
157 (aDictionaryDescription == iStringPool.String(Si1_0StringDict00TagTable::EUri, Si1_0StringDict00TagTable::Table)) || |
|
158 (aDictionaryDescription == iStringPool.String(Si1_0StringDict00TagTable::EPublicId, Si1_0StringDict00TagTable::Table))|| |
|
159 (aDictionaryDescription == iStringPool.String(Si1_0StringDict00TagTable::EFormalPublicId, Si1_0StringDict00TagTable::Table))); |
|
160 } |
|
161 |
|
162 |
|
163 |
|
164 TInt CSi1_0StringDict00::SwitchCodePage(TInt aCodePage) |
|
165 { |
|
166 // We only have one codepage sp can't switch |
|
167 if (aCodePage != iCodePage) |
|
168 { |
|
169 return KErrXmlMissingStringDictionary; |
|
170 } |
|
171 return iCodePage; |
|
172 } |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 /** |
|
179 This method obtains the public identifier from the StringTable. |
|
180 Either the formal or non formal public id will do. |
|
181 The stringDictionary .rss files must list both these as wbxml |
|
182 documents have one or the other. |
|
183 |
|
184 @param aPubId The public identifier for this string |
|
185 dictionary. |
|
186 */ |
|
187 |
|
188 void CSi1_0StringDict00::PublicIdentifier(RString& aPubId) |
|
189 { |
|
190 aPubId = iStringPool.String( |
|
191 Si1_0StringDict00TagTable::EFormalPublicId, |
|
192 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
193 } |
|
194 |
|
195 |
|
196 /** |
|
197 The element types in the Device Information DTD are defined within |
|
198 a namespace associated with the Uri/Urn available from the StringTable. |
|
199 The RString need not be closed, but closing is harmless. |
|
200 |
|
201 @param aUri The associated namespace for this string |
|
202 dictionary. |
|
203 */ |
|
204 |
|
205 void CSi1_0StringDict00::NamespaceUri(RString& aUri) |
|
206 { |
|
207 aUri = iStringPool.String( |
|
208 Si1_0StringDict00TagTable::EUri, |
|
209 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
210 } |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 // __________________________________________________________________________ |
|
216 // Exported proxy for instantiation method resolution |
|
217 // Define the interface UIDs |
|
218 const TImplementationProxy ImplementationTable[] = { |
|
219 IMPLEMENTATION_PROXY_ENTRY(0x101FE2A7,CSi1_0StringDict00::NewL) |
|
220 }; |
|
221 |
|
222 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
223 { |
|
224 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
225 |
|
226 return ImplementationTable; |
|
227 } |
|
228 |