fpspreadsheet: Further reduction of hints and warnings

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3206 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-06-20 15:58:22 +00:00
parent f9aede8d35
commit d0927d2d03
12 changed files with 104 additions and 31 deletions

View File

@ -290,7 +290,6 @@ procedure TOLEStorage.WriteDirectoryEntry(AStream: TStream; AName: widestring;
EntryType, EntryColor: Byte; AIsStorage: Boolean;
AFirstSecID, AStreamSize: Cardinal);
var
i: Integer;
EntryName: array[0..31] of WideChar;
begin
{ Contents of the directory entry structure:
@ -695,8 +694,6 @@ procedure TOLEStorage.WriteOLEFile(AFileName: string;
const AStreamName: UTF8String);
var
cbWritten: Cardinal;
AFileStream: TFileStream;
i, x: Cardinal;
lMode: Word;
begin
// The behavior of LCL classes is failling to write to existing file,

View File

@ -165,11 +165,6 @@ implementation
uses
TypInfo, StrUtils, fpsutils;
const
COMPARE_STR: array[TsCompareOperation] of string = (
'', '=', '<>', '<', '>', '<=', '>'
);
{ TsNumFormatParser }

View File

@ -856,6 +856,8 @@ var
Hours, Minutes, Seconds, Days: integer;
HoursPos, MinutesPos, SecondsPos: integer;
begin
Unused(AFormatStr);
// Format expects ISO 8601 type date string or
// time string
fmt := DefaultFormatSettings;
@ -1497,6 +1499,7 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
hasColor: Boolean;
begin
fmt := '';
cs := '';
hasColor := false;
node := ANumFormatNode.FirstChild;
while Assigned(node) do begin
@ -1666,7 +1669,7 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
procedure ReadTextStyle(ANumFormatNode: TDOMNode; ANumFormatName: String);
var
node, childNode: TDOMNode;
nf: TsNumberFormat;
nf: TsNumberFormat = nfGeneral;
fmt: String;
nodeName: String;
begin
@ -2776,6 +2779,8 @@ procedure TsSpreadOpenDocWriter.WriteToFile(const AFileName: string;
var
FZip: TZipper;
begin
Unused(AOverwriteExisting);
{ Fill the strings with the contents of the files }
WriteMimetype();
@ -2822,6 +2827,7 @@ end;
procedure TsSpreadOpenDocWriter.WriteToStream(AStream: TStream);
begin
Unused(AStream);
// Not supported at the moment
raise Exception.Create('TsSpreadOpenDocWriter.WriteToStream not supported');
end;
@ -2829,6 +2835,8 @@ end;
procedure TsSpreadOpenDocWriter.WriteFormula(AStream: TStream; const ARow,
ACol: Cardinal; const AFormula: TsFormula; ACell: PCell);
begin
Unused(AStream, ARow, ACol);
Unused(AFormula, ACell);
{ // The row should already be the correct one
FContent := FContent +
' <table:table-cell office:value-type="string">' + LineEnding +
@ -2850,6 +2858,9 @@ var
lStyle: String = '';
lIndex: Integer;
begin
Unused(AStream, ACell);
Unused(ARow, ACol);
// Write empty cell only if it has formatting
if ACell^.UsedFormattingFields <> [] then begin
lIndex := FindFormattingInList(ACell);
@ -3080,6 +3091,9 @@ var
lStyle: string = '';
lIndex: Integer;
begin
Unused(AStream, ACell);
Unused(ARow, ACol);
if ACell^.UsedFormattingFields <> [] then begin
lIndex := FindFormattingInList(ACell);
lStyle := ' table:style-name="ce' + IntToStr(lIndex) + '" ';
@ -3102,6 +3116,9 @@ var
lIndex: Integer;
valType: String;
begin
Unused(AStream, ACell);
Unused(ARow, ACol);
valType := 'float';
if ACell^.UsedFormattingFields <> [] then begin
lIndex := FindFormattingInList(ACell);
@ -3147,6 +3164,9 @@ var
lIndex: Integer;
isTimeOnly: Boolean;
begin
Unused(AStream, ACell);
Unused(ARow, ACol);
if ACell^.UsedFormattingFields <> [] then begin
lIndex := FindFormattingInList(ACell);
lStyle := 'table:style-name="ce' + IntToStr(lIndex) + '" ';

View File

@ -476,10 +476,9 @@ type
procedure WriteFormula(ARow, ACol: Cardinal; AFormula: TsFormula);
procedure WriteNumber(ARow, ACol: Cardinal; ANumber: double;
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2;
ACurrencySymbol: String = ''); overload;
procedure WriteNumber(ACell: PCell; ANumber: Double; AFormat: TsNumberFormat = nfGeneral;
ADecimals: Byte = 2; ACurrencySymbol: String = ''); overload;
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2); overload;
procedure WriteNumber(ACell: PCell; ANumber: Double;
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2); overload;
procedure WriteNumber(ARow, ACol: Cardinal; ANumber: double;
AFormat: TsNumberFormat; AFormatString: String); overload;
procedure WriteNumber(ACell: PCell; ANumber: Double;
@ -1193,6 +1192,7 @@ end;
}
procedure TsWorksheet.RemoveCallback(data, arg: pointer);
begin
Unused(arg);
{ The strings and dyn arrays must be reset to nil content manually, because
FreeMem only frees the record mem, without checking its content }
PCell(data).UTF8StringValue := '';
@ -1649,7 +1649,7 @@ begin
cctDateTime:
Result := DateTimeToStrNoNaN(DateTimeValue, NumberFormat, NumberFormatStr);
cctBool:
Result := IfThen(BoolValue, lpTRUE, lpFALSE);
Result := StrUtils.IfThen(BoolValue, lpTRUE, lpFALSE);
cctError:
case TsErrorValue(ErrorValue) of
errEmptyIntersection : Result := lpErrEmptyIntersection;
@ -1912,18 +1912,15 @@ end;
@param ANumber The number to be written
@param AFormat The format identifier, e.g. nfFixed (optional)
@param ADecimals The number of decimals used for formatting (optional)
@param ACurrencySymbol The currency symbol in case of currency format (nfCurrency)
}
procedure TsWorksheet.WriteNumber(ARow, ACol: Cardinal; ANumber: double;
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2;
ACurrencySymbol: String = '');
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2);
begin
WriteNumber(GetCell(ARow, ACol), ANumber, AFormat, ADecimals, ACurrencySymbol);
WriteNumber(GetCell(ARow, ACol), ANumber, AFormat, ADecimals);
end;
procedure TsWorksheet.WriteNumber(ACell: PCell; ANumber: Double;
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2;
ACurrencySymbol: String = '');
AFormat: TsNumberFormat = nfGeneral; ADecimals: Byte = 2);
begin
if IsDateTimeFormat(AFormat) or IsCurrencyFormat(AFormat) then
raise Exception.Create(lpInvalidNumberFormat);
@ -2694,6 +2691,7 @@ end;
}
procedure TsWorkbook.RemoveWorksheetsCallback(data, arg: pointer);
begin
Unused(arg);
TsWorksheet(data).Free;
end;
@ -3488,6 +3486,7 @@ end;
procedure TsCustomNumFormatList.ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat);
begin
Unused(AFormatString, ANumFormat);
// nothing to do here. But see, e.g., xlscommon.TsBIFFNumFormatList
end;
@ -3498,7 +3497,7 @@ end;
procedure TsCustomNumFormatList.AnalyzeAndAdd(AFormatIndex: Integer;
AFormatString: String);
var
nf: TsNumberFormat;
nf: TsNumberFormat = nfGeneral;
begin
if FindByIndex(AFormatIndex) > -1 then
exit;
@ -3717,6 +3716,7 @@ end;
procedure TsCustomSpreadReader.ReadFromStrings(AStrings: TStrings;
AData: TsWorkbook);
begin
Unused(AStrings, AData);
raise Exception.Create(lpUnsupportedReadFormat);
end;
@ -3800,6 +3800,7 @@ end;
Must be overridden by descendants. See BIFF2 }
procedure TsCustomSpreadWriter.FixFormat(ACell: PCell);
begin
Unused(ACell);
// to be overridden
end;
@ -3821,6 +3822,8 @@ procedure TsCustomSpreadWriter.ListAllFormattingStylesCallback(ACell: PCell; ASt
var
Len: Integer;
begin
Unused(AStream);
FixFormat(ACell);
if ACell^.UsedFormattingFields = [] then Exit;
@ -3859,6 +3862,8 @@ var
fmt: string;
nf: TsNumberFormat;
begin
Unused(AStream);
if ACell^.NumberFormat = nfGeneral then
exit;
@ -4026,18 +4031,24 @@ end;
procedure TsCustomSpreadWriter.WriteToStrings(AStrings: TStrings);
begin
Unused(AStrings);
raise Exception.Create(lpUnsupportedWriteFormat);
end;
procedure TsCustomSpreadWriter.WriteFormula(AStream: TStream; const ARow,
ACol: Cardinal; const AFormula: TsFormula; ACell: PCell);
begin
Unused(AStream, ARow, ACol);
Unused(AFormula, ACell);
// Silently dump the formula; child classes should implement their own support
end;
procedure TsCustomSpreadWriter.WriteRPNFormula(AStream: TStream; const ARow,
ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell);
begin
Unused(AStream, ARow, ACol);
Unused(AFormula, ACell);
// Silently dump the formula; child classes should implement their own support
end;

View File

@ -210,6 +210,7 @@ procedure TsWorksheetChartSource.LoadPropertiesFromStrings(AXInterval,
var
lXCount, lYCount: Integer;
begin
Unused(AXTitle, AYTitle, ATitle);
ParseIntervalString(AXInterval, FXFirstCellRow, FXFirstCellCol, lXCount, FXSelectionDirection);
ParseIntervalString(AYInterval, FYFirstCellRow, FYFirstCellCol, lYCount, FYSelectionDirection);
if lXCount <> lYCount then raise Exception.Create(

View File

@ -108,7 +108,6 @@ type
protected
{ Protected declarations }
procedure DefaultDrawCell(ACol, ARow: Integer; var ARect: TRect; AState: TGridDrawState); override;
procedure DoPrepareCanvas(ACol, ARow: Integer; AState: TGridDrawState); override;
procedure DrawAllRows; override;
procedure DrawCellBorders; overload;
@ -146,6 +145,7 @@ type
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure BeginUpdate;
procedure DefaultDrawCell(ACol, ARow: Integer; var ARect: TRect; AState: TGridDrawState); override;
procedure EditingDone; override;
procedure EndUpdate;
procedure GetSheets(const ASheets: TStrings);
@ -540,6 +540,7 @@ end;
procedure TsCustomWorksheetGrid.ChangedCellHandler(ASender: TObject; ARow, ACol:Cardinal);
begin
Unused(ASender, ARow, ACol);
if FLockCount = 0 then Invalidate;
end;
@ -550,6 +551,7 @@ procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol:
var
lRow: PRow;
begin
Unused(ASender, ACol);
if (FWorksheet <> nil) then begin
lRow := FWorksheet.FindRow(ARow);
if lRow = nil then begin
@ -717,7 +719,7 @@ procedure TsCustomWorksheetGrid.DrawAllRows;
var
cliprect: TRect;
rgn: HRGN;
tmp: Integer;
tmp: Integer = 0;
begin
inherited;
@ -852,6 +854,7 @@ end;
dashed rectangle here, but the thick Excel-like rectangle. }
procedure TsCustomWorksheetGrid.DrawFocusRect(aCol, aRow: Integer; ARect: TRect);
begin
Unused(ACol, ARow, ARect);
// Nothing do to
end;

View File

@ -122,6 +122,10 @@ function HTMLLengthStrToPts(AValue: String): Double;
function HTMLColorStrToColor(AValue: String): TsColorValue;
function ColorToHTMLColorStr(AValue: TsColorValue): String;
procedure Unused(const A1);
procedure Unused(const A1, A2);
procedure Unused(const A1, A2, A3);
var
ScreenPixelsPerInch: Integer = 96;
@ -191,8 +195,10 @@ begin
end;
function WideStringToLE(const AValue: WideString): WideString;
{$IFNDEF FPC}
var
j: integer;
{$ENDIF}
begin
{$IFDEF FPC}
{$IFDEF FPC_LITTLE_ENDIAN}
@ -209,8 +215,10 @@ begin
end;
function WideStringLEToN(const AValue: WideString): WideString;
{$IFNDEF FPC}
var
j: integer;
{$ENDIF}
begin
{$IFDEF FPC}
{$IFDEF FPC_LITTLE_ENDIAN}
@ -1263,13 +1271,12 @@ var
ResultLen: integer;
ResultBuffer: array[0..255] of char;
ResultCurrent: pchar;
(* ---- not needed here ---
{$IFDEF MSWindows}
isEnable_E_Format : Boolean;
isEnable_G_Format : Boolean;
eastasiainited : boolean;
{$ENDIF MSWindows}
(* ---- not needed here ---
{$IFDEF MSWindows}
procedure InitEastAsia;
var ALCID : LCID;
PriLangID , SubLangID : Word;
@ -1342,7 +1349,6 @@ var
var
Year, Month, Day, DayOfWeek, Hour, Minute, Second, MilliSecond: word;
DT : TDateTime;
procedure StoreFormat(const FormatStr: string; Nesting: Integer; TimeFlag: Boolean);
var
@ -1577,10 +1583,11 @@ var
end;
end;
begin
begin (*
{$ifdef MSWindows}
eastasiainited:=false;
{$endif MSWindows}
*)
DecodeDateFully(DateTime, Year, Month, Day, DayOfWeek);
DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);
ResultLen := 0;
@ -1611,5 +1618,20 @@ begin
DateTimeToString(Result, FormatStr, DateTime, FormatSettings,Options);
end;
{ "Borrowed" from TAChart: silence warnings of unused parameters }
{$PUSH}{$HINTS OFF}
procedure Unused(const A1);
begin
end;
procedure Unused(const A1, A2);
begin
end;
procedure Unused(const A1, A2, A3);
begin
end;
{$POP}
end.

View File

@ -212,6 +212,8 @@ procedure TsBIFF2NumFormatList.ConvertBeforeWriting(var AFormatString: String;
var
parser: TsNumFormatParser;
begin
Unused(ANumFormat);
if AFormatString = '' then
AFormatString := 'General'
else begin
@ -401,6 +403,7 @@ end;
// Read the FORMAT record for formatting numerical data
procedure TsSpreadBIFF2Reader.ReadFormat(AStream: TStream);
begin
Unused(AStream);
// We ignore the formats in the file, everything is known
// (Using the formats in the file would require de-localizing them).
end;
@ -1238,6 +1241,8 @@ var
len: Integer;
s: ansistring;
begin
Unused(AFormatData);
s := NumFormatList.FormatStringForWriting(AListIndex);
len := Length(s);
@ -1546,6 +1551,8 @@ var
w: Word;
h: Single;
begin
Unused(ASheet);
containsXF := false;
{ BIFF record header }

View File

@ -377,6 +377,7 @@ begin
WriteStyle(AStream);
// A BOUNDSHEET for each worksheet
SetLength(Boundsheets, 0);
for i := 0 to Workbook.GetWorksheetCount - 1 do
begin
len := Length(Boundsheets);
@ -1188,6 +1189,8 @@ var
RecordType: Word;
CurStreamPos: Int64;
begin
Unused(AData);
// Clear existing fonts. They will be replaced by those from the file.
FWorkbook.RemoveAllFonts;

View File

@ -405,6 +405,7 @@ begin
WriteStyle(AStream);
// A BOUNDSHEET for each worksheet
SetLength(Boundsheets, 0);
for i := 0 to Workbook.GetWorksheetCount - 1 do
begin
len := Length(Boundsheets);
@ -1395,6 +1396,7 @@ var
RecordType: Word;
CurStreamPos: Int64;
begin
Unused(AData);
// Clear existing fonts. They will be replaced by those from the file.
FWorkbook.RemoveAllFonts;
if Assigned(FSharedStringTable) then FreeAndNil(FSharedStringTable);

View File

@ -1050,6 +1050,7 @@ end;
// Read the FORMAT record for formatting numerical data
procedure TsSpreadBIFFReader.ReadFormat(AStream: TStream);
begin
Unused(AStream);
// to be overridden
end;
@ -1543,6 +1544,7 @@ end;
Must be overridden because the implementation depends on BIFF version. }
procedure TsSpreadBIFFReader.ReadStringRecord(AStream: TStream);
begin
Unused(AStream);
//
end;
@ -1643,6 +1645,7 @@ end;
procedure TsSpreadBIFFWriter.GetLastRowCallback(ACell: PCell; AStream: TStream);
begin
Unused(AStream);
if ACell^.Row > FLastRow then FLastRow := ACell^.Row;
end;
@ -1655,6 +1658,7 @@ end;
procedure TsSpreadBIFFWriter.GetLastColCallback(ACell: PCell; AStream: TStream);
begin
Unused(AStream);
if ACell^.Col > FLastCol then FLastCol := ACell^.Col;
end;
@ -1776,6 +1780,7 @@ end;
procedure TsSpreadBIFFWriter.WriteFormat(AStream: TStream;
AFormatData: TsNumFormatData; AListIndex: Integer);
begin
Unused(AStream, AFormatData, AListIndex);
// needs to be overridden
end;

View File

@ -312,8 +312,6 @@ FSheets[CurStr] :=
procedure TsSpreadOOXMLWriter.WriteWorksheet(CurSheet: TsWorksheet);
var
j, k: Integer;
CurCell: PCell;
CurRow: array of PCell;
LastColIndex: Cardinal;
LCell: TCell;
AVLNode: TAVLTreeNode;
@ -417,8 +415,13 @@ procedure TsSpreadOOXMLWriter.WriteToFile(const AFileName: string;
const AOverwriteExisting: Boolean);
var
lStream: TFileStream;
lMode: word;
begin
lStream:=TFileStream.Create(AFileName, fmCreate);
if AOverwriteExisting
then lMode := fmCreate or fmOpenWrite
else lMode := fmCreate;
lStream:=TFileStream.Create(AFileName, lMode);
try
WriteToStream(lStream);
finally
@ -499,6 +502,9 @@ var
TextTooLong: boolean=false;
ResultingValue: string;
begin
Unused(AStream);
Unused(ARow, ACol, ACell);
// Office 2007-2010 (at least) support no more characters in a cell;
if Length(AValue)>MaxBytes then
begin
@ -538,6 +544,7 @@ var
CellPosText: String;
CellValueText: String;
begin
Unused(AStream, ACell);
CellPosText := TsWorksheet.CellPosToText(ARow, ACol);
CellValueText := Format('%g', [AValue], FPointSeparatorSettings);
FSheets[FCurSheetNum] := FSheets[FCurSheetNum] +