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:
parent
7c09abbb51
commit
1b146107ad
@ -63,6 +63,7 @@ begin
|
||||
book := TsWorkbook.Create;
|
||||
try
|
||||
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.DateLastModified := Now();
|
||||
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('Assign the author to the field CreatedBy.');
|
||||
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.AddCustom('Comparny', 'Disney');
|
||||
book.MetaData.AddCustom('Status', 'finished');
|
||||
|
@ -1984,6 +1984,9 @@ begin
|
||||
'meta:keyword':
|
||||
if s <> '' then
|
||||
book.MetaData.KeyWords.Add(s);
|
||||
'<dc:creator>':
|
||||
if s <> '' then
|
||||
book.MetaData.LastModifiedBy := s;
|
||||
'dc:date':
|
||||
if s <> '' then
|
||||
book.MetaData.DateLastModified := ISO8601StrToDateTime(s);
|
||||
@ -5888,6 +5891,10 @@ begin
|
||||
AppendToStream(FSMeta, Format(
|
||||
'<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
|
||||
begin
|
||||
// ODS stored the creation date in UTC.
|
||||
|
@ -968,27 +968,30 @@ type
|
||||
{@@ Meta data for the workbook}
|
||||
TsMetaData = class
|
||||
private
|
||||
FCreatedBy: String;
|
||||
FDateCreated: TDateTime;
|
||||
FDateLastModified: TDateTime;
|
||||
FLastModifiedBy: String;
|
||||
FTitle: String;
|
||||
FSubject: String;
|
||||
FAuthors: TStrings;
|
||||
FComments: TStrings;
|
||||
FKeywords: TStrings;
|
||||
FCustom: TStrings;
|
||||
function GetCreatedBy: String;
|
||||
procedure SetCreatedBy(AValue: String);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function AddCustom(AName, AValue: String): Integer;
|
||||
procedure Clear;
|
||||
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 DateCreated: TDateTime read FDateCreated write FDateCreated;
|
||||
property DateLastModified: TDatetime read FDateLastModified write FDateLastModified;
|
||||
property Subject: String read FSubject write FSubject;
|
||||
property Title: String read FTitle write FTitle;
|
||||
property Authors: TStrings read FAuthors write FAuthors;
|
||||
property Comments: TStrings read FComments write FComments;
|
||||
property Custom: TStrings read FCustom write FCustom;
|
||||
property Keywords: TStrings read FKeywords write FKeywords;
|
||||
@ -1201,6 +1204,9 @@ end;
|
||||
constructor TsMetaData.Create;
|
||||
begin
|
||||
inherited;
|
||||
FAuthors := TStringList.Create;
|
||||
FAuthors.StrictDelimiter := true;
|
||||
FAuthors.Delimiter := ';';
|
||||
FComments := TStringList.Create;
|
||||
FKeywords := TStringList.Create;
|
||||
FCustom := TStringList.Create;
|
||||
@ -1208,6 +1214,7 @@ end;
|
||||
|
||||
destructor TsMetaData.Destroy;
|
||||
begin
|
||||
FAuthors.Free;
|
||||
FComments.Free;
|
||||
FKeywords.Free;
|
||||
FCustom.Free;
|
||||
@ -1218,10 +1225,10 @@ procedure TsMetaData.Clear;
|
||||
begin
|
||||
FTitle := '';
|
||||
FSubject := '';
|
||||
FCreatedBy := '';
|
||||
FLastModifiedBy := '';
|
||||
FDateCreated := 0;
|
||||
FDateLastModified := 0;
|
||||
FAuthors.Clear;
|
||||
FComments.Clear;
|
||||
FKeywords.Clear;
|
||||
FCustom.Clear;
|
||||
@ -1236,12 +1243,23 @@ begin
|
||||
Result := FCustom.Add(AName + '=' + AValue);
|
||||
end;
|
||||
|
||||
function TsMetaData.GetCreatedBy: String;
|
||||
begin
|
||||
Result := FAuthors.DelimitedText;
|
||||
end;
|
||||
|
||||
function TsMetaData.IsEmpty: Boolean;
|
||||
begin
|
||||
Result := (FCreatedBy = '') and (FLastModifiedBy = '') and
|
||||
(FTitle = '') and (FSubject = '') and
|
||||
(FComments.Count = 0) and (FKeywords.Count = 0) and (FCustom.Count = 0) and
|
||||
(FDateCreated = 0) and (FDateLastModified = 0);
|
||||
Result := (FLastModifiedBy = '') and (FTitle = '') and (FSubject = '') and
|
||||
(FAuthors.Count = 0) and (FComments.Count = 0) and (FKeywords.Count = 0) and
|
||||
(FCustom.Count = 0) and (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;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user