+ Initial write date/time cell support for opendocument/OpenOffice/Libreoffice

To do: adjust test suite for .ods files



git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2867 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
bigchimp
2013-12-23 13:35:36 +00:00
parent 93206c37ca
commit 018f05324b
2 changed files with 16 additions and 5 deletions

View File

@ -712,17 +712,26 @@ end;
{******************************************************************* {*******************************************************************
* TsSpreadOpenDocWriter.WriteDateTime () * TsSpreadOpenDocWriter.WriteDateTime ()
* *
* DESCRIPTION: Writes a date/time value as a text * DESCRIPTION: Writes a date/time value
* ISO 8601 format is used to preserve interoperability
* between locales.
* *
* Note: this should be replaced by writing actual date/time values
* *
*******************************************************************} *******************************************************************}
procedure TsSpreadOpenDocWriter.WriteDateTime(AStream: TStream; procedure TsSpreadOpenDocWriter.WriteDateTime(AStream: TStream;
const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell); const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell);
var
lStyle: string = '';
lIndex: Integer;
begin begin
WriteLabel(AStream, ARow, ACol, FormatDateTime(ISO8601Format, AValue), ACell); if ACell^.UsedFormattingFields <> [] then
begin
lIndex := FindFormattingInList(ACell);
lStyle := ' table:style-name="ce' + IntToStr(lIndex) + '" ';
end;
// The row should already be the correct one
FContent := FContent +
' <table:table-cell office:value-type="date" office:date-value="' + FormatDateTime(ISO8601FormatExtended, AValue) + '"' + lStyle + '>' + LineEnding +
' </table:table-cell>' + LineEnding;
end; end;
{ {

View File

@ -18,6 +18,8 @@ const
// Date formatting string for unambiguous date/time display as strings // Date formatting string for unambiguous date/time display as strings
// Can be used for text output when date/time cell support is not available // Can be used for text output when date/time cell support is not available
ISO8601Format='yyyymmdd"T"hhmmss'; ISO8601Format='yyyymmdd"T"hhmmss';
// Extended ISO 8601 date/time format, used in e.g. ODF/opendocument
ISO8601FormatExtended='yyyy"-"mm"-"dd"T"hh":"mm":"ss';
// Endianess helper functions // Endianess helper functions
function WordToLE(AValue: Word): Word; function WordToLE(AValue: Word): Word;