fpspreadsheet: Add currency test cases to numbertests. 1 fail for biff to be fixed, ods ok. Remove experimental code from opendocread.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3142 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-06-05 09:14:13 +00:00
parent 292908eac3
commit c335deb56c
7 changed files with 65 additions and 15 deletions

View File

@ -42,15 +42,11 @@ begin
WriteLn('Contents of the first worksheet of the file:'); WriteLn('Contents of the first worksheet of the file:');
WriteLn(''); WriteLn('');
WriteLn('****', EncodeDate(1908,12,09) + EncodeTime(12,0,0,0));
cell := MyWorkSheet.GetFirstCell(); cell := MyWorkSheet.GetFirstCell();
for i := 0 to MyWorksheet.GetCellCount - 1 do begin for i := 0 to MyWorksheet.GetCellCount - 1 do begin
WriteLn('Row: ', cell^.Row, WriteLn('Row: ', cell^.Row,
' Col: ', cell^.Col, ' Value: ', ' Col: ', cell^.Col, ' Value: ',
UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(cell^.Row, cell^.Col)) UTF8ToAnsi(MyWorkSheet.ReadAsUTF8Text(cell^.Row, cell^.Col))
, ' NumberValue:', FloatToStr(cell^.NumberValue)
, ' DateTimeValue: ', FloatToStr(cell^.DateTimeValue)
); );
cell := MyWorkSheet.GetNextCell(); cell := MyWorkSheet.GetNextCell();
end; end;

View File

@ -42,10 +42,11 @@ uses
fpsutils; fpsutils;
type type
TDateMode=(dm1899 {default for ODF; almost same as Excel 1900}, TDateMode=(
dm1899 {default for ODF; almost same as Excel 1900},
dm1900 {StarCalc legacy only}, dm1900 {StarCalc legacy only},
dm1904 {e.g. Quattro Pro,Mac Excel compatibility} dm1904 {e.g. Quattro Pro,Mac Excel compatibility}
); );
{ TsSpreadOpenDocNumFormatList } { TsSpreadOpenDocNumFormatList }
TsSpreadOpenDocNumFormatList = class(TsCustomNumFormatList) TsSpreadOpenDocNumFormatList = class(TsCustomNumFormatList)
@ -1271,7 +1272,10 @@ begin
if paramValueType = 'string' then if paramValueType = 'string' then
ReadLabel(row, col, cellNode) ReadLabel(row, col, cellNode)
else if (paramValueType = 'float') or (paramValueType = 'percentage') then else
if (paramValueType = 'float') or (paramValueType = 'percentage') or
(paramValueType = 'currency')
then
ReadNumber(row, col, cellNode) ReadNumber(row, col, cellNode)
else if (paramValueType = 'date') or (paramValueType = 'time') then else if (paramValueType = 'date') or (paramValueType = 'time') then
ReadDateTime(row, col, cellNode) ReadDateTime(row, col, cellNode)

View File

