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 } { Fields for both }
FOLEDocument: TOLEDocument; FOLEDocument: TOLEDocument;
FUseShortSectors: Boolean; FUseShortSectors: Boolean;
FNumSATSectors, FNumStreamSectors, FNumTotalSectors: Cardinal; FNumSATSectors, FNumStreamSectors: Cardinal;
FNumStreamShortSectors: Cardinal; FNumStreamShortSectors: Cardinal;
{ Writer Helper routines } { Writer Helper routines }
procedure WriteOLEHeader(AStream: TStream); procedure WriteOLEHeader(AStream: TStream);
@ -84,19 +84,19 @@ type
procedure WriteUserStream(ADest, ASource: TStream); procedure WriteUserStream(ADest, ASource: TStream);
{ Reader helper routines } { Reader helper routines }
procedure ReadOLEHeader(AStream: TStream); procedure ReadOLEHeader(AStream: TStream);
procedure ReadSectorAllocationTable(AStream: TStream); procedure ReadSectorAllocationTable({%H-}AStream: TStream);
procedure ReadDirectoryStream(AStream: TStream); procedure ReadDirectoryStream(AStream: TStream);
procedure ReadDirectoryEntry(AStream: TStream; out AName: widestring; procedure ReadDirectoryEntry(AStream: TStream; out AName: widestring;
out EntryType, EntryColor: Byte; out AIsStorage: Boolean; out EntryType, EntryColor: Byte; out AIsStorage: Boolean;
out AFirstSecID, AStreamSize: Cardinal); out AFirstSecID, AStreamSize: Cardinal);
procedure ReadShortSectorAllocationTable(AStream: TStream); procedure ReadShortSectorAllocationTable({%H-}AStream: TStream);
procedure ReadUserStream(ADest, ASource: TStream); procedure ReadUserStream(ADest, ASource: TStream);
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
procedure WriteOLEFile(AFileName: string; AOLEDocument: TOLEDocument; procedure WriteOLEFile(AFileName: string; AOLEDocument: TOLEDocument;
const AOverwriteExisting: Boolean = False; const AStreamName: UTF8String='Book'); 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); procedure FreeOLEDocumentData(AOLEDocument: TOLEDocument);
end; end;
@ -104,7 +104,7 @@ implementation
const const
INT_OLE_SECTOR_SIZE = 512; // in bytes 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_SHORT_SECTOR_SIZE = 64; // in bytes
INT_OLE_MIN_SIZE_FOR_STANDARD_STREAMS = 4096; INT_OLE_MIN_SIZE_FOR_STANDARD_STREAMS = 4096;
@ -492,7 +492,7 @@ end;
procedure TOLEStorage.ReadOLEHeader(AStream: TStream); procedure TOLEStorage.ReadOLEHeader(AStream: TStream);
var var
BaseAddr: Int64; {%H-}BaseAddr: Int64;
begin begin
BaseAddr := AStream.Position; 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 } 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); AStream.ReadBuffer(EntryName, 64);
AName := EntryName; AName := EntryName;
@ -694,7 +695,7 @@ procedure TOLEStorage.WriteOLEFile(AFileName: string;
const AStreamName: UTF8String); const AStreamName: UTF8String);
var var
cbWritten: Cardinal; cbWritten: Cardinal;
lMode: Word; {%H-}lMode: Word;
{$IFNDEF FPOLESTORAGE_USE_COM} {$IFNDEF FPOLESTORAGE_USE_COM}
AFileStream: TStream; AFileStream: TStream;
{$ENDIF} {$ENDIF}

View File

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

View File

@ -7552,7 +7552,11 @@ begin
begin begin
Workbook.UpdateCaches; Workbook.UpdateCaches;
AFirstRow := AWorksheet.GetFirstRowIndex; 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; 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; ALastRow := AWorksheet.GetLastRowIndex;
ALastCol := AWorksheet.GetLastColIndex; ALastCol := AWorksheet.GetLastColIndex;
end; end;

View File

@ -48,6 +48,7 @@
<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"/>
@ -56,7 +57,6 @@
<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"/>
@ -71,11 +71,11 @@
<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"/>
@ -96,7 +96,6 @@
<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"/>
@ -106,12 +105,10 @@
<Unit14> <Unit14>
<Filename Value="emptycelltests.pas"/> <Filename Value="emptycelltests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="emptycelltests"/>
</Unit14> </Unit14>
<Unit15> <Unit15>
<Filename Value="errortests.pas"/> <Filename Value="errortests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="errortests"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<Filename Value="virtualmodetests.pas"/> <Filename Value="virtualmodetests.pas"/>

View File

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

View File

@ -1678,7 +1678,8 @@ end;
procedure TsSpreadBIFF2Writer.WriteRPNTokenArraySize(AStream: TStream; procedure TsSpreadBIFF2Writer.WriteRPNTokenArraySize(AStream: TStream;
ASize: Word); ASize: Word);
begin begin
AStream.WriteByte(Lo(ASize)); AStream.WriteByte(ASize);
// AStream.WriteByte(Lo(ASize));
end; end;
{ Is intended to write the token array of a shared formula stored in ACell. { 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 // Loop writing the merged cell ranges
while (n > 0) and (i < Length(rngList)) do begin 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].Row1)));
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Row2))); AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Row2)));
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Col1))); AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Col1)));
AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Col2))); AStream.WriteWord(WordToLE({%H-}Lo(rngList[i].Col2)));
*)
inc(i); inc(i);
dec(n); dec(n);
end; end;

View File

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