Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed references to the boost library in remaining source and header files.
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadName.cpp
1 // frmContactEditor-LoadName.cpp - frmContactEditor load name subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
21 void frmContactEditor::LoadFN(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *FNCount, 
22         bool *FNProcessed, vCard *ContactData){
23         
24         size_t intPropertyLen = wxSPropertySeg1.Len();
25         std::map<int, int> SplitPoints;
26         std::map<int, int> SplitLength;
27         std::map<int, int>::iterator SLiter;                    
28         wxString PropertyData;
29         wxString PropertyName;
30         wxString PropertyValue;
31         wxString PropertyTokens;
32         bool FirstToken = TRUE;                 
33         int intSplitsFound = 0;
34         int intSplitSize = 0;
35         int intPrevValue = 4;
36         int intPref = 0;                        
37         int intType = 0;
38         
39         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
40         
41         intPrevValue = 3;
42         
43         // Look for type before continuing.             
44         
45         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
46         intiter != SplitPoints.end(); ++intiter){
47         
48                 SLiter = SplitLength.find(intiter->first);
49         
50                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
51                 
52                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
53                 PropertyName = PropertyElement.GetNextToken();                          
54                 PropertyValue = PropertyElement.GetNextToken();
55                 
56                 intPrevValue = intiter->second;
57                 
58                 if (PropertyName == wxT("TYPE")){
59                 
60                         if (PropertyValue == wxT("work")){
61                         
62                                 intType = 2;                                    
63                         
64                         } else if (PropertyValue == wxT("home")){
66                                 intType = 1;
67                         
68                         } else {
69                         
70                                 intType = 0;
71                         
72                         }
73                 
74                 }
75         
76         }
77         
78         // Setup blank lines for later on.
80         FullNamesList.insert(std::make_pair(intValueSeek, wxT("")));
81         FullNamesListAltID.insert(std::make_pair(intValueSeek, wxT("")));
82         FullNamesListPID.insert(std::make_pair(intValueSeek, wxT("")));
83         FullNamesListPref.insert(std::make_pair(intValueSeek, 0));
84         FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
85         FullNamesListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
86         FullNamesListTokens.insert(std::make_pair(intValueSeek, wxT("")));              
87         
88         intPrevValue = 3;
89         
90         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
91         intiter != SplitPoints.end(); ++intiter){
92         
93                 SLiter = SplitLength.find(intiter->first);
94         
95                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
96                 
97                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
98                 PropertyName = PropertyElement.GetNextToken();                          
99                 PropertyValue = PropertyElement.GetNextToken();
100                 
101                 ProcessCaptureStrings(&PropertyValue);
102                 
103                 intPrevValue = intiter->second;
104                 
105                 // Process properties.
106                 
107                 if (PropertyName == wxT("ALTID")){
109                         FullNamesListAltID.erase(intValueSeek); FullNamesListAltID.insert(std::make_pair(intValueSeek, PropertyValue));
110                 
111                 } else if (PropertyName == wxT("PID")){
113                         FullNamesListPID.erase(intValueSeek); FullNamesListPID.insert(std::make_pair(intValueSeek, PropertyValue));
114                 
115                 } else if (PropertyName == wxT("PREF")){
116                         
117                         intPref = wxAtoi(PropertyValue);
118                         
119                         if (intPref > 0 && intPref < 101){
120                 
121                                 FullNamesListPref.erase(intValueSeek); FullNamesListPref.insert(std::make_pair(intValueSeek, intPref));
122                                 
123                         }
124                 
125                 } else if (PropertyName == wxT("LANG")){
127                         FullNamesListLanguage.erase(intValueSeek); FullNamesListLanguage.insert(std::make_pair(intValueSeek, PropertyValue));
128                 
129                 } else {
130                 
131                         // Something else we don't know about so append
132                         // to the tokens variable.
133                         
134                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
135                         
136                                 if (FirstToken == TRUE){
137                                 
138                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
139                                         FirstToken = FALSE;
140                                 
141                                 } else {
142                                 
143                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
144                                 
145                                 }
146                         
147                         }
148                 
149                 }
150         
151         }                       
152         
153         // Split the address.           
155         //std::map<int, int>::iterator SLiter;
156         intPropertyLen = wxSPropertySeg2.Len();
157         SplitPoints.clear();
158         SplitLength.clear();
159         intSplitsFound = 0;
160         intSplitSize = 0;
161         intPrevValue = 0;
162         
163         for (int i = 0; i <= intPropertyLen; i++){
165                 intSplitSize++;
166         
167                 if (wxSPropertySeg2.Mid(i, 1) == wxT(":") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
168         
169                         intSplitsFound++;
170                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
171                         
172                         if (intSplitsFound == 1){ 
173                         
174                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
175                                 break; 
176                                 
177                         }
178                         
179                         intSplitSize = 0;                                       
180         
181                 }
183         }                       
184         
185         // Add the data to the General/Home/Work address variables.
186         
187         /*
188         
189         wxListItem coldata;
191         coldata.SetId(intValueSeek);
192         coldata.SetData(intValueSeek);
193         coldata.SetText(IMPPType);
194         
195         */
196         
197         //ProcessCaptureStrings(wxsPropertySeg2);
198         
199         ProcessCaptureStrings(&wxSPropertySeg2);
200         
201         FullNamesList.erase(intValueSeek);
202         FullNamesListType.erase(intValueSeek);
203         FullNamesListTokens.erase(intValueSeek);
204         FullNamesList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
205         FullNamesListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
206         
207         if (intType == 0){
208         
209                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("")));
210         
211         } else if (intType == 1){
212         
213                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("home")));                    
214         
215         } else if (intType == 2){
216         
217                 FullNamesListType.insert(std::make_pair(intValueSeek, wxT("work")));                    
218         
219         }
220         
221         if (*FNProcessed == FALSE){
222         
223                 NameDisplayAs = wxSPropertySeg2;
224                 cmbDisplayAs->SetValue(ContactData->Convert(wxSPropertySeg2, TRUE));
225                 *FNProcessed = TRUE;
226                 
227         }
228         
229         FNCount++;
230         intValueSeek++;
234 void frmContactEditor::LoadN(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *NameProcessed, 
235         vCard *ContactData){
237         size_t intPropertyLen = wxSPropertySeg1.Len();
238         std::map<int, int> SplitPoints;
239         std::map<int, int> SplitLength;
240         std::map<int, int>::iterator SLiter;                    
241         wxString PropertyData;
242         wxString PropertyName;
243         wxString PropertyValue;
244         wxString PropertyTokens;
245         bool FirstToken = TRUE;                 
246         int intSplitsFound = 0;
247         int intSplitSize = 0;
248         int intPrevValue = 3;
249         int intSplitSeek = 0;
250         
251         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
252         
253         // Look for type before continuing.             
254         
255         intPrevValue = 2;                       
256         
257         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
258         intiter != SplitPoints.end(); ++intiter){
259         
260                 SLiter = SplitLength.find(intiter->first);
261         
262                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
263                 
264                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
265                 PropertyName = PropertyElement.GetNextToken();                          
266                 PropertyValue = PropertyElement.GetNextToken();
267                 
268                 intPrevValue = intiter->second;
269         
270         }
271         
272         intPrevValue = 2;
273         
274         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
275         intiter != SplitPoints.end(); ++intiter){
276         
277                 SLiter = SplitLength.find(intiter->first);
278         
279                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
280                 
281                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
282                 PropertyName = PropertyElement.GetNextToken();                          
283                 PropertyValue = PropertyElement.GetNextToken();
284                 
285                 ProcessCaptureStrings(&PropertyValue);
286                 
287                 intPrevValue = intiter->second;
288                 
289                 // Process properties.
290                 
291                 if (PropertyName == wxT("ALTID")){
293                         NameAltID = PropertyValue;
294                 
295                 } else if (PropertyName == wxT("LANG")){
297                         NameLanguage = PropertyValue;
298                 
299                 } else if (PropertyName == wxT("SORT-AS")){
300                 
301                         NameDisplayAs = PropertyValue;
302                 
303                 } else {
304                 
305                         // Something else we don't know about so append
306                         // to the tokens variable.
307                         
308                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
309                         
310                                 if (FirstToken == TRUE){
311                                 
312                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
313                                         FirstToken = FALSE;
314                                 
315                                 } else {
316                                 
317                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
318                                 
319                                 }
320                         
321                         }
322                 
323                 }
324         
325         }
326         
327         intPropertyLen = wxSPropertySeg2.Len();
328         SplitPoints.clear();
329         SplitLength.clear();
330         intSplitSeek = 0;               
331         intSplitsFound = 0;
332         intSplitSize = 0;
333         intPrevValue = 0;                                       
334         
335         for (int i = 0; i <= intPropertyLen; i++){
337                 intSplitSize++;
338         
339                 if (wxSPropertySeg2.Mid(i, 1) == wxT(";") && wxSPropertySeg2.Mid((i - 1), 1) != wxT("\\")){
340         
341                         intSplitsFound++;
342                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
343                         
344                         if (intSplitsFound == 4){ 
345                         
346                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
347                                 break; 
348                                 
349                         } else {
350                         
351                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
352                         
353                         }
354                         
355                         intSplitSize = 0;                                       
356         
357                 }
359         }
360         
361         // Split the data into several parts.
362                         
363         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
364         intiter != SplitPoints.end(); ++intiter){
365         
366                 if (intiter->first == 1){
367                 
368                         // Deal with family name.
369                         
370                         SLiter = SplitLength.find(1);
371                                                                 
372                         txtSurname->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
373                         
374                         intPrevValue = intiter->second;
375                         NameSurname = wxSPropertySeg2.Mid(0, SLiter->second);                                   
376                 
377                 } else if (intiter->first == 2){
378                 
379                         // Deal with given names.
380                         
381                         SLiter = SplitLength.find(2);
382                                                                 
383                         txtForename->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
384                         intPrevValue = intiter->second;
385                         NameForename = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
386                 
387                 } else if (intiter->first == 3){
388                 
389                         // Deal with additional names.
390                         
391                         SLiter = SplitLength.find(3);
392                                                                 
393                         txtOtherNames->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
394                         intPrevValue = intiter->second;
395                         NameOtherNames = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
396                 
397                 } else if (intiter->first == 4){
398                 
399                         // Deal with honorifix prefixes and suffixes.
401                         SLiter = SplitLength.find(4);
402                                                                 
403                         txtTitle->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
404                         intPrevValue = intiter->second;
405                         NameTitle = wxSPropertySeg2.Mid(intPrevValue, SLiter->second);
406                 
407                         txtSuffix->SetValue(ContactData->Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
408                         NameSuffix = wxSPropertySeg2.Mid(intPrevValue);
409                 
410                 }
411         
412         }
413         
414         NameTokens = PropertyTokens;
415         *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