@ -22,7 +22,7 @@ uses
var var
// Norm to test against - list of numbers/times that should occur in spreadsheet // Norm to test against - list of numbers/times that should occur in spreadsheet
SollNumbers: array[0..20] of double; //"Soll" is a German word in Dutch accountancy jargon meaning "normative value to check against". There ;) SollNumbers: array[0..23] of double; //"Soll" is a German word in Dutch accountancy jargon meaning "normative value to check against". There ;)
// Initializes Soll*/normative variables. // Initializes Soll*/normative variables.
// Useful in test setup procedures to make sure the norm is correct. // Useful in test setup procedures to make sure the norm is correct.
procedure InitSollNumbers; procedure InitSollNumbers;
@ -61,6 +61,10 @@ type
procedure TestReadNumber17; procedure TestReadNumber17;
procedure TestReadNumber18; procedure TestReadNumber18;
procedure TestReadNumber19; procedure TestReadNumber19;
procedure TestReadNumber20;
procedure TestReadNumber21;
procedure TestReadNumber22;
procedure TestReadNumber23;
procedure TestReadODFNumber0; //number tests using ODF/LibreOffice file format procedure TestReadODFNumber0; //number tests using ODF/LibreOffice file format
procedure TestReadODFNumber1; //number and time procedure TestReadODFNumber1; //number and time
procedure TestReadODFNumber2; procedure TestReadODFNumber2;
@ -81,6 +85,10 @@ type
procedure TestReadODFNumber17; procedure TestReadODFNumber17;
procedure TestReadODFNumber18; procedure TestReadODFNumber18;
procedure TestReadODFNumber19; procedure TestReadODFNumber19;
procedure TestReadODFNumber20;
procedure TestReadODFNumber21;
procedure TestReadODFNumber22;
procedure TestReadODFNumber23;
end; end;
{ TSpreadWriteReadNumberTests } { TSpreadWriteReadNumberTests }
@ -140,8 +148,11 @@ begin
SollNumbers[16]:=59000000.1234; // 59 million + 0.1234 formatted with thousand separator, 2 decimals SollNumbers[16]:=59000000.1234; // 59 million + 0.1234 formatted with thousand separator, 2 decimals
SollNumbers[17]:=-59000000.1234; // minus 59 million + 0.1234, formatted as "scientific" with 1 decimal SollNumbers[17]:=-59000000.1234; // minus 59 million + 0.1234, formatted as "scientific" with 1 decimal
SollNumbers[18]:=-59000000.1234; // minus 59 million + 0.1234, formatted as "exp" with 2 decimals SollNumbers[18]:=-59000000.1234; // minus 59 million + 0.1234, formatted as "exp" with 2 decimals
SollNumbers[19]:=59000000.1234; // 59 million + 0.1234 formatted as currrency (EUROs), 2 decimals SollNumbers[19]:=59000000.1234; // 59 million + 0.1234 formatted as currrency (EUROs, at end), 2 decimals
SollNumbers[20]:=59000000.1234; // 59 million + 0.1234 formatted as currrency (Dollars), 2 decimals SollNumbers[20]:=59000000.1234; // 59 million + 0.1234 formatted as currrency (Dollars, at end), 2 decimals
SollNumbers[21]:=-59000000.1234; // minus 59 million + 0.1234 formatted as currrency (EUROs, at end), 2 decimals
SollNumbers[22]:=-59000000.1234; // minus 59 million + 0.1234 formatted as currrency (Dollars, at end), 2 decimals
SollNumbers[23]:=-59000000.1234; // minus 59 million + 0.1234 formatted as currrency (Dollars, at end, neg red), 2 decimals
end; end;
{ TSpreadWriteReadNumberTests } { TSpreadWriteReadNumberTests }
@ -360,12 +371,32 @@ end;
procedure TSpreadReadNumberTests.TestReadNumber18; procedure TSpreadReadNumberTests.TestReadNumber18;
begin begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,16); TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,18);
end; end;
procedure TSpreadReadNumberTests.TestReadNumber19; procedure TSpreadReadNumberTests.TestReadNumber19;
begin begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,17); TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,19);
end;
procedure TSpreadReadNumberTests.TestReadNumber20;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,20);
end;
procedure TSpreadReadNumberTests.TestReadNumber21;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,21);
end;
procedure TSpreadReadNumberTests.TestReadNumber22;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,22);
end;
procedure TSpreadReadNumberTests.TestReadNumber23;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileBIFF8,23);
end; end;
procedure TSpreadReadNumberTests.TestReadODFNumber0; procedure TSpreadReadNumberTests.TestReadODFNumber0;
@ -460,21 +491,40 @@ end;
procedure TSpreadReadNumberTests.TestReadODFNumber18; procedure TSpreadReadNumberTests.TestReadODFNumber18;
begin begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,16); TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,18);
end; end;
procedure TSpreadReadNumberTests.TestReadODFNumber19; procedure TSpreadReadNumberTests.TestReadODFNumber19;
begin begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,17); TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,19);
end; end;
procedure TSpreadReadNumberTests.TestReadODFNumber20;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,20);
end;
procedure TSpreadReadNumberTests.TestReadODFNumber21;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,21);
end;
procedure TSpreadReadNumberTests.TestReadODFNumber22;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,22);
end;
procedure TSpreadReadNumberTests.TestReadODFNumber23;
begin
TestReadNumber(ExtractFilePath(ParamStr(0)) + TestFileODF,23);
end;
initialization initialization
// Register so these tests are included in a full run // Register so these tests are included in a full run
RegisterTest(TSpreadReadNumberTests); RegisterTest(TSpreadReadNumberTests);
RegisterTest(TSpreadWriteReadNumberTests); RegisterTest(TSpreadWriteReadNumberTests);
InitSollNumbers; //useful to have norm data if other code want to use this unit InitSollNumbers; //useful to have norm data if other code wants to use this unit
finalization finalization
FreeAndNil(TestWorkbook); FreeAndNil(TestWorkbook);