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