fpspreadsheet:

- test for bug 26447: fpspreadsheet columns >26 wrong with ooxml (patch) as fixed in r3273
- fix typo in documentation rfRow=>rfRelRow
- cosmetic changes



git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3276 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
bigchimp
2014-07-04 08:48:12 +00:00
parent 78af234614
commit fb2b3159ea
4 changed files with 28 additions and 11 deletions

View File

@ -287,7 +287,7 @@ const
scPurple = $0C; scPurple = $0C;
scTeal = $0D; scTeal = $0D;
scSilver = $0E; scSilver = $0E;
scGrey = $0F; scGray = $0F; // redefine to allow different kinds of writing scGrey = $0F; scGray = $0F; // redefine to allow different spelling
scGrey10pct = $10; scGray10pct = $10; scGrey10pct = $10; scGray10pct = $10;
scGrey20pct = $11; scGray20pct = $11; scGrey20pct = $11; scGray20pct = $11;
scOrange = $12; scOrange = $12;
@ -1587,8 +1587,8 @@ end;
{@@ {@@
Converts a FPSpreadsheet cell position, which is Row, Col in numbers Converts a FPSpreadsheet cell position, which is Row, Col in numbers
and zero based, to a textual representation which is [Col][Row], and zero based - e.g. 0,0 - to a textual representation which is [Col][Row],
being that the Col is in letters and the row is in 1-based numbers } where the Col is in letters and the row is in 1-based numbers - e.g. A1 }
class function TsWorksheet.CellPosToText(ARow, ACol: Cardinal): string; class function TsWorksheet.CellPosToText(ARow, ACol: Cardinal): string;
begin begin
Result := GetCellString(ARow, ACol, [rfRelCol, rfRelRow]); Result := GetCellString(ARow, ACol, [rfRelCol, rfRelRow]);

View File

@ -599,9 +599,9 @@ const
@param AColIndex Zero-based column index @param AColIndex Zero-based column index
@param AFlags A set containing an entry for column and row if these @param AFlags A set containing an entry for column and row if these
addresses are relative. addresses are relative.
@return Excel-type of cell address containing $ characters for absolute @return Excel type of cell address containing $ characters for absolute
address parts. address parts.
@example ARowIndex = 0, AColIndex = 0, AFlags = [rfRow] --> $A1 @example ARowIndex = 0, AColIndex = 0, AFlags = [rfRelRow] --> $A1
} }
function GetCellString(ARow, ACol: Cardinal; AFlags: TsRelFlags): String; function GetCellString(ARow, ACol: Cardinal; AFlags: TsRelFlags): String;
begin begin
@ -621,10 +621,10 @@ end;
@param ACol2 Zero-based index of the last column in the range @param ACol2 Zero-based index of the last column in the range
@param AFlags A set containing an entry for first and last column and @param AFlags A set containing an entry for first and last column and
row if their addresses are relative. row if their addresses are relative.
@return Excel-type of cell address range containing '$' characters for absolute @return Excel type of cell address range containing '$' characters for absolute
address parts and a ':' to separate the first and last cells of the address parts and a ':' to separate the first and last cells of the
range range
@example ARow1 = 0, ACol1 = 0, ARow = 2, ACol = 1, AFlags = [rfRow, rfRow2] @example ARow1 = 0, ACol1 = 0, ARow = 2, ACol = 1, AFlags = [rfRelRow, rfRelRow2]
--> $A1:$B3 --> $A1:$B3
} }
function GetCellRangeString(ARow1, ACol1, ARow2, ACol2: Cardinal; AFlags: TsRelFlags): String; function GetCellRangeString(ARow1, ACol1, ARow2, ACol2: Cardinal; AFlags: TsRelFlags): String;

View File

@ -17,7 +17,7 @@ uses
// Instead, add .. to unit search path // Instead, add .. to unit search path
Classes, SysUtils, fpcunit, testutils, testregistry, Classes, SysUtils, fpcunit, testutils, testregistry,
fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling},
testsutility, md5; fpsutils, testsutility, md5;
type type
{ TSpreadReadInternalTests } { TSpreadReadInternalTests }
@ -33,6 +33,9 @@ type
procedure SetUp; override; procedure SetUp; override;
procedure TearDown; override; procedure TearDown; override;
published published
// Tests getting Excel style A1 cell locations from row/column based locations.
// Bug 26447
procedure TestCellString;
//todo: add more calls, rename sheets, try to get sheets with invalid indexes etc //todo: add more calls, rename sheets, try to get sheets with invalid indexes etc
//(see strings tests for how to deal with expected exceptions) //(see strings tests for how to deal with expected exceptions)
procedure GetSheetByIndex; procedure GetSheetByIndex;
@ -152,10 +155,17 @@ begin
MyWorkbook.Free; MyWorkbook.Free;
end; end;
procedure TSpreadInternalTests.TestCellString;
begin
CheckEquals('$A$1',GetCellString(0,0,[]));
CheckEquals('$Z$1',GetCellString(0,25,[])); //bug 26447
CheckEquals('$AA$2',GetCellString(1,26,[])); //just past the last letter
CheckEquals('$GW$5',GetCellString(4,204,[])); //some big value
end;
procedure TSpreadInternalTests.SetUp; procedure TSpreadInternalTests.SetUp;
begin begin
end; end;
procedure TSpreadInternalTests.TearDown; procedure TSpreadInternalTests.TearDown;
@ -165,6 +175,8 @@ end;
initialization initialization
// Register so these tests are included in a full run // Register so these tests are included in a full run
RegisterTest(TSpreadInternalTests); RegisterTest(TSpreadInternalTests);

View File

@ -80,14 +80,17 @@
<Unit1> <Unit1>
<Filename Value="datetests.pas"/> <Filename Value="datetests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="datetests"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="stringtests.pas"/> <Filename Value="stringtests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="stringtests"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="numberstests.pas"/> <Filename Value="numberstests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="numberstests"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="manualtests.pas"/> <Filename Value="manualtests.pas"/>
@ -96,14 +99,17 @@
<Unit5> <Unit5>
<Filename Value="testsutility.pas"/> <Filename Value="testsutility.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="testsutility"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="internaltests.pas"/> <Filename Value="internaltests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="internaltests"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="formattests.pas"/> <Filename Value="formattests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="formattests"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="colortests.pas"/> <Filename Value="colortests.pas"/>
@ -112,6 +118,7 @@
<Unit9> <Unit9>
<Filename Value="fonttests.pas"/> <Filename Value="fonttests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fonttests"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="optiontests.pas"/> <Filename Value="optiontests.pas"/>
@ -124,12 +131,10 @@
<Unit12> <Unit12>
<Filename Value="rpnformulaunit.pas"/> <Filename Value="rpnformulaunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="rpnFormulaUnit"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="formulatests.pas"/> <Filename Value="formulatests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="formulatests"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
<Filename Value="emptycelltests.pas"/> <Filename Value="emptycelltests.pas"/>