From 018f05324b9f1e14b10cf63ed3e2598e611138b1 Mon Sep 17 00:00:00 2001 From: bigchimp Date: Mon, 23 Dec 2013 13:35:36 +0000 Subject: [PATCH] + 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 --- components/fpspreadsheet/fpsopendocument.pas | 19 ++++++++++++++----- components/fpspreadsheet/fpsutils.pas | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas index 27b93a3e7..1af762647 100755 --- a/components/fpspreadsheet/fpsopendocument.pas +++ b/components/fpspreadsheet/fpsopendocument.pas @@ -712,17 +712,26 @@ end; {******************************************************************* * TsSpreadOpenDocWriter.WriteDateTime () * -* DESCRIPTION: Writes a date/time value as a text -* ISO 8601 format is used to preserve interoperability -* between locales. +* DESCRIPTION: Writes a date/time value * -* Note: this should be replaced by writing actual date/time values * *******************************************************************} procedure TsSpreadOpenDocWriter.WriteDateTime(AStream: TStream; const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell); +var + lStyle: string = ''; + lIndex: Integer; 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 + + ' ' + LineEnding + + ' ' + LineEnding; end; { diff --git a/components/fpspreadsheet/fpsutils.pas b/components/fpspreadsheet/fpsutils.pas index b82bc4669..d7b2ffe71 100644 --- a/components/fpspreadsheet/fpsutils.pas +++ b/components/fpspreadsheet/fpsutils.pas @@ -18,6 +18,8 @@ const // Date formatting string for unambiguous date/time display as strings // Can be used for text output when date/time cell support is not available 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 function WordToLE(AValue: Word): Word;