You've already forked lazarus-ccr
fpspreadsheet: Add workaround for missing xml spaces to TsOpenDocReader.ReadNumFormats.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3120 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3,8 +3,9 @@ opendocread.dpr
|
|||||||
|
|
||||||
Demonstrates how to read an OpenDocument file using the fpspreadsheet library
|
Demonstrates how to read an OpenDocument file using the fpspreadsheet library
|
||||||
|
|
||||||
AUTHORS: Felipe Monteiro de Carvalho, Werner Pamler
|
AUTHORS: Felipe Monteiro de Carvalho
|
||||||
}
|
}
|
||||||
|
|
||||||
program opendocread;
|
program opendocread;
|
||||||
|
|
||||||
{$mode delphi}{$H+}
|
{$mode delphi}{$H+}
|
||||||
@ -26,7 +27,7 @@ begin
|
|||||||
|
|
||||||
// Open the input file
|
// Open the input file
|
||||||
MyDir := ExtractFilePath(ParamStr(0));
|
MyDir := ExtractFilePath(ParamStr(0));
|
||||||
InputFileName := MyDir + 'testodf.ods';
|
InputFileName := MyDir + 'test.ods';
|
||||||
WriteLn('Opening input file ', InputFilename);
|
WriteLn('Opening input file ', InputFilename);
|
||||||
|
|
||||||
// Create the spreadsheet
|
// Create the spreadsheet
|
||||||
|
@ -18,6 +18,11 @@ http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.pdf
|
|||||||
|
|
||||||
AUTHORS: Felipe Monteiro de Carvalho / Jose Luis Jurado Rincon
|
AUTHORS: Felipe Monteiro de Carvalho / Jose Luis Jurado Rincon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ TODO: Remove the date/time separator workaround in ReadNumStyle once a patch
|
||||||
|
giving access to PreserveSpaces in xmlRead is available in fpc }
|
||||||
|
|
||||||
|
|
||||||
unit fpsopendocument;
|
unit fpsopendocument;
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef fpc}
|
||||||
@ -851,6 +856,7 @@ var
|
|||||||
nf: TsNumberFormat;
|
nf: TsNumberFormat;
|
||||||
nex: Integer;
|
nex: Integer;
|
||||||
s, s1, s2: String;
|
s, s1, s2: String;
|
||||||
|
sep: String; // separator between date/time parts
|
||||||
begin
|
begin
|
||||||
if not Assigned(AStylesNode) then
|
if not Assigned(AStylesNode) then
|
||||||
exit;
|
exit;
|
||||||
@ -900,6 +906,7 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
fmtName := GetAttrValue(NumFormatNode, 'style:name');
|
fmtName := GetAttrValue(NumFormatNode, 'style:name');
|
||||||
fmt := '';
|
fmt := '';
|
||||||
|
sep := ' '; // part of date/time separator workaround
|
||||||
node := NumFormatNode.FirstChild;
|
node := NumFormatNode.FirstChild;
|
||||||
while Assigned(node) do begin
|
while Assigned(node) do begin
|
||||||
if node.NodeName = 'number:year' then begin
|
if node.NodeName = 'number:year' then begin
|
||||||
@ -955,8 +962,16 @@ begin
|
|||||||
if node.NodeName = 'number:am-pm' then
|
if node.NodeName = 'number:am-pm' then
|
||||||
fmt := fmt + 'AM/PM'
|
fmt := fmt + 'AM/PM'
|
||||||
else
|
else
|
||||||
if node.NodeName = 'number:text' then
|
if node.NodeName = 'number:text' then begin
|
||||||
fmt := fmt + node.TextContent;
|
{ date/time separator workaround: sep is a space by default
|
||||||
|
and is replaced here by the TextContent separator. It has the
|
||||||
|
consequence that the equivalent of the format string "yymmdd" will
|
||||||
|
be decoded as "yy mm dd"!
|
||||||
|
Remove this once a patch giving access to PreserveSpaces in xmlRead
|
||||||
|
is included in fpc. }
|
||||||
|
sep := node.TextContent;
|
||||||
|
fmt := fmt + sep;
|
||||||
|
end;
|
||||||
node := node.NextSibling;
|
node := node.NextSibling;
|
||||||
end;
|
end;
|
||||||
NumFormatList.AddFormat(fmtName, fmt, nfFmtDateTime);
|
NumFormatList.AddFormat(fmtName, fmt, nfFmtDateTime);
|
||||||
|
Reference in New Issue
Block a user