Ignore:
Timestamp:
Jul 1, 2023, 11:54:02 AM (17 months ago)
Author:
chronos
Message:
  • Added: Import form preparation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Table.pas

    r158 r167  
    3939    procedure GetOutputListView(ListView: TListView);
    4040    function GetOutput(OutputFormat: TTableFormat): string;
     41    procedure SetInputTabs(Text: string);
     42    procedure SetInputPlain(Text: string);
     43    procedure SetInputCsv(Text: string);
     44    procedure SetInputXml(Text: string);
     45    procedure SetInputHtml(Text: string);
     46    procedure SetInputMediaWiki(Text: string);
     47    procedure SetInput(OutputFormat: TTableFormat; Text: string);
    4148    constructor Create;
    4249    destructor Destroy; override;
     
    5562  Common;
    5663
     64resourcestring
     65  SUnsupportedFormat = 'Unsupported format';
     66
    5767{ TTable }
    5868
     
    7484procedure TTable.Clear;
    7585begin
     86  Columns.Clear;
    7687  Rows.Clear;
    7788end;
     
    138149begin
    139150  Result := '<?xml version="1.0" encoding="UTF-8"?>' + LineEnding +
    140     '<vcard>' + LineEnding +
     151    '<table>' + LineEnding +
    141152    '  <title>' + Title + '</title>' + LineEnding +
    142     '  <contacts>' + LineEnding;
     153    '  <rows>' + LineEnding;
    143154  for I := 0 to Rows.Count - 1 do begin
    144     Result := Result + '    <contact>' + LineEnding;
     155    Result := Result + '    <row>' + LineEnding;
    145156    for J := 0 to Rows[I].Cells.Count - 1 do
    146157      if Rows[I].Cells[J] <> '' then
    147         Result := Result + '      <property name="' + Columns[J] + '">' + ReplaceXmlEntities(Rows[I].Cells[J]) + '</property>' + LineEnding;
    148     Result := Result + '    </contact>' + LineEnding;
    149   end;
    150   Result := Result + '  </contacts>' + LineEnding +
    151     '</vcard>';
     158        Result := Result + '      <cell name="' + Columns[J] + '">' + ReplaceXmlEntities(Rows[I].Cells[J]) + '</cell>' + LineEnding;
     159    Result := Result + '    </row>' + LineEnding;
     160  end;
     161  Result := Result + '  </rows>' + LineEnding +
     162    '</table>';
    152163end;
    153164
     
    255266    tfMediaWiki: Result := GetOutputMediaWiki;
    256267    tfXml: Result := GetOutputXml;
    257     else Result := '';
     268    else raise Exception.Create(SUnsupportedFormat);
     269  end;
     270end;
     271
     272procedure TTable.SetInputTabs(Text: string);
     273begin
     274
     275end;
     276
     277procedure TTable.SetInputPlain(Text: string);
     278begin
     279
     280end;
     281
     282procedure TTable.SetInputCsv(Text: string);
     283begin
     284
     285end;
     286
     287procedure TTable.SetInputXml(Text: string);
     288begin
     289
     290end;
     291
     292procedure TTable.SetInputHtml(Text: string);
     293begin
     294
     295end;
     296
     297procedure TTable.SetInputMediaWiki(Text: string);
     298begin
     299
     300end;
     301
     302procedure TTable.SetInput(OutputFormat: TTableFormat; Text: string);
     303begin
     304  case OutputFormat of
     305    tfExcel: SetInputTabs(Text);
     306    tfPlain: SetInputPlain(Text);
     307    tfCsv: SetInputCsv(Text);
     308    tfHtml: SetInputHtml(Text);
     309    tfMediaWiki: SetInputMediaWiki(Text);
     310    tfXml: SetInputXml(Text);
     311    else raise Exception.Create(SUnsupportedFormat);
    258312  end;
    259313end;
Note: See TracChangeset for help on using the changeset viewer.