X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=7bd80be97a13987fcc25427e0c4ed4c5834a0264;hp=d40087c57bac4a2d2795f679e5ff56d7f8405336;hb=825e100fbd7f2492240af1d8688356fc210aeaae;hpb=a23e50effb7909d2217c6364b31f258bb9c55ff2 diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index d40087c..7bd80be 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -94,6 +94,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int URLCount = 0; int TitleCount = 0; int RoleCount = 0; + int OrganisationCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -298,6 +299,13 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessRole(PropertySeg1, PropertySeg2, &RoleCount); RoleCount++; + } else if (Property == wxT("ORG")) { + + // See frmContactEditor-LoadOrg.cpp + + ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount); + OrganisationCount++; + } } @@ -3355,6 +3363,189 @@ void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2 } +void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 5; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *OrganisationsList = NULL; + std::map *OrganisationsListAltID = NULL; + std::map *OrganisationsListPID = NULL; + std::map *OrganisationsListType = NULL; + std::map *OrganisationsListTokens = NULL; + std::map *OrganisationsListLanguage = NULL; + std::map *OrganisationsListSortAs = NULL; + std::map *OrganisationsListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + OrganisationsList = &GeneralOrganisationsList; + OrganisationsListType = &GeneralOrganisationsListType; + OrganisationsListAltID = &GeneralOrganisationsListAltID; + OrganisationsListPID = &GeneralOrganisationsListPID; + OrganisationsListTokens = &GeneralOrganisationsListTokens; + OrganisationsListLanguage = &GeneralOrganisationsListLanguage; + OrganisationsListSortAs = &GeneralOrganisationsListSortAs; + OrganisationsListPref = &GeneralOrganisationsListPref; + break; + case PROPERTY_HOME: + OrganisationsList = &HomeOrganisationsList; + OrganisationsListType = &HomeOrganisationsListType; + OrganisationsListAltID = &HomeOrganisationsListAltID; + OrganisationsListPID = &HomeOrganisationsListPID; + OrganisationsListTokens = &HomeOrganisationsListTokens; + OrganisationsListLanguage = &HomeOrganisationsListLanguage; + OrganisationsListSortAs = &HomeOrganisationsListSortAs; + OrganisationsListPref = &HomeOrganisationsListPref; + break; + case PROPERTY_WORK: + OrganisationsList = &BusinessOrganisationsList; + OrganisationsListType = &BusinessOrganisationsListType; + OrganisationsListAltID = &BusinessOrganisationsListAltID; + OrganisationsListPID = &BusinessOrganisationsListPID; + OrganisationsListTokens = &BusinessOrganisationsListTokens; + OrganisationsListLanguage = &BusinessOrganisationsListLanguage; + OrganisationsListSortAs = &BusinessOrganisationsListSortAs; + OrganisationsListPref = &BusinessOrganisationsListPref; + break; + } + + intPrevValue = 4; + + 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")){ + + OrganisationsListAltID->erase(*OrganisationCount); + OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + OrganisationsListPID->erase(*OrganisationCount); + OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue)); + + } else if (PropertyName == wxT("SORT-AS")){ + + OrganisationsListSortAs->erase(*OrganisationCount); + OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, 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){ + + OrganisationsListPref->erase(*OrganisationCount); + OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + OrganisationsListLanguage->erase(*OrganisationCount); + OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, 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); + + OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,