~chronoscz/vcard-studio/trunk

« back to all changes in this revision

Viewing changes to Packages/VCard/VCard.pas

  • Committer: chronos
  • Date: 2023-06-06 15:05:18 UTC
  • Revision ID: svn-v4:b2f690cb-8b89-471c-b043-dbd4632e1e77:trunk:152
* Added: VCardProcessor class for processing contacts available from VCard package.
* Added: Normalize menu action for normalization of contact property values.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1297
1297
procedure TContacts.Sort;
1298
1298
var
1299
1299
  I: Integer;
 
1300
  ContactProperty: TContactProperty;
1300
1301
begin
1301
1302
  inherited Sort(TComparer<TContact>.Construct(CompareContactFullName));
1302
 
  for I := 0 to Count - 1 do
 
1303
  for I := 0 to Count - 1 do begin
1303
1304
    Items[I].Properties.Sort(TComparer<TContactProperty>.Construct(ComparePropertyName));
 
1305
 
 
1306
    // Make sure VERSION is first property
 
1307
    ContactProperty := Items[I].Properties.GetByName('VERSION');
 
1308
    if Assigned(ContactProperty) then begin
 
1309
      Items[I].Properties.Move(Items[I].Properties.IndexOf(ContactProperty), 0);
 
1310
    end;
 
1311
  end;
1304
1312
end;
1305
1313
 
1306
1314
procedure TContacts.AssignToList(List: TObjects);
1790
1798
  CutText: string;
1791
1799
  LinePrefix: string;
1792
1800
  CutLength: Integer;
 
1801
  Cut: Boolean;
1793
1802
begin
1794
1803
  with Output do begin
1795
1804
    LineBreak := VCardLineEnding;
1813
1822
        OutText := NameText + ':' + Value2;
1814
1823
        LineIndex := 0;
1815
1824
        LinePrefix := '';
 
1825
        Cut := False;
1816
1826
        while True do begin
1817
1827
          if UTF8Length(OutText) > ParentVCard.MaxLineLength then begin
 
1828
            Cut := True;
1818
1829
            CutLength := ParentVCard.MaxLineLength;
1819
1830
            if Encoding = veQuotedPrintable then begin
1820
1831
              Dec(CutLength); // There will be softline break at the end
1836
1847
            Continue;
1837
1848
          end else begin
1838
1849
            Add(LinePrefix + OutText);
 
1850
            if Cut then Add('');
1839
1851
            Break;
1840
1852
          end;
1841
1853
        end;