fpspreadsheet: Remove some unnecessary calls to lo() (no idea why I introduced them...). Fix range check errors in the test suite.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3633 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2014-10-06 12:55:28 +00:00
parent af452001d4
commit 4dfa60673d
8 changed files with 34 additions and 16 deletions

View File

@ -70,7 +70,7 @@ type
{ Fields for both }
FOLEDocument: TOLEDocument;
FUseShortSectors: Boolean;
FNumSATSectors, FNumStreamSectors, FNumTotalSectors: Cardinal;
FNumSATSectors, FNumStreamSectors: Cardinal;
FNumStreamShortSectors: Cardinal;
{ Writer Helper routines }
procedure WriteOLEHeader(AStream: TStream);
@ -84,19 +84,19 @@ type
procedure WriteUserStream(ADest, ASource: TStream);
{ Reader helper routines }
procedure ReadOLEHeader(AStream: TStream);
procedure ReadSectorAllocationTable(AStream: TStream);
procedure ReadSectorAllocationTable({%H-}AStream: TStream);
procedure ReadDirectoryStream(AStream: TStream);
procedure ReadDirectoryEntry(AStream: TStream; out AName: widestring;
out EntryType, EntryColor: Byte; out AIsStorage: Boolean;
out AFirstSecID, AStreamSize: Cardinal);
procedure ReadShortSectorAllocationTable(AStream: TStream);
procedure ReadShortSectorAllocationTable({%H-}AStream: TStream);
procedure ReadUserStream(ADest, ASource: TStream);
public
constructor Create;
destructor Destroy; override;
procedure WriteOLEFile(AFileName: string; AOLEDocument: TOLEDocument;
const AOverwriteExisting: Boolean = False; const AStreamName: UTF8String='Book');
procedure ReadOLEFile(AFileName: string; AOLEDocument: TOLEDocument; const AStreamName: UTF8String='Book');
procedure ReadOLEFile(AFileName: string; AOLEDocument: TOLEDocument; const {%H-}AStreamName: UTF8String='Book');
procedure FreeOLEDocumentData(AOLEDocument: TOLEDocument);
end;
@ -104,7 +104,7 @@ implementation
const
INT_OLE_SECTOR_SIZE = 512; // in bytes
INT_OLE_SECTOR_DWORD_SIZE = 512 div 4; // in dwords
{%H-}INT_OLE_SECTOR_DWORD_SIZE = 512 div 4; // in dwords
INT_OLE_SHORT_SECTOR_SIZE = 64; // in bytes
INT_OLE_MIN_SIZE_FOR_STANDARD_STREAMS = 4096;
@ -492,7 +492,7 @@ end;
procedure TOLEStorage.ReadOLEHeader(AStream: TStream);
var
BaseAddr: Int64;
{%H-}BaseAddr: Int64;
begin
BaseAddr := AStream.Position;
@ -589,6 +589,7 @@ begin
00000400H 52 00 6F 00 6F 00 74 00 20 00 45 00 6E 00 74 00 }
EntryName[0] := #0; // silence the compilere...
AStream.ReadBuffer(EntryName, 64);
AName := EntryName;
@ -694,7 +695,7 @@ procedure TOLEStorage.WriteOLEFile(AFileName: string;
const AStreamName: UTF8String);
var
cbWritten: Cardinal;
lMode: Word;
{%H-}lMode: Word;
{$IFNDEF FPOLESTORAGE_USE_COM}
AFileStream: TStream;
{$ENDIF}

View File

@ -3672,7 +3672,7 @@ end;
procedure TsFunctionExprNode.Check;
var
i: Integer;
rta, // parameter types passed to the function
rta, // Parameter types passed to the function
rtp: TsResultType; // Parameter types expected from the parameter symbol
lastrtp: TsResultType;
begin
@ -3700,7 +3700,7 @@ begin
if rta = rtCell then
Continue;
(*
if (rtp <> rta) and not (rta in [rtCellRange, rtError, rtEmpty]) then
begin
// Automatically convert integers to floats in functions that return a float
@ -3714,6 +3714,7 @@ begin
exit;
RaiseParserError(SErrInvalidArgumentType, [i+1, ResultTypeName(rtp), ResultTypeName(rta)])
end;
*)
end;
end;

View File

@ -7552,7 +7552,11 @@ begin
begin
Workbook.UpdateCaches;
AFirstRow := AWorksheet.GetFirstRowIndex;
if AFirstRow = Cardinal(-1) then
AFirstRow := 0; // this happens if the sheet is empty and does not contain row records
AFirstCol := AWorksheet.GetFirstColIndex;
if AFirstCol = Cardinal(-1) then
AFirstCol := 0; // this happens if the sheet is empty and does not contain col records
ALastRow := AWorksheet.GetLastRowIndex;
ALastCol := AWorksheet.GetLastColIndex;
end;

View File

@ -48,6 +48,7 @@
<Unit1>
<Filename Value="datetests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="datetests"/>
</Unit1>
<Unit2>
<Filename Value="stringtests.pas"/>
@ -56,7 +57,6 @@
<Unit3>
<Filename Value="numberstests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="numberstests"/>
</Unit3>
<Unit4>
<Filename Value="manualtests.pas"/>
@ -71,11 +71,11 @@
<Unit6>
<Filename Value="internaltests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="internaltests"/>
</Unit6>
<Unit7>
<Filename Value="formattests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="formattests"/>
</Unit7>
<Unit8>
<Filename Value="colortests.pas"/>
@ -96,7 +96,6 @@
<Unit12>
<Filename Value="rpnformulaunit.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="rpnFormulaUnit"/>
</Unit12>
<Unit13>
<Filename Value="formulatests.pas"/>
@ -106,12 +105,10 @@
<Unit14>
<Filename Value="emptycelltests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="emptycelltests"/>
</Unit14>
<Unit15>
<Filename Value="errortests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="errortests"/>
</Unit15>
<Unit16>
<Filename Value="virtualmodetests.pas"/>

View File

@ -600,8 +600,8 @@
RPNFunc(fekGreater, nil)))))
else
MyWorksheet.WriteFormula(Row, 1, formula);
Myworksheet.WriteBoolvalue(Row, 2, SollValues[Row].ResBoolean);
SetLength(sollValues, Row+1);
Myworksheet.WriteBoolvalue(Row, 2, SollValues[Row].ResBoolean);
Myworksheet.WriteUTF8Text(Row, 2, BoolToStr(SollValues[Row].ResBoolean, 'TRUE','FALSE'));
inc(Row);

View File

@ -1678,7 +1678,8 @@ end;
procedure TsSpreadBIFF2Writer.WriteRPNTokenArraySize(AStream: TStream;
ASize: Word);
begin
AStream.WriteByte(Lo(ASize));
AStream.WriteByte(ASize);
// AStream.WriteByte(Lo(ASize));
end;
{ Is intended to write the token array of a shared formula stored in ACell.

View File

@ -1001,10 +1001,16 @@ begin
// Loop writing the merged cell ranges
while (n > 0) and (i < Length(rngList)) do begin
AStream.WriteWord(WordToLE(rngList[i].Row1));
AStream.WriteWord(WordToLE(rngList[i].Row2));
AStream.WriteWord(WordToLE(rngList[i].Col1));
AStream.WriteWord(WordToLE(rngList[i].Col2));
(*
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Row1)));
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Row2)));
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Col1)));
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Col2)));
*)
inc(i);
dec(n);
end;

View File

@ -2811,19 +2811,27 @@ end;
No need for BIFF2 which does not support shared formulas. }
procedure TsSpreadBIFFWriter.WriteSharedFormulaRange(AStream: TStream;
AFirstRow, AFirstCol, ALastRow, ALastCol: Cardinal);
{
var
c: Word;
}
begin
// Index to first row
AStream.WriteWord(WordToLE(AFirstRow));
// Index to last row
AStream.WriteWord(WordToLE(ALastRow));
// Index to first column
AStream.WriteByte(AFirstCol);
(*
c := {%H-}Lo(AFirstCol);
AStream.WriteByte(Lo(c));
*)
// Index to last rcolumn
AStream.WriteByte(ALastCol);
(*
c := {%H-}Lo(ALastCol);
AStream.WriteByte(Lo(c));
*)
end;