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;
10 wxString PropertyValue;
11 wxString PropertyTokens;
12 bool FirstToken = TRUE;
18 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
22 // Look for type before continuing.
24 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
25 intiter != SplitPoints.end(); ++intiter){
27 SLiter = SplitLength.find(intiter->first);
29 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
31 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
32 PropertyName = PropertyElement.GetNextToken();
33 PropertyValue = PropertyElement.GetNextToken();
35 intPrevValue = intiter->second;
37 if (PropertyName == wxT("TYPE")){
39 if (PropertyValue == wxT("work")){
43 } else if (PropertyValue == wxT("home")){
57 // Setup blank lines for later on.
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){
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("")));
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("")));
87 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
88 intiter != SplitPoints.end(); ++intiter){
90 SLiter = SplitLength.find(intiter->first);
92 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
94 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
95 PropertyName = PropertyElement.GetNextToken();
96 PropertyValue = PropertyElement.GetNextToken();
98 intPrevValue = intiter->second;
100 // Process properties.
102 size_t intPropertyValueLen = PropertyValue.Len();
104 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
106 PropertyValue.Trim();
107 PropertyValue.RemoveLast();
111 if (PropertyValue.Mid(0, 1) == wxT("\"")){
113 PropertyValue.Remove(0, 1);
117 ProcessCaptureStrings(&PropertyValue);
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)); }
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)); }
131 } else if (PropertyName == wxT("PREF")){
133 intPref = wxAtoi(PropertyValue);
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)); }
141 // Something else we don't know about so append
142 // to the tokens variable.
144 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
146 if (FirstToken == TRUE){
148 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
153 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
163 // Add the data to the General/Home/Work address variables.
165 ProcessCaptureStrings(&wxSPropertySeg2);
169 coldata.SetId(intValueSeek);
170 coldata.SetData(intValueSeek);
171 coldata.SetText(wxSPropertySeg2);
175 ListCtrlIndex = lboLanguages->InsertItem(coldata);
177 if (intPref > 0 && intPref < 101){
179 lboLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
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));
190 } else if (intType == 1){
192 ListCtrlIndex = lboHomeLanguages->InsertItem(coldata);
194 if (intPref > 0 && intPref < 101){
196 lboHomeLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
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));
207 } else if (intType == 2){
209 ListCtrlIndex = lboBusinessLanguages->InsertItem(coldata);
211 if (intPref > 0 && intPref < 101){
213 lboBusinessLanguages->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
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));