fpspreadsheet: Fix ods writer crashing if number format has more than three sections.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6034 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-10-05 11:41:32 +00:00
parent ea26c9887d
commit f8bfbd673f

View File

@ -684,10 +684,21 @@ var
int,num,denom: Integer; int,num,denom: Integer;
begin begin
Result := ''; Result := '';
if ASection > 2 then // ods supports only at most 3 sections
exit;
if AFormatName = 'N1006' then
ns := 1;
ns := Length(FSections); ns := Length(FSections);
if (ns = 0) then if (ns = 0) then
exit; exit;
if ns > 3 then // ods supports only at most 3 sections
ns := 3;
styleMapStr := ''; styleMapStr := '';
timeIntervalStr := ''; timeIntervalStr := '';
@ -708,8 +719,10 @@ begin
'<style:map '+ '<style:map '+
'style:apply-style-name="' + AFormatName + 'P1" ' + // < 0 'style:apply-style-name="' + AFormatName + 'P1" ' + // < 0
'style:condition="value()&lt;0" />'; 'style:condition="value()&lt;0" />';
{
else else
raise Exception.Create('At most 3 format sections allowed.'); raise Exception.Create('At most 3 format sections allowed.');
}
end end
else else
AFormatName := AFormatName + 'P' + IntToStr(ASection); AFormatName := AFormatName + 'P' + IntToStr(ASection);