1 #include "frmContactEditor.h"
3 void frmContactEditor::LoadBDay(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *BirthdayProcessed){
5 // Process date. Preserve the remainder in the string.
7 std::map<int, int> SplitPoints;
8 std::map<int, int> SplitLength;
9 std::map<int, int>::iterator SLiter;
10 wxString PropertyData;
11 wxString PropertyName;
12 wxString PropertyValue;
13 wxString PropertyTokens;
14 bool BirthdayText = FALSE;
17 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
21 // Look for type before continuing.
23 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
24 intiter != SplitPoints.end(); ++intiter){
26 SLiter = SplitLength.find(intiter->first);
28 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
30 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
31 PropertyName = PropertyElement.GetNextToken();
32 PropertyValue = PropertyElement.GetNextToken();
34 intPrevValue = intiter->second;
36 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
38 ProcessCaptureStrings(&wxSPropertySeg2);
39 txtBirthday->SetValue(wxSPropertySeg2);
40 Birthday = wxSPropertySeg2;
47 // Setup blank lines for later on.
51 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
52 intiter != SplitPoints.end(); ++intiter){
54 SLiter = SplitLength.find(intiter->first);
56 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
58 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
59 PropertyName = PropertyElement.GetNextToken();
60 PropertyValue = PropertyElement.GetNextToken();
62 intPrevValue = intiter->second;
64 // Process properties.
66 ProcessCaptureStrings(&PropertyValue);
68 size_t intPropertyValueLen = PropertyValue.Len();
70 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
73 PropertyValue.RemoveLast();
77 if (PropertyValue.Mid(0, 1) == wxT("\"")){
79 PropertyValue.Remove(0, 1);
83 if (PropertyName == wxT("ALTID")){
85 BirthdayAltID = PropertyValue;
87 } else if (PropertyName == wxT("CALSCALE")){
89 BirthdayCalScale = PropertyValue;
91 } else if (PropertyName != wxT("VALUE")) {
93 // Something else we don't know about so append
94 // to the tokens variable.
96 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
98 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
106 // Add the data to the variables and form.
108 if (BirthdayText == FALSE){
110 Birthday = wxSPropertySeg2;
112 wxDateTime::Month DateMonth;
113 unsigned int DateDay;
117 if (Birthday.Mid(0, 2) == wxT("--")){
123 DateYear = wxAtoi(Birthday.Mid(0,4));
127 DateMonth = (wxDateTime::Month)(wxAtoi(Birthday.Mid(4,2)) - 1);
128 DateDay = wxAtoi(Birthday.Mid(6,2));
130 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
132 /*BDayDate.SetDay(DateDay);
133 BDayDate.SetMonth(wxDateTime::Month::Jan);
134 BDayDate.SetYear(DateYear);*/
136 dapBirthday->SetValue(BDayDate);
140 BirthdayTokens = PropertyTokens;
142 *BirthdayProcessed = TRUE;
146 void frmContactEditor::LoadAnniversary(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *AnniversaryProcessed){
148 // Process date. Preserve the remainder in the string.
150 std::map<int, int> SplitPoints;
151 std::map<int, int> SplitLength;
152 std::map<int, int>::iterator SLiter;
153 wxString PropertyData;
154 wxString PropertyName;
155 wxString PropertyValue;
156 wxString PropertyTokens;
157 bool AnniversaryText = FALSE;
158 int intPrevValue = 13;
160 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
164 // Look for type before continuing.
166 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
167 intiter != SplitPoints.end(); ++intiter){
169 SLiter = SplitLength.find(intiter->first);
171 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
173 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
174 PropertyName = PropertyElement.GetNextToken();
175 PropertyValue = PropertyElement.GetNextToken();
177 intPrevValue = intiter->second;
179 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
181 ProcessCaptureStrings(&wxSPropertySeg2);
182 txtAnniversary->SetValue(wxSPropertySeg2);
183 Anniversary = wxSPropertySeg2;
184 AnniversaryText = TRUE;
190 // Setup blank lines for later on.
194 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
195 intiter != SplitPoints.end(); ++intiter){
197 SLiter = SplitLength.find(intiter->first);
199 PropertyData = wxSPropertySeg1.Mid(intPrevValue, SLiter->second);
201 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
202 PropertyName = PropertyElement.GetNextToken();
203 PropertyValue = PropertyElement.GetNextToken();
205 intPrevValue = intiter->second;
207 // Process properties.
209 size_t intPropertyValueLen = PropertyValue.Len();
211 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
213 PropertyValue.Trim();
214 PropertyValue.RemoveLast();
218 if (PropertyValue.Mid(0, 1) == wxT("\"")){
220 PropertyValue.Remove(0, 1);
224 ProcessCaptureStrings(&PropertyValue);
226 if (PropertyName == wxT("ALTID")){
228 AnniversaryAltID = PropertyValue;
230 } else if (PropertyName == wxT("CALSCALE")){
232 AnniversaryCalScale = PropertyValue;
234 } else if (PropertyName != wxT("VALUE")) {
236 // Something else we don't know about so append
237 // to the tokens variable.
239 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
241 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
249 // Add the data to the variables and form.
251 if (AnniversaryText == FALSE){
253 Anniversary = wxSPropertySeg2;
255 wxDateTime::Month DateMonth;
260 if (Anniversary.Mid(0, 2) == wxT("--")){
266 DateYear = wxAtoi(Anniversary.Mid(0,4));
270 DateMonth = (wxDateTime::Month)(wxAtoi(Anniversary.Mid(4,2)) - 1);
271 DateDay = wxAtoi(Anniversary.Mid(6,2));
273 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
275 dapAnniversary->SetValue(ADayDate);
279 AnniversaryTokens = PropertyTokens;
281 *AnniversaryProcessed = TRUE;