You've already forked lazarus-ccr
fpspreadsheet: Fix reading time interval format for ods
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3134 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 359
|
Left = 409
|
||||||
Height = 649
|
Height = 649
|
||||||
Top = 193
|
Top = 248
|
||||||
Width = 884
|
Width = 884
|
||||||
Caption = 'fpsGrid'
|
Caption = 'fpsGrid'
|
||||||
ClientHeight = 629
|
ClientHeight = 629
|
||||||
|
@ -864,12 +864,27 @@ procedure TsSpreadOpenDocReader.ReadDateTime(ARow: Word; ACol : Word;
|
|||||||
var
|
var
|
||||||
dt: TDateTime;
|
dt: TDateTime;
|
||||||
styleName: String;
|
styleName: String;
|
||||||
|
cell: PCell;
|
||||||
begin
|
begin
|
||||||
dt := ExtractDateTimeFromNode(ACellNode);
|
dt := ExtractDateTimeFromNode(ACellNode);
|
||||||
FWorkSheet.WriteDateTime(ARow, ACol, dt);
|
FWorkSheet.WriteDateTime(ARow, ACol, dt);
|
||||||
|
|
||||||
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
||||||
ApplyStyleToCell(ARow, ACol, stylename);
|
ApplyStyleToCell(ARow, ACol, stylename);
|
||||||
|
|
||||||
|
if abs(dt) > 1 then begin
|
||||||
|
// Correct days for time intervals: "interval" is independent of origin.
|
||||||
|
// --> we have to undo the DateMode offset added by ExtractDateTimeFromNode
|
||||||
|
cell := FWorksheet.FindCell(ARow, ACol);
|
||||||
|
if (cell^.NumberFormat = nfTimeInterval) or
|
||||||
|
((cell^.NumberFormat = nfFmtDateTime) and (cell^.NumberFormatStr[1] = '['))
|
||||||
|
then
|
||||||
|
case FDateMode of
|
||||||
|
dm1899: cell^.DateTimeValue := cell^.DateTimeValue - DATEMODE_1899_BASE;
|
||||||
|
dm1900: cell^.DateTimeValue := cell^.DateTimeValue - DATEMODE_1900_BASE;
|
||||||
|
dm1904: cell^.DateTimeValue := cell^.DateTimeValue - DATEMODE_1904_BASE;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
||||||
@ -882,18 +897,11 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
styleindex: Integer;
|
styleindex: Integer;
|
||||||
fmt: String;
|
fmt: String;
|
||||||
posfmt, negfmt, zerofmt: String;
|
posfmt, negfmt, zerofmt: String;
|
||||||
isPos, isNeg, isZero: Boolean;
|
|
||||||
begin
|
begin
|
||||||
posfmt := '';
|
posfmt := '';
|
||||||
negfmt := '';
|
negfmt := '';
|
||||||
zerofmt := '';
|
zerofmt := '';
|
||||||
|
|
||||||
// These are indicators which part of the format is currently being read.
|
|
||||||
// Needed to assign text elements correctly.
|
|
||||||
isPos := false;
|
|
||||||
isNeg := false;
|
|
||||||
isZero := false;
|
|
||||||
|
|
||||||
while ANode <> nil do begin
|
while ANode <> nil do begin
|
||||||
condition := ANode.NodeName;
|
condition := ANode.NodeName;
|
||||||
|
|
||||||
@ -921,27 +929,16 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
case condition[1] of
|
case condition[1] of
|
||||||
'<': begin
|
'<': begin
|
||||||
negfmt := fmt;
|
negfmt := fmt;
|
||||||
isneg := true;
|
if (Length(condition) > 1) and (condition[2] = '=') then
|
||||||
ispos := false;
|
|
||||||
if (Length(condition) > 1) and (condition[2] = '=') then begin
|
|
||||||
zerofmt := fmt;
|
zerofmt := fmt;
|
||||||
iszero := true;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
'>': begin
|
'>': begin
|
||||||
posfmt := fmt;
|
posfmt := fmt;
|
||||||
ispos := true;
|
if (Length(condition) > 1) and (condition[2] = '=') then
|
||||||
isneg := false;
|
|
||||||
if (Length(condition) > 1) and (condition[2] = '=') then begin
|
|
||||||
zerofmt := fmt;
|
zerofmt := fmt;
|
||||||
iszero := true;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
'=': begin
|
'=': begin
|
||||||
zerofmt := fmt;
|
zerofmt := fmt;
|
||||||
ispos := false;
|
|
||||||
isneg := false;
|
|
||||||
iszero := true;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ANode := ANode.NextSibling;
|
ANode := ANode.NextSibling;
|
||||||
|
Reference in New Issue
Block a user