merge with master
[platform/framework/native/uifw.git] / src / ui / resource / FUi_ResourceConfigParser.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUi_ResourceConfigParser.cpp
20  * @brief       This is the header file for the ConfigParser.
21  *
22  * This header file contains the declarations of the ConfigParser.
23  */
24
25 #include <FBaseByteBuffer.h>
26 #include <FBaseInteger.h>
27 #include <FBaseString.h>
28 #include <FBaseSysLog.h>
29 #include <FBaseColHashMapT.h>
30 #include <FIoFile.h>
31 #include <FGrpColor.h>
32 #include <FGrpDimension.h>
33 #include <FBase_StringConverter.h>
34 #include "FUi_CoordinateSystemUtils.h"
35 #include "FUi_ResourceMapContainer.h"
36 #include "FUi_ResourceConfigParser.h"
37
38 using namespace Tizen::Base;
39 using namespace Collection;
40 using namespace Tizen::Io;
41 using namespace Tizen::Graphics;
42
43 namespace
44 {
45 class _ColorMatchingMapProvider
46         : public IHashCodeProviderT <String>
47 {
48 public:
49         _ColorMatchingMapProvider(void) {}
50         virtual ~_ColorMatchingMapProvider(void) {}
51
52         virtual int GetHashCode(const String& obj) const
53         {
54                 return obj.GetHashCode();
55         }
56 };
57
58 class _ColorMatchingMapComparer
59         : public IComparerT <String>
60 {
61 public:
62         _ColorMatchingMapComparer(void) {}
63         virtual ~_ColorMatchingMapComparer(void) {}
64         virtual result Compare(const String& obj1, const String& obj2, int& cmp) const
65         {
66                 if (obj1 == obj2)
67                 {
68                         cmp = 0;
69                         return E_SUCCESS;
70                 }
71                 else
72                 {
73                         cmp = -1;
74                         return E_SUCCESS;
75                 }
76         }
77 };
78 }
79
80 namespace
81 {
82 xmlSAXHandler mySaxHandler = {null, null, null, null, null, null, null, null, null, null, null, null, null, null,
83                                                         Tizen::Ui::_Resource::ConfigParser::StartSaxFunc,
84                                                         null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null};
85 }
86
87 namespace Tizen { namespace Ui { namespace _Resource
88 {
89 ConfigParser* pConfigXmlHandler = null;
90 HashMapT<String, String*>* pColorMatchingMap = null;
91
92 ConfigParser::ColorMatchingMap::ColorMatchingMap(void)
93         :HashMapT<String, String*>()
94         , __pProvider(null)
95         , __pComparer(null)
96 {
97         __pProvider = new (std::nothrow) _ColorMatchingMapProvider;
98         SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
99         __pComparer = new (std::nothrow) _ColorMatchingMapComparer;
100         SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
101 }
102 ConfigParser::ColorMatchingMap::~ColorMatchingMap(void)
103 {
104         result r = E_SUCCESS;
105         Collection::IMapEnumeratorT< String, String* >* pMapEnum = null;
106         if (Collection::HashMapT<String, String*>::GetCount() > 0)
107         {
108                 pMapEnum = Collection::HashMapT<String, String*>::GetMapEnumeratorN();
109                 SysTryReturn(NID_UI_ANIM, (pMapEnum != null), , E_SYSTEM, "[E_SYSTEM] System Error.");
110
111                 Collection::MapEntryT< String, String* > value;
112                 while ((pMapEnum->MoveNext() == E_SUCCESS))
113                 {
114                         r = pMapEnum->GetCurrent(value);
115                         SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error.");
116
117                         String* pObj = value.GetValue();
118                         delete pObj;
119                 }
120                 Collection::HashMapT<String, String*>::RemoveAll();
121         }
122         //fall through
123         CATCH:
124         delete pMapEnum;
125         delete __pProvider;
126         __pProvider = null;
127         delete __pComparer;
128         __pComparer = null;
129 }
130 bool
131 ConfigParser::ColorMatchingMap::Initialize(const String& version, const String& dVersion)
132 {
133         if (HashMapT<String, String*>::Construct(0,0,*__pProvider, *__pComparer) != E_SUCCESS)
134         {
135                 return false;
136         }
137         /*
138         if(version == L"beta1")
139         {
140                 Add(L"W0612", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text_disabled"));
141                 Add(L"B0622", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_01"));
142                 Add(L"B0231", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_01"));
143                 Add(L"B022", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_01"));
144
145                 Add(L"B011", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_bg"));
146                 Add(L"B012", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_group_list_bg"));
147                 Add(L"B013", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_black"));
148                 Add(L"B014", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_white"));
149                 Add(L"B015", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_list_reorder_bg"));
150                 Add(L"B0211", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_bg"));
151                 Add(L"B0211D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_bg_disabled"));
152                 Add(L"B0212", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_item_bg"));
153                 Add(L"B0213", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_grid_item_bg"));
154                 Add(L"B0214", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_2nd_depth_item_bg"));
155                 Add(L"B0215", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_bg"));
156                 Add(L"B0216", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_select_all_item_bg"));
157                 Add(L"B0217", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bg"));
158                 Add(L"B0217D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bg_disabled"));
159                 Add(L"B0221", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_01"));
160                 Add(L"B0222", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_02"));
161                 Add(L"B0231L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_01"));
162                 Add(L"B0231L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_02"));
163                 Add(L"B0232", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bar"));
164                 Add(L"B0233", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_top_line"));
165                 Add(L"B031", new (std::nothrow) String(L"DEFAULTCOLORTABLE::indicator_bg"));
166                 Add(L"B041", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_bg_pressed"));
167                 Add(L"B042", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_item_bg_pressed"));
168                 Add(L"B043", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_item_bg_pressed"));
169                 Add(L"B044", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_bg_pressed"));
170                 Add(L"B0511", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_bg"));
171                 Add(L"B0512", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_optiontray_bg"));
172                 Add(L"B0513", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_bg"));
173                 Add(L"B0514", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg"));
174                 Add(L"B0514P1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg_selected"));
175                 Add(L"B0514P2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg_edit"));
176                 Add(L"B0515", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_toolbar_bg"));
177                 Add(L"B0516", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_toolbar_item_bg_pressed"));
178                 Add(L"B0517", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_bg"));
179                 Add(L"B0517P1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_selected"));
180                 Add(L"B0517P2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_bg_edit"));
181                 Add(L"B0518", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_item_bg"));
182                 Add(L"B0518P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_bg"));
183                 Add(L"B0520", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_bg_normal"));
184                 Add(L"B0520P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_bg_pressed"));
185                 Add(L"B052L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_normal"));
186                 Add(L"B052L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_selected"));
187                 Add(L"B052L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_disabled"));
188                 Add(L"B052L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_normal"));
189                 Add(L"B052L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_more_icon_pressed"));
190                 Add(L"B052L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_font_normal"));
191                 Add(L"B052L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_normal"));
192                 Add(L"B052L4P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_pressed"));
193                 Add(L"B052L4D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_disabled"));
194                 Add(L"B052L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_title_text_normal"));
195                 Add(L"B052L6", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_text_normal"));
196                 Add(L"B052L6P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_text_pressed"));
197                 Add(L"B052L8", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_normal"));
198                 Add(L"B052L8P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_pressed"));
199                 Add(L"B052L8D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_disabled"));
200                 Add(L"B052L9", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_normal"));
201                 Add(L"B052L9P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_pressed"));
202                 Add(L"B052L9D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_disabled"));
203                 Add(L"B0531", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_item_bg_normal"));
204                 Add(L"B0532", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_item_bg_selected"));
205                 Add(L"B0533", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_segment_item_bg_normal"));
206                 Add(L"B0534", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_segment_item_bg_selected"));
207                 Add(L"B0535", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_segment_item_bg_normal"));
208                 Add(L"B0536", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_segment_item_bg_selected"));
209                 Add(L"B0537", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_expandable_line"));
210                 Add(L"B0545", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_button_item_bg_pressed"));
211                 Add(L"B0556", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg"));
212                 Add(L"B0557", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg_normal"));
213                 Add(L"B0558", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg_pressed"));
214                 Add(L"B061L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_bg"));
215                 Add(L"B061L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_title_bg"));
216                 Add(L"B061L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_bottom_bg"));
217                 Add(L"B061L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_bg"));
218                 Add(L"B0621", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_list_item_divider"));
219                 Add(L"B0622L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_01"));
220                 Add(L"B0622L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_02"));
221                 Add(L"B0623L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_grid_item_divider_01"));
222                 Add(L"B0623L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_grid_item_divider_02"));
223                 Add(L"B063L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_text"));
224                 Add(L"B063L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_pressed"));
225                 Add(L"B063L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::ticker_detail_text"));
226                 Add(L"B063L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_progress_text"));
227                 Add(L"B063L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_title_text"));
228                 Add(L"B063L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_normal"));
229                 Add(L"B063L5D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_disabled"));
230                 Add(L"B071", new (std::nothrow) String(L"DEFAULTCOLORTABLE::scroll_bar_bg"));
231                 Add(L"B0721", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_text_normal"));
232                 Add(L"B0722", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_text_selected"));
233                 Add(L"B0723", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_bg"));
234                 Add(L"B0724", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_line_01"));
235                 Add(L"B0725", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_line_02"));
236                 Add(L"B0731", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_popup_bg"));
237                 Add(L"B0732", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_popup_text"));
238                 Add(L"B0741", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_text_normal"));
239                 Add(L"B0742", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_text_selected"));
240                 Add(L"B0743", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_bg"));
241                 Add(L"B0744", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_line_01"));
242                 Add(L"B0745", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_line_02"));
243                 Add(L"B0751", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_popup_bg"));
244                 Add(L"F011L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_normal"));
245                 Add(L"F011L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_pressed"));
246                 Add(L"F011L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_disabled"));
247                 Add(L"F011L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_setting_normal"));
248                 Add(L"F011L2D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_setting_disabled"));
249                 Add(L"F011L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_title_normal"));
250                 Add(L"F011L3D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_title_disabled"));
251                 Add(L"F011L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_read_normal"));
252                 Add(L"F011L4D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_read_disabled"));
253                 Add(L"F011L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_title_text"));
254                 Add(L"F011L6", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_no_content_text"));
255                 Add(L"F011L7", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_3line_2nd_text_normal"));
256                 Add(L"F011L7D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_3line_2nd_text_disabled"));
257                 Add(L"F011L8", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_invalid"));
258                 Add(L"F011L9", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_white"));
259                 Add(L"F011L10", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_bubble_text"));
260                 Add(L"F011L11", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_contact_text"));
261                 Add(L"F011L12", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_name_text"));
262                 Add(L"F011L13", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_edit_mode_text_01"));
263                 Add(L"F011L14", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_edit_mode_text_02"));
264                 Add(L"F011L15", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_failed_text"));
265                 Add(L"F011L16", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_sent_text"));
266                 Add(L"F011L17", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_receive_text"));
267                 Add(L"F011L18", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_date_text"));
268                 Add(L"F011L19", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_group_chat_name_text"));
269                 Add(L"F011L20", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sweep_text"));
270                 Add(L"F011L21", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_help_text"));
271                 Add(L"F011L22", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_help_text"));
272                 Add(L"F021L1i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_normal"));
273                 Add(L"F021L1iP", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_pressed"));
274                 Add(L"F021L1iD", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_disabled"));
275                 Add(L"F022L1i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_star_icon_normal"));
276                 Add(L"F022L2i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_star_icon_selected"));
277                 Add(L"F031L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_normal"));
278                 Add(L"F031L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_pressed"));
279                 Add(L"F031L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_disabled"));
280                 Add(L"F031L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_normal"));
281                 Add(L"F031L3P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_pressed"));
282                 Add(L"F031L3D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_disabled"));
283                 Add(L"F032L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_normal"));
284                 Add(L"F032L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_pressed"));
285                 Add(L"F032L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_disabled"));
286                 Add(L"F032L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_normal"));
287                 Add(L"F032L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_pressed"));
288                 Add(L"F032L2D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_disabled"));
289                 Add(L"F041i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_icon_normal"));
290                 Add(L"F041iD", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_icon_disabled"));
291                 Add(L"F051", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_guide_text"));
292                 Add(L"F052", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_cursor"));
293                 Add(L"W011", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_bg"));
294                 Add(L"W012", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_button_bg"));
295                 Add(L"W013", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_item_button_bg"));
296                 Add(L"W0141", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_delete_button_bg_normal"));
297                 Add(L"W0141P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_delete_button_bg_pressed"));
298                 Add(L"W021L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_bg_normal"));
299                 Add(L"W021L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_bg_pressed"));
300                 Add(L"W021L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_line_normal"));
301                 Add(L"W021L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_line_pressed"));
302                 Add(L"W021L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_text_normal"));
303                 Add(L"W021L3P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_text_pressed"));
304                 Add(L"W031", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_field_bg_normal"));
305                 Add(L"W031D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_field_bg_disabled"));
306                 Add(L"W032", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_text_normal"));
307                 Add(L"W032D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_text_disabled"));
308                 Add(L"W041", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_bg"));
309                 Add(L"W0611", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text"));
310                 Add(L"W0611D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text_disabled"));
311                 Add(L"W062L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bar_bg"));
312                 Add(L"W062L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bar"));
313                 Add(L"W062L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::progress_circle_bar_bg"));
314                 Add(L"W062L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::progress_circle_bar"));
315                 Add(L"W063", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bubble_bg"));
316                 Add(L"W0641", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg"));
317                 Add(L"W0641P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg_pressed"));
318                 Add(L"W0641D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg_disabled"));
319                 Add(L"W0711", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_bg_normal"));
320                 Add(L"W0712", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_outline_normal"));
321                 Add(L"W0713", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_bg_pressed"));
322                 Add(L"W0714", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_outline_pressed"));
323                 Add(L"W0721", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_expansion_button_bg"));
324                 Add(L"W0811", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_bg"));
325                 Add(L"W0812", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_button_bg"));
326                 Add(L"W082", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_bg"));
327                 Add(L"W083", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_keypad_button_bg"));
328                 Add(L"W084", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_text_normal"));
329                 Add(L"W084P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_text_pressed"));
330                 Add(L"W101", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_bg_pressed"));
331                 Add(L"W111", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_bg"));
332                 Add(L"W1121", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_normal"));
333                 Add(L"W1122", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_pressed"));
334                 Add(L"W1123", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_disabled"));
335                 Add(L"W1211", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_bg"));
336                 Add(L"W1212", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_inputmode_bg"));
337                 Add(L"W1221", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text"));
338                 Add(L"W1222", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text_inputmode"));
339                 Add(L"W1223", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text_pressed"));
340                 Add(L"W131", new (std::nothrow) String(L"DEFAULTCOLORTABLE::splitpanel_divider_bg"));
341                 Add(L"W132", new (std::nothrow) String(L"DEFAULTCOLORTABLE::splitpanel_divider_bg_pressed"));
342                 Add(L"W141", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_no_content_icon"));
343                 Add(L"W151", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_normal"));
344                 Add(L"W152", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_loading"));
345                 Add(L"W153", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_selected"));
346         }
347         */
348         return true;
349 }
350 HashMapT<String, String*>*
351 ConfigParser::GetMatchingTable(void)
352 {
353         return pColorMatchingMap;
354 }
355
356 ConfigParser::ConfigParser(void)
357         : __pMapContainer(null)
358         , __currentAttribute(L"")
359         , __pCurrentAnimationList(null)
360 {
361 }
362 ConfigParser::~ConfigParser(void)
363 {
364         delete pColorMatchingMap;
365         pColorMatchingMap = null;
366 }
367 bool
368 ConfigParser::Parse(const String& filename, MapContainer & table)
369 {
370         File file;
371         ByteBuffer buffer;
372         FileAttributes attrib;
373         int readCount = 0;
374         byte* pXmlContents = null;
375         result r = E_SUCCESS;
376         int size = 0;
377
378         if (!File::IsFileExist(filename))
379         {
380                 return false;
381         }
382         r = file.Construct(filename, L"r");
383         if (IsFailed(r))
384         {
385                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- XML file Construct.");
386                 return false;
387         }
388
389         r = Tizen::Io::File::GetAttributes(filename, attrib);
390         if (IsFailed(r))
391         {
392                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- XML file GetAttributes.");
393                 return false;
394         }
395         size = (int) attrib.GetFileSize();
396
397         r = buffer.Construct(size);
398         if (IsFailed(r))
399         {
400                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed - Buffer Construct Failed.");
401                 return false;
402         }
403
404         r = file.Read(buffer);
405         if (IsFailed(r))
406         {
407                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- can't read the file.");
408                 return false;
409         }
410
411         readCount = buffer.GetPosition();
412         pXmlContents = new (std::nothrow) byte[readCount];
413         SysTryReturn(NID_UI, pXmlContents != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create XmlContents.");
414         buffer.Flip();
415
416         r = buffer.GetArray(pXmlContents, 0, readCount);
417         if (IsFailed(r))
418         {
419                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- buffer.GetArray is Failed.");
420                 delete[] pXmlContents;
421                 return false;
422         }
423         char* pXmlBuffer = (char*) pXmlContents;
424
425         __pMapContainer = &table;
426         pConfigXmlHandler = this;
427         xmlSAXHandlerPtr pMySaxhandler = &mySaxHandler;
428         xmlSubstituteEntitiesDefault(1);
429         xmlSAXUserParseMemory(pMySaxhandler, null, pXmlBuffer, readCount);
430         pConfigXmlHandler = null;
431         delete [] pXmlContents;
432         return true;
433 }
434 void
435 ConfigParser::StartSaxFunc(void* pXmlParserCtxt, const xmlChar* pName, const xmlChar** pAttributes)
436 {
437         if (xmlStrcasecmp(pName, (xmlChar*) "Image") == 0)
438         {
439                 pConfigXmlHandler->AddImage(pAttributes);
440         }
441         else if (xmlStrcasecmp(pName, (xmlChar*) "Color") == 0)
442         {
443                 pConfigXmlHandler->AddColor(pAttributes);
444         }
445         else if (xmlStrcasecmp(pName, (xmlChar*) "Theme") == 0)
446         {
447                 pConfigXmlHandler->SetInformation(pAttributes);
448         }
449         else if (xmlStrcasecmp(pName, (xmlChar*) "Palette") == 0)
450         {
451                 pConfigXmlHandler->StartAttribute(pAttributes);
452         }
453         else if (xmlStrcasecmp(pName, (xmlChar*) "Control") == 0)
454         {
455                 pConfigXmlHandler->StartAttribute(pAttributes);
456         }
457         else if (xmlStrcasecmp(pName, (xmlChar*) "Animation") == 0)
458         {
459                 pConfigXmlHandler->AddAnimation(pAttributes);
460         }
461         else if (xmlStrcasecmp(pName, (xmlChar*) "AnimationFrame") == 0)
462         {
463                 pConfigXmlHandler->AddAnimationFrame(pAttributes);
464         }
465         else
466         {
467                 ;//nothing to do
468         }
469 }
470
471 void
472 ConfigParser::SetInformation(const xmlChar** pAttributes)
473 {
474         if (pAttributes != null)
475         {
476                 for (int i = 0; (pAttributes[i] != null); i++)
477                 {
478                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Version") == 0)
479                         {
480                                 String version = (char*) pAttributes[++i];
481                                 __pMapContainer->SetVersion(version);
482 //                              ColorMatchingMap* matchingMap = new ColorMatchingMap;
483 //                              if (!matchingMap->Initialize(version))
484 //                              {
485 //                                      delete matchingMap;
486 //                              }
487 //                              else
488 //                              {
489 //                                      pColorMatchingMap = matchingMap;
490 //                              }
491                         }
492                 }
493         }
494 }
495
496 void
497 ConfigParser::StartAttribute(const xmlChar** pAttributes)
498 {
499         if (pAttributes != null)
500         {
501                 for (int i = 0; (pAttributes[i] != null); i++)
502                 {
503                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Name") == 0)
504                         {
505                                 __currentAttribute = (char*) pAttributes[++i];
506                         }
507                 }
508         }
509 }
510
511 void
512 ConfigParser::AddColor(const xmlChar** pAttributes)
513 {
514         if (pAttributes != null)
515         {
516                 for (int i = 0; (pAttributes[i] != null); i++)
517                 {
518                         if (pAttributes[++i] != null)
519                         {
520                                 bool exist = false;
521                                 String key = __currentAttribute + L"::" + (char*) pAttributes[i - 1];
522                                 if(__pMapContainer->GetColorMap()->ContainsKey(key, exist) == E_SUCCESS)
523                                 {
524                                         if(exist)
525                                         {
526                                                 Color color;
527                                                 GetValue((char*) pAttributes[i], color);
528 //                                              SysLog(NID_UI,"The resource config parser changes resource color value, key %s, color %s", pAttributes[i - 1], pAttributes[i]);
529                                                 __pMapContainer->GetColorMap()->SetValue(key,&color);
530                                         }
531                                         else
532                                         {
533                                                 Color* pColor = new (std::nothrow) Color();
534                                                 SysTryReturnVoidResult(NID_UI, pColor, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
535 //                                              SysLog(NID_UI,"The resource config parser adds resource color, key %s, color %s", pAttributes[i - 1], pAttributes[i]);
536                                                 GetValue((char*) pAttributes[i], *pColor);
537                                                 result r = __pMapContainer->GetColorMap()->Add(key, pColor);
538                                                 if(r != E_SUCCESS)
539                                                 {
540                                                         SysAssert(0);
541                                                 }
542                                         }
543                                 }
544                         }
545                 }
546         }
547 }
548
549 void
550 ConfigParser::AddImage(const xmlChar** pAttributes)
551 {
552         if (pAttributes != null)
553         {
554                 for (int i = 0; (pAttributes[i] != null); i++)
555                 {
556                         if (pAttributes[++i] != null)
557                         {
558                                 bool exist = false;
559                                 String key = __currentAttribute + L"::" + (char*) pAttributes[i - 1];
560                                 if(__pMapContainer->GetImageMap()->ContainsKey(key, exist) == E_SUCCESS)
561                                 {
562                                         if(exist)
563                                         {
564                                                 String value((char*) pAttributes[i]);
565                                                 value.SubString(1, value);
566                                                 __pMapContainer->GetImageMap()->SetValue(key,&value);
567                                         }
568                                         else
569                                         {
570                                                 String* pString = new (std::nothrow) String((char*) pAttributes[i]);
571                                                 SysTryReturnVoidResult(NID_UI, pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
572                                                 pString->SubString(1,*pString);
573                                                 result r = __pMapContainer->GetImageMap()->Add(key, pString);
574                                                 if(r != E_SUCCESS)
575                                                 {
576                                                         SysAssert(0);
577                                                 }
578                                         }
579                                 }
580                         }
581                 }
582         }
583 }
584
585 void
586 ConfigParser::AddAnimation(const xmlChar** pAttributes)
587 {
588         __pCurrentAnimationList = null;
589         if (pAttributes != null)
590         {
591                 for (int i = 0; (pAttributes[i] != null); i++)
592                 {
593                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Name") == 0)
594                         {
595                                 bool exist = false;
596                                 String key =__currentAttribute + L"::" + (char*) pAttributes[++i];
597                                 if(__pMapContainer->GetAnimationMap()->ContainsKey(key, exist) == E_SUCCESS)
598                                 {
599                                         if(exist)
600                                         {
601                                                 __pMapContainer->GetAnimationMap()->GetValue(key,__pCurrentAnimationList);
602                                                 __pCurrentAnimationList->Clear();
603                                         }
604                                         else
605                                         {
606                                                 __pCurrentAnimationList = new ResourceAnimationFrameList();
607                                         }
608                                 }
609                         }
610                 }
611         }
612 }
613 void
614 ConfigParser::AddAnimationFrame(const xmlChar** pAttributes)
615 {
616         ResourceAnimationFrame* pFrame = null;
617         String fileName;
618         String duration;
619         if (pAttributes != null)
620         {
621                 for (int i = 0; (pAttributes[i] != null); i++)
622                 {
623                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Image") == 0)
624                         {
625                                 fileName = (char*) pAttributes[++i];
626                                 fileName.SubString(1, fileName);
627                         }
628                         if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Duration") == 0)
629                         {
630                                 duration = (char*) pAttributes[++i];
631                         }
632                 }
633         }
634         if (!fileName.IsEmpty() && !duration.IsEmpty())
635         {
636                 int durationInt =0;
637                 if (Integer::Parse(duration, durationInt) == E_SUCCESS)
638                 {
639                         pFrame = new (std::nothrow) ResourceAnimationFrame(fileName, durationInt);
640                         SysTryReturn(NID_UI, pFrame, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
641                         __pCurrentAnimationList->Add(*pFrame);
642                 }
643         }
644 }
645
646 void
647 ConfigParser::ConvertStringToColor32(const char* pString, Color& color)
648 {
649         int index = 0;
650         int len = 0;
651         int gap = 0;
652         char ch;
653         unsigned int temp = 0;
654
655         len = strlen(pString);
656
657         if (len < 1)
658         {
659                 SysLog(NID_UI, "String is empty");
660                 return;
661         }
662
663         for (index = 1; index < len + 1; index++)
664         {
665                 ch = pString[index];
666                 if ((ch >= '0') && (ch <= '9'))
667                 {
668                         temp = temp << 4;
669                         gap = ch - '0';
670                         temp |= gap;
671
672                 }
673                 else if ((ch >= 'A') && (ch <= 'F'))
674                 {
675                         temp = temp << 4;
676                         gap = ch - 'A' + 10;
677                         temp |= gap;
678
679                 }
680                 else if ((ch >= 'a') && (ch <= 'f'))
681                 {
682                         temp = temp << 4;
683                         gap = ch - 'a' + 10;
684                         temp |= gap;
685                 }
686         }
687         color.SetRGB32(temp, true);
688 }
689
690 void
691 ConfigParser::GetValue(const String& value, String& out)
692 {
693         if (value.StartsWith(L"#", 0))
694         {
695                 value.SubString(1, out);
696         }
697         else if (value.StartsWith(L"$", 0))
698         {
699                 String* pString = null;
700                 if(__pMapContainer->GetImageMap()->GetValue(value, pString) != E_SUCCESS)
701                 {
702                         SysAssert(0);
703                 }
704                 out = *pString;
705         }
706         else
707         {
708                 //nothing to do
709         }
710 }
711 void
712 ConfigParser::GetValue(const String& value, Color& out)
713 {
714         if (value.StartsWith(L"#", 0))
715         {
716                 char* pString = _StringConverter::CopyToCharArrayN(value);
717                 ConvertStringToColor32(pString, out);
718                 delete [] pString;
719         }
720         else if (value.StartsWith(L"$", 0))
721         {
722                 Color* pColor = null;
723                 String key(L"");
724                 value.SubString(1, key);
725                 if(__pMapContainer->GetColorMap()->GetValue(key, pColor) != E_SUCCESS)
726                 {
727                         SysAssert(0);
728                 }
729                 out = *pColor;
730         }
731         else
732         {
733                 //nothing to do
734         }
735 }
736
737 }}}//Tizen::Ui