diff --git a/components/fpspreadsheet/fpsfunc.pas b/components/fpspreadsheet/fpsfunc.pas index 53e7558ee..e13c165c0 100644 --- a/components/fpspreadsheet/fpsfunc.pas +++ b/components/fpspreadsheet/fpsfunc.pas @@ -1293,6 +1293,7 @@ end; function fpsPI(Args: TsArgumentStack; NumArgs: Integer): TsArgument; begin + Unused(Args); Unused(NumArgs); Result := CreateNumberArg(pi); end; @@ -1308,6 +1309,7 @@ end; function fpsRAND(Args: TsArgumentStack; NumArgs: Integer): TsArgument; begin + Unused(Args); Unused(NumArgs); Result := CreateNumberArg(random); end; @@ -1493,6 +1495,7 @@ end; function fpsNOW(Args: TsArgumentStack; NumArgs: Integer): TsArgument; // NOW() begin + Unused(Args); Unused(NumArgs); Result := CreateNumberArg(now); end; @@ -1532,6 +1535,7 @@ end; function fpsToday(Args: TsArgumentStack; NumArgs: Integer): TsArgument; // TODAY() begin + Unused(Args); Unused(NumArgs); Result := CreateNumberArg(Date()); end; @@ -1899,6 +1903,7 @@ end; function fpsFALSE(Args: TsArgumentStack; NumArgs: Integer): TsArgument; // FALSE( ) begin + Unused(Args); Unused(NumArgs); Result := CreateBoolArg(false); end; @@ -1908,7 +1913,6 @@ function fpsIF(Args: TsArgumentStack; NumArgs: Integer): TsArgument; var condition: TsArgument; case1, case2: TsArgument; - err: TsErrorValue; begin if NumArgs = 3 then case2 := Args.Pop; @@ -1954,6 +1958,7 @@ end; function fpsTRUE(Args: TsArgumentStack; NumArgs: Integer): TsArgument; // TRUE ( ) begin + Unused(Args); Unused(NumArgs); Result := CreateBoolArg(true); end; @@ -2118,7 +2123,6 @@ function fpsSUBSTITUTE(Args: TsArgumentStack; NumArgs: Integer): TsArgument; var number: Double; n: Integer; - arg: TsArgument; data: TsArgStringArray; s, s_old, s_new: String; begin @@ -2310,7 +2314,6 @@ var arg: TsArgument; cell: PCell; sname: String; - data: TsArgStringArray; res: TsArgument; begin if NumArgs < 2 then begin diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas index 8ff7cfe24..3dda41f2c 100755 --- a/components/fpspreadsheet/fpsopendocument.pas +++ b/components/fpspreadsheet/fpsopendocument.pas @@ -1035,7 +1035,6 @@ var s: String; defCellStyleIndex: Integer; colStyleIndex: Integer; - colStyleData: TColumnStyleData; colData: TColumnData; colsRepeated: Integer; j: Integer; @@ -1052,7 +1051,6 @@ begin colStyleIndex := FindColStyleByName(s); if colStyleIndex <> -1 then begin defCellStyleIndex := -1; - colStyleData := TColumnStyleData(FColumnStyleList[colStyleIndex]); s := GetAttrValue(ColNode, 'table:default-cell-style-name'); if s <> '' then begin defCellStyleIndex := FindCellStyleByName(s); diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 606f6128d..34f132ad3 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -4535,7 +4535,6 @@ end; procedure TsWorksheet.InsertCol(ACol: Cardinal); var cellnode: TAVLTreeNode; - cell: PCell; col: PCol; i: Integer; begin diff --git a/components/fpspreadsheet/fpsutils.pas b/components/fpspreadsheet/fpsutils.pas index 416975a97..c24694075 100644 --- a/components/fpspreadsheet/fpsutils.pas +++ b/components/fpspreadsheet/fpsutils.pas @@ -155,6 +155,9 @@ implementation uses Math, lazutf8; +type + TRGBA = record r, g, b, a: byte end; + {******************************************************************************} { Endianess helper functions } {******************************************************************************} @@ -2101,8 +2104,6 @@ end; (with the exception that max hue is 240, nur 255!) } function TintedColor(AColor: TsColorValue; tint: Double): TsColorValue; -type - TRGBA = record r, g, b, a: byte end; const HLSMAX = 255; var @@ -2135,7 +2136,6 @@ begin TRGBA(Result).a := 0; end; - {$PUSH}{$HINTS OFF} {@@ Silence warnings due to an unused parameter } procedure Unused(const A1); diff --git a/components/fpspreadsheet/tests/formattests.pas b/components/fpspreadsheet/tests/formattests.pas index c53fd0c23..494b3527e 100644 --- a/components/fpspreadsheet/tests/formattests.pas +++ b/components/fpspreadsheet/tests/formattests.pas @@ -616,8 +616,6 @@ var MyWorkbook: TsWorkbook; MyCell: PCell; col, maxCol: Integer; - expected: String; - current: String; TempFile: string; //write xls/xml to this file and read back from it function GetBordersAsText(ABorders: TsCellBorders): String; diff --git a/components/fpspreadsheet/tests/formulatests.pas b/components/fpspreadsheet/tests/formulatests.pas index 836f52848..e45852af8 100644 --- a/components/fpspreadsheet/tests/formulatests.pas +++ b/components/fpspreadsheet/tests/formulatests.pas @@ -190,8 +190,8 @@ begin The test file contains the text representation in column A, and the formula in column B. } Row := 0; - {$I testcases_calcrpnformula.inc} TempFile:=GetTempFileName; + {$I testcases_calcrpnformula.inc} MyWorkBook.WriteToFile(TempFile, AFormat, true); finally MyWorkbook.Free; diff --git a/components/fpspreadsheet/tests/spreadtestgui.lpi b/components/fpspreadsheet/tests/spreadtestgui.lpi index 7307951e4..f03ad7c7a 100644 --- a/components/fpspreadsheet/tests/spreadtestgui.lpi +++ b/components/fpspreadsheet/tests/spreadtestgui.lpi @@ -48,10 +48,12 @@ + + @@ -70,6 +72,7 @@ + @@ -95,7 +98,6 @@ - @@ -105,7 +107,6 @@ - diff --git a/components/fpspreadsheet/tests/virtualmodetests.pas b/components/fpspreadsheet/tests/virtualmodetests.pas index 1016dfd7a..8723bb99c 100644 --- a/components/fpspreadsheet/tests/virtualmodetests.pas +++ b/components/fpspreadsheet/tests/virtualmodetests.pas @@ -59,6 +59,8 @@ end; procedure TSpreadVirtualModeTests.WriteVirtualCellDataHandler(Sender: TObject; ARow, ACol: Cardinal; var AValue:Variant; var AStyleCell: PCell); begin + Unused(ACol); + Unused(AStyleCell); // First read the SollNumbers, then the first 4 SollStrings // See comment in TestVirtualMode(). if ARow < Length(SollNumbers) then diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas index 725e0b7f0..9269483e5 100755 --- a/components/fpspreadsheet/xlsbiff2.pas +++ b/components/fpspreadsheet/xlsbiff2.pas @@ -1529,13 +1529,8 @@ procedure TsSpreadBIFF2Writer.WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); var FormulaResult: double; - i: Integer; RPNLength: Word; - TokenArraySizePos, RecordSizePos, FinalPos: Cardinal; - FormulaKind, ExtraInfo: Word; - r: Cardinal; - len: Integer; - s: ansistring; + RecordSizePos, FinalPos: Cardinal; xf: Word; begin if (ARow >= FLimitations.MaxRowCount) or (ACol >= FLimitations.MaxColCount) then @@ -1697,7 +1692,6 @@ const var L: Byte; AnsiText: ansistring; - TextTooLong: boolean=false; rec: TBIFF2LabelRecord; buf: array of byte; var @@ -1715,7 +1709,6 @@ begin // so BIFF2 won't either // Rather than lose data when reading it, let the application programmer deal // with the problem or purposefully ignore it. - TextTooLong:=true; AnsiText := Copy(AnsiText, 1, MAXBYTES); Workbook.AddErrorMsg( 'Text value exceeds %d character limit in cell %s. ' + diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas index de40b55f1..b49d4af38 100755 --- a/components/fpspreadsheet/xlsbiff5.pas +++ b/components/fpspreadsheet/xlsbiff5.pas @@ -952,7 +952,6 @@ const var L: Word; AnsiValue: ansistring; - TextTooLong: boolean=false; rec: TBIFF5LabelRecord; buf: array of byte; begin @@ -983,7 +982,6 @@ begin if Length(AnsiValue) > MAXBYTES then begin // Rather than lose data when reading it, let the application programmer deal // with the problem or purposefully ignore it. - TextTooLong := true; AnsiValue := Copy(AnsiValue, 1, MAXBYTES); Workbook.AddErrorMsg( 'Text value exceeds %d character limit in cell %s. ' + diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas index bdff0d1db..13703ca6f 100644 --- a/components/fpspreadsheet/xlscommon.pas +++ b/components/fpspreadsheet/xlscommon.pas @@ -400,7 +400,7 @@ type ANumberFormatStr: String; out ADateTime: TDateTime): Boolean; // Here we can add reading of records which didn't change across BIFF5-8 versions // Read a blank cell - procedure ReadBlank(AStream: TStream); virtual; + procedure ReadBlank(AStream: TStream); override; procedure ReadCodePage(AStream: TStream); // Read column info procedure ReadColInfo(const AStream: TStream); @@ -529,7 +529,7 @@ type implementation uses - Variants, fpsStreams, fpsNumFormatParser; + Math, Variants, fpsStreams, fpsNumFormatParser; { Helper table for rpn formulas: Assignment of FormulaElementKinds (fekXXXX) to EXCEL_TOKEN IDs. } @@ -685,6 +685,11 @@ const INT_EXCEL_TOKEN_TATTR {fekOpSum} ); +resourcestring + rsTooManyPaletteColors = 'This workbook contains more colors (%d) than are ' + + 'supported by the file format (%d). The redundant colors are replaced by '+ + 'the best-matching palette colors.'; + type TBIFF58BlankRecord = packed record RecordID: Word; @@ -1151,7 +1156,6 @@ var XF: WORD; ResultFormula: Double = 0.0; Data: array [0..7] of byte; - Flags: WORD; dt: TDateTime; nf: TsNumberFormat; nfs: String; @@ -1169,7 +1173,7 @@ begin AStream.ReadBuffer(Data, Sizeof(Data)); { Options flags } - Flags := WordLEtoN(AStream.ReadWord); + WordLEtoN(AStream.ReadWord); { Not used } AStream.ReadDWord; @@ -1779,7 +1783,6 @@ end; function TsSpreadBIFFWriter.FindXFIndex(ACell: PCell): Integer; var idx: Integer; - xfIndex: Word; cell: TCell; begin // First try the fast methods for default formats @@ -2080,6 +2083,7 @@ end; *) procedure TsSpreadBIFFWriter.WritePalette(AStream: TStream); var i, n: Integer; + rgb: TsColorValue; begin { BIFF Record header } AStream.WriteWord(WordToLE(INT_EXCEL_ID_PALETTE)); @@ -2089,13 +2093,17 @@ begin AStream.WriteWord(WordToLE(56)); { Take the colors from the palette of the Worksheet } - { Skip the first 8 entries - they are hard-coded into Excel } n := Workbook.GetPaletteSize; + + if n > 64 then + Workbook.AddErrorMsg(rsTooManyPaletteColors, [n, 64]); + + { Skip the first 8 entries - they are hard-coded into Excel } for i:=8 to 63 do - if i < n then - AStream.WriteDWord(DWordToLE(Workbook.GetPaletteColor(i))) - else - AStream.WriteDWord(DWordToLE($FFFFFF)); + begin + rgb := Math.IfThen(i < n, Workbook.GetPaletteColor(i), $FFFFFF); + AStream.WriteDWord(DWordToLE(rgb)) + end; end; {@@ @@ -2103,7 +2111,6 @@ end; } procedure TsSpreadBIFFWriter.WritePageSetup(AStream: TStream); var - flags: Word; dbl: Double; begin { BIFF record header } @@ -2125,7 +2132,6 @@ begin { Fit worksheet height to this number of pages, 0 = use as many as needed } AStream.WriteWord(WordToLE(0)); - flags := 0; AStream.WriteWord(WordToLE(0)); { Print resolution in dpi } @@ -2265,8 +2271,7 @@ end; procedure TsSpreadBIFFWriter.WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); var - i: Integer; - RPNLength: Word; + RPNLength: Word = 0; RecordSizePos, FinalPos: Int64; begin if (ARow >= FLimitations.MaxRowCount) or (ACol >= FLimitations.MaxColCount) then diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas index 27b6b5e39..e4884047a 100755 --- a/components/fpspreadsheet/xlsxooxml.pas +++ b/components/fpspreadsheet/xlsxooxml.pas @@ -791,8 +791,6 @@ begin end; function TsSpreadOOXMLReader.ReadColor(ANode: TDOMNode): TsColor; -type - TRGBA = record r,g,b,a: Byte end; var s: String; rgb: TsColorValue;