1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadTitle(wxString wxSPropertySeg1, wxString wxSPropertySeg2, int *TitleCount){
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 GeneralTitleList.insert(std::make_pair(intValueSeek, wxT("")));
62 GeneralTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
63 GeneralTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
64 GeneralTitleListPref.insert(std::make_pair(intValueSeek, 0));
65 GeneralTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
66 GeneralTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
68 } else if (intType == 1){
70 HomeTitleList.insert(std::make_pair(intValueSeek, wxT("")));
71 HomeTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
72 HomeTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
73 HomeTitleListPref.insert(std::make_pair(intValueSeek, 0));
74 HomeTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
75 HomeTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
77 } else if (intType == 2){
79 BusinessTitleList.insert(std::make_pair(intValueSeek, wxT("")));
80 BusinessTitleListAltID.insert(std::make_pair(intValueSeek, wxT("")));
81 BusinessTitleListPID.insert(std::make_pair(intValueSeek, wxT("")));
82 BusinessTitleListPref.insert(std::make_pair(intValueSeek, 0));
83 BusinessTitleListTokens.insert(std::make_pair(intValueSeek, wxT("")));
84 BusinessTitleListLanguage.insert(std::make_pair(intValueSeek, wxT("")));
90 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
91 intiter != SplitPoints.end(); ++intiter){
93 SLiter = SplitLength.find(intiter->first);
95 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
97 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
98 PropertyName = PropertyElement.GetNextToken();
99 PropertyValue = PropertyElement.GetNextToken();
101 intPrevValue = intiter->second;
103 // Process properties.
105 size_t intPropertyValueLen = PropertyValue.Len();
107 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
109 PropertyValue.Trim();
110 PropertyValue.RemoveLast();
114 if (PropertyValue.Mid(0, 1) == wxT("\"")){
116 PropertyValue.Remove(0, 1);
120 ProcessCaptureStrings(&PropertyValue);
122 if (PropertyName == wxT("ALTID")){
124 if (intType == 0){ GeneralTitleListAltID.erase(intValueSeek); GeneralTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
125 else if (intType == 1){ HomeTitleListAltID.erase(intValueSeek); HomeTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
126 else if (intType == 2){ BusinessTitleListAltID.erase(intValueSeek); BusinessTitleListAltID.insert(std::make_pair(intValueSeek, PropertyValue)); }
128 } else if (PropertyName == wxT("PID")){
130 if (intType == 0){ GeneralTitleListPID.erase(intValueSeek); GeneralTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
131 else if (intType == 1){ HomeTitleListPID.erase(intValueSeek); HomeTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
132 else if (intType == 2){ BusinessTitleListPID.erase(intValueSeek); BusinessTitleListPID.insert(std::make_pair(intValueSeek, PropertyValue)); }
134 } else if (PropertyName == wxT("PREF")){
136 intPref = wxAtoi(PropertyValue);
138 if (intType == 0){ GeneralTitleListPref.erase(intValueSeek); GeneralTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
139 else if (intType == 1){ HomeTitleListPref.erase(intValueSeek); HomeTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
140 else if (intType == 2){ BusinessTitleListPref.erase(intValueSeek); BusinessTitleListPref.insert(std::make_pair(intValueSeek, intPref)); }
142 } else if (PropertyName == wxT("LANGUAGE")){
144 if (intType == 0){ GeneralTitleListLanguage.erase(intValueSeek); GeneralTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
145 else if (intType == 1){ HomeTitleListLanguage.erase(intValueSeek); HomeTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
146 else if (intType == 2){ BusinessTitleListLanguage.erase(intValueSeek); BusinessTitleListLanguage.insert(std::make_pair(intValueSeek, PropertyValue)); }
150 // Something else we don't know about so append
151 // to the tokens variable.
153 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
155 if (FirstToken == TRUE){
157 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
162 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
172 // Add the data to the General/Home/Work address variables.
174 ProcessCaptureStrings(&wxSPropertySeg2);
178 coldata.SetId(intValueSeek);
179 coldata.SetData(intValueSeek);
180 coldata.SetText(wxSPropertySeg2);
184 ListCtrlIndex = lboTitles->InsertItem(coldata);
186 if (intPref > 0 && intPref < 101){
188 lboTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
192 GeneralTitleList.erase(intValueSeek);
193 GeneralTitleListType.erase(intValueSeek);
194 GeneralTitleListTokens.erase(intValueSeek);
195 GeneralTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
196 GeneralTitleListType.insert(std::make_pair(intValueSeek, wxT("")));
197 GeneralTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
199 } else if (intType == 1){
201 ListCtrlIndex = lboHomeTitles->InsertItem(coldata);
203 if (intPref > 0 && intPref < 101){
205 lboHomeTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
209 HomeTitleList.erase(intValueSeek);
210 HomeTitleListType.erase(intValueSeek);
211 HomeTitleListTokens.erase(intValueSeek);
212 HomeTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
213 HomeTitleListType.insert(std::make_pair(intValueSeek, wxT("home")));
214 HomeTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));
216 } else if (intType == 2){
218 ListCtrlIndex = lboBusinessTitles->InsertItem(coldata);
220 if (intPref > 0 && intPref < 101){
222 lboBusinessTitles->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), intPref));
226 BusinessTitleList.erase(intValueSeek);
227 BusinessTitleListType.erase(intValueSeek);
228 BusinessTitleListTokens.erase(intValueSeek);
229 BusinessTitleList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
230 BusinessTitleListType.insert(std::make_pair(intValueSeek, wxT("work")));
231 BusinessTitleListTokens.insert(std::make_pair(intValueSeek, PropertyTokens));