You've already forked lazarus-ccr
fpspreadsheet: Allow multiple authors in metadata.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7592 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -63,6 +63,7 @@ begin
|
|||||||
book := TsWorkbook.Create;
|
book := TsWorkbook.Create;
|
||||||
try
|
try
|
||||||
book.MetaData.CreatedBy := 'Donald Duck';
|
book.MetaData.CreatedBy := 'Donald Duck';
|
||||||
|
book.MetaData.Authors.Add('Donald Duck II');
|
||||||
book.MetaData.DateCreated := EncodeDate(2020, 1, 1) + EncodeTime(12, 30, 40, 20);
|
book.MetaData.DateCreated := EncodeDate(2020, 1, 1) + EncodeTime(12, 30, 40, 20);
|
||||||
book.MetaData.DateLastModified := Now();
|
book.MetaData.DateLastModified := Now();
|
||||||
book.MetaData.LastModifiedBy := 'Dagobert Duck';
|
book.MetaData.LastModifiedBy := 'Dagobert Duck';
|
||||||
@ -71,7 +72,7 @@ begin
|
|||||||
book.MetaData.Comments.Add('This is a test of spreadsheet metadata.');
|
book.MetaData.Comments.Add('This is a test of spreadsheet metadata.');
|
||||||
book.MetaData.Comments.Add('Assign the author to the field CreatedBy.');
|
book.MetaData.Comments.Add('Assign the author to the field CreatedBy.');
|
||||||
book.MetaData.Comments.Add('Assign the creation date to the field CreatedAt.');
|
book.MetaData.Comments.Add('Assign the creation date to the field CreatedAt.');
|
||||||
book.MetaData.Keywords.Add('Test');
|
book.MetaData.Keywords.Add('Test1,Test2');
|
||||||
book.MetaData.Keywords.Add('FPSpreadsheet');
|
book.MetaData.Keywords.Add('FPSpreadsheet');
|
||||||
book.MetaData.AddCustom('Comparny', 'Disney');
|
book.MetaData.AddCustom('Comparny', 'Disney');
|
||||||
book.MetaData.AddCustom('Status', 'finished');
|
book.MetaData.AddCustom('Status', 'finished');
|
||||||
|
@ -1984,6 +1984,9 @@ begin
|
|||||||
'meta:keyword':
|
'meta:keyword':
|
||||||
if s <> '' then
|
if s <> '' then
|
||||||
book.MetaData.KeyWords.Add(s);
|
book.MetaData.KeyWords.Add(s);
|
||||||
|
'<dc:creator>':
|
||||||
|
if s <> '' then
|
||||||
|
book.MetaData.LastModifiedBy := s;
|
||||||
'dc:date':
|
'dc:date':
|
||||||
if s <> '' then
|
if s <> '' then
|
||||||
book.MetaData.DateLastModified := ISO8601StrToDateTime(s);
|
book.MetaData.DateLastModified := ISO8601StrToDateTime(s);
|
||||||
@ -5888,6 +5891,10 @@ begin
|
|||||||
AppendToStream(FSMeta, Format(
|
AppendToStream(FSMeta, Format(
|
||||||
'<meta:initial-creator>%s</meta:initial-creator>', [book.MetaData.CreatedBy]));
|
'<meta:initial-creator>%s</meta:initial-creator>', [book.MetaData.CreatedBy]));
|
||||||
|
|
||||||
|
if book.MetaData.LastModifiedBy <> '' then
|
||||||
|
AppendToStream(FSMeta, Format(
|
||||||
|
'<dc:creator>%s</dc:creator>', [book.Metadata.LastMofifiedBy]));
|
||||||
|
|
||||||
if book.MetaData.DateCreated > 0 then
|
if book.MetaData.DateCreated > 0 then
|
||||||
begin
|
begin
|
||||||
// ODS stored the creation date in UTC.
|
// ODS stored the creation date in UTC.
|
||||||
|
@ -968,27 +968,30 @@ type
|
|||||||
{@@ Meta data for the workbook}
|
{@@ Meta data for the workbook}
|
||||||
TsMetaData = class
|
TsMetaData = class
|
||||||
private
|
private
|
||||||
FCreatedBy: String;
|
|
||||||
FDateCreated: TDateTime;
|
FDateCreated: TDateTime;
|
||||||
FDateLastModified: TDateTime;
|
FDateLastModified: TDateTime;
|
||||||
FLastModifiedBy: String;
|
FLastModifiedBy: String;
|
||||||
FTitle: String;
|
FTitle: String;
|
||||||
FSubject: String;
|
FSubject: String;
|
||||||
|
FAuthors: TStrings;
|
||||||
FComments: TStrings;
|
FComments: TStrings;
|
||||||
FKeywords: TStrings;
|
FKeywords: TStrings;
|
||||||
FCustom: TStrings;
|
FCustom: TStrings;
|
||||||
|
function GetCreatedBy: String;
|
||||||
|
procedure SetCreatedBy(AValue: String);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function AddCustom(AName, AValue: String): Integer;
|
function AddCustom(AName, AValue: String): Integer;
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
function IsEmpty: Boolean;
|
function IsEmpty: Boolean;
|
||||||
property CreatedBy: String read FCreatedBy write FCreatedBy;
|
property CreatedBy: String read GetCreatedBy write SetCreatedBy;
|
||||||
property LastModifiedBy: String read FLastModifiedBy write FLastModifiedBy;
|
property LastModifiedBy: String read FLastModifiedBy write FLastModifiedBy;
|
||||||
property DateCreated: TDateTime read FDateCreated write FDateCreated;
|
property DateCreated: TDateTime read FDateCreated write FDateCreated;
|
||||||
property DateLastModified: TDatetime read FDateLastModified write FDateLastModified;
|
property DateLastModified: TDatetime read FDateLastModified write FDateLastModified;
|
||||||
property Subject: String read FSubject write FSubject;
|
property Subject: String read FSubject write FSubject;
|
||||||
property Title: String read FTitle write FTitle;
|
property Title: String read FTitle write FTitle;
|
||||||
|
property Authors: TStrings read FAuthors write FAuthors;
|
||||||
property Comments: TStrings read FComments write FComments;
|
property Comments: TStrings read FComments write FComments;
|
||||||
property Custom: TStrings read FCustom write FCustom;
|
property Custom: TStrings read FCustom write FCustom;
|
||||||
property Keywords: TStrings read FKeywords write FKeywords;
|
property Keywords: TStrings read FKeywords write FKeywords;
|
||||||
@ -1201,6 +1204,9 @@ end;
|
|||||||
constructor TsMetaData.Create;
|
constructor TsMetaData.Create;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
FAuthors := TStringList.Create;
|
||||||
|
FAuthors.StrictDelimiter := true;
|
||||||
|
FAuthors.Delimiter := ';';
|
||||||
FComments := TStringList.Create;
|
FComments := TStringList.Create;
|
||||||
FKeywords := TStringList.Create;
|
FKeywords := TStringList.Create;
|
||||||
FCustom := TStringList.Create;
|
FCustom := TStringList.Create;
|
||||||
@ -1208,6 +1214,7 @@ end;
|
|||||||
|
|
||||||
destructor TsMetaData.Destroy;
|
destructor TsMetaData.Destroy;
|
||||||
begin
|
begin
|
||||||
|
FAuthors.Free;
|
||||||
FComments.Free;
|
FComments.Free;
|
||||||
FKeywords.Free;
|
FKeywords.Free;
|
||||||
FCustom.Free;
|
FCustom.Free;
|
||||||
@ -1218,10 +1225,10 @@ procedure TsMetaData.Clear;
|
|||||||
begin
|
begin
|
||||||
FTitle := '';
|
FTitle := '';
|
||||||
FSubject := '';
|
FSubject := '';
|
||||||
FCreatedBy := '';
|
|
||||||
FLastModifiedBy := '';
|
FLastModifiedBy := '';
|
||||||
FDateCreated := 0;
|
FDateCreated := 0;
|
||||||
FDateLastModified := 0;
|
FDateLastModified := 0;
|
||||||
|
FAuthors.Clear;
|
||||||
FComments.Clear;
|
FComments.Clear;
|
||||||
FKeywords.Clear;
|
FKeywords.Clear;
|
||||||
FCustom.Clear;
|
FCustom.Clear;
|
||||||
@ -1236,12 +1243,23 @@ begin
|
|||||||
Result := FCustom.Add(AName + '=' + AValue);
|
Result := FCustom.Add(AName + '=' + AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TsMetaData.GetCreatedBy: String;
|
||||||
|
begin
|
||||||
|
Result := FAuthors.DelimitedText;
|
||||||
|
end;
|
||||||
|
|
||||||
function TsMetaData.IsEmpty: Boolean;
|
function TsMetaData.IsEmpty: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (FCreatedBy = '') and (FLastModifiedBy = '') and
|
Result := (FLastModifiedBy = '') and (FTitle = '') and (FSubject = '') and
|
||||||
(FTitle = '') and (FSubject = '') and
|
(FAuthors.Count = 0) and (FComments.Count = 0) and (FKeywords.Count = 0) and
|
||||||
(FComments.Count = 0) and (FKeywords.Count = 0) and (FCustom.Count = 0) and
|
(FCustom.Count = 0) and (FDateCreated = 0) and (FDateLastModified = 0);
|
||||||
(FDateCreated = 0) and (FDateLastModified = 0);
|
end;
|
||||||
|
|
||||||
|
{ Provide initial author. In case of multiple authors, separate the names by
|
||||||
|
semicolons. }
|
||||||
|
procedure TsMetaData.SetCreatedBy(AValue: String);
|
||||||
|
begin
|
||||||
|
FAuthors.DelimitedText := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user