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-LoadOrg.cpp
1 // frmContactEditor-LoadOrg.cpp - frmContactEditor load organisation 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::LoadOrg(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *OrgCount){
23         std::map<int, int> SplitPoints;
24         std::map<int, int> SplitLength;
25         std::map<int, int>::iterator SLiter;                    
26         wxString PropertyData;
27         wxString PropertyName;
28         wxString PropertyValue;
29         wxString PropertyTokens;
30         bool FirstToken = TRUE;
31         int intPrevValue = 5;
32         int intPref = 0;
33         int intType = 0;
34         long ListCtrlIndex;
35         
36         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
37         
38         intPrevValue = 4;
39         
40         // Look for type before continuing.
41         
42         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
43         intiter != SplitPoints.end(); ++intiter){
44         
45                 SLiter = SplitLength.find(intiter->first);
46         
47                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
48                 
49                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
50                 PropertyName = PropertyElement.GetNextToken();                          
51                 PropertyValue = PropertyElement.GetNextToken();
52                 
53                 intPrevValue = intiter->second;
54                 
55                 if (PropertyName == wxT("TYPE")){
56                 
57                         if (PropertyValue == wxT("work")){
58                         
59                                 intType = 2;                                    
60                         
61                         } else if (PropertyValue == wxT("home")){
63                                 intType = 1;
64                         
65                         } else {
66                         
67                                 intType = 0;
68                         
69                         }
70                 
71                 }
72         
73         }
74         
75         // Setup blank lines for later on.
76         
77         if (intType == 0){
78         
79                 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
80                 GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
81                 GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
82                 GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
83                 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
84                 GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
85                 GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
87         } else if (intType == 1){
88         
89                 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
90                 HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
91                 HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
92                 HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
93                 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
94                 HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
95                 HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));
96         
97         } else if (intType == 2){
99                 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxT("")));
100                 BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, wxT("")));
101                 BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, wxT("")));
102                 BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, 0));
103                 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, wxT("")));
104                 BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
105                 BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, wxT("")));                          
106         
107         }
108         
109         intPrevValue = 4;
110         
111         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
112         intiter != SplitPoints.end(); ++intiter){
113         
114                 SLiter = SplitLength.find(intiter->first);
115         
116                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
117                 
118                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
119                 PropertyName = PropertyElement.GetNextToken();                          
120                 PropertyValue = PropertyElement.GetNextToken();
121                 
122                 intPrevValue = intiter->second;
123                 
124                 // Process properties.
125                 
126                 size_t intPropertyValueLen = PropertyValue.Len();
127                 
128                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
129                         
130                         PropertyValue.Trim();
131                         PropertyValue.RemoveLast();
132                         
133                 }                               
134                 
135                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
136                         
137                         PropertyValue.Remove(0, 1);
138                         
139                 }
140                 
141                 ProcessCaptureStrings(&PropertyValue);
142                 
143                 if (PropertyName == wxT("ALTID")){
145                         if (intType == 0){ GeneralOrganisationsListAltID.erase(intValueSeek); GeneralOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
146                         else if (intType == 1){ HomeOrganisationsListAltID.erase(intValueSeek); HomeOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
147                         else if (intType == 2){ BusinessOrganisationsListAltID.erase(intValueSeek); BusinessOrganisationsListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
148                 
149                 } else if (PropertyName == wxT("PID")){
151                         if (intType == 0){ GeneralOrganisationsListPID.erase(intValueSeek); GeneralOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
152                         else if (intType == 1){ HomeOrganisationsListPID.erase(intValueSeek); HomeOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
153                         else if (intType == 2){ BusinessOrganisationsListPID.erase(intValueSeek); BusinessOrganisationsListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
154                 
155                 } else if (PropertyName == wxT("PREF")){
156                         
157                         intPref = wxAtoi(PropertyValue);
158                 
159                         if (intType == 0){ GeneralOrganisationsListPref.erase(intValueSeek); GeneralOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
160                         else if (intType == 1){ HomeOrganisationsListPref.erase(intValueSeek); HomeOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
161                         else if (intType == 2){ BusinessOrganisationsListPref.erase(intValueSeek); BusinessOrganisationsListPref.insert(std::make_pair(intValueSeek, intPref)); }
162                 
163                 } else if (PropertyName == wxT("LANGUAGE")){
164                 
165                         if (intType == 0){ GeneralOrganisationsListLanguage.erase(intValueSeek); GeneralOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
166                         else if (intType == 1){ HomeOrganisationsListLanguage.erase(intValueSeek); HomeOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
167                         else if (intType == 2){ BusinessOrganisationsListLanguage.erase(intValueSeek); BusinessOrganisationsListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
168                 
169                 } else if (PropertyName == wxT("SORT-AS")){
170                 
171                         if (intType == 0){ GeneralOrganisationsListSortAs.erase(intValueSeek); GeneralOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
172                         else if (intType == 1){ HomeOrganisationsListSortAs.erase(intValueSeek); HomeOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
173                         else if (intType == 2){ BusinessOrganisationsListSortAs.erase(intValueSeek); BusinessOrganisationsListSortAs.insert(std::make_pair(intValueSeek, PropertyValue)); }
174                 
175                 } else {
176                 
177                         // Something else we don't know about so append
178                         // to the tokens variable.
179                 
180                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
181                 
182                                 if (FirstToken == TRUE){
183                         
184                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
185                                         FirstToken = FALSE;
186                         
187                                 } else {
188                         
189                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
190                         
191                                 }
192                 
193                         }
194                 
195                 }
196         
197         }                       
198         
199         // Add the data to the General/Home/Work address variables.
200         
201         wxListItem coldata;
203         ProcessCaptureStrings(&wxSPropertySeg2);
205         coldata.SetId(intValueSeek);
206         coldata.SetData(intValueSeek);
207         coldata.SetText(wxSPropertySeg2);
208         
209         if (intType == 0){
210         
211                 ListCtrlIndex = lboOrganisations->InsertItem(coldata);
212                 
213                 if (intPref > 0 && intPref < 101){
214                 
215                         lboOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
216                         
217                 }
218                 
219                 GeneralOrganisationsList.erase(intValueSeek);
220                 GeneralOrganisationsListType.erase(intValueSeek);
221                 GeneralOrganisationsListTokens.erase(intValueSeek);
222                 GeneralOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
223                 GeneralOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("")));
224                 GeneralOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
225         
226         } else if (intType == 1){ 
227         
228                 ListCtrlIndex = lboHomeOrganisations->InsertItem(coldata);
230                 if (intPref > 0 && intPref < 101){
231                 
232                         lboHomeOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
233                         
234                 }
236                 HomeOrganisationsList.erase(intValueSeek);
237                 HomeOrganisationsListType.erase(intValueSeek);
238                 HomeOrganisationsListTokens.erase(intValueSeek);                                
239                 HomeOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
240                 HomeOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("home")));
241                 HomeOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
242         
243         } else if (intType == 2){ 
244         
245                 ListCtrlIndex = lboBusinessOrganisations->InsertItem(coldata);
247                 if (intPref > 0 && intPref < 101){
248                 
249                         lboBusinessOrganisations->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
250                         
251                 }
253                 BusinessOrganisationsList.erase(intValueSeek);
254                 BusinessOrganisationsListType.erase(intValueSeek);
255                 BusinessOrganisationsListTokens.erase(intValueSeek);                            
256                 BusinessOrganisationsList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
257                 BusinessOrganisationsListType.insert(std::make_pair(intValueSeek, wxT("work")));
258                 BusinessOrganisationsListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));                           
259         
260         }
261         
262         OrgCount++;
263         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