|
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_2opaquestringdictionary00.h" |
|
23 #include "syncml1_2opaquecodepage00tagtable.h" |
|
24 |
|
25 using namespace Xml; |
|
26 |
|
27 MStringDictionary* CSyncml1_2OpaqueStringDictionary00::NewL(TAny* aStringPool) |
|
28 { |
|
29 CSyncml1_2OpaqueStringDictionary00* self = new(ELeave) CSyncml1_2OpaqueStringDictionary00(reinterpret_cast<RStringPool*>(aStringPool)); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(self); |
|
33 return (static_cast<MStringDictionary*>(self)); |
|
34 } |
|
35 |
|
36 |
|
37 |
|
38 CSyncml1_2OpaqueStringDictionary00::CSyncml1_2OpaqueStringDictionary00(RStringPool* aStringPool) |
|
39 : iStringPool(*aStringPool), |
|
40 iCodePage(0) |
|
41 { |
|
42 // do nothing; |
|
43 } |
|
44 |
|
45 |
|
46 |
|
47 void CSyncml1_2OpaqueStringDictionary00::ConstructL() |
|
48 { |
|
49 // we don't own this stringpool |
|
50 iStringPool.OpenL(Syncml1_2OpaqueCodePage00TagTable::Table); |
|
51 |
|
52 iCodepage00Table = CDictionaryCodePage::NewL(&Syncml1_2OpaqueCodePage00TagTable::Table, 0, 0, 0); |
|
53 |
|
54 // Construct the correlation mapping |
|
55 iCodepage00Table->ConstructIndexMappingL(iCodePage00, CDictionaryCodePage::EStringTypeElement); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 void CSyncml1_2OpaqueStringDictionary00::Release() |
|
62 { |
|
63 delete (this); |
|
64 } |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 CSyncml1_2OpaqueStringDictionary00::~CSyncml1_2OpaqueStringDictionary00() |
|
70 { |
|
71 if (iCodepage00Table) |
|
72 { |
|
73 delete iCodepage00Table; |
|
74 } |
|
75 } |
|
76 |
|
77 |
|
78 |
|
79 void CSyncml1_2OpaqueStringDictionary00::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_2OpaqueStringDictionary00::AttributeL(TInt /*aToken*/, RString& /*aAttribute*/) const |
|
98 { |
|
99 // SyncML does not have attributes |
|
100 User::Leave(KErrXmlUnsupportedAttribute); |
|
101 }; |
|
102 |
|
103 |
|
104 |
|
105 void CSyncml1_2OpaqueStringDictionary00::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_2OpaqueStringDictionary00::AttributeValueL(TInt /*aToken*/, RString& /*aValue*/) const |
|
114 { |
|
115 // SyncML does not have attributes |
|
116 User::Leave(KErrXmlUnsupportedAttributeValue); |
|
117 }; |
|
118 |
|
119 |
|
120 |
|
121 TBool CSyncml1_2OpaqueStringDictionary00::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_2OpaqueCodePage00TagTable::EUrn, Syncml1_2OpaqueCodePage00TagTable::Table)) || |
|
128 (aDictionaryDescription == iStringPool.String(Syncml1_2OpaqueCodePage00TagTable::EPublicId, Syncml1_2OpaqueCodePage00TagTable::Table))|| |
|
129 (aDictionaryDescription == iStringPool.String(Syncml1_2OpaqueCodePage00TagTable::EFormalPublicId, Syncml1_2OpaqueCodePage00TagTable::Table))); |
|
130 } |
|
131 |
|
132 |
|
133 |
|
134 TInt CSyncml1_2OpaqueStringDictionary00::SwitchCodePage(TInt aCodePage) |
|
135 { |
|
136 // We only have one codepage so can't switch |
|
137 if (aCodePage != iCodePage) |
|
138 { |
|
139 return KErrXmlMissingStringDictionary; |
|
140 } |
|
141 return iCodePage; |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 /** |
|
149 This method obtains the public identifier from the StringTable. |
|
150 Either the formal or non formal public id will do. |
|
151 The stringDictionary .rss files must list both these as wbxml |
|
152 documents have one or the other. |
|
153 |
|
154 @param aPubId The public identifier for this string |
|
155 dictionary. |
|
156 */ |
|
157 |
|
158 void CSyncml1_2OpaqueStringDictionary00::PublicIdentifier(RString& aPubId) |
|
159 { |
|
160 // Better to use the element table as some documents don't have attributes. |
|
161 aPubId = iStringPool.String( |
|
162 Syncml1_2OpaqueCodePage00TagTable::EFormalPublicId, |
|
163 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
164 } |
|
165 |
|
166 |
|
167 /** |
|
168 The element types in the Device Information DTD are defined within |
|
169 a namespace associated with the Uri/Urn available from the StringTable. |
|
170 The RString need not be closed, but closing is harmless. |
|
171 |
|
172 @param aUri The associated namespace for this string |
|
173 dictionary. |
|
174 */ |
|
175 |
|
176 void CSyncml1_2OpaqueStringDictionary00::NamespaceUri(RString& aUri) |
|
177 { |
|
178 // Better to use the element table as some documents don't have attributes. |
|
179 aUri = iStringPool.String( |
|
180 Syncml1_2OpaqueCodePage00TagTable::EUrn, |
|
181 *(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement))); |
|
182 } |
|
183 |
|
184 |
|
185 // __________________________________________________________________________ |
|
186 // Exported proxy for instantiation method resolution |
|
187 // Define the interface UIDs |
|
188 const TImplementationProxy ImplementationTable[] = { |
|
189 IMPLEMENTATION_PROXY_ENTRY(0x10207FA4,CSyncml1_2OpaqueStringDictionary00::NewL) |
|
190 }; |
|
191 |
|
192 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
193 { |
|
194 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
195 |
|
196 return ImplementationTable; |
|
197 } |
|
198 |