|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef MLEQCOMPDATAPARSE_H |
|
21 #define MLEQCOMPDATAPARSE_H |
|
22 |
|
23 // disable "identifier was truncated to '255' characters in the browser information" warning |
|
24 #pragma warning (disable:4786) |
|
25 |
|
26 #include "LayoutCompilerErr.h" |
|
27 #include "MLEqCompData.h" |
|
28 |
|
29 #include <avkon.hrh> // for logical font ids |
|
30 |
|
31 #include "SaxErrorHandler.h" |
|
32 |
|
33 #include <vector> |
|
34 #include <string> |
|
35 #include <iosfwd> |
|
36 #include <stack> |
|
37 |
|
38 using namespace std; |
|
39 |
|
40 |
|
41 // |
|
42 // defines |
|
43 // |
|
44 #define ELayoutCompilerFontCategoryUndefined KAknFontCategoryUndefined /* 0 */ |
|
45 #define ELayoutCompilerFontCategoryPrimary KAknFontCategoryPrimary /* 1*/ |
|
46 #define ELayoutCompilerFontCategorySecondary KAknFontCategorySecondary /* 2 */ |
|
47 #define ELayoutCompilerFontCategoryTitle KAknFontCategoryTitle /* 3 */ |
|
48 #define ELayoutCompilerFontCategoryPrimarySmall KAknFontCategoryPrimarySmall /* 4 */ |
|
49 #define ELayoutCompilerFontCategoryDigital KAknFontCategoryDigital /* 5 */ |
|
50 |
|
51 |
|
52 class MSaxLayoutEqHandler |
|
53 { |
|
54 public: |
|
55 typedef SAX::basic_Attributes<std::string> TAttribs; |
|
56 virtual MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs) { return this; }; |
|
57 virtual void HandleSaxEnd(const std::string& aElement) { }; |
|
58 }; |
|
59 |
|
60 |
|
61 |
|
62 class TMLEqCompDataParseFormula : public TMLEqCompDataFormula, public MSaxLayoutEqHandler |
|
63 { |
|
64 public: |
|
65 TMLEqCompDataParseFormula(); |
|
66 public: // from MSaxLayoutEqHandler |
|
67 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
68 public: |
|
69 void HandleSaxEnd(const std::string& aElement); |
|
70 void HandleSaxFormulaAttributes(const std::string& aElement, const TAttribs& aAttribs); |
|
71 private: |
|
72 string iSaxFormulaString; |
|
73 }; |
|
74 |
|
75 |
|
76 class TMLEqCompDataParseValuesOptionSet : public TMLEqCompDataValuesOptionSet, public MSaxLayoutEqHandler |
|
77 { |
|
78 public: |
|
79 TMLEqCompDataParseValuesOptionSet(); |
|
80 public: // from MSaxLayoutEqHandler |
|
81 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
82 public: |
|
83 void HandleSaxEnd(const std::string& aElement); |
|
84 void HandleSaxOptionSetNo(const std::string& aElement, const TAttribs& aAttribs); |
|
85 MSaxLayoutEqHandler* HandleSaxFormula(const std::string& aElement, const TAttribs& aAttribs); |
|
86 public: |
|
87 int OptionSetNo() const {return iSaxOptionSetNo;} |
|
88 private: |
|
89 TMLEqCompDataParseFormula* iSaxFormula; |
|
90 int iSaxFormulaNo; |
|
91 int iSaxOptionSetNo; |
|
92 }; |
|
93 |
|
94 // this corresponds to a "param" in the xml |
|
95 class TMLEqCompDataParseValues : public TMLEqCompDataValues, public MSaxLayoutEqHandler |
|
96 { |
|
97 public: |
|
98 TMLEqCompDataParseValues(TMLEqCompDataLine* aLine); |
|
99 static int ConvertZoomStr(const std::string& aValueStr); |
|
100 public: // from MSaxLayoutEqHandler |
|
101 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
102 private: |
|
103 void HandleSaxEnd(const std::string& aElement); |
|
104 MSaxLayoutEqHandler* HandleSaxOptionSet(const std::string& aElement, const TAttribs& aAttribs); |
|
105 private: |
|
106 void ConvertValueStr(std::string& aValueStr); |
|
107 private: |
|
108 TMLEqCompDataParseValuesOptionSet* iSaxOptionSet; |
|
109 }; |
|
110 |
|
111 |
|
112 // this corresponds to a "component" in the xml |
|
113 class TMLEqCompDataParseLine : public TMLEqCompDataLine, public MSaxLayoutEqHandler |
|
114 { |
|
115 public: |
|
116 TMLEqCompDataParseLine(); |
|
117 string ShortParamName(string& aName); |
|
118 public: // from MSaxLayoutEqHandler |
|
119 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
120 private: |
|
121 void HandleSaxEnd(const std::string& aElement); |
|
122 void HandleSaxAttributes(const TAttribs& aAttribs); |
|
123 // MSaxLayoutEqHandler* HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs); |
|
124 MSaxLayoutEqHandler* HandleSaxParam(const std::string& aElement, const TAttribs& aAttribs); |
|
125 // MSaxLayoutEqHandler* HandleSaxAttributeInfo(const std::string& aElement, const TAttribs& aAttribs); |
|
126 private: |
|
127 TMLEqCompDataParseValues* iSaxValues; |
|
128 // TMLEqCompDataParseParentInfo* iSaxParentInfo; |
|
129 // TMLEqCompDataParseAttributeInfo* iSaxAttributeInfo; |
|
130 }; |
|
131 |
|
132 |
|
133 // This is the component element stored in the list xml. |
|
134 class TMLEqListParseComponent : public TMLEqListComponent, public MSaxLayoutEqHandler |
|
135 { |
|
136 public: |
|
137 TMLEqListParseComponent(); |
|
138 public: // from MSaxLayoutEqHandler |
|
139 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
140 void HandleSaxEnd(const std::string& aElement); |
|
141 }; |
|
142 |
|
143 |
|
144 // This is the component element stored in the list xml. |
|
145 class TMLEqParChildParseComponent : public TMLEqParChildComponent, public MSaxLayoutEqHandler |
|
146 { |
|
147 public: |
|
148 TMLEqParChildParseComponent(); |
|
149 public: // from MSaxLayoutEqHandler |
|
150 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
151 void HandleSaxEnd(const std::string& aElement); |
|
152 private: |
|
153 void HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs); |
|
154 }; |
|
155 |
|
156 // this corresponds to a layout in the xml |
|
157 class TMLEqCompDataParseLayout : public TMLEqCompData, public MSaxLayoutEqHandler |
|
158 { |
|
159 public: |
|
160 static auto_ptr<TMLEqCompDataParseLayout> Parse(const string& aListName, const string& aCompDataName, const string& aParChildName); |
|
161 public: // from MSaxLayoutEqHandler |
|
162 MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs); |
|
163 void HandleSaxEnd(const std::string& aElement); |
|
164 private: |
|
165 MSaxLayoutEqHandler* HandleSaxComponent(const std::string& aElement, const TAttribs& aAttribs); |
|
166 private: |
|
167 TMLEqCompDataParseLine* iSaxLine; |
|
168 string iSaxLayoutType; |
|
169 }; |
|
170 |
|
171 |
|
172 class TEqLayoutSaxParser : private SAX::basic_DefaultHandler<std::string> |
|
173 { |
|
174 private: |
|
175 typedef stack<MSaxLayoutEqHandler*> TSaxHandlerStack; |
|
176 typedef SAX::basic_ErrorHandler<std::string>::SAXParseExceptionT TException; |
|
177 |
|
178 public: |
|
179 TEqLayoutSaxParser(MSaxLayoutEqHandler* aHandler); |
|
180 void Parse(const std::string& aFileName); |
|
181 |
|
182 private: // from basic_DefaultHandler |
|
183 void startElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName, const SAX::basic_Attributes<std::string>& atts); |
|
184 void endElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName); |
|
185 |
|
186 void warning(const TException& aException); |
|
187 void error(const TException& aException); |
|
188 void fatalError(const TException& aException); |
|
189 |
|
190 private: |
|
191 TSaxHandlerStack iStack; // stack content not owned |
|
192 }; |
|
193 |
|
194 |
|
195 #endif // MLEQCOMPDATAPARSE_H |
|
196 |
|
197 // End of File |