diff --git a/components/fpspreadsheet/source/common/fpscsv.pas b/components/fpspreadsheet/source/common/fpscsv.pas index 59cc786bc..1f2516412 100644 --- a/components/fpspreadsheet/source/common/fpscsv.pas +++ b/components/fpspreadsheet/source/common/fpscsv.pas @@ -192,8 +192,8 @@ procedure TsCSVReader.ReadFromStream(AStream: TStream; APassword: String = ''; AParams: TsStreamParams = []); var Parser: TCSVParser; - s: String; encoding: String; + s: String = ''; begin Unused(AParams, APassword); diff --git a/components/fpspreadsheet/source/common/fpsexprparser.pas b/components/fpspreadsheet/source/common/fpsexprparser.pas index 4a9aac514..82e6c1f0d 100644 --- a/components/fpspreadsheet/source/common/fpsexprparser.pas +++ b/components/fpspreadsheet/source/common/fpsexprparser.pas @@ -1873,7 +1873,7 @@ var X: TsExprFloat; lCount: Integer; ID: TsExprIdentifierDef; - Args: TsExprArgumentArray; + Args: TsExprArgumentArray = nil; AI: Integer; optional: Boolean; token: String; @@ -2185,7 +2185,7 @@ procedure TsExpressionParser.SetRPNFormula(const AFormula: TsRPNFormula); flags: TsRelFlags; ID: TsExprIdentifierDef; i, n: Integer; - args: TsExprArgumentArray; + args: TsExprArgumentArray = nil; sn, sn2: string; rng: TsCellRange; begin @@ -4742,7 +4742,7 @@ var idx, idx1, idx2: Integer; begin AError := errOK; - SetLength(AData, BLOCKSIZE); + SetLength(AData{%H-}, BLOCKSIZE); n := 0; for i:=Low(Args) to High(Args) do begin diff --git a/components/fpspreadsheet/source/common/fpshtmlutils.pas b/components/fpspreadsheet/source/common/fpshtmlutils.pas index ac654b317..12b08a1c8 100644 --- a/components/fpspreadsheet/source/common/fpshtmlutils.pas +++ b/components/fpspreadsheet/source/common/fpshtmlutils.pas @@ -951,6 +951,7 @@ var len: Integer; nrtp: Integer; begin + ARichTextParams := nil; analyzer := TsHTMLAnalyzer.Create(AWorkbook as TsWorkbook, AFont, AHTMLText + ''); try analyzer.PreserveSpaces := true; @@ -967,8 +968,7 @@ begin SetLength(ARichTextParams, nrtp); for j:=0 to nrtp-1 do ARichTextParams[j] := analyzer.RichTextParams[j]; - end else - SetLength(ARichTextParams, 0); + end; finally analyzer.Free; end; @@ -1162,7 +1162,7 @@ procedure TsHTMLComposer.GetFontsFromWorkbook(out AFonts: TsFontArray); var i: Integer; begin - SetLength(AFonts, Length(FRichTextParams)); + SetLength(AFonts{%H-}, Length(FRichTextParams)); for i:=0 to High(AFonts) do AFonts[i] := FWorkbook.GetFont(FRichTextParams[i].FontIndex); end; diff --git a/components/fpspreadsheet/source/common/fpsnumformat.pas b/components/fpspreadsheet/source/common/fpsnumformat.pas index d846d9138..71e6a7874 100644 --- a/components/fpspreadsheet/source/common/fpsnumformat.pas +++ b/components/fpspreadsheet/source/common/fpsnumformat.pas @@ -2573,7 +2573,7 @@ end; function TsNumFormatList.AddFormat(AFormatStr: String): Integer; var parser: TsNumFormatParser; - newSections: TsNumFormatSections; + newSections: TsNumFormatSections = nil; i: Integer; begin parser := TsNumFormatParser.Create(AFormatStr, FFormatSettings); diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas index aba277611..68b3a5081 100644 --- a/components/fpspreadsheet/source/common/fpsopendocument.pas +++ b/components/fpspreadsheet/source/common/fpsopendocument.pas @@ -2172,7 +2172,6 @@ end; procedure TsSpreadOpenDocReader.ReadConditionalFormats(ANode: TDOMNode; AWorksheet: TsBasicWorksheet); var - sheet: TsWorksheet; childNode: TDOMNode; nodeName: String; s: String; @@ -2184,7 +2183,6 @@ begin if ANode = nil then exit; - sheet := TsWorksheet(AWorksheet); ANode := ANode.FirstChild; while ANode <> nil do begin @@ -2888,7 +2886,7 @@ var nodeName: String; cell: PCell; hyperlink: string; - rtParams: TsRichTextParams; + rtParams: TsRichTextParams = nil; idx: Integer; rtFntIndex, fntIndex: Integer; rtFnt, fnt: TsFont; @@ -3827,7 +3825,8 @@ var fmt: TsCellFormat; ok: Boolean; condition: TsCFCondition; - param1, param2: String; + param1: String = ''; + param2: String = ''; op1, op2: Variant; sheet: TsWorksheet; begin @@ -3939,8 +3938,8 @@ begin if not ok then exit; - if param1 = '' then VarClear(op1) else op1 := param1; - if param2 = '' then VarClear(op2) else op2 := param2; + if param1 = '' then VarClear(op1{%H-}) else op1 := param1; + if param2 = '' then VarClear(op2{%H-}) else op2 := param2; sheet.WriteConditionalCellFormat(ARange, condition, op1, op2, fmtIndex); end; diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index 83670f018..e4d8a48c9 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -1255,15 +1255,13 @@ function TsWorksheet.BuildRPNFormula(ACell: PCell; var formula: PsFormula; begin - if (ACell = nil) or (not HasFormula(ACell)) then begin - SetLength(Result, 0); + Result := nil; + if (ACell = nil) or (not HasFormula(ACell)) then exit; - end; + formula := FFormulas.FindFormula(ACell^.Row, ACell^.Col); - if formula = nil then begin - SetLength(Result, 0); + if formula = nil then exit; - end; if ADestCell <> nil then begin formula^.Parser.PrepareCopyMode(ACell, ADestCell); @@ -3630,7 +3628,7 @@ function TsWorksheet.GetSelection: TsCellRangeArray; var i: Integer; begin - SetLength(Result, Length(FSelection)); + SetLength(Result{%H-}, Length(FSelection)); for i:=0 to High(FSelection) do Result[i] := FSelection[i]; end; @@ -6398,7 +6396,7 @@ var fmtIDs: TsSpreadformatIDArray; i, j: Integer; begin - SetLength(AFormatIDs, 0); + AFormatIDs := nil; if AStream = nil then exit; @@ -7314,7 +7312,7 @@ var begin Result := false; AWorksheet := nil; - SetLength(ARanges, 0); + ARanges := nil; if AText = '' then exit; diff --git a/components/fpspreadsheet/source/common/fpspreadsheet_clipbrd.inc b/components/fpspreadsheet/source/common/fpspreadsheet_clipbrd.inc index e83a5eec7..798ebf278 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet_clipbrd.inc +++ b/components/fpspreadsheet/source/common/fpspreadsheet_clipbrd.inc @@ -76,7 +76,7 @@ var clipbook: TsWorkbook; clipsheet: TsWorksheet; sel: TsCellRange; - selArray: TsCellRangeArray; + selArray: TsCellRangeArray = nil; r, c: LongInt; dr, dc: LongInt; srcCell, destCell: PCell; diff --git a/components/fpspreadsheet/source/common/fpsreaderwriter.pas b/components/fpspreadsheet/source/common/fpsreaderwriter.pas index bd01b87db..e7c9c87af 100644 --- a/components/fpspreadsheet/source/common/fpsreaderwriter.pas +++ b/components/fpspreadsheet/source/common/fpsreaderwriter.pas @@ -1171,7 +1171,7 @@ begin end; end; - SetLength(Result, FList.Count); + SetLength(Result{%H-}, FList.Count); n := 0; for i := 0 to FList.Count-1 do begin @@ -1205,7 +1205,7 @@ begin FList.Exchange(0, idx); end; - SetLength(Result, FList.Count); + SetLength(Result{%H-}, FList.Count); n := 0; for i := 0 to FList.Count - 1 do begin diff --git a/components/fpspreadsheet/source/common/fpsrpn.pas b/components/fpspreadsheet/source/common/fpsrpn.pas index a5da39096..e9d020737 100644 --- a/components/fpspreadsheet/source/common/fpsrpn.pas +++ b/components/fpspreadsheet/source/common/fpsrpn.pas @@ -472,7 +472,7 @@ begin end; // Set array length of TsRPNFormula result - SetLength(Result, n); + SetLength(Result{%H-}, n); // Copy FormulaElements to result and free temporary RPNItems item := AItem; diff --git a/components/fpspreadsheet/source/common/fpsutils.pas b/components/fpspreadsheet/source/common/fpsutils.pas index 59d9e04ee..8e2cf60c0 100644 --- a/components/fpspreadsheet/source/common/fpsutils.pas +++ b/components/fpspreadsheet/source/common/fpsutils.pas @@ -491,7 +491,6 @@ var p: Integer; s: String; f: TsRelFlags; - singleCell: Boolean = false; begin Result := True; @@ -499,7 +498,6 @@ begin p := pos(':', AStr); if p = 0 then //exit(false); begin - singleCell := true; Result := ParseCellString(AStr, AFirstcellRow, AFirstCellCol, f); if not Result then exit; ALastCellRow := AFirstCellRow; @@ -2355,7 +2353,7 @@ function RandomString(ALen: Integer): String; var i: Integer; begin - SetLength(Result, ALen); + SetLength(Result{%H-}, ALen); for i:=1 to ALen do Result[i] := char(Random(26) + ord('a')); end; @@ -2411,6 +2409,7 @@ var arr1, arr2: TStringArray; i: Integer; begin + ARichText := nil; p := pos(SEPARATOR, AValue); if p = 0 then begin AText := AValue; @@ -2438,6 +2437,7 @@ var L: TStringList; i: Integer; begin + Result := nil; L := TStringList.Create; try L.Delimiter := ADelimiter; diff --git a/components/fpspreadsheet/source/common/uvirtuallayer.pas b/components/fpspreadsheet/source/common/uvirtuallayer.pas index a57412008..756cef21e 100644 --- a/components/fpspreadsheet/source/common/uvirtuallayer.pas +++ b/components/fpspreadsheet/source/common/uvirtuallayer.pas @@ -113,7 +113,7 @@ procedure TVirtualLayer.SplitPath(const APath: UTF8String;const ASplittedPath: T var j,k: integer; LB: integer; - Chunk: UTF8String; + Chunk: UTF8String = ''; ChunkC: integer; begin ASplittedPath.Clear; diff --git a/components/fpspreadsheet/source/common/xlsbiff2.pas b/components/fpspreadsheet/source/common/xlsbiff2.pas index 12bbfe37a..c2e980385 100644 --- a/components/fpspreadsheet/source/common/xlsbiff2.pas +++ b/components/fpspreadsheet/source/common/xlsbiff2.pas @@ -559,7 +559,7 @@ var lHeight: Word; lOptions: Word; Len: Byte; - lFontName: UTF8String; + lFontName: UTF8String = ''; isDefaultFont: Boolean; begin FFont := TsFont.Create; @@ -613,7 +613,7 @@ end;*) procedure TsSpreadBIFF2Reader.ReadFormat(AStream: TStream); var len: byte; - fmtString: AnsiString; + fmtString: AnsiString = ''; nfs: String; begin // number format string @@ -798,7 +798,7 @@ var L: Byte; ARow, ACol: Cardinal; XF: Word; - ansiStr: ansistring; + ansiStr: ansistring = ''; valueStr: UTF8String; cell: PCell; sheet: TsWorksheet; @@ -1099,7 +1099,7 @@ end; procedure TsSpreadBIFF2Reader.ReadStringRecord(AStream: TStream); var len: Byte; - s: ansistring; + s: ansistring = ''; begin // The string is a byte-string with 8 bit length len := AStream.ReadByte; @@ -1948,7 +1948,7 @@ var len: Integer; s: string; //ansistring; rec: TNumFormatRecord; - buf: array of byte; + buf: array of byte = nil; begin Unused(AFormatIndex); @@ -2239,7 +2239,7 @@ var L: Byte; AnsiText: ansistring; rec: TBIFF2_LabelRecord; - buf: array of byte; + buf: array of byte = nil; var xf: Word; begin diff --git a/components/fpspreadsheet/source/common/xlsbiff5.pas b/components/fpspreadsheet/source/common/xlsbiff5.pas index 4818c0c2a..bb097e86f 100644 --- a/components/fpspreadsheet/source/common/xlsbiff5.pas +++ b/components/fpspreadsheet/source/common/xlsbiff5.pas @@ -397,7 +397,7 @@ end; procedure TsSpreadBIFF5Reader.ReadBOUNDSHEET(AStream: TStream); var len: Byte; - s: AnsiString; + s: AnsiString = ''; sheetState: Byte; sheet: TsWorksheet; //sheetData: TsSheetData; @@ -433,7 +433,7 @@ var options: Word; len: byte; formulaSize: Word; - ansistr: ansiString; + ansistr: ansiString = ''; defName: String; rpnformula: TsRPNFormula; {%H-}extsheetIndex: Integer; @@ -721,10 +721,10 @@ var B: Byte; ARow, ACol: Cardinal; XF: Word; - ansistr: ansistring; + ansistr: ansistring = ''; valueStr: UTF8String; cell: PCell; - rtfRuns: TBiff5_RichTextFormattingRuns; + rtfRuns: TBiff5_RichTextFormattingRuns = nil; fntIndex: Integer; fnt: TsFont; sheet: TsWorksheet; @@ -796,7 +796,7 @@ end; procedure TsSpreadBIFF5Reader.ReadStringRecord(AStream: TStream); var len: Word; - s: ansistring; + s: ansistring = ''; begin // The string is a byte-string with 16 bit length len := WordLEToN(AStream.ReadWord); @@ -1045,7 +1045,7 @@ var lWeight: Word; lEsc: Word; Len: Byte; - fontname: ansistring; + fontname: ansistring = ''; font: TsFont; isDefaultFont: Boolean; begin @@ -1132,7 +1132,7 @@ procedure TsSpreadBIFF5Reader.ReadFormat(AStream: TStream); var len: byte; fmtIndex: Integer; - fmtString: AnsiString; + fmtString: AnsiString = ''; nfs: String; begin // Record FORMAT, BIFF 8 (5.49): @@ -1162,7 +1162,7 @@ var ARow, ACol: Cardinal; XF: WORD; cell: PCell; - ansistr: ansistring; + ansistr: ansistring = ''; valuestr: String; begin rec.Row := 0; // to silence the compiler... @@ -1223,7 +1223,7 @@ end; procedure TsSpreadBIFF5Writer.InternalWriteToStream(AStream: TStream); var CurrentPos: Int64; - sheetPos: array of Int64; + sheetPos: array of Int64 = nil; i: Integer; pane: Byte; book: TsWorkbook; @@ -1769,7 +1769,7 @@ var //fmtStr: String; ansiFmtStr: ansiString; rec: TNumFormatRecord; - buf: array of byte; + buf: array of byte = nil; begin //fmtStr := NumFormatList.FormatStringForWriting(AListIndex); ansiFmtStr := ConvertEncoding(ANumFormatStr, encodingUTF8, FCodePage); @@ -1867,9 +1867,9 @@ var L: Word; AnsiValue: ansistring; rec: TBIFF5_LabelRecord; - buf: array of byte; i, nRuns: Integer; - rtfRuns: TBIFF5_RichTextFormattingRuns; + rtfRuns: TBIFF5_RichTextFormattingRuns = nil; + buf: array of byte = nil; begin if (ARow >= FLimitations.MaxRowCount) or (ACol >= FLimitations.MaxColCount) then exit; diff --git a/components/fpspreadsheet/source/common/xlsbiff8.pas b/components/fpspreadsheet/source/common/xlsbiff8.pas index 8ffcb5381..39a2c02f8 100644 --- a/components/fpspreadsheet/source/common/xlsbiff8.pas +++ b/components/fpspreadsheet/source/common/xlsbiff8.pas @@ -967,13 +967,14 @@ function TsSpreadBIFF8Reader.ReadUnformattedWideString(const AStream: TStream; const ALength: WORD): WideString; var flags: Byte; - DecomprStrValue: WideString; + DecomprStrValue: WideString = ''; i: Integer; len: SizeInt; recType: Word; {%H-}recSize: Word; C: WideChar; begin + Result := ''; flags := AStream.ReadByte; dec(PendingRecordSize); if flags and 1 = 1 Then begin @@ -1019,8 +1020,8 @@ function TsSpreadBIFF8Reader.ReadWideString(const AStream: TStream; const ALength: WORD; out ARichTextParams: TsRichTextParams): WideString; var StringFlags: BYTE; - DecomprStrValue: WideString; - AnsiStrValue: ansistring; + DecomprStrValue: WideString = ''; + AnsiStrValue: ansistring = ''; RunsCounter: WORD; AsianPhoneticBytes: DWORD; rtf_dummy: TsRichTextParams; @@ -1031,6 +1032,7 @@ var recSize: WORD; C: WideChar; begin + Result := ''; StringFlags := AStream.ReadByte; Dec(PendingRecordSize); if StringFlags and 8 = 8 then begin @@ -1698,7 +1700,7 @@ var XF: Word; wideStrValue: WideString; cell: PCell; - rtfRuns: TBiff8_RichTextFormattingRuns; + rtfRuns: TBiff8_RichTextFormattingRuns = nil; fntIndex: Integer; fnt: TsFont; book: TsWorkbook; @@ -1859,7 +1861,7 @@ var cell: PCell; ms: TMemoryStream; i, n: Integer; - rtParams: TsRichTextParams; + rtParams: TsRichTextParams = nil; fnt: TsFont; fntIndex: Integer; book: TsWorkbook; @@ -2432,13 +2434,13 @@ var row, col, row1, col1, row2, col2: word; guid: TGUID; flags: DWord; - widestr: widestring; + widestr: widestring = ''; len: DWord; link: String; linkDos: String; mark: String; dirUpCount: Word; - ansistr: ansistring; + ansistr: ansistring = ''; size: DWord; begin { Row and column index range of cells using the hyperlink } @@ -2574,7 +2576,7 @@ end; procedure TsSpreadBIFF8Reader.ReadHyperlinkToolTip(const AStream: TStream); var txt: String; - widestr: widestring; + widestr: widestring = ''; //row, col, row1, col1, row2, col2: Word; hyperlink: PsHyperlink; @@ -2770,7 +2772,7 @@ const isBIFF8 = true; var currentPos: Int64; - sheetPos: array of Int64; + sheetPos: array of Int64 = nil; i: Integer; pane: Byte; book: TsWorkbook; @@ -3503,7 +3505,7 @@ var len: Integer; ws: widestring; rec: TNumFormatRecord; - buf: array of byte; + buf: array of byte = nil; begin ws := UTF8Decode(ANumFormatStr); len := Length(ws); @@ -3819,9 +3821,9 @@ var WideStr: WideString; rec: TBIFF8_LabelRecord; recSST: TBIFF8_LabelSSTRecord; - buf: array of byte; + buf: array of byte = nil; i, nRuns, idx: Integer; - rtfRuns: TBiff8_RichTextFormattingRuns; + rtfRuns: TBiff8_RichTextFormattingRuns = nil; begin if (ARow >= FLimitations.MaxRowCount) or (ACol >= FLimitations.MaxColCount) then exit; @@ -4742,7 +4744,7 @@ procedure TsSpreadBIFF8Writer.WriteTXO(AStream: TStream; AComment: PsComment); var recTXO: TBIFF8TXORecord; comment: widestring; - compressed: ansistring; + compressed: ansistring = ''; len: Integer; wchar: widechar; i: Integer; diff --git a/components/fpspreadsheet/source/common/xlscommon.pas b/components/fpspreadsheet/source/common/xlscommon.pas index f3ea7779e..e04600f42 100644 --- a/components/fpspreadsheet/source/common/xlscommon.pas +++ b/components/fpspreadsheet/source/common/xlscommon.pas @@ -1102,7 +1102,7 @@ var i, n: Integer; elem: TsFormulaElement; begin - SetLength(Result, 0); + Result := nil; for i:=0 to Length(FFormula)-1 do begin n := Length(Result); elem := FFormula[i]; @@ -1740,7 +1740,7 @@ var rec: TBIFF25NoteRecord; r, c: Cardinal; n: Word; - s: ansiString; + s: ansiString = ''; List: TStringList; sheet: TsWorksheet; begin @@ -1885,7 +1885,7 @@ procedure TsSpreadBIFFReader.ReadEXTERNSHEET(AStream: TStream; AWorksheet: TsBasicWorksheet); var len, b: Byte; - ansistr: AnsiString; + ansistr: AnsiString = ''; s: String; sheetlist: TsBIFFExternSheetList; begin @@ -2046,7 +2046,7 @@ end; procedure TsSpreadBIFFReader.ReadHeaderFooter(AStream: TStream; AIsHeader: Boolean); var - s: ansistring; + s: ansistring = ''; len: Byte; begin if RecordSize = 0 then @@ -2094,7 +2094,7 @@ begin n := WordLEToN(AStream.ReadWord); for i := 1 to n do begin - AStream.ReadBuffer(rec, SizeOf(rec)); + AStream.ReadBuffer(rec{%H-}, SizeOf(rec)); r := WordLEToN(rec.RowIndex); TsWorksheet(AWorksheet).AddPageBreakToRow(r); end; @@ -2790,6 +2790,7 @@ begin dr2 := SmallInt(r2 and $3FFF) else dr2 := SmallInt($C000 or (r2 and $3FFF)); + ARowOffset2 := dr2; // 1 byte for col1 and col2, each dc1 := ShortInt(AStream.ReadByte); @@ -3341,7 +3342,7 @@ var {%H-}rngIndex: Word; actRow, actCol: Word; n, i: Integer; - sel: TsCellRangeArray; + sel: TsCellRangeArray = nil; begin // Pane index paneIdx := AStream.ReadByte; @@ -3441,7 +3442,7 @@ end; function TsSpreadBIFFReader.ReadString_8bitLen(AStream: TStream): String; var len: Byte; - s: ansistring; + s: ansistring = ''; begin len := AStream.ReadByte; SetLength(s, len); @@ -3493,7 +3494,7 @@ begin n := WordLEToN(AStream.ReadWord); for i := 1 to n do begin - AStream.ReadBuffer(rec, SizeOf(rec)); + AStream.ReadBuffer(rec{%H-}, SizeOf(rec)); c := WordLEToN(rec.ColIndex); TsWorksheet(AWorksheet).AddPageBreakToCol(c); end; diff --git a/components/fpspreadsheet/source/common/xlsxml.pas b/components/fpspreadsheet/source/common/xlsxml.pas index 2f95ef7d8..a40d9fe81 100644 --- a/components/fpspreadsheet/source/common/xlsxml.pas +++ b/components/fpspreadsheet/source/common/xlsxml.pas @@ -341,8 +341,6 @@ begin end; function TryStrToCFCellBorder(s: String; out ABorder: TsCellBorder): Boolean; -var - cb: TsCellBorder; begin Result := true; if s = 'border-left' then @@ -860,8 +858,8 @@ begin // initialize parameters condition := -1; range := fpsUtils.Range(Cardinal(-1), Cardinal(-1), Cardinal(-1), Cardinal(-1)); - VarClear(op1); - VarClear(op2); + VarClear(op1{%H-}); + VarClear(op2{%H-}); bgColor := scNotDefined; fgColor := scNotDefined; fill := fsNoFill; @@ -1044,7 +1042,7 @@ begin exit; end; - if condition = Cardinal(-1) then + if condition = -1 then begin book.AddErrorMsg('No condition given in conditional format.'); exit; @@ -1392,7 +1390,6 @@ procedure TsSpreadExcelXMLReader.ReadPageBreak(ANode: TDOMNode; AWorksheet: TsBasicWorksheet); var sheet: TsWorksheet absolute AWorksheet; - node: TDOMNode; nodeName: String; s: String; n: Integer; @@ -1422,8 +1419,6 @@ var sheet: TsWorksheet absolute AWorksheet; nodeName: String; node: TDOMNode; - child: TDOMNode; - s: String; begin while ANode <> nil do begin @@ -1524,7 +1519,6 @@ var nodeName: String; s: String; n: Integer; - x: Double; begin while ANode <> nil do begin nodeName := ANode.NodeName; @@ -2012,6 +2006,8 @@ procedure TsSpreadExcelXMLReader.ReadFromStream(AStream: TStream; var doc: TXMLDocument; begin + Unused(APassword, AParams); + try ReadXMLStream(doc, AStream); @@ -2614,12 +2610,10 @@ procedure TsSpreadExcelXMLWriter.WriteConditionalFormatting(AStream: TStream; AWorksheet: TsBasicWorksheet); var book: TsWorkbook; - sheet: TsWorksheet; cf: TsConditionalFormat; i: Integer; begin book := TsWorkbook(FWorkbook); - sheet := TsWorksheet(AWorksheet); for i := 0 to book.GetNumConditionalFormats-1 do begin cf := book.GetConditionalFormat(i); @@ -2731,6 +2725,9 @@ var xmlnsStr: String; dataTagStr: String; begin + Unused(ARow); + Unused(ACol); + if ACell^.ContentType <> cctFormula then raise Exception.Create('WriteFormula called for calculated cell.'); @@ -2873,9 +2870,9 @@ begin if (RepeatedCols.FirstIndex <> UNASSIGNED_ROW_COL_INDEX) and (RepeatedCols.LastIndex <> UNASSIGNED_ROW_COL_INDEX) then begin - s := 'C' + IntToStr(RepeatedCols.FirstIndex + 1); + s := 'C' + {%H-}IntToStr(RepeatedCols.FirstIndex + 1); if RepeatedCols.FirstIndex <> RepeatedCols.LastIndex then - s := s + ':C' + IntToStr(RepeatedCols.LastIndex + 1); + s := s + ':C' + {%H-}IntToStr(RepeatedCols.LastIndex + 1); s := sheet.Name + '!' + s; print_titles_str := s; end; @@ -2884,9 +2881,9 @@ begin if (RepeatedRows.FirstIndex <> UNASSIGNED_ROW_COL_INDEX) and (RepeatedRows.LastIndex <> UNASSIGNED_ROW_COL_INDEX) then begin - s := 'R' + IntToStr(RepeatedRows.FirstIndex + 1); + s := 'R' + {%H-}IntToStr(RepeatedRows.FirstIndex + 1); if RepeatedRows.FirstIndex <> RepeatedRows.LastIndex then - s := s + ':R' + IntToStr(RepeatedRows.LastIndex + 1); + s := s + ':R' + {%H-}IntToStr(RepeatedRows.LastIndex + 1); s := sheet.Name + '!' + s; if print_titles_str = '' then print_titles_str := s diff --git a/components/fpspreadsheet/source/common/xlsxooxml.pas b/components/fpspreadsheet/source/common/xlsxooxml.pas index 89c3107de..89910ecc7 100644 --- a/components/fpspreadsheet/source/common/xlsxooxml.pas +++ b/components/fpspreadsheet/source/common/xlsxooxml.pas @@ -59,7 +59,6 @@ type FBorderList: TFPList; FHyperlinkList: TFPList; FSharedFormulaBaseList: TFPList; - FDxfList: TFPList; FPalette: TsPalette; FThemeColors: array of TsColor; FLastRow, FLastCol: Cardinal; @@ -167,9 +166,9 @@ type procedure WriteConditionalFormatCellRule(AStream: TStream; ARule: TsCFCellRule; ARange: TsCellRange; APriority: Integer); procedure WriteConditionalFormatColorRangeRule(AStream: TStream; ARule: TsCFColorRangeRule; - const ARange: TsCellRange; APriority: Integer); + APriority: Integer); procedure WriteConditionalFormatDataBarRule(AStream: TStream; ARule: TsCFDatabarRule; - const ARange: TsCellRange; APriority: Integer); + APriority: Integer); procedure WriteConditionalFormatRule(AStream: TStream; ARule: TsCFRule; const ARange: TsCellRange; var APriority: Integer); procedure WriteConditionalFormats(AStream: TStream; AWorksheet: TsBasicWorksheet); @@ -1271,7 +1270,7 @@ end; procedure TsSpreadOOXMLReader.ReadCFAverage(ANode: TDOMNode; AWorksheet: TsBasicWorksheet; ARange: TsCellRange; AFormatIndex: Integer); var - s, sStdDev, sEquAve, sAboveAve: String; + sStdDev, sEquAve, sAboveAve: String; condition: TsCFCondition; stdDev: Double; sheet: TsWorksheet; @@ -1310,8 +1309,8 @@ procedure TsSpreadOOXMLReader.ReadCFCellFormat(ANode: TDOMNode; AWorksheet: TsBasicWorksheet; ARange: TsCellRange; AFormatIndex: Integer); var nodeName: String; - s, sType, sOp: String; - sFormula: Array of String; + sOp: String; + sFormula: Array of String = nil; cf: TsCFCondition; found: Boolean; i: Integer; @@ -1319,7 +1318,7 @@ var x: Double; r, c: Cardinal; condition: TsCFCondition; - values: array of Variant; + values: array of Variant = nil; sheet: TsWorksheet; begin sheet := TsWorksheet(AWorksheet); @@ -2015,7 +2014,6 @@ var nodeName: String; childNode: TDOMNode; pattNode: TDOMNode; - s: String; fontStyles: TsFontStyles; fontColor: TsColor; bgColor: TsColor; @@ -2854,7 +2852,7 @@ var nodename: String; totaltxt, sval: String; fntIndex: Integer; - rtParams: TsRichTextParams; + rtParams: TsRichTextParams = nil; ms: TMemoryStream; fnt: TsFont; begin @@ -3787,10 +3785,9 @@ end; procedure TsSpreadOOXMLWriter.ListAllDifferentialFormats; var book: TsWorkbook; - sheet: TsWorksheet; n: Integer; idx: Integer; - i, j, k, r, d: Integer; + j, k, d: Integer; CF: TsConditionalFormat; rule: TsCFCellRule; begin @@ -4157,7 +4154,7 @@ begin end; procedure TsSpreadOOXMLWriter.WriteConditionalFormatColorRangeRule(AStream: TStream; - ARule: TsCFColorRangeRule; const ARange: TsCellRange; APriority: Integer); + ARule: TsCFColorRangeRule; APriority: Integer); { example: @@ -4189,7 +4186,7 @@ begin end; procedure TsSpreadOOXMLWriter.WriteConditionalFormatDatabarRule(AStream: TStream; - ARule: TsCFDataBarRule; const ARange: TsCellRange; APriority: Integer); + ARule: TsCFDataBarRule; APriority: Integer); { example from test file: @@ -4225,10 +4222,10 @@ begin WriteConditionalFormatCellRule(AStream, TsCFCellRule(ARule), ARange, APriority) else if ARule is TsCFColorRangeRule then - WriteConditionalFormatColorRangeRule(AStream, TsCFColorRangeRule(ARule), ARange, APriority) + WriteConditionalFormatColorRangeRule(AStream, TsCFColorRangeRule(ARule), APriority) else if ARule is TsCFDataBarRule then - WriteConditionalFormatDataBarRule(AStream, TsCFDataBarRule(ARule), ARange, APriority) + WriteConditionalFormatDataBarRule(AStream, TsCFDataBarRule(ARule), APriority) else exit; dec(APriority); @@ -6135,7 +6132,6 @@ procedure TsSpreadOOXMLWriter.WriteDifferentialFormat(AStream: TStream; var pt, bc, fc, diag: string; - font: TsFont; begin AppendToStream(AStream, '');