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-LoadOrg.cpp
1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadOrg(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *OrgCount){
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 = 5;
14         int intPref = 0;
15         int intType = 0;
16         long ListCtrlIndex;
17         
18         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
19         
20         intPrevValue = 4;
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                 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
62                 GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63                 GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
64                 GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
65                 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66                 GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
67                 GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
69         } else if (intType == 1){
70         
71                 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
72                 HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
73                 HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
74                 HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
75                 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
76                 HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
77                 HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
78         
79         } else if (intType == 2){
81                 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
82                 BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
83                 BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
84                 BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
85                 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
86                 BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
87                 BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));                          
88         
89         }
90         
91         intPrevValue = 4;
92         
93         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
94         intiter != SplitPoints.end(); ++intiter){
95         
96                 SLiter = SplitLength.find(intiter->first);
97         
98                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
99                 
100                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
101                 PropertyName = PropertyElement.GetNextToken();                          
102                 PropertyValue = PropertyElement.GetNextToken();
103                 
104                 intPrevValue = intiter->second;
105                 
106                 // Process properties.
107                 
108                 size_t intPropertyValueLen = PropertyValue.Len();
109                 
110                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
111                         
112                         PropertyValue.Trim();
113                         PropertyValue.RemoveLast();
114                         
115                 }                               
116                 
117                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
118                         
119                         PropertyValue.Remove(0, 1);
120                         
121                 }
122                 
123                 ProcessCaptureStrings(&PropertyValue);
124                 
125                 if (PropertyName == wxT("ALTID")){
127                         if (intType == 0){ GeneralOrganisationsListAltID.erase(intValueSeek); GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128                         else if (intType == 1){ HomeOrganisationsListAltID.erase(intValueSeek); HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
129                         else if (intType == 2){ BusinessOrganisationsListAltID.erase(intValueSeek); BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
130                 
131                 } else if (PropertyName == wxT("PID")){
133                         if (intType == 0){ GeneralOrganisationsListPID.erase(intValueSeek); GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134                         else if (intType == 1){ HomeOrganisationsListPID.erase(intValueSeek); HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
135                         else if (intType == 2){ BusinessOrganisationsListPID.erase(intValueSeek); BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
136                 
137                 } else if (PropertyName == wxT("PREF")){
138                         
139                         intPref = wxAtoi(PropertyValue);
140                 
141                         if (intType == 0){ GeneralOrganisationsListPref.erase(intValueSeek); GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
142                         else if (intType == 1){ HomeOrganisationsListPref.erase(intValueSeek); HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
143                         else if (intType == 2){ BusinessOrganisationsListPref.erase(intValueSeek); BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
144                 
145                 } else if (PropertyName == wxT("LANGUAGE")){
146                 
147                         if (intType == 0){ GeneralOrganisationsListLanguage.erase(intValueSeek); GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
148                         else if (intType == 1){ HomeOrganisationsListLanguage.erase(intValueSeek); HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
149                         else if (intType == 2){ BusinessOrganisationsListLanguage.erase(intValueSeek); BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
150                 
151                 } else if (PropertyName == wxT("SORT-AS")){
152                 
153                         if (intType == 0){ GeneralOrganisationsListSortAs.erase(intValueSeek); GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
154                         else if (intType == 1){ HomeOrganisationsListSortAs.erase(intValueSeek); HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
155                         else if (intType == 2){ BusinessOrganisationsListSortAs.erase(intValueSeek); BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
156                 
157                 } else {
158                 
159                         // Something else we don't know about so append
160                         // to the tokens variable.
161                 
162                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
163                 
164                                 if (FirstToken == TRUE){
165                         
166                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
167                                         FirstToken = FALSE;
168                         
169                                 } else {
170                         
171                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
172                         
173                                 }
174                 
175                         }
176                 
177                 }
178         
179         }                       
180         
181         // Add the data to the General/Home/Work address variables.
182         
183         wxListItem coldata;
185         ProcessCaptureStrings(&wxSPropertySeg2);
187         coldata.SetId(intValueSeek);
188         coldata.SetData(intValueSeek);
189         coldata.SetText(wxSPropertySeg2);
190         
191         if (intType == 0){
192         
193                 ListCtrlIndex = lboOrganisations->InsertItem(coldata);
194                 
195                 if (intPref > 0 && intPref < 101){
196                 
197                         lboOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
198                         
199                 }
200                 
201                 GeneralOrganisationsList.erase(intValueSeek);
202                 GeneralOrganisationsListType.erase(intValueSeek);
203                 GeneralOrganisationsListTokens.erase(intValueSeek);
204                 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
205                 GeneralOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("")));
206                 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
207         
208         } else if (intType == 1){ 
209         
210                 ListCtrlIndex = lboHomeOrganisations->InsertItem(coldata);
212                 if (intPref > 0 && intPref < 101){
213                 
214                         lboHomeOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
215                         
216                 }
218                 HomeOrganisationsList.erase(intValueSeek);
219                 HomeOrganisationsListType.erase(intValueSeek);
220                 HomeOrganisationsListTokens.erase(intValueSeek);                                
221                 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
222                 HomeOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("home")));
223                 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
224         
225         } else if (intType == 2){ 
226         
227                 ListCtrlIndex = lboBusinessOrganisations->InsertItem(coldata);
229                 if (intPref > 0 && intPref < 101){
230                 
231                         lboBusinessOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
232                         
233                 }
235                 BusinessOrganisationsList.erase(intValueSeek);
236                 BusinessOrganisationsListType.erase(intValueSeek);
237                 BusinessOrganisationsListTokens.erase(intValueSeek);                            
238                 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
239                 BusinessOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("work")));
240                 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
241         
242         }
243         
244         OrgCount++;
245         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