Issue #1013: create Jira Textile format for grid result export

This commit is contained in:
Ansgar Becker
2022-02-13 11:41:51 +01:00
parent e6d7a899ee
commit 4ceec67f08

View File

@ -5,10 +5,10 @@ interface
uses uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList, Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList,
extra_controls, dbstructures, SynRegExpr; extra_controls, dbstructures, SynRegExpr, System.StrUtils;
type type
TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efSQLUpdate, efLaTeX, efTextile, efPHPArray, efMarkDown, efJSON); TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efSQLUpdate, efLaTeX, efTextile, efJiraTextile, efPHPArray, efMarkDown, efJSON);
TfrmExportGrid = class(TExtForm) TfrmExportGrid = class(TExtForm)
btnOK: TButton; btnOK: TButton;
@ -85,11 +85,11 @@ type
public public
{ Public declarations } { Public declarations }
const FormatToFileExtension: Array[TGridExportFormat] of String = const FormatToFileExtension: Array[TGridExportFormat] of String =
(('csv'), ('csv'), ('html'), ('xml'), ('sql'), ('sql'), ('sql'), ('sql'), ('LaTeX'), ('textile'), ('php'), ('md'), ('json')); (('csv'), ('csv'), ('html'), ('xml'), ('sql'), ('sql'), ('sql'), ('sql'), ('LaTeX'), ('textile'), ('jira-textile'), ('php'), ('md'), ('json'));
const FormatToDescription: Array[TGridExportFormat] of String = const FormatToDescription: Array[TGridExportFormat] of String =
(('Excel CSV'), ('Delimited text'), ('HTML table'), ('XML'), ('SQL INSERTs'), ('SQL REPLACEs'), ('SQL DELETEs/INSERTs'), ('SQL UPDATEs'), ('LaTeX'), ('Textile'), ('PHP Array'), ('Markdown Here'), ('JSON')); (('Excel CSV'), ('Delimited text'), ('HTML table'), ('XML'), ('SQL INSERTs'), ('SQL REPLACEs'), ('SQL DELETEs/INSERTs'), ('SQL UPDATEs'), ('LaTeX'), ('Textile'), ('Jira Textile'), ('PHP Array'), ('Markdown Here'), ('JSON'));
const FormatToImageIndex: Array[TGridExportFormat] of Integer = const FormatToImageIndex: Array[TGridExportFormat] of Integer =
(49, 50, 32, 48, 201, 201, 201, 201, 153, 154, 202, 199, 200); (49, 50, 32, 48, 201, 201, 201, 201, 153, 154, 154, 202, 199, 200);
const CopyAsActionPrefix = 'actCopyAs'; const CopyAsActionPrefix = 'actCopyAs';
property Grid: TVirtualStringTree read FGrid write FGrid; property Grid: TVirtualStringTree read FGrid write FGrid;
property ExportFormat: TGridExportFormat read GetExportFormat write SetExportFormat; property ExportFormat: TGridExportFormat read GetExportFormat write SetExportFormat;
@ -719,12 +719,12 @@ begin
end; end;
end; end;
efTextile: begin efTextile, efJiraTextile: begin
Separator := ' |_. '; Separator := IfThen(ExportFormat=efTextile, ' |_. ', ' || ');
Encloser := ''; Encloser := '';
Terminator := ' |'+CRLF; Terminator := IfThen(ExportFormat=efTextile, ' |', ' ||') + CRLF;
if chkIncludeColumnNames.Checked then begin if chkIncludeColumnNames.Checked then begin
Header := '|_. '; Header := TrimLeft(Separator);
Col := Grid.Header.Columns.GetFirstVisibleColumn; Col := Grid.Header.Columns.GetFirstVisibleColumn;
while Col > NoColumn do begin while Col > NoColumn do begin
if Col <> ExcludeCol then if Col <> ExcludeCol then
@ -735,6 +735,7 @@ begin
Header := Header + Terminator; Header := Header + Terminator;
end; end;
Separator := ' | '; Separator := ' | ';
Terminator := ' |' + CRLF;
end; end;
efPHPArray: begin efPHPArray: begin
@ -842,7 +843,7 @@ begin
tmp := tmp + ' VALUES ('; tmp := tmp + ' VALUES (';
end; end;
efTextile: tmp := TrimLeft(Separator); efTextile, efJiraTextile: tmp := TrimLeft(Separator);
efPHPArray: tmp := #9 + 'array('+CRLF; efPHPArray: tmp := #9 + 'array('+CRLF;
@ -907,7 +908,7 @@ begin
tmp := tmp + Data + Separator; tmp := tmp + Data + Separator;
end; end;
efTextile: begin efTextile, efJiraTextile: begin
tmp := tmp + Data + Separator; tmp := tmp + Data + Separator;
end; end;
@ -997,7 +998,7 @@ begin
case ExportFormat of case ExportFormat of
efHTML: efHTML:
tmp := tmp + ' </tr>' + CRLF; tmp := tmp + ' </tr>' + CRLF;
efExcel, efCSV, efLaTeX, efTextile: begin efExcel, efCSV, efLaTeX, efTextile, efJiraTextile: begin
Delete(tmp, Length(tmp)-Length(Separator)+1, Length(Separator)); Delete(tmp, Length(tmp)-Length(Separator)+1, Length(Separator));
tmp := tmp + Terminator; tmp := tmp + Terminator;
end; end;