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