Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Split frmContactEditor-Load.cpp into 24 files to make it more manageable.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadLanguage.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadLanguage(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *LangCount){
5         std::map<int, int> SplitPoints;
6         std::map<int, int> SplitLength;
7         std::map<int, int>::iterator SLiter;                    
8         wxString PropertyData;
9         wxString PropertyName;
10         wxString PropertyValue;
11         wxString PropertyTokens;
12         bool FirstToken = TRUE;
13         int intPrevValue = 6;
14         int intPref = 0;                        
15         int intType = 0;
16         long ListCtrlIndex;
17         
18         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
19         
20         intPrevValue = 5;
21         
22         // Look for type before continuing.
23         
24         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
25         intiter != SplitPoints.end(); ++intiter){
26         
27                 SLiter = SplitLength.find(intiter->first);
28         
29                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
30                 
31                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32                 PropertyName = PropertyElement.GetNextToken();                          
33                 PropertyValue = PropertyElement.GetNextToken();
34                 
35                 intPrevValue = intiter->second;
36                 
37                 if (PropertyName == wxT("TYPE")){
38                 
39                         if (PropertyValue == wxT("work")){
40                         
41                                 intType = 2;                                    
42                         
43                         } else if (PropertyValue == wxT("home")){
45                                 intType = 1;
46                         
47                         } else {
48                         
49                                 intType = 0;
50                         
51                         }
52                 
53                 }
54         
55         }
56         
57         // Setup blank lines for later on.
58         
59         if (intType == 0){
60         
61                 GeneralLanguageList.insert(std::make_pair(intValueSeek, wxT("")));
62                 GeneralLanguageListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63                 GeneralLanguageListPID.insert(std::make_pair(intValueSeek, wxT("")));
64                 GeneralLanguageListPref.insert(std::make_pair(intValueSeek, 0));
65                 GeneralLanguageListTokens.insert(std::make_pair(intValueSeek, wxT("")));
67         } else if (intType == 1){
68         
69                 HomeLanguageList.insert(std::make_pair(intValueSeek, wxT("")));
70                 HomeLanguageListAltID.insert(std::make_pair(intValueSeek, wxT("")));
71                 HomeLanguageListPID.insert(std::make_pair(intValueSeek, wxT("")));
72                 HomeLanguageListPref.insert(std::make_pair(intValueSeek, 0));
73                 HomeLanguageListTokens.insert(std::make_pair(intValueSeek, wxT("")));
74         
75         } else if (intType == 2){
77                 BusinessLanguageList.insert(std::make_pair(intValueSeek, wxT("")));
78                 BusinessLanguageListAltID.insert(std::make_pair(intValueSeek, wxT("")));
79                 BusinessLanguageListPID.insert(std::make_pair(intValueSeek, wxT("")));
80                 BusinessLanguageListPref.insert(std::make_pair(intValueSeek, 0));
81                 BusinessLanguageListTokens.insert(std::make_pair(intValueSeek, wxT("")));
82         
83         }
84         
85         intPrevValue = 5;                       
86         
87         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
88         intiter != SplitPoints.end(); ++intiter){
89         
90                 SLiter = SplitLength.find(intiter->first);
91         
92                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
93                 
94                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
95                 PropertyName = PropertyElement.GetNextToken();                          
96                 PropertyValue = PropertyElement.GetNextToken();
97                 
98                 intPrevValue = intiter->second;
99                 
100                 // Process properties.
101                 
102                 size_t intPropertyValueLen = PropertyValue.Len();
103                 
104                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
105                         
106                         PropertyValue.Trim();
107                         PropertyValue.RemoveLast();
108                         
109                 }                               
110                 
111                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
112                         
113                         PropertyValue.Remove(0, 1);
114                         
115                 }
116                 
117                 ProcessCaptureStrings(&PropertyValue);                          
118                 
119                 if (PropertyName == wxT("ALTID")){
121                         if (intType == 0){ GeneralLanguageListAltID.erase(intValueSeek); GeneralLanguageListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
122                         else if (intType == 1){ HomeLanguageListAltID.erase(intValueSeek); HomeLanguageListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
123                         else if (intType == 2){ BusinessLanguageListAltID.erase(intValueSeek); BusinessLanguageListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
124                 
125                 } else if (PropertyName == wxT("PID")){
127                         if (intType == 0){ GeneralLanguageListPID.erase(intValueSeek); GeneralLanguageListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128                         else if (intType == 1){ HomeLanguageListPID.erase(intValueSeek); HomeLanguageListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129                         else if (intType == 2){ BusinessLanguageListPID.erase(intValueSeek); BusinessLanguageListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
130                 
131                 } else if (PropertyName == wxT("PREF")){
132                         
133                         intPref = wxAtoi(PropertyValue);
134                 
135                         if (intType == 0){ GeneralLanguageListPref.erase(intValueSeek); GeneralLanguageListPref.insert(std::make_pair(intValueSeek, intPref)); }
136                         else if (intType == 1){ HomeLanguageListPref.erase(intValueSeek); HomeLanguageListPref.insert(std::make_pair(intValueSeek, intPref)); }
137                         else if (intType == 2){ BusinessLanguageListPref.erase(intValueSeek); BusinessLanguageListPref.insert(std::make_pair(intValueSeek, intPref)); }
138                 
139                 } else {
140                 
141                         // Something else we don't know about so append
142                         // to the tokens variable.
143                 
144                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
145                 
146                                 if (FirstToken == TRUE){
147                         
148                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
149                                         FirstToken = FALSE;
150                         
151                                 } else {
152                         
153                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
154                         
155                                 }
156                 
157                         }
158                 
159                 }
160         
161         }       
162         
163         // Add the data to the General/Home/Work address variables.
164         
165         ProcessCaptureStrings(&wxSPropertySeg2);
166         
167         wxListItem coldata;
169         coldata.SetId(intValueSeek);
170         coldata.SetData(intValueSeek);
171         coldata.SetText(wxSPropertySeg2);
172         
173         if (intType == 0){
174         
175                 ListCtrlIndex = lboLanguages->InsertItem(coldata);
176                 
177                 if (intPref > 0 && intPref < 101){
178                 
179                         lboLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
180                         
181                 }
182                 
183                 GeneralLanguageList.erase(intValueSeek);
184                 GeneralLanguageListType.erase(intValueSeek);
185                 GeneralLanguageListTokens.erase(intValueSeek);
186                 GeneralLanguageList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
187                 GeneralLanguageListType.insert(std::make_pair(intValueSeek, wxT("")));
188                 GeneralLanguageListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
189         
190         } else if (intType == 1){ 
191         
192                 ListCtrlIndex = lboHomeLanguages->InsertItem(coldata);
194                 if (intPref > 0 && intPref < 101){
195                 
196                         lboHomeLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
197                         
198                 }
200                 HomeLanguageList.erase(intValueSeek);
201                 HomeLanguageListType.erase(intValueSeek);
202                 HomeLanguageListTokens.erase(intValueSeek);                             
203                 HomeLanguageList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
204                 HomeLanguageListType.insert(std::make_pair(intValueSeek, wxT("home")));
205                 HomeLanguageListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
206         
207         } else if (intType == 2){ 
208         
209                 ListCtrlIndex = lboBusinessLanguages->InsertItem(coldata);
211                 if (intPref > 0 && intPref < 101){
212                 
213                         lboBusinessLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
214                         
215                 }
217                 BusinessLanguageList.erase(intValueSeek);
218                 BusinessLanguageListType.erase(intValueSeek);
219                 BusinessLanguageListTokens.erase(intValueSeek);                         
220                 BusinessLanguageList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
221                 BusinessLanguageListType.insert(std::make_pair(intValueSeek, wxT("work")));
222                 BusinessLanguageListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                                
223         
224         }
225         
226         LangCount++;
227         intValueSeek++;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy