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:
wp_xxyyzz
2014-06-01 13:08:14 +00:00
parent 100e8978ef
commit 6f96f3bcb6
2 changed files with 20 additions and 4 deletions

View File

@ -3,8 +3,9 @@ opendocread.dpr
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;
{$mode delphi}{$H+}
@ -26,7 +27,7 @@ begin
// Open the input file
MyDir := ExtractFilePath(ParamStr(0));
InputFileName := MyDir + 'testodf.ods';
InputFileName := MyDir + 'test.ods';
WriteLn('Opening input file ', InputFilename);
// Create the spreadsheet

View File

@ -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
}
{ TODO: Remove the date/time separator workaround in ReadNumStyle once a patch
giving access to PreserveSpaces in xmlRead is available in fpc }
unit fpsopendocument;
{$ifdef fpc}
@ -851,6 +856,7 @@ var
nf: TsNumberFormat;
nex: Integer;
s, s1, s2: String;
sep: String; // separator between date/time parts
begin
if not Assigned(AStylesNode) then
exit;
@ -900,6 +906,7 @@ begin
then begin
fmtName := GetAttrValue(NumFormatNode, 'style:name');
fmt := '';
sep := ' '; // part of date/time separator workaround
node := NumFormatNode.FirstChild;
while Assigned(node) do begin
if node.NodeName = 'number:year' then begin
@ -955,8 +962,16 @@ begin
if node.NodeName = 'number:am-pm' then
fmt := fmt + 'AM/PM'
else
if node.NodeName = 'number:text' then
fmt := fmt + node.TextContent;
if node.NodeName = 'number:text' then begin
{ 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;
end;
NumFormatList.AddFormat(fmtName, fmt, nfFmtDateTime);