X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=55d2a14dbb8c17f3840e72c4741d8646e87b0bc5;hb=1c717d77d60dabd298622aec1f022094bce77c23;hp=266a5e0eceda576864815d8774381b50d3e64821;hpb=5ab6af24eb42838438875f9c7af77210ccfa44a8;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 266a5e0..55d2a14 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -74,6 +74,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ bool QuoteMode = FALSE; bool PropertyFind = TRUE; bool KindProcessed = FALSE; + bool NameProcessed = FALSE; int ContactLineLen = 0; int QuoteBreakPoint = 0; int GroupCount = 0; @@ -190,6 +191,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessFN(PropertySeg1, PropertySeg2, &FNCount); FNCount++; + } else if (Property == wxT("N") && NameProcessed == FALSE){ + + ProcessN(PropertySeg1, PropertySeg2); + NameProcessed = TRUE; + } } @@ -428,6 +434,163 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, } +void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){ + + std::map SplitPoints; + std::map SplitLength; + + int intPrevValue = 3; + int intPref = 0; + int intType = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 2; + + NameForename = PropertySeg2; + + wxString PropertyName; + wxString PropertyValue; + wxString PropertyData; + wxString PropertyTokens; + std::map::iterator SLiter; + bool FirstToken = TRUE; + + 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; + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName == wxT("ALTID")){ + + NameAltID = PropertyValue; + + } else if (PropertyName == wxT("LANGUAGE")){ + + NameLanguage = PropertyValue; + + } else if (PropertyName == wxT("SORT-AS")){ + + if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") && + PropertyValue.Len() >= 3){ + NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2)); + } + + } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){ + + if (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + } + + // Split the name data. + + int intSplitSeek = 0; + int intSplitsFound = 0; + int intSplitSize = 0; + int intPropertyLen = PropertySeg2.Len(); + + std::map NameValues; + intPrevValue = 0; + + for (int i = 0; i <= intPropertyLen; i++){ + + if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){ + + NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize))); + + intSplitSeek = i; + intSplitSeek++; + + if (intSplitsFound == 4){ + + NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos))); + break; + + } + + intSplitSize = 0; + continue; + + } + + intSplitSize++; + + } + + // Split the data into several parts. + + for (std::map::iterator iter = NameValues.begin(); + iter != NameValues.end(); ++iter){ + + if (iter->first == 1){ + + // Deal with family name. + + NameSurname = iter->second; + + } else if (iter->first == 2){ + + // Deal with given names. + + NameForename = iter->second; + + } else if (iter->first == 3){ + + // Deal with additional names. + + NameOtherNames = iter->second; + + } else if (iter->first == 4){ + + // Deal with honorifix prefixes and suffixes. + + NameTitle = iter->second; + + iter++; + + if (iter == NameValues.end()){ + + break; + + } + + NameSuffix = iter->second; + + } + + } + + // Add the name token data. + + if (!PropertyTokens.IsEmpty()){ + + NameTokens = PropertyTokens; + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,