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-LoadName.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadFN(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *FNCount, 
4         bool *FNProcessed, vCard *ContactData){
5         
6         size_t intPropertyLen = wxSPropertySeg1.Len();
7         std::map<int, int> SplitPoints;
8         std::map<int, int> SplitLength;
9         std::map<int, int>::iterator SLiter;                    
10         wxString PropertyData;
11         wxString PropertyName;
12         wxString PropertyValue;
13         wxString PropertyTokens;
14         bool FirstToken = TRUE;                 
15         int intSplitsFound = 0;
16         int intSplitSize = 0;
17         int intPrevValue = 4;
18         int intPref = 0;                        
19         int intType = 0;
20         
21         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
22         
23         intPrevValue = 3;
24         
25         // Look for type before continuing.             
26         
27         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
28         intiter != SplitPoints.end(); ++intiter){
29         
30                 SLiter = SplitLength.find(intiter->first);
31         
32                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
33                 
34                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
35                 PropertyName = PropertyElement.GetNextToken();                          
36                 PropertyValue = PropertyElement.GetNextToken();
37                 
38                 intPrevValue = intiter->second;
39                 
40                 if (PropertyName == wxT("TYPE")){
41                 
42                         if (PropertyValue == wxT("work")){
43                         
44                                 intType = 2;                                    
45                         
46                         } else if (PropertyValue == wxT("home")){
48                                 intType = 1;
49                         
50                         } else {
51                         
52                                 intType = 0;
53                         
54                         }
55                 
56                 }
57         
58         }
59         
60         // Setup blank lines for later on.
62         FullNamesList.insert(std::make_pair(intValueSeek, wxT("")));
63         FullNamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
64         FullNamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
65         FullNamesListPref.insert(std::make_pair(intValueSeek, 0));
66         FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
67         FullNamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68         FullNamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));              
69         
70         intPrevValue = 3;
71         
72         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
73         intiter != SplitPoints.end(); ++intiter){
74         
75                 SLiter = SplitLength.find(intiter->first);
76         
77                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
78                 
79                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
80                 PropertyName = PropertyElement.GetNextToken();                          
81                 PropertyValue = PropertyElement.GetNextToken();
82                 
83                 ProcessCaptureStrings(&PropertyValue);
84                 
85                 intPrevValue = intiter->second;
86                 
87                 // Process properties.
88                 
89                 if (PropertyName == wxT("ALTID")){
91                         FullNamesListAltID.erase(intValueSeek); FullNamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
92                 
93                 } else if (PropertyName == wxT("PID")){
95                         FullNamesListPID.erase(intValueSeek); FullNamesListPID.insert(std::make_pair(intValueSeek, PropertyValue));
96                 
97                 } else if (PropertyName == wxT("PREF")){
98                         
99                         intPref = wxAtoi(PropertyValue);
100                         
101                         if (intPref > 0 && intPref < 101){
102                 
103                                 FullNamesListPref.erase(intValueSeek); FullNamesListPref.insert(std::make_pair(intValueSeek, intPref));
104                                 
105                         }
106                 
107                 } else if (PropertyName == wxT("LANG")){
109                         FullNamesListLanguage.erase(intValueSeek); FullNamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
110                 
111                 } else {
112                 
113                         // Something else we don't know about so append
114                         // to the tokens variable.
115                         
116                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
117                         
118                                 if (FirstToken == TRUE){
119                                 
120                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
121                                         FirstToken = FALSE;
122                                 
123                                 } else {
124                                 
125                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
126                                 
127                                 }
128                         
129                         }
130                 
131                 }
132         
133         }                       
134         
135         // Split the address.           
137         //std::map<int, int>::iterator SLiter;
138         intPropertyLen = wxSPropertySeg2.Len();
139         SplitPoints.clear();
140         SplitLength.clear();
141         intSplitsFound = 0;
142         intSplitSize = 0;
143         intPrevValue = 0;
144         
145         for (int i = 0; i <= intPropertyLen; i++){
147                 intSplitSize++;
148         
149                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
150         
151                         intSplitsFound++;
152                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
153                         
154                         if (intSplitsFound == 1){ 
155                         
156                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
157                                 break; 
158                                 
159                         }
160                         
161                         intSplitSize = 0;                                       
162         
163                 }
165         }                       
166         
167         // Add the data to the General/Home/Work address variables.
168         
169         /*
170         
171         wxListItem coldata;
173         coldata.SetId(intValueSeek);
174         coldata.SetData(intValueSeek);
175         coldata.SetText(IMPPType);
176         
177         */
178         
179         //ProcessCaptureStrings(wxsPropertySeg2);
180         
181         ProcessCaptureStrings(&wxSPropertySeg2);
182         
183         FullNamesList.erase(intValueSeek);
184         FullNamesListType.erase(intValueSeek);
185         FullNamesListTokens.erase(intValueSeek);
186         FullNamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
187         FullNamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
188         
189         if (intType == 0){
190         
191                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
192         
193         } else if (intType == 1){
194         
195                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("home")));                    
196         
197         } else if (intType == 2){
198         
199                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("work")));                    
200         
201         }
202         
203         if (*FNProcessed == FALSE){
204         
205                 NameDisplayAs = wxSPropertySeg2;
206                 cmbDisplayAs->SetValue(ContactData->Convert(wxSPropertySeg2, TRUE));
207                 *FNProcessed = TRUE;
208                 
209         }
210         
211         FNCount++;
212         intValueSeek++;
216 void frmContactEditor::LoadN(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *NameProcessed, 
217         vCard *ContactData){
219         size_t intPropertyLen = wxSPropertySeg1.Len();
220         std::map<int, int> SplitPoints;
221         std::map<int, int> SplitLength;
222         std::map<int, int>::iterator SLiter;                    
223         wxString PropertyData;
224         wxString PropertyName;
225         wxString PropertyValue;
226         wxString PropertyTokens;
227         bool FirstToken = TRUE;                 
228         int intSplitsFound = 0;
229         int intSplitSize = 0;
230         int intPrevValue = 3;
231         int intSplitSeek = 0;
232         
233         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
234         
235         // Look for type before continuing.             
236         
237         intPrevValue = 2;                       
238         
239         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
240         intiter != SplitPoints.end(); ++intiter){
241         
242                 SLiter = SplitLength.find(intiter->first);
243         
244                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
245                 
246                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
247                 PropertyName = PropertyElement.GetNextToken();                          
248                 PropertyValue = PropertyElement.GetNextToken();
249                 
250                 intPrevValue = intiter->second;
251         
252         }
253         
254         intPrevValue = 2;
255         
256         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
257         intiter != SplitPoints.end(); ++intiter){
258         
259                 SLiter = SplitLength.find(intiter->first);
260         
261                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
262                 
263                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
264                 PropertyName = PropertyElement.GetNextToken();                          
265                 PropertyValue = PropertyElement.GetNextToken();
266                 
267                 ProcessCaptureStrings(&PropertyValue);
268                 
269                 intPrevValue = intiter->second;
270                 
271                 // Process properties.
272                 
273                 if (PropertyName == wxT("ALTID")){
275                         NameAltID = PropertyValue;
276                 
277                 } else if (PropertyName == wxT("LANG")){
279                         NameLanguage = PropertyValue;
280                 
281                 } else if (PropertyName == wxT("SORT-AS")){
282                 
283                         NameDisplayAs = PropertyValue;
284                 
285                 } else {
286                 
287                         // Something else we don't know about so append
288                         // to the tokens variable.
289                         
290                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
291                         
292                                 if (FirstToken == TRUE){
293                                 
294                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
295                                         FirstToken = FALSE;
296                                 
297                                 } else {
298                                 
299                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
300                                 
301                                 }
302                         
303                         }
304                 
305                 }
306         
307         }
308         
309         intPropertyLen = wxSPropertySeg2.Len();
310         SplitPoints.clear();
311         SplitLength.clear();
312         intSplitSeek = 0;               
313         intSplitsFound = 0;
314         intSplitSize = 0;
315         intPrevValue = 0;                                       
316         
317         for (int i = 0; i <= intPropertyLen; i++){
319                 intSplitSize++;
320         
321                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
322         
323                         intSplitsFound++;
324                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
325                         
326                         if (intSplitsFound == 4){ 
327                         
328                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
329                                 break; 
330                                 
331                         } else {
332                         
333                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
334                         
335                         }
336                         
337                         intSplitSize = 0;                                       
338         
339                 }
341         }
342         
343         // Split the data into several parts.
344                         
345         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
346         intiter != SplitPoints.end(); ++intiter){
347         
348                 if (intiter->first == 1){
349                 
350                         // Deal with family name.
351                         
352                         SLiter = SplitLength.find(1);
353                                                                 
354                         txtSurname->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
355                         
356                         intPrevValue = intiter->second;
357                         NameSurname = wxSPropertySeg2.Mid(0, SLiter->second);                                   
358                 
359                 } else if (intiter->first == 2){
360                 
361                         // Deal with given names.
362                         
363                         SLiter = SplitLength.find(2);
364                                                                 
365                         txtForename->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
366                         intPrevValue = intiter->second;
367                         NameForename = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
368                 
369                 } else if (intiter->first == 3){
370                 
371                         // Deal with additional names.
372                         
373                         SLiter = SplitLength.find(3);
374                                                                 
375                         txtOtherNames->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
376                         intPrevValue = intiter->second;
377                         NameOtherNames = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
378                 
379                 } else if (intiter->first == 4){
380                 
381                         // Deal with honorifix prefixes and suffixes.
383                         SLiter = SplitLength.find(4);
384                                                                 
385                         txtTitle->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
386                         intPrevValue = intiter->second;
387                         NameTitle = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
388                 
389                         txtSuffix->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
390                         NameSuffix = wxSPropertySeg2.Mid(intPrevValue);
391                 
392                 }
393         
394         }
395         
396         NameTokens = PropertyTokens;
397         *NameProcessed = TRUE;
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