X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=d40087c57bac4a2d2795f679e5ff56d7f8405336;hb=a23e50effb7909d2217c6364b31f258bb9c55ff2;hp=13c869fe301fc338860c85a31cb28f1a03332558;hpb=5d618c0c96ee88769cc63b0a6fe03679cf68bd18;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 13c869f..d40087c 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -92,6 +92,8 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int GeographicCount = 0; int RelatedCount = 0; int URLCount = 0; + int TitleCount = 0; + int RoleCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -282,6 +284,20 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessURL(PropertySeg1, PropertySeg2, &URLCount); URLCount++; + } else if (Property == wxT("TITLE")) { + + // See frmContactEditor-LoadTitle.cpp + + ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount); + TitleCount++; + + } else if (Property == wxT("ROLE")) { + + // See frmContactEditor-LoadTitle.cpp + + ProcessRole(PropertySeg1, PropertySeg2, &RoleCount); + RoleCount++; + } } @@ -2757,14 +2773,22 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS } else if (PropertyName == wxT("PREF")){ - intPref = wxAtoi(PropertyValue); - - if (intPref > 0 && intPref < 101){ - + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue.ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + GeneralRelatedListPref.erase(*RelatedCount); - GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, intPref)); + GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber)); - } } else if (PropertyName == wxT("LANGUAGE")){ @@ -2983,6 +3007,354 @@ void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, } +void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 7; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 6; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *TitleList = NULL; + std::map *TitleListAltID = NULL; + std::map *TitleListPID = NULL; + std::map *TitleListType = NULL; + std::map *TitleListTokens = NULL; + std::map *TitleListLanguage = NULL; + std::map *TitleListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + TitleList = &GeneralTitleList; + TitleListType = &GeneralTitleListType; + TitleListAltID = &GeneralTitleListAltID; + TitleListPID = &GeneralTitleListPID; + TitleListTokens = &GeneralTitleListTokens; + TitleListLanguage = &GeneralTitleListLanguage; + TitleListPref = &GeneralTitleListPref; + break; + case PROPERTY_HOME: + TitleList = &HomeTitleList; + TitleListType = &HomeTitleListType; + TitleListAltID = &HomeTitleListAltID; + TitleListPID = &HomeTitleListPID; + TitleListTokens = &HomeTitleListTokens; + TitleListLanguage = &HomeTitleListLanguage; + TitleListPref = &HomeTitleListPref; + break; + case PROPERTY_WORK: + TitleList = &BusinessTitleList; + TitleListType = &BusinessTitleListType; + TitleListAltID = &BusinessTitleListAltID; + TitleListPID = &BusinessTitleListPID; + TitleListTokens = &BusinessTitleListTokens; + TitleListLanguage = &BusinessTitleListLanguage; + TitleListPref = &BusinessTitleListPref; + break; + } + + intPrevValue = 6; + + for (std::map::iterator intiter = SplitPoints.begin(); + intiter != SplitPoints.end(); ++intiter){ + + SLiter = SplitLength.find(intiter->first); + + PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second)); + + wxStringTokenizer PropertyElement (PropertyData, wxT("=")); + PropertyName = PropertyElement.GetNextToken(); + PropertyValue = PropertyElement.GetNextToken(); + + intPrevValue = intiter->second; + + // Process properties. + + size_t intPropertyValueLen = PropertyValue.Len(); + + if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){ + + PropertyValue.Trim(); + PropertyValue.RemoveLast(); + + } + + if (PropertyValue.Mid(0, 1) == wxT("\"")){ + + PropertyValue.Remove(0, 1); + + } + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName == wxT("ALTID")){ + + TitleListAltID->erase(*TitleCount); + TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + TitleListPID->erase(*TitleCount); + TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue)); + + } else if (PropertyName == wxT("PREF")){ + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue.ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + TitleListPref->erase(*TitleCount); + TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + TitleListLanguage->erase(*TitleCount); + TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue)); + + } else { + + // Something else we don't know about so append + // to the tokens variable. + + if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + + if (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + } + + } + + // Add the data to the General/Home/Work address variables. + + CaptureString(&PropertySeg2, FALSE); + + TitleList->insert(std::make_pair(*TitleCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens)); + + } + +} + +void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 6; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 5; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *RoleList = NULL; + std::map *RoleListAltID = NULL; + std::map *RoleListPID = NULL; + std::map *RoleListType = NULL; + std::map *RoleListTokens = NULL; + std::map *RoleListLanguage = NULL; + std::map *RoleListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + RoleList = &GeneralRoleList; + RoleListType = &GeneralRoleListType; + RoleListAltID = &GeneralRoleListAltID; + RoleListPID = &GeneralRoleListPID; + RoleListTokens = &GeneralRoleListTokens; + RoleListLanguage = &GeneralRoleListLanguage; + RoleListPref = &GeneralRoleListPref; + break; + case PROPERTY_HOME: + RoleList = &HomeRoleList; + RoleListType = &HomeRoleListType; + RoleListAltID = &HomeRoleListAltID; + RoleListPID = &HomeRoleListPID; + RoleListTokens = &HomeRoleListTokens; + RoleListLanguage = &HomeRoleListLanguage; + RoleListPref = &HomeRoleListPref; + break; + case PROPERTY_WORK: + RoleList = &BusinessRoleList; + RoleListType = &BusinessRoleListType; + RoleListAltID = &BusinessRoleListAltID; + RoleListPID = &BusinessRoleListPID; + RoleListTokens = &BusinessRoleListTokens; + RoleListLanguage = &BusinessRoleListLanguage; + RoleListPref = &BusinessRoleListPref; + break; + } + + intPrevValue = 5; + + for (std::map::iterator intiter = SplitPoints.begin(); + intiter != SplitPoints.end(); ++intiter){ + + SLiter = SplitLength.find(intiter->first); + + PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second)); + + wxStringTokenizer PropertyElement (PropertyData, wxT("=")); + PropertyName = PropertyElement.GetNextToken(); + PropertyValue = PropertyElement.GetNextToken(); + + intPrevValue = intiter->second; + + // Process properties. + + size_t intPropertyValueLen = PropertyValue.Len(); + + if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){ + + PropertyValue.Trim(); + PropertyValue.RemoveLast(); + + } + + if (PropertyValue.Mid(0, 1) == wxT("\"")){ + + PropertyValue.Remove(0, 1); + + } + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName == wxT("ALTID")){ + + RoleListAltID->erase(*RoleCount); + RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + RoleListPID->erase(*RoleCount); + RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue)); + + } else if (PropertyName == wxT("PREF")){ + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue.ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + RoleListPref->erase(*RoleCount); + RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + RoleListLanguage->erase(*RoleCount); + RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue)); + + } else { + + // Something else we don't know about so append + // to the tokens variable. + + if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + + if (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + } + + } + + // Add the data to the General/Home/Work address variables. + + CaptureString(&PropertySeg2, FALSE); + + RoleList->insert(std::make_pair(*RoleCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,