From 1626e8ab2fe50571e771002ff50e2b8b54da9261 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 27 Oct 2021 16:14:40 +0000 Subject: [PATCH] fpspreadsheet: Less hints and warnings git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8126 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/common/fpsclasses.pas | 18 +- .../source/common/fpsnumformat.pas | 2 +- .../source/common/fpsopendocument.pas | 7 - .../source/common/fpsxmlcommon.pas | 2 - .../fpspreadsheet/source/common/xlsbiff8.pas | 2 +- .../fpspreadsheet/source/common/xlsxml.pas | 29 +- .../fpspreadsheet/source/common/xlsxooxml.pas | 16 +- .../source/crypto/xlsxdecrypter.pas | 10 +- .../source/crypto/xlsxooxml_crypto.pas | 2 +- .../source/dataset/fpsdataset.pas | 11 +- .../source/visual/fpspreadsheetgrid.pas | 3 +- .../unit-tests/common/celltypetests.pas | 2 - .../unit-tests/common/colortests.pas | 9 +- .../unit-tests/common/colrowtests.pas | 4 +- .../unit-tests/common/commenttests.pas | 2 - .../common/conditionalformattests.pas | 5 +- .../unit-tests/common/datetests.pas | 8 +- .../unit-tests/common/enumeratortests.pas | 4 +- .../unit-tests/common/errortests.pas | 3 +- .../unit-tests/common/fileformattests.pas | 5 +- .../unit-tests/common/fonttests.pas | 2 +- .../unit-tests/common/formattests.pas | 43 ++- .../unit-tests/common/formulatests.pas | 12 +- .../unit-tests/common/internaltests.pas | 33 +- .../unit-tests/common/manualtests.pas | 33 +- .../unit-tests/common/mathtests.pas | 2 +- .../common/numformatparsertests.pas | 5 +- .../unit-tests/common/pagelayouttests.pas | 9 +- .../unit-tests/common/protectiontests.pas | 16 +- .../unit-tests/common/rpnformulaunit.pas | 291 +++++++++--------- .../unit-tests/common/singleformulatests.pas | 3 +- .../unit-tests/common/sortingtests.pas | 10 +- .../unit-tests/common/spreadtestgui.lpi | 4 +- .../unit-tests/common/ssttests.pas | 11 +- .../unit-tests/common/stringtests.pas | 16 +- .../common/testcases_calcrpnformula.inc | 2 +- .../unit-tests/common/virtualmodetests.pas | 4 +- .../unit-tests/dataset/GuiTestProject.lpi | 1 - .../dataset/copyfromdatasetunit.pas | 9 +- .../dataset/emptycolumnstestunit.pas | 1 - .../unit-tests/dataset/filtertestunit.pas | 2 +- .../unit-tests/dataset/posttestunit.pas | 2 +- .../unit-tests/dataset/readfieldstestunit.pas | 3 +- .../unit-tests/dataset/searchtestunit.pas | 4 +- 44 files changed, 282 insertions(+), 380 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpsclasses.pas b/components/fpspreadsheet/source/common/fpsclasses.pas index c1d9d2657..07057e94c 100644 --- a/components/fpspreadsheet/source/common/fpsclasses.pas +++ b/components/fpspreadsheet/source/common/fpsclasses.pas @@ -260,7 +260,7 @@ var currentSheet, changedSheet: TsBasicWorksheet; rng: TsCellRange; begin - colIndex := PtrInt(AData1); + colIndex := {%H-}PtrInt(AData1); changedSheet := TsBasicWorksheet(AData2); if AExprNode is TsCellExprNode then begin @@ -321,7 +321,7 @@ var changedSheet: TsBasicWorksheet; currentSheet, referencedSheet, referencedSheet2: TsBasicWorksheet; begin - rowIndex := PtrInt(AData1); + rowIndex := {%H-}PtrInt(AData1); changedSheet := TsBasicWorksheet(AData2); if AExprNode is TsCellExprNode then @@ -386,7 +386,7 @@ var referencedSheet, referencedSheet2: TsBasicWorksheet; rng: TsCellRange; begin - colIndex := PtrInt(AData1); + colIndex := {%H-}PtrInt(AData1); changedSheet := TsBasicWorksheet(AData2); if AExprNode is TsCellExprNode then begin @@ -437,7 +437,7 @@ var referencedSheet, referencedSheet2: TsBasicWorksheet; rng: TsCellRange; begin - rowIndex := PtrInt(AData1); + rowIndex := {%H-}PtrInt(AData1); changedSheet := TsBasicWorksheet(AData2); if AExprNode is TsCellExprNode then begin @@ -549,8 +549,8 @@ begin if not InRange(LongInt(curr^.Col), FStartCol, FEndCol) then begin rc := curr^; - if LongInt(rc.Col) < FStartCol then - dec(LongInt(rc.Row)); + if rc.Col < FStartCol then + dec(rc.Row); rc.Col := FEndCol; FCurrentNode := FTree.FindNearest(@rc); if FCurrentNode <> nil then begin @@ -571,17 +571,17 @@ begin begin curr := PsRowCol(FCurrentNode.Data); rc.Col := FStartCol; - if LongInt(rc.Col) > FEndCol then inc(rc.Row); + if rc.Col > FEndCol then inc(rc.Row); if not InRange(LongInt(curr^.Col), FStartCol, FEndCol) then begin rc := curr^; - if LongInt(rc.Col) > FEndCol then inc(rc.Row); + if rc.Col > FEndCol then inc(rc.Row); rc.Col := FStartCol; FCurrentNode := FTree.FindNearest(@rc); if FCurrentNode <> nil then begin curr := PsRowCol(FCurrentNode.Data); - if (LongInt(curr^.Col) < FStartCol) then + if (Int64(curr^.Col) < FStartCol) then while (FCurrentNode <> nil) and not InRange(curr^.Col, FStartCol, FEndCol) do begin FCurrentNode := FTree.FindSuccessor(FCurrentNode); diff --git a/components/fpspreadsheet/source/common/fpsnumformat.pas b/components/fpspreadsheet/source/common/fpsnumformat.pas index 8e1f93920..745176ae8 100644 --- a/components/fpspreadsheet/source/common/fpsnumformat.pas +++ b/components/fpspreadsheet/source/common/fpsnumformat.pas @@ -12,7 +12,7 @@ unit fpsNumFormat; {$ifdef fpc} {$mode objfpc}{$H+} {$endif} - +{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} interface uses diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas index ba622fad8..16e59a6cb 100644 --- a/components/fpspreadsheet/source/common/fpsopendocument.pas +++ b/components/fpspreadsheet/source/common/fpsopendocument.pas @@ -5171,7 +5171,6 @@ var numFmtStr: String; numFmtIndex: Integer; numFmtParams: TsNumFormatParams; - clr: TsColor; fnt: TsFont; fntName: String; fntSize: Single; @@ -5179,7 +5178,6 @@ var fntColor: TsColor; fntPos: TsFontPosition; fntIndex: Integer; - s: String; idx: Integer; begin if not Assigned(AStylesNode) then @@ -6046,9 +6044,6 @@ procedure TsSpreadopenDocWriter.WriteStyleNode(AStream: TStream; var s: String; nfs: String; - nfParams: TsNumFormatParams; - nfIdx: Integer; - j, p: Integer; addProtection: Boolean; begin addProtection := (AConditionalFormatIndex = -1); @@ -6561,8 +6556,6 @@ procedure TsSpreadOpenDocWriter.WriteConditionalFormats(AStream: TStream; } -const - VALUE_OR_DATE: array[boolean] of string = ('value', 'date'); var book: TsWorkbook; ncf: Integer; diff --git a/components/fpspreadsheet/source/common/fpsxmlcommon.pas b/components/fpspreadsheet/source/common/fpsxmlcommon.pas index 99a5ca43a..cbe41b132 100644 --- a/components/fpspreadsheet/source/common/fpsxmlcommon.pas +++ b/components/fpspreadsheet/source/common/fpsxmlcommon.pas @@ -232,8 +232,6 @@ begin end; function XMLQuote(AText: String): String; -var - i: Integer; begin if AText <> '' then Result := StringReplace(AText, '"', '"', [rfReplaceAll]) diff --git a/components/fpspreadsheet/source/common/xlsbiff8.pas b/components/fpspreadsheet/source/common/xlsbiff8.pas index 779eef124..8a9923058 100644 --- a/components/fpspreadsheet/source/common/xlsbiff8.pas +++ b/components/fpspreadsheet/source/common/xlsbiff8.pas @@ -217,7 +217,7 @@ type AWorksheet: TsBasicWorksheet): Int64; procedure WriteComment(AStream: TStream; ACell: PCell); override; procedure WriteComments(AStream: TStream; AWorksheet: TsBasicWorksheet); - procedure WriteConditionalFormatting(AStream: TStream; AWorksheet: TsBasicWorksheet); + procedure WriteConditionalFormatting({%H-}AStream: TStream; {%H-}AWorksheet: TsBasicWorksheet); procedure WriteDefinedName(AStream: TStream; AWorksheet: TsBasicWorksheet; const AName: String; AIndexToREF, ASheetIndex: Word; AKind: TsBIFFExternKind); reintroduce; diff --git a/components/fpspreadsheet/source/common/xlsxml.pas b/components/fpspreadsheet/source/common/xlsxml.pas index bab1f913f..35fffc296 100644 --- a/components/fpspreadsheet/source/common/xlsxml.pas +++ b/components/fpspreadsheet/source/common/xlsxml.pas @@ -2741,34 +2741,11 @@ procedure TsSpreadExcelXMLWriter.WriteDateTime(AStream: TStream; var valueStr: String = ''; ExcelDate: TDateTime; - nfp: TsNumFormatParams; - fmt: PsCellFormat; begin Unused(ARow, ACol); - (* - fmt := (FWorkbook as TsWorkbook).GetPointerToCellFormat(ACell^.FormatIndex); - if (fmt <> nil) and (uffNumberFormat in fmt^.UsedFormattingFields) then - begin - nfp := (FWorkbook as TsWorkbook).GetNumberFormat(fmt^.NumberFormatIndex); - if IsTimeIntervalFormat(nfp) then - valueStr := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz', AValue); - { - if IsTimeIntervalFormat(nfp) or IsTimeFormat(nfp) then - begin - case FDateMode of - dm1900: ExcelDate := AValue + DATEMODE_1900_BASE; - dm1904: ExcelDate := AValue + DATEMODE_1904_BASE; - end; - valueStr := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz', AValue); - end; - } - end; - if valueStr = '' then - begin - *) - ExcelDate := ConvertDateTimeToExcelDateTime(AValue, FDateMode); - valueStr := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz', ExcelDate); - //end; + + ExcelDate := ConvertDateTimeToExcelDateTime(AValue, FDateMode); + valueStr := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz', ExcelDate); AppendToStream(AStream, Format(CELL_INDENT + '' + LF + VALUE_INDENT + // colIndex, style, formula, hyperlink, merge diff --git a/components/fpspreadsheet/source/common/xlsxooxml.pas b/components/fpspreadsheet/source/common/xlsxooxml.pas index 4cbea5df6..69d7e440e 100644 --- a/components/fpspreadsheet/source/common/xlsxooxml.pas +++ b/components/fpspreadsheet/source/common/xlsxooxml.pas @@ -1649,7 +1649,6 @@ var v: array of Double = nil; n: Integer; x: Double; - res: Integer; begin ANode := ANode.FirstChild; if (ANode <> nil) and (ANode.NodeName = 'iconSet') then @@ -1698,9 +1697,9 @@ begin sheet := TsWorksheet(AWorksheet); // Ignore the first value because it is always 0 case n of - 3: res := sheet.WriteIconSet(ARange, iconSet, vk[1], v[1], vk[2], v[2]); - 4: res := sheet.WriteIconSet(ARange, iconSet, vk[1], v[1], vk[2], v[2], vk[3], v[3]); - 5: res := sheet.WriteIconSet(ARange, iconSet, vk[1], v[1], vk[2], v[2], vk[3], v[3], vk[4], v[4]); + 3: sheet.WriteIconSet(ARange, iconSet, vk[1], v[1], vk[2], v[2]); + 4: sheet.WriteIconSet(ARange, iconSet, vk[1], v[1], vk[2], v[2], vk[3], v[3]); + 5: sheet.WriteIconSet(ARange, iconSet, vk[1], v[1], vk[2], v[2], vk[3], v[3], vk[4], v[4]); end; ANode := ANode.NextSibling; @@ -2732,15 +2731,11 @@ var book: TsWorkbook; s: String; name: String; - dt: TDateTime; - fs: TFormatSettings; begin if ANode = nil then exit; book := TsWorkbook(FWorkbook); - fs := DefaultFormatSettings; - fs.DateSeparator := '-'; ANode := ANode.FirstChild; while ANode <> nil do @@ -3626,7 +3621,6 @@ procedure TsSpreadOOXMLReader.ReadFromStream(AStream: TStream; APassword: String = ''; AParams: TsStreamParams = []); var Doc : TXMLDocument; - metadataNode: TDOMNode; RelsNode: TDOMNode; i, j: Integer; fn: String; @@ -4340,7 +4334,7 @@ end; procedure TsSpreadOOXMLWriter.WriteCFDatabarRule(AStream: TStream; ARule: TsCFDataBarRule; APriority: Integer); -{ example from test file: +(* example from test file: @@ -4352,7 +4346,7 @@ procedure TsSpreadOOXMLWriter.WriteCFDatabarRule(AStream: TStream; {A620EE03-2FEC-4D54-872C-66BDB99CB07E} - } + *) begin AppendToStream(AStream, '' + diff --git a/components/fpspreadsheet/source/crypto/xlsxdecrypter.pas b/components/fpspreadsheet/source/crypto/xlsxdecrypter.pas index 03adcc0b0..8c345b4ef 100644 --- a/components/fpspreadsheet/source/crypto/xlsxdecrypter.pas +++ b/components/fpspreadsheet/source/crypto/xlsxdecrypter.pas @@ -287,7 +287,7 @@ const var AES_Cipher: TDCP_rijndael; - ConcArr : TBytes; + ConcArr : TBytes = nil; LastHash: TSHA1Digest; Iterator, i: DWord; @@ -375,12 +375,12 @@ begin // 2. Decrypt the EncryptedVerifier AES_Cipher := TDCP_rijndael.Create(nil); AES_Cipher.Init( FEncryptionKey[0], FEncInfo.Header.KeySize, nil ); - AES_Cipher.DecryptECB(FEncInfo.Verifier.EncryptedVerifier[0] , Verifier[0]); + AES_Cipher.DecryptECB(FEncInfo.Verifier.EncryptedVerifier[0] , {%H-}Verifier[0]); // 3. Decrypt the DecryptedVerifierHash AES_Cipher.Burn; AES_Cipher.Init( FEncryptionKey[0], FEncInfo.Header.KeySize, nil ); - AES_Cipher.DecryptECB(FEncInfo.Verifier.EncryptedVerifierHash[0] , VerifierHash[0]); + AES_Cipher.DecryptECB(FEncInfo.Verifier.EncryptedVerifierHash[0] , {%H-}VerifierHash[0]); AES_Cipher.DecryptECB(FEncInfo.Verifier.EncryptedVerifierHash[16], VerifierHash[16]); AES_Cipher.Free; @@ -429,8 +429,8 @@ var OLEDocument: TOLEDocument; AES_Cipher : TDCP_rijndael; - inData : TBytes; - outData : TBytes; + inData : TBytes = nil; + outData : TBytes = nil; StreamSize : QWord; KeySizeByte: Integer; diff --git a/components/fpspreadsheet/source/crypto/xlsxooxml_crypto.pas b/components/fpspreadsheet/source/crypto/xlsxooxml_crypto.pas index 7d23a6f16..977a59324 100644 --- a/components/fpspreadsheet/source/crypto/xlsxooxml_crypto.pas +++ b/components/fpspreadsheet/source/crypto/xlsxooxml_crypto.pas @@ -35,7 +35,7 @@ begin begin DecryptedStream := TMemoryStream.Create; try - ExcelDecrypt.Decrypt(AStream, DecryptedStream, APassword); + ExcelDecrypt.Decrypt(AStream, DecryptedStream, UnicodeString(APassword)); // Discard encrypted stream and load decrypted one. AStream.Free; AStream := TMemoryStream.Create; diff --git a/components/fpspreadsheet/source/dataset/fpsdataset.pas b/components/fpspreadsheet/source/dataset/fpsdataset.pas index f85bf7ca3..b00b7f624 100644 --- a/components/fpspreadsheet/source/dataset/fpsdataset.pas +++ b/components/fpspreadsheet/source/dataset/fpsdataset.pas @@ -54,7 +54,7 @@ unit fpsDataset; {$mode ObjFPC}{$H+} {$R ../../resource/fpsdatasetreg.res} - +{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} interface uses @@ -691,7 +691,6 @@ procedure TsWorksheetDataset.CopyFromDataset(ADataset: TDataset; var i: Integer; fsrc, fdest: TField; - fd: TFieldDef; stream: TMemoryStream; bm: TBookmark; begin @@ -709,7 +708,7 @@ begin FieldDefs.Clear; for fsrc in ADataset.Fields do begin - fd := AddFieldDef(fsrc.FieldName, fsrc.DataType, fsrc.Size, fsrc.FieldNo-1, CP_UTF8); + AddFieldDef(fsrc.FieldName, fsrc.DataType, fsrc.Size, fsrc.FieldNo-1, CP_UTF8); if fsrc is TAutoIncField then begin FAutoIncField := TAutoIncField(fsrc); @@ -866,7 +865,6 @@ var r, c: Integer; cLast: cardinal; cell: PCell; - fd: TFieldDef; fn: String; ft: TFieldType; fs: Integer; @@ -1903,7 +1901,6 @@ procedure TsWorksheetDataset.SetFieldData(Field: TField; Buffer: Pointer); var destBuffer: TRecordBuffer; idx: Integer; - fsize: Integer; {%H-}dt: TDateTime; dtr: TDateTimeRec; s: String; @@ -2088,7 +2085,7 @@ procedure TsWorksheetDataset.SortOnField(const FieldName: String; const Options: TsSortOptions); var bm: TBookmark; - optns: TsSortOptionsArray; + optns: TsSortOptionsArray = nil; begin bm := GetBookmark; try @@ -2146,7 +2143,7 @@ var P: Pointer; s: String = ''; ws: WideString = ''; - curr: Currency; + curr: Currency = 0; begin row := GetCurrentRowIndex; P := Buffer; diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas b/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas index 2a56be819..6224a044f 100644 --- a/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas +++ b/components/fpspreadsheet/source/visual/fpspreadsheetgrid.pas @@ -13,6 +13,7 @@ unit fpspreadsheetgrid; {$mode objfpc}{$H+} +{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} {$I fps.inc} {.$DEFINE GRID_DEBUG} @@ -307,7 +308,7 @@ type function GetCellText(ACol, ARow: Integer; ATrim: Boolean = true): String; function GetEditText(ACol, ARow: Integer): String; override; function GetDefaultColumnTitle(Column: Integer): string; override; - function GetIsCellTitle(ACol, ARow: Integer): boolean; override; + function GetIsCellTitle({%H-}ACol, ARow: Integer): boolean; override; function HasBorder(ACell: PCell; ABorder: TsCellBorder): Boolean; procedure HeaderSizing(const IsColumn:boolean; const AIndex,ASize:Integer); override; procedure HeaderSized(IsColumn: Boolean; AIndex: Integer); override; diff --git a/components/fpspreadsheet/unit-tests/common/celltypetests.pas b/components/fpspreadsheet/unit-tests/common/celltypetests.pas index 4b3605fa4..7605d21d3 100644 --- a/components/fpspreadsheet/unit-tests/common/celltypetests.pas +++ b/components/fpspreadsheet/unit-tests/common/celltypetests.pas @@ -77,7 +77,6 @@ var MyWorkbook: TsWorkbook; row, col: Integer; MyCell: PCell; - value: Boolean; TempFile: string; //write xls/xml to this file and read back from it begin MyWorkbook := TsWorkbook.Create; @@ -142,7 +141,6 @@ begin GetEnumName(TypeInfo(TCellContentType), ord(MyCell^.ContentType)), 'Test saved content type mismatch, cell '+CellNotation(MyWorksheet, row, col) ); - value := MyCell^.BoolValue; CheckEquals( Boolean(col), MyCell^.BoolValue, diff --git a/components/fpspreadsheet/unit-tests/common/colortests.pas b/components/fpspreadsheet/unit-tests/common/colortests.pas index 9c3d894b4..ff16bb043 100644 --- a/components/fpspreadsheet/unit-tests/common/colortests.pas +++ b/components/fpspreadsheet/unit-tests/common/colortests.pas @@ -167,7 +167,7 @@ begin row := 0; col := 0; for i := 0 to palette.Count-1 do begin - MyWorksheet.WriteUTF8Text(row, col, CELLTEXT); + MyWorksheet.WriteText(row, col, CELLTEXT); MyCell := MyWorksheet.WriteBackgroundColor(row, col, palette[i]); if MyCell = nil then fail('Error in test code. Failed to get cell.'); @@ -255,7 +255,7 @@ begin row := 0; col := 0; for i := 0 to palette.Count-1 do begin - MyWorksheet.WriteUTF8Text(row, col, CELLTEXT); + MyWorksheet.WriteText(row, col, CELLTEXT); MyWorksheet.WriteFontColor(row, col, palette[i]); MyCell := MyWorksheet.FindCell(row, col); if MyCell = nil then @@ -308,17 +308,12 @@ end; procedure TSpreadWriteReadColorTests.TestWriteReadTabColor( AFormat: TsSpreadsheetFormat; ATabColor: TsColor); -const - CELLTEXT = 'Color test'; var MyWorksheet: TsWorksheet; MyWorkbook: TsWorkbook; - row, col: Integer; - MyCell: PCell; TempFile: string; //write xls/xml to this file and read back from it expectedRGB: DWord; currentRGB: DWord; - i: Integer; begin if not (AFormat in [sfOOXML, sfExcel8, sfOpenDocument]) then exit; diff --git a/components/fpspreadsheet/unit-tests/common/colrowtests.pas b/components/fpspreadsheet/unit-tests/common/colrowtests.pas index e6c36d717..ee879f3b4 100644 --- a/components/fpspreadsheet/unit-tests/common/colrowtests.pas +++ b/components/fpspreadsheet/unit-tests/common/colrowtests.pas @@ -365,7 +365,7 @@ type implementation uses - StrUtils, fpsUtils; + fpsUtils; const InsertColRowSheet = 'InsertDelete_ColumnsRows'; @@ -1984,8 +1984,6 @@ var worksheet3: TsWorksheet; expected: Double; actual: Double; - expectedFormula: String; - actualFormula: String; begin workbook := TsWorkbook.Create; try diff --git a/components/fpspreadsheet/unit-tests/common/commenttests.pas b/components/fpspreadsheet/unit-tests/common/commenttests.pas index cae51ed74..c53fe54a5 100644 --- a/components/fpspreadsheet/unit-tests/common/commenttests.pas +++ b/components/fpspreadsheet/unit-tests/common/commenttests.pas @@ -84,8 +84,6 @@ var { TSpreadWriteReadCommentTests } procedure TSpreadWriteReadCommentTests.SetUp; -var - i: Integer; begin inherited SetUp; diff --git a/components/fpspreadsheet/unit-tests/common/conditionalformattests.pas b/components/fpspreadsheet/unit-tests/common/conditionalformattests.pas index 8cf740ef1..e9fc5d998 100644 --- a/components/fpspreadsheet/unit-tests/common/conditionalformattests.pas +++ b/components/fpspreadsheet/unit-tests/common/conditionalformattests.pas @@ -12,9 +12,8 @@ interface uses // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, testsutility, - Math, Variants, - fpsTypes, fpsUtils, fpsAllFormats, fpSpreadsheet, fpsConditionalFormat; + Classes, SysUtils, fpcunit, testregistry, testsutility, Variants, + fpsTypes, fpsUtils, {%H-}fpsAllFormats, fpSpreadsheet, fpsConditionalFormat; type { TSpreadWriteReadCFTests } diff --git a/components/fpspreadsheet/unit-tests/common/datetests.pas b/components/fpspreadsheet/unit-tests/common/datetests.pas index 4d865c2a9..a931a4f61 100644 --- a/components/fpspreadsheet/unit-tests/common/datetests.pas +++ b/components/fpspreadsheet/unit-tests/common/datetests.pas @@ -17,8 +17,8 @@ interface uses // Not using lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, - fpstypes, fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, + Classes, SysUtils, fpcunit, testregistry, + fpstypes, {%H-}fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, testsutility; var @@ -485,7 +485,6 @@ var actualDateTime: TDateTime; actualStr: String; r, c: Cardinal; - h, m, s, ms: Word; t: TTime; tempFile: String; begin @@ -630,7 +629,7 @@ begin // We know these are valid time/date/datetime values.... // Just test for empty string; we'll probably end up in a maze of localized date/time stuff // if we don't. - CheckNotEquals(TestWorkSheet.ReadAsUTF8Text(Row, 0), '', + CheckNotEquals(TestWorkSheet.ReadAsText(Row, 0), '', 'Could not read date time as string for cell '+CellNotation(TestWorkSheet,Row)); if not(TestWorkSheet.ReadAsDateTime(Row, 0, ActualDateTime)) then @@ -1899,7 +1898,6 @@ var i: Integer; actualDateTime: TDateTime; ok: boolean; - cell: PCell; tempFile: String; ErrorMargin: TDateTime; //margin for error in comparison test begin diff --git a/components/fpspreadsheet/unit-tests/common/enumeratortests.pas b/components/fpspreadsheet/unit-tests/common/enumeratortests.pas index d1fdd2b02..bdc11586d 100644 --- a/components/fpspreadsheet/unit-tests/common/enumeratortests.pas +++ b/components/fpspreadsheet/unit-tests/common/enumeratortests.pas @@ -177,7 +177,7 @@ begin for row := 0 to NUM_ROWS-1 do for col := 0 to NUM_COLS-1 do if (withGaps and odd(row + col)) or (not withGaps) then - MyWorksheet.WriteComment(row, col, IntToStr(row*10000 + col)); + MyWorksheet.WriteComment(row, col, IntToStr(QWord(row)*10000 + col)); case what of 1: enumerator := MyWorksheet.Comments.GetEnumerator; @@ -189,7 +189,7 @@ begin row := comment^.Row; col := comment^.Col; if (withgaps and odd(row + col)) or (not withgaps) then - expected := IntToStr(row * 10000 + col) + expected := IntToStr(QWord(row) * 10000 + col) else expected := ''; actual := MyWorksheet.ReadComment(row, col); diff --git a/components/fpspreadsheet/unit-tests/common/errortests.pas b/components/fpspreadsheet/unit-tests/common/errortests.pas index ea046a6c5..97ebbdd5e 100644 --- a/components/fpspreadsheet/unit-tests/common/errortests.pas +++ b/components/fpspreadsheet/unit-tests/common/errortests.pas @@ -36,7 +36,7 @@ type implementation uses - StrUtils, fpsPalette, fpsRPN, xlsbiff5; + StrUtils, Graphics, fpsPalette, fpsRPN, xlsbiff5; const ERROR_SHEET = 'ErrorTest'; //worksheet name @@ -165,6 +165,7 @@ begin // to file. for row := 0 to palette.Count-1 do begin + s := ColorToString(palette[row]); MyWorksheet.WriteText(row, 0, s); MyWorksheet.WriteFontColor(row, 0, palette[row]); end; diff --git a/components/fpspreadsheet/unit-tests/common/fileformattests.pas b/components/fpspreadsheet/unit-tests/common/fileformattests.pas index 241d29e78..143b3ca87 100644 --- a/components/fpspreadsheet/unit-tests/common/fileformattests.pas +++ b/components/fpspreadsheet/unit-tests/common/fileformattests.pas @@ -64,9 +64,6 @@ const var MyWorksheet: TsWorksheet; MyWorkbook: TsWorkbook; - row, col: Integer; - MyCell: PCell; - value: Boolean; TempFile: string; //write xls/xml to this file and read back from it actualText: String; begin @@ -93,7 +90,7 @@ begin // If the tests gets here the format was detected correctly. // Quickly check the cell content MyWorksheet := MyWorkbook.GetFirstWorksheet; - actualText := MyWorksheet.ReadAsUTF8Text(0, 0); + actualText := MyWorksheet.ReadAsText(0, 0); CheckEquals(EXPECTED_TEXT, actualText, 'Cell mismatch in A1'); except fail('Cannot read file with format ' + GetSpreadFormatName(ord(AFormat))); diff --git a/components/fpspreadsheet/unit-tests/common/fonttests.pas b/components/fpspreadsheet/unit-tests/common/fonttests.pas index 63fdaeb65..675c60ffc 100644 --- a/components/fpspreadsheet/unit-tests/common/fonttests.pas +++ b/components/fpspreadsheet/unit-tests/common/fonttests.pas @@ -161,7 +161,7 @@ begin for col := 0 to High(SollStyles) do begin cellText := Format('%s, %.1f-pt', [AFontName, SollSizes[row]]); - MyWorksheet.WriteUTF8Text(row, col, celltext); + MyWorksheet.WriteText(row, col, celltext); MyWorksheet.WriteFont(row, col, AFontName, SollSizes[row], SollStyles[col], scBlack); MyCell := MyWorksheet.FindCell(row, col); diff --git a/components/fpspreadsheet/unit-tests/common/formattests.pas b/components/fpspreadsheet/unit-tests/common/formattests.pas index 62defe163..327cb8b5d 100644 --- a/components/fpspreadsheet/unit-tests/common/formattests.pas +++ b/components/fpspreadsheet/unit-tests/common/formattests.pas @@ -17,8 +17,8 @@ uses {$ENDIF} // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, testsutility, - fpstypes, fpsallformats, fpspreadsheet, fpscell, xlsbiff8; + Classes, SysUtils, fpcunit, testregistry, testsutility, + fpstypes, {%H-}fpsallformats, fpspreadsheet, fpscell, xlsbiff8; var // Norm to test against - list of strings that should occur in spreadsheet @@ -177,7 +177,7 @@ type implementation uses - Math, TypInfo, fpsPatches, fpsutils, fpsnumformat, fpspalette, fpscsv; + Math, TypInfo, {%H-}fpsPatches, fpsutils, fpsnumformat, fpspalette, fpscsv; const FmtNumbersSheet = 'NumbersFormat'; //let's distinguish it from the regular numbers sheet @@ -200,7 +200,6 @@ var i: Integer; fs: TFormatSettings; myworkbook: TsWorkbook; - ch: Char; begin // Set up norm - MUST match spreadsheet cells exactly @@ -407,7 +406,7 @@ begin MyWorksheet.WriteCurrency(Row, Col, SollNumbers[Row], SollNumberFormats[Col], SollNumberDecimals[Col]) else MyWorksheet.WriteNumber(Row, Col, SollNumbers[Row], SollNumberFormats[Col], SollNumberDecimals[Col]); - ActualString := MyWorksheet.ReadAsUTF8Text(Row, Col); + ActualString := MyWorksheet.ReadAsText(Row, Col); CheckEquals(SollNumberStrings[Row, Col], ActualString, 'Test unsaved string mismatch, cell ' + CellNotation(MyWorksheet,Row,Col)); end; @@ -433,7 +432,7 @@ begin for Row := Low(SollNumbers) to High(SollNumbers) do for Col := Low(SollNumberFormats) to High(SollNumberFormats) do begin - ActualString := MyWorkSheet.ReadAsUTF8Text(Row,Col); + ActualString := MyWorkSheet.ReadAsText(Row,Col); ExpectedString := SollNumberStrings[Row, Col]; if (ExpectedString <> ActualString) then begin @@ -520,7 +519,7 @@ begin if (AFormat = sfCSV) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then Continue; // No chance for csv to detect custom formats without further information MyWorksheet.WriteDateTime(Row, Col, SollDateTimes[Row], SollDateTimeFormats[Col], SollDateTimeFormatStrings[Col]); MyWorksheet.WriteDateTime(Row, Col, SollDateTimes[Row], SollDateTimeFormats[Col], SollDateTimeFormatStrings[Col]); - ActualString := MyWorksheet.ReadAsUTF8Text(Row, Col); + ActualString := MyWorksheet.ReadAsText(Row, Col); CheckEquals( Lowercase(SollDateTimeStrings[Row, Col]), Lowercase(ActualString), @@ -556,7 +555,7 @@ begin then Continue; // No chance for csv to detect a datetime format < 1 (must be time only) end; - ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col); + ActualString := MyWorksheet.ReadAsText(Row,Col); CheckEquals( Lowercase(SollDateTimeStrings[Row, Col]), Lowercase(ActualString), @@ -636,7 +635,7 @@ begin if AFormat = sfExcel2 then begin // BIFF2 can only do horizontal alignment --> no need for vertical alignment. - MyWorksheet.WriteUTF8Text(row, col, HORALIGN_TEXT[horAlign]); + MyWorksheet.WriteText(row, col, HORALIGN_TEXT[horAlign]); MyWorksheet.WriteHorAlignment(row, col, horAlign); MyCell := MyWorksheet.FindCell(row, col); if MyCell = nil then @@ -650,7 +649,7 @@ begin else for vertAlign in TsVertAlignment do begin - MyWorksheet.WriteUTF8Text(row, col, HORALIGN_TEXT[horAlign]+'/'+VERTALIGN_TEXT[vertAlign]); + MyWorksheet.WriteText(row, col, HORALIGN_TEXT[horAlign]+'/'+VERTALIGN_TEXT[vertAlign]); MyWorksheet.WriteHorAlignment(row, col, horAlign); MyWorksheet.WriteVertAlignment(row, col, vertAlign); MyCell := MyWorksheet.FindCell(row, col); @@ -775,8 +774,6 @@ var col, row: Integer; style: TsFillStyle; TempFile: String; - actualstyle: TsFillStyle; - actualcolor: TsColor; patt: TsFillPattern; begin // Write out all test values @@ -785,7 +782,7 @@ begin MyWorkSheet:= MyWorkBook.AddWorksheet(BackgroundSheet); for style in TsFillStyle do begin row := ord(style); - MyWorksheet.WriteUTF8Text(row, 0, GetEnumName(TypeInfo(TsFillStyle), ord(style))); + MyWorksheet.WriteText(row, 0, GetEnumName(TypeInfo(TsFillStyle), ord(style))); MyWorksheet.WriteBackground(row, 1, style, PATTERN_COLOR, BK_COLOR); MyWorksheet.WriteBackground(row, 2, style, PATTERN_COLOR, scTransparent); end; @@ -932,7 +929,7 @@ begin // It is important for the test to write contents to the cell. Without it // the first cell (col=0) would not even contain a format and would be // dropped by the ods reader resulting in a matching error. - MyCell := MyWorksheet.WriteUTF8Text(row, col, GetBordersAsText(SollBorders[col])); + MyCell := MyWorksheet.WriteText(row, col, GetBordersAsText(SollBorders[col])); MyWorksheet.WriteBorders(MyCell, SollBorders[col]); end; @@ -1163,7 +1160,6 @@ var ActualColWidth: Single; Col: Integer; lpCol: PCol; - lCol: TCol; TempFile: string; //write xls/xml to this file and read back from it begin {// Not needed: use workbook.writetofile with overwrite=true @@ -1449,14 +1445,14 @@ begin MyWorkbook := TsWorkbook.Create; try MyWorkSheet:= MyWorkBook.AddWorksheet(WordwrapSheet); - MyWorksheet.WriteUTF8Text(0, 0, LONGTEXT); + MyWorksheet.WriteText(0, 0, LONGTEXT); MyWorksheet.WriteUsedFormatting(0, 0, [uffWordwrap]); MyCell := MyWorksheet.FindCell(0, 0); if MyCell = nil then fail('Error in test code. Failed to get word-wrapped cell.'); CheckEquals(true, MyWorksheet.ReadWordwrap(MyCell), 'Test unsaved word wrap mismatch cell ' + CellNotation(MyWorksheet,0,0)); - MyWorksheet.WriteUTF8Text(1, 0, LONGTEXT); + MyWorksheet.WriteText(1, 0, LONGTEXT); MyWorksheet.WriteUsedFormatting(1, 0, []); MyCell := MyWorksheet.FindCell(1, 0); if MyCell = nil then @@ -1536,7 +1532,6 @@ var cell: PCell; TempFile: string; //write xls/xml to this file and read back from it r1, c1, r2, c2: Cardinal; - r, c: Cardinal; actual, expected: String; i: Integer; begin @@ -1547,7 +1542,7 @@ begin for i:=0 to High(TEST_RANGES) do begin ParseCellRangeString(TEST_RANGES[i], r1, c1, r2, c2); - Myworksheet.WriteUTF8Text(r1, c1, CELL_TEXT); + Myworksheet.WriteText(r1, c1, CELL_TEXT); Myworksheet.MergeCells(r1, c1, r2, c2); end; @@ -1564,7 +1559,7 @@ begin for i:=0 to High(TEST_RANGES) do begin ParseCellRangeString(TEST_RANGES[i], r1, c1, r2, c2); - Myworksheet.WriteUTF8Text(r1, c1, CELL_TEXT); + Myworksheet.WriteText(r1, c1, CELL_TEXT); Myworksheet.MergeCells(r1, c1, r2, c2); Myworksheet.UnmergeCells(r1, c1); end; @@ -1601,7 +1596,7 @@ begin end else if not (AFormat in [sfExcel2, sfExcel5]) then fail('Unmerged cell found, ' + CellNotation(MyWorksheet, r1, c1)); - CheckEquals(CELL_TEXT, MyWorksheet.ReadAsUTF8Text(cell), + CheckEquals(CELL_TEXT, MyWorksheet.ReadAsText(cell), 'Merged cell content mismatch, cell '+ CellNotation(MyWorksheet, r1, c1)); end; @@ -1626,7 +1621,7 @@ begin end else if AFormat <> sfExcel5 then fail('Unmerged cell found, ' + CellNotation(MyWorksheet, r1, c1)); - CheckEquals('', MyWorksheet.ReadAsUTF8Text(cell), + CheckEquals('', MyWorksheet.ReadAsText(cell), 'Merged cell content mismatch, cell '+CellNotation(MyWorksheet, r1, c1)); end; @@ -1639,7 +1634,7 @@ begin cell := MyWorksheet.FindCell(r1, c1); if MyWorksheet.IsMergeBase(cell) then fail('Unmerged cell expected, cell ' + CellNotation(MyWorksheet, r1, c1)); - CheckEquals(CELL_TEXT, MyWorksheet.ReadAsUTF8Text(cell), + CheckEquals(CELL_TEXT, MyWorksheet.ReadAsText(cell), 'Merged/unmerged cell content mismatch, cell '+CellNotation(MyWorksheet, r1, c1)); end; @@ -1691,11 +1686,9 @@ var MyWorksheet: TsWorksheet; cell: PCell; TempFile: string; //write xls/xml to this file and read back from it - r1, c1, r2, c2: Cardinal; r, c: Cardinal; fnt: TsFont; actual, expected: String; - i: Integer; palette: TsPalette; begin palette := TsPalette.Create; diff --git a/components/fpspreadsheet/unit-tests/common/formulatests.pas b/components/fpspreadsheet/unit-tests/common/formulatests.pas index 39f293b41..007d09965 100644 --- a/components/fpspreadsheet/unit-tests/common/formulatests.pas +++ b/components/fpspreadsheet/unit-tests/common/formulatests.pas @@ -18,8 +18,8 @@ interface uses // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, - fpstypes, fpsallformats, fpspreadsheet, fpsexprparser, + Classes, SysUtils, fpcunit, testregistry, + fpstypes, {%H-}fpsallformats, fpspreadsheet, fpsexprparser, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, testsutility; @@ -133,7 +133,7 @@ uses var // Array containing the "true" results of the formulas, for comparison - SollValues: array of TsExpressionResult; + SollValues: array of TsExpressionResult = nil; // Helper for statistics tests const @@ -210,7 +210,7 @@ begin cell := MyWorksheet.FindCell(Row, 1); if HasFormula(cell) then begin actual := MyWorksheet.ReadFormulaAsString(cell); - expected := MyWorksheet.ReadAsUTF8Text(Row, 0); + expected := MyWorksheet.ReadAsText(Row, 0); CheckEquals(expected, actual, 'Test read formula mismatch, cell '+CellNotation(MyWorkSheet,Row,1)); end; end; @@ -451,7 +451,7 @@ begin for Row := 0 to MyWorksheet.GetLastRowIndex do begin - formula := MyWorksheet.ReadAsUTF8Text(Row, 0); + formula := MyWorksheet.ReadAsText(Row, 0); cell := MyWorksheet.FindCell(Row, 1); if (cell = nil) then fail('Error in test code: Failed to get cell ' + CellNotation(MyWorksheet, Row, 1)); @@ -759,7 +759,7 @@ var tempFile: string; //write xls/xml to this file and read back from it actual, expected: TsExpressionResult; cell: PCell; - sollValues: array of TsExpressionResult; + sollValues: array of TsExpressionResult = nil; formula, actualformula: String; begin TempFile := GetTempFileName; diff --git a/components/fpspreadsheet/unit-tests/common/internaltests.pas b/components/fpspreadsheet/unit-tests/common/internaltests.pas index d7713387d..b160d2126 100644 --- a/components/fpspreadsheet/unit-tests/common/internaltests.pas +++ b/components/fpspreadsheet/unit-tests/common/internaltests.pas @@ -15,8 +15,8 @@ Adding tests/test data: uses // Not using lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, - fpstypes, fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, + Classes, SysUtils, fpcunit, testregistry, + fpstypes, {%H-}fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, fpsutils, fpsstreams, fpshtmlutils, testsutility, md5; type @@ -226,7 +226,7 @@ begin MyWorkbook:=TsWorkbook.Create; try MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet); - MyWorkSheet.WriteUTF8Text(0,0,FirstFileCellText); + MyWorkSheet.WriteText(0,0,FirstFileCellText); TempFile:=NewTempFile; MyWorkBook.WriteToFile(TempFile, sfExcel8, false); finally @@ -241,7 +241,7 @@ begin MyWorkbook:=TsWorkbook.Create; try MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet); - MyWorkSheet.WriteUTF8Text(0,0,SecondFileCellText); + MyWorkSheet.WriteText(0,0,SecondFileCellText); MyWorkBook.WriteToFile(TempFile,sfExcel8,true); finally MyWorkbook.Free; @@ -277,7 +277,7 @@ begin +'cell '+CellNotation(MyWorkSheet,Row,Column)); //Check reading as string, convert to date & compare - ActualDTString:=MyWorkSheet.ReadAsUTF8Text(Row,Column); + ActualDTString:=MyWorkSheet.ReadAsText(Row,Column); ActualDT:=StrToDateTimeDef(ActualDTString,EncodeDate(1906,1,1)); CheckEquals(TestDT,ActualDT,'Date/time mismatch using ReadAsUTF8Text'); @@ -293,8 +293,8 @@ const var tempFileName: String; stream: TStream; - writedata: array of Byte; - readdata: array of Byte; + writedata: array of Byte = nil; + readdata: array of Byte = nil; i, n, nread: Integer; begin RandSeed := 0; @@ -380,7 +380,9 @@ const BUFSIZE = 1024; var stream: TBufStream; - readBuf, writeBuf1, writeBuf2: array of byte; + readBuf: array of byte = nil; + writeBuf1: array of byte = nil; + writeBuf2: array of byte = nil; nRead, nWrite1, nWrite2: Integer; i: Integer; begin @@ -430,8 +432,8 @@ begin stream.WriteBuffer(writeBuf2[0], nWrite2); // The stream pointer must be at 100+2000, same for the size - CheckEquals(nWrite1+nWrite2, stream.Position, 'Stream position mismatch (#9)'); - CheckEquals(nWrite1+nWrite2, stream.Size, 'Stream size mismatch (#10)'); + CheckEquals(Int64(nWrite1)+nWrite2, stream.Position, 'Stream position mismatch (#9)'); + CheckEquals(Int64(nWrite1)+nWrite2, stream.Size, 'Stream size mismatch (#10)'); // Read the last 10 bytes and compare Stream.Seek(10, soFromEnd); @@ -549,7 +551,6 @@ end; procedure TSpreadInternalTests.TestCellString_R1C1; var r,c: Cardinal; - s: String; flags: TsRelFlags; res: Boolean; begin @@ -671,7 +672,6 @@ end; procedure TSpreadInternalTests.TestCellRangeString_R1C1; var r1,c1,r2,c2: Cardinal; - s: String; flags: TsRelFlags; res: Boolean; begin @@ -760,18 +760,13 @@ begin end; procedure TSpreadInternalTests.FractionTest(AMaxDigits: Integer); -const - N = 300; var - j: Integer; sollNum, sollDenom: Integer; sollValue: Double; actualNum, actualDenom: Int64; max: Integer; - prec: Double; begin max := Round(IntPower(10, AMaxDigits)); - prec := 0.001/max; for sollDenom := 1 to max-1 do for sollNum := 1 to sollDenom-1 do begin sollValue := StrToFloat(FormatFloat('0.000000000', sollNum/sollDenom)); @@ -811,7 +806,7 @@ type const HtmlRTParams: array[0..3] of THtmlRichTextParam = ( (HTML: 'ABC'; PlainText: 'ABC'; - NumRichTextParams: 0), + NumRichTextParams: 0{%H-}), (HTML: 'ABCabc'; PlainText: 'ABCabc'; NumRichTextParams: 1; RichTextParams: ( @@ -867,7 +862,7 @@ procedure TSpreadInternalTests.RichTextToHtmlTest(ATestIndex: Integer); var book: TsWorkbook; fnt: TsFont; - rtparams: TsRichTextParams; + rtparams: TsRichTextParams = nil; html: String; i: Integer; begin diff --git a/components/fpspreadsheet/unit-tests/common/manualtests.pas b/components/fpspreadsheet/unit-tests/common/manualtests.pas index be0f196f9..ad340d4ed 100644 --- a/components/fpspreadsheet/unit-tests/common/manualtests.pas +++ b/components/fpspreadsheet/unit-tests/common/manualtests.pas @@ -20,8 +20,8 @@ interface uses // Not using lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, testutils, testregistry, testdecorator, fpcunit, - fpsallformats, fpspreadsheet, fpscell, + Classes, SysUtils, testregistry, testdecorator, fpcunit, + {%H-}fpsallformats, fpspreadsheet, {%H-}fpscell, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, testsutility; @@ -75,7 +75,6 @@ uses const COLORSHEETNAME='color_sheet'; //for background color tests RPNSHEETNAME='rpn_formula_sheet'; //for rpn formula tests - FORMULASHEETNAME='formula_sheet'; // for string formula tests NUMBERFORMATSHEETNAME='number format sheet'; // for number format tests OUTPUT_FORMAT = sfExcel8; //change manually if you want to test different formats. To do: automatically output all formats @@ -190,12 +189,12 @@ var palette: TsPalette; begin if OUTPUT_FORMAT <> sfExcel8 then - Ignore('This test only applies to BIFF8 XLS output format.'); + {%H-}Ignore('This test only applies to BIFF8 XLS output format.'); // No worksheets in BIFF2. Since main interest is here in formulas we just jump // off here - need to change this in the future... if OUTPUT_FORMAT = sfExcel2 then - Ignore('BIFF2 does not support worksheets. Ignoring manual tests for now'); + {%H-}Ignore('BIFF2 does not support worksheets. Ignoring manual tests for now'); if Workbook = nil then Workbook := TsWorkbook.Create; @@ -206,16 +205,16 @@ begin palette.AddExcelColors; Worksheet := Workbook.AddWorksheet(COLORSHEETNAME); - WorkSheet.WriteUTF8Text(0, 1, 'TSpreadManualTests.TestBiff8CellBackgroundColor'); + WorkSheet.WriteText(0, 1, 'TSpreadManualTests.TestBiff8CellBackgroundColor'); RowOffset := 1; for i:=0 to palette.Count-1 do begin - cell := WorkSheet.WriteUTF8Text(i+RowOffset,0,'BACKGROUND COLOR TEST'); + cell := WorkSheet.WriteText(i+RowOffset,0,'BACKGROUND COLOR TEST'); Worksheet.WriteBackgroundColor(Cell, palette[i]); Worksheet.WriteFontColor(cell, HighContrastColor(palette[i])); - WorkSheet.WriteUTF8Text(i+RowOffset,1,'Cell to the left should be '+GetColorName(palette[i])+'. Please check.'); + WorkSheet.WriteText(i+RowOffset,1,'Cell to the left should be '+GetColorName(palette[i])+'. Please check.'); end; - Worksheet.WriteColWidth(0, 30); - Worksheet.WriteColWidth(1, 60); + Worksheet.WriteColWidth(0, 30, suChars); + Worksheet.WriteColWidth(1, 60, suChars); finally palette.Free; end; @@ -240,34 +239,30 @@ const ); var Worksheet: TsWorksheet; - Cell : PCell; - i: cardinal; r, c: Cardinal; - palette: TsPalette; - nfs: String; begin if OUTPUT_FORMAT <> sfExcel8 then - Ignore('This test only applies to BIFF8 XLS output format.'); + {%H-}Ignore('This test only applies to BIFF8 XLS output format.'); // No worksheets in BIFF2. Since main interest is here in formulas we just jump // off here - need to change this in the future... if OUTPUT_FORMAT = sfExcel2 then - Ignore('BIFF2 does not support worksheets. Ignoring manual tests for now'); + {%H-}Ignore('BIFF2 does not support worksheets. Ignoring manual tests for now'); if Workbook = nil then Workbook := TsWorkbook.Create; Worksheet := Workbook.AddWorksheet(NUMBERFORMATSHEETNAME); - WorkSheet.WriteUTF8Text(0, 1, 'Number format tests'); + WorkSheet.WriteText(0, 1, 'Number format tests'); for r:=0 to High(FormatStrings) do begin - Worksheet.WriteUTF8Text(r+2, 0, FormatStrings[r]); + Worksheet.WriteText(r+2, 0, FormatStrings[r]); for c:=0 to High(Values) do Worksheet.WriteNumber(r+2, c+1, values[c], nfCustom, FormatStrings[r]); end; - Worksheet.WriteColWidth(0, 20); + Worksheet.WriteColWidth(0, 20, suChars); end; {$IFDEF FPSPREAD_HAS_NEWRPNSUPPORT} diff --git a/components/fpspreadsheet/unit-tests/common/mathtests.pas b/components/fpspreadsheet/unit-tests/common/mathtests.pas index b3bc5dc0e..c30677476 100644 --- a/components/fpspreadsheet/unit-tests/common/mathtests.pas +++ b/components/fpspreadsheet/unit-tests/common/mathtests.pas @@ -16,7 +16,7 @@ uses {$ENDIF} // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, testsutility, + Classes, SysUtils, fpcunit, testregistry, fpstypes, fpspreadsheet, fpsutils; type diff --git a/components/fpspreadsheet/unit-tests/common/numformatparsertests.pas b/components/fpspreadsheet/unit-tests/common/numformatparsertests.pas index 3162e5174..faa9a683c 100644 --- a/components/fpspreadsheet/unit-tests/common/numformatparsertests.pas +++ b/components/fpspreadsheet/unit-tests/common/numformatparsertests.pas @@ -8,9 +8,7 @@ uses // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path Classes, SysUtils, fpcunit, testregistry, - fpstypes, fpspreadsheet, fpsnumformat - {and a project requirement for lclbase for utf8 handling}, - testsutility; + fpstypes, fpspreadsheet, fpsnumformat; type TParserTestData = record @@ -384,7 +382,6 @@ end; procedure TSpreadNumFormatParserTests.TestRounding; var i: Integer; - parser: TsNumFormatParser; MyWorkbook: TsWorkbook; MyWorksheet: TsWorksheet; actual: String; diff --git a/components/fpspreadsheet/unit-tests/common/pagelayouttests.pas b/components/fpspreadsheet/unit-tests/common/pagelayouttests.pas index 0958db103..85324a610 100644 --- a/components/fpspreadsheet/unit-tests/common/pagelayouttests.pas +++ b/components/fpspreadsheet/unit-tests/common/pagelayouttests.pas @@ -12,8 +12,7 @@ uses // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path Classes, SysUtils, fpcunit, testregistry, - fpstypes, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, - testsutility; + fpstypes, fpspreadsheet, xlsbiff8; type { TSpreadWriteReadHyperlinkTests } @@ -469,8 +468,6 @@ var MyWorkbook: TsWorkbook; row, col, p: Integer; sollPageLayout, actualPageLayout: TsPageLayout; - expected, actual: String; - cell: PCell; TempFile: string; //write xls/xml to this file and read back from it begin TempFile := GetTempFileName; @@ -564,7 +561,7 @@ var MyWorksheet: TsWorksheet; MyWorkbook: TsWorkbook; row, col, p: Integer; - sollPageLayout: Array of TsPageLayout; + sollPageLayout: Array of TsPageLayout = nil; actualPageLayout: TsPageLayout; TempFile: string; //write xls/xml to this file and read back from it @@ -876,10 +873,8 @@ procedure TSpreadWriteReadPageLayoutTests.TestWriteRead_RepeatedColRows( AFormat: TsSpreadsheetFormat; AFirstCol, ALastCol, AFirstRow, ALastRow: Integer); var tempFile: String; - i, j: Integer; MyWorkbook: TsWorkbook; MyWorksheet: TsWorksheet; - rng: TsCellRange; sheetname: String; r, c: Cardinal; begin diff --git a/components/fpspreadsheet/unit-tests/common/protectiontests.pas b/components/fpspreadsheet/unit-tests/common/protectiontests.pas index 33bd35f51..6fa609347 100644 --- a/components/fpspreadsheet/unit-tests/common/protectiontests.pas +++ b/components/fpspreadsheet/unit-tests/common/protectiontests.pas @@ -12,8 +12,7 @@ uses // Not using Lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path Classes, SysUtils, fpcunit, testregistry, - fpstypes, fpspreadsheet, //xlsbiff2, xlsbiff5, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, - testsutility; + fpstypes, fpspreadsheet; type { TSpreadWriteReadProtectionTests } @@ -201,19 +200,12 @@ end; procedure TSpreadWriteReadProtectionTests.TestWriteRead_WorksheetProtection( AFormat: TsSpreadsheetFormat; ACondition: Integer); -const - ALL_SHEET_PROTECTIONS = [ - spFormatCells, spFormatColumns, spFormatRows, - spDeleteColumns, spDeleteRows, spInsertColumns, spInsertRows, - spInsertHyperlinks, spSort, spObjects, - spSelectLockedCells, spSelectUnlockedCells - ]; // NOTE: spCells is handled separately var MyWorkbook: TsWorkbook; MyWorksheet: TsWorksheet; TempFile: string; //write xls/xml to this file and read back from it expected, actual: TsWorksheetProtections; - msg: String; + msg: String = ''; begin TempFile := GetTempFileName; @@ -302,7 +294,7 @@ var MyWorksheet: TsWorksheet; cell: PCell; TempFile: string; //write xls/xml to this file and read back from it - expected, actual: TsCellProtections; + actual: TsCellProtections; msg: String; begin TempFile := GetTempFileName; @@ -375,10 +367,8 @@ procedure TSpreadWriteReadProtectionTests.TestWriteRead_Passwords( var MyWorkbook: TsWorkbook; MyWorksheet: TsWorksheet; - cell: PCell; TempFile: string; //write xls/xml to this file and read back from it bi, si, cinfo: TsCryptoInfo; - msg: String; begin TempFile := GetTempFileName; diff --git a/components/fpspreadsheet/unit-tests/common/rpnformulaunit.pas b/components/fpspreadsheet/unit-tests/common/rpnformulaunit.pas index b44b48e4f..51549a574 100644 --- a/components/fpspreadsheet/unit-tests/common/rpnformulaunit.pas +++ b/components/fpspreadsheet/unit-tests/common/rpnformulaunit.pas @@ -34,7 +34,6 @@ const var Row: Integer; value: Double; - r,c: Cardinal; celladdr: String; fs: TFormatSettings; ls: char; @@ -50,7 +49,7 @@ begin a bit inconvenient here: '=SUM(A1, B1)' becomes Format('=SUM(A1%s B1)', [ls]) } - Worksheet.WriteUTF8Text(0, 0, SBaseCells); + Worksheet.WriteText(0, 0, SBaseCells); Worksheet.WriteFont(0, 0, BOLD_FONTINDEX); Worksheet.WriteNumber(0,1, cellB1); @@ -61,21 +60,21 @@ begin Worksheet.WriteNumber(0,6, cellG1); Row := 2; - Worksheet.WriteUTF8Text(Row, 1, 'read value'); + Worksheet.WriteText(Row, 1, 'read value'); Worksheet.WriteFont(Row, 1, BOLD_FONTINDEX); - Worksheet.WriteUTF8Text(Row, 2, 'expected value'); + Worksheet.WriteText(Row, 2, 'expected value'); Worksheet.WriteFont(Row, 2, BOLD_FONTINDEX); { ---------- } inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Constants'); + Worksheet.WriteText(Row, 0, 'Constants'); Worksheet.WriteFont(Row, 0, BOLD_FONTINDEX); // Numbers inc(Row); value := 1.2; - Worksheet.WriteUTF8Text(Row, 0, '='+Format('%.1f', [value], fs)); + Worksheet.WriteText(Row, 0, '='+Format('%.1f', [value], fs)); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, nil)) @@ -84,31 +83,31 @@ begin // Strings inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('="%s"', [SHelloWorld])); + Worksheet.WriteText(Row, 0, Format('="%s"', [SHelloWorld])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNString(SHelloWorld, nil))); - Worksheet.WriteUTF8Text(Row, 2, SHelloWorld); + Worksheet.WriteText(Row, 2, SHelloWorld); // Boolean inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=TRUE'); + Worksheet.WriteText(Row, 0, '=TRUE'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNBool(true, nil))); - Worksheet.WriteUTF8Text(Row, 2, 'TRUE'); + Worksheet.WriteText(Row, 2, 'TRUE'); { ---------- } inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Cell references - please check formula in editing line'); + Worksheet.WriteText(Row, 0, 'Cell references - please check formula in editing line'); Worksheet.WriteFont(Row, 0, BOLD_FONTINDEX); // Absolute col and row references inc(Row); cellAddr := '$B$1'; - Worksheet.WriteUTF8Text(Row, 0, '='+cellAddr); + Worksheet.WriteText(Row, 0, '='+cellAddr); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue(cellAddr, nil @@ -118,7 +117,7 @@ begin // Relative col and row references inc(Row); cellAddr := 'B1'; - Worksheet.WriteUTF8Text(Row, 0, '='+cellAddr); + Worksheet.WriteText(Row, 0, '='+cellAddr); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue(cellAddr, nil @@ -128,7 +127,7 @@ begin // Relative row reference inc(Row); cellAddr := '$B1'; - Worksheet.WriteUTF8Text(Row, 0, '='+cellAddr); + Worksheet.WriteText(Row, 0, '='+cellAddr); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('$B1', nil @@ -138,7 +137,7 @@ begin // Relative col reference inc(Row); cellAddr := 'B$1'; - Worksheet.WriteUTF8Text(Row, 0, '='+cellAddr); + Worksheet.WriteText(Row, 0, '='+cellAddr); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B$1', nil @@ -148,7 +147,7 @@ begin // Relative block reference inc(Row); cellAddr := 'A1:G2'; - Worksheet.WriteUTF8Text(Row, 0, Format('=COUNT(%s)', [cellAddr])); + Worksheet.WriteText(Row, 0, Format('=COUNT(%s)', [cellAddr])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRange(cellAddr, RPNFunc('COUNT', 1, // 1 parameter used in COUNT @@ -159,7 +158,7 @@ begin // Relative block cols reference inc(Row); cellAddr := 'A$1:G$2'; - Worksheet.WriteUTF8Text(Row, 0, Format('=COUNT(%s)', [cellAddr])); + Worksheet.WriteText(Row, 0, Format('=COUNT(%s)', [cellAddr])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRange(cellAddr, RPNFunc('COUNT', 1, @@ -170,7 +169,7 @@ begin // Relative block rows reference inc(Row); cellAddr := '$A1:$G2'; - Worksheet.WriteUTF8Text(Row, 0, Format('=COUNT(%s)', [cellAddr])); + Worksheet.WriteText(Row, 0, Format('=COUNT(%s)', [cellAddr])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRange(cellAddr, RPNFunc('COUNT', 1, @@ -182,12 +181,12 @@ begin inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Basic operations'); + Worksheet.WriteText(Row, 0, 'Basic operations'); Worksheet.WriteFont(Row, 0, BOLD_FONTINDEX); // Add two cells inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=B1+C1'); + Worksheet.WriteText(Row, 0, '=B1+C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNCellValue('C1', @@ -198,7 +197,7 @@ begin // Add three cells inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=B1+C1+$D$1'); + Worksheet.WriteText(Row, 0, '=B1+C1+$D$1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNCellValue('C1', @@ -211,7 +210,7 @@ begin // Subtract two cells inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=B1-C1'); + Worksheet.WriteText(Row, 0, '=B1-C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNCellValue('C1', @@ -222,7 +221,7 @@ begin // Multiply two (absolute) cells = $C$1*$D$1 inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=$C$1*$D$1'); + Worksheet.WriteText(Row, 0, '=$C$1*$D$1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('$C$1', RPNCellValue('$D$1', @@ -233,7 +232,7 @@ begin // Divide two (relative) cells = C1/D1 inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1/D1'); + Worksheet.WriteText(Row, 0, '=C1/D1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('D1', @@ -244,7 +243,7 @@ begin // Power of two cells = C1^D1 inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1^D1'); + Worksheet.WriteText(Row, 0, '=C1^D1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('D1', @@ -255,7 +254,7 @@ begin // Unary plus =+C1 inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=+C1'); + Worksheet.WriteText(Row, 0, '=+C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNFunc(fekUPlus, @@ -265,7 +264,7 @@ begin // Unary minus =-$C$1 inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=-$C$1'); + Worksheet.WriteText(Row, 0, '=-$C$1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('$C$1', RPNFunc(fekUMinus, @@ -275,7 +274,7 @@ begin // Percent inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=B1*$C$1%'); + Worksheet.WriteText(Row, 0, '=B1*$C$1%'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNCellValue('$C$1', @@ -283,237 +282,237 @@ begin RPNFunc(fekMul, nil )))))); - Worksheet.WriteUTF8Text(Row, 2, FloatToStr(cellB1*cellC1/100)); + Worksheet.WriteText(Row, 2, FloatToStr(cellB1*cellC1/100)); // String concatenation inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '="Hello "&"world"'); + Worksheet.WriteText(Row, 0, '="Hello "&"world"'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNString('Hello ', RPNString('world', RPNFunc(fekConcat, nil ))))); - Worksheet.WriteUTF8Text(Row, 2, 'Hello ' + 'world'); + Worksheet.WriteText(Row, 2, 'Hello ' + 'world'); // Less Than - case a inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1D1'); + Worksheet.WriteText(Row, 0, '=C1>D1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('D1', RPNFunc(fekGreater, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1>cellD1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1>cellD1]); // Greater Than - case b inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=D1>C1'); + Worksheet.WriteText(Row, 0, '=D1>C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('D1', RPNCellValue('C1', RPNFunc(fekGreater, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellD1>cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellD1>cellC1]); // Greater Than - case c inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1>C1'); + Worksheet.WriteText(Row, 0, '=C1>C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('C1', RPNFunc(fekGreater, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1>cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1>cellC1]); // Greater Than or Equal - case a inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1>=D1'); + Worksheet.WriteText(Row, 0, '=C1>=D1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('D1', RPNFunc(fekGreaterEqual, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1>=cellD1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1>=cellD1]); // Greater Than or Equal - case b inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=D1>=C1'); + Worksheet.WriteText(Row, 0, '=D1>=C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('D1', RPNCellValue('C1', RPNFunc(fekGreaterEqual, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellD1>=cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellD1>=cellC1]); // Greater Than or Equal - case c inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1>=C1'); + Worksheet.WriteText(Row, 0, '=C1>=C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('C1', RPNFunc(fekGreaterEqual, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1>=cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1>=cellC1]); // Equal - case a inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1=D1'); + Worksheet.WriteText(Row, 0, '=C1=D1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('D1', RPNFunc(fekEqual, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1=cellD1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1=cellD1]); // Equal - case b inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=D1=C1'); + Worksheet.WriteText(Row, 0, '=D1=C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('D1', RPNCellValue('C1', RPNFunc(fekEQUAL, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellD1=cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellD1=cellC1]); // Equal - case c inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1=C1'); + Worksheet.WriteText(Row, 0, '=C1=C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('C1', RPNFunc(fekEQUAL, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1=cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1=cellC1]); // Not equal - case a inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1<>D1'); + Worksheet.WriteText(Row, 0, '=C1<>D1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('D1', RPNFunc(fekNotEQUAL, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1<>cellD1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1<>cellD1]); // Not equal - case b inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=D1<>C1'); + Worksheet.WriteText(Row, 0, '=D1<>C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('D1', RPNCellValue('C1', RPNFunc(fekNotEQUAL, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellD1<>cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellD1<>cellC1]); // Not equal - case c inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=C1<>C1'); + Worksheet.WriteText(Row, 0, '=C1<>C1'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('C1', RPNFunc(fekNotEQUAL, nil))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[cellC1<>cellC1]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[cellC1<>cellC1]); { ---------- } inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Logical functions'); + Worksheet.WriteText(Row, 0, 'Logical functions'); Worksheet.WriteFont(Row, 0, BOLD_FONTINDEX); // TRUE() inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=TRUE()'); + Worksheet.WriteText(Row, 0, '=TRUE()'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('TRUE', nil))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[true]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[true]); // FALSE() inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=FALSE()'); + Worksheet.WriteText(Row, 0, '=FALSE()'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('FALSE', nil))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[false]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[false]); // Logical NOT inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=NOT(C1=C1)'); + Worksheet.WriteText(Row, 0, '=NOT(C1=C1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('C1', RPNCellValue('C1', RPNFunc(fekEqual, RPNFunc('NOT', nil)))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[not (cellC1=cellC1)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[not (cellC1=cellC1)]); // Logical AND - case false/false =AND(1=0, 1=2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=AND(1=0%s 1=2)',[ls])); + Worksheet.WriteText(Row, 0, Format('=AND(1=0%s 1=2)',[ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(1, RPNNumber(0, @@ -523,11 +522,11 @@ begin RPNFunc(fekEQUAL, RPNFunc('AND', 2, nil))))))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[(1=0) and (1=2)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[(1=0) and (1=2)]); // Logical AND - case false/true =AND(1=0, 2=2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=AND(1=0%s 2=2)', [ls])); + Worksheet.WriteText(Row, 0, Format('=AND(1=0%s 2=2)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(1, RPNNumber(0, @@ -537,11 +536,11 @@ begin RPNFunc(fekEQUAL, RPNFunc('AND', 2, nil))))))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[(1=0) and (2=2)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[(1=0) and (2=2)]); // Logical AND - case true/true =AND(1=1, 2=2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=AND(1=1%s 2=2)', [ls])); + Worksheet.WriteText(Row, 0, Format('=AND(1=1%s 2=2)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(1, RPNNumber(1, @@ -551,11 +550,11 @@ begin RPNFunc(fekEQUAL, RPNFunc('AND', 2, nil))))))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[(1=1) and (2=2)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[(1=1) and (2=2)]); // Logical OR - case false/false =OR(1=0, 1=2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=OR(1=0%s 1=2)',[ls])); + Worksheet.WriteText(Row, 0, Format('=OR(1=0%s 1=2)',[ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(1, RPNNumber(0, @@ -565,11 +564,11 @@ begin RPNFunc(fekEQUAL, RPNFunc('OR', 2, nil))))))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[(1=0) or (1=2)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[(1=0) or (1=2)]); // Logical OR - case false/true =OR(1=0, 2=2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=OR(1=0%s 2=2)', [ls])); + Worksheet.WriteText(Row, 0, Format('=OR(1=0%s 2=2)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(1, RPNNumber(0, @@ -579,11 +578,11 @@ begin RPNFunc(fekEQUAL, RPNFunc('OR', 2, nil))))))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[(1=0) or (2=2)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[(1=0) or (2=2)]); // Logical OR - case true/true =OR(1=1, 2=2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=OR(1=1%s 2=2)', [ls])); + Worksheet.WriteText(Row, 0, Format('=OR(1=1%s 2=2)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(1, RPNNumber(1, @@ -593,11 +592,11 @@ begin RPNFunc(fekEQUAL, RPNFunc('OR', 2, nil))))))))); - Worksheet.WriteUTF8Text(Row, 2, FALSE_TRUE[(1=1) or (2=2)]); + Worksheet.WriteText(Row, 2, FALSE_TRUE[(1=1) or (2=2)]); // IF - case true =IF(B1=1, "correct", "wrong") inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=IF(B1=1%s "correct"%s "wrong")', [ls, ls])); + Worksheet.WriteText(Row, 0, Format('=IF(B1=1%s "correct"%s "wrong")', [ls, ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNNumber(1, @@ -606,11 +605,11 @@ begin RPNString('wrong', RPNFunc('IF', 3, nil)))))))); - Worksheet.WriteUTF8Text(Row, 2, IfThen(cellB1=1.0, 'correct', 'wrong')); + Worksheet.WriteText(Row, 2, IfThen(cellB1=1.0, 'correct', 'wrong')); // IF - case false =IF(B1<>1, "correct", "wrong") inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=IF(B1<>1%s "correct"%s "wrong")', [ls, ls])); + Worksheet.WriteText(Row, 0, Format('=IF(B1<>1%s "correct"%s "wrong")', [ls, ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNNumber(1, @@ -619,11 +618,11 @@ begin RPNString('wrong', RPNFunc('IF', 3, nil)))))))); - Worksheet.WriteUTF8Text(Row, 2, IfThen(cellB1<>1.0, 'correct', 'wrong')); + Worksheet.WriteText(Row, 2, IfThen(cellB1<>1.0, 'correct', 'wrong')); // IF - case true (2 params) =IF(B1=1, "correct") inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=IF(B1=1%s "correct")', [ls])); + Worksheet.WriteText(Row, 0, Format('=IF(B1=1%s "correct")', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNNumber(1, @@ -631,11 +630,11 @@ begin RPNString('correct', RPNFunc('IF', 2, nil))))))); - Worksheet.WriteUTF8Text(Row, 2, IfThen(cellB1=1.0, 'correct', 'FALSE')); + Worksheet.WriteText(Row, 2, IfThen(cellB1=1.0, 'correct', 'FALSE')); // IF - case false (2 params) =IF(B1<>1, "correct") inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=IF(B1<>1%s "correct")', [ls])); + Worksheet.WriteText(Row, 0, Format('=IF(B1<>1%s "correct")', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B1', RPNNumber(1, @@ -643,18 +642,18 @@ begin RPNString('correct', RPNFunc('IF', 2, nil))))))); - Worksheet.WriteUTF8Text(Row, 2, IfThen(cellB1<>1.0, 'correct', 'FALSE')); + Worksheet.WriteText(Row, 2, IfThen(cellB1<>1.0, 'correct', 'FALSE')); { ---------- } inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Math functions'); + Worksheet.WriteText(Row, 0, 'Math functions'); Worksheet.WriteFont(Row, 0, BOLD_FONTINDEX); // absolute of positive number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ABS($B1)'); + Worksheet.WriteText(Row, 0, '=ABS($B1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('$B1', RPNFunc('ABS', @@ -663,7 +662,7 @@ begin // absolute of negative number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ABS(E$1)'); + Worksheet.WriteText(Row, 0, '=ABS(E$1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('E$1', RPNFunc('ABS', @@ -672,7 +671,7 @@ begin // sign of positive number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=SIGN(F1)'); + Worksheet.WriteText(Row, 0, '=SIGN(F1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('F1', RPNFunc('SIGN', @@ -681,7 +680,7 @@ begin // sign of zero inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=SIGN(0)'); + Worksheet.WriteText(Row, 0, '=SIGN(0)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(0, RPNFunc('SIGN', @@ -690,7 +689,7 @@ begin // sign of negative number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=SIGN(G1)'); + Worksheet.WriteText(Row, 0, '=SIGN(G1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G1', RPNFunc('SIGN', @@ -699,15 +698,15 @@ begin // Random number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=RAND()'); + Worksheet.WriteText(Row, 0, '=RAND()'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('RAND', nil))); - Worksheet.WriteUTF8Text(Row, 2, '(random number - cannot compare)'); + Worksheet.WriteText(Row, 2, '(random number - cannot compare)'); // pi inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=PI()'); + Worksheet.WriteText(Row, 0, '=PI()'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('PI', nil))); @@ -717,7 +716,7 @@ begin // Degrees inc(Row); value := pi/2; - Worksheet.WriteUTF8Text(Row, 0, '=DEGREES(PI()/2)'); + Worksheet.WriteText(Row, 0, '=DEGREES(PI()/2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('PI', RPNNumber(2, @@ -729,7 +728,7 @@ begin // Radians inc(Row); value := 90; - Worksheet.WriteUTF8Text(Row, 0, '=RADIANS(90)'); + Worksheet.WriteText(Row, 0, '=RADIANS(90)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('RADIANS', @@ -739,7 +738,7 @@ begin // sin(pi/2) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=SIN(PI()/2)'); + Worksheet.WriteText(Row, 0, '=SIN(PI()/2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('PI', RPNNumber(2, @@ -751,7 +750,7 @@ begin // arcsin(0.5) =ASIN(0.5) inc(Row); value := 0.5; - Worksheet.WriteUTF8Text(Row, 0, Format('=ASIN(%.1f)', [value], fs)); + Worksheet.WriteText(Row, 0, Format('=ASIN(%.1f)', [value], fs)); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('ASIN', @@ -760,7 +759,7 @@ begin // cos(pi) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=COS(PI())'); + Worksheet.WriteText(Row, 0, '=COS(PI())'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('PI', RPNFunc('COS', @@ -770,7 +769,7 @@ begin // arccos(0.5) =ACOS(0.5) inc(Row); value := 0.5; - Worksheet.WriteUTF8Text(Row, 0, Format('=ACOS(%.1f)', [value], fs)); + Worksheet.WriteText(Row, 0, Format('=ACOS(%.1f)', [value], fs)); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('ACOS', @@ -779,7 +778,7 @@ begin // tan(pi/4) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=TAN(PI()/4)'); + Worksheet.WriteText(Row, 0, '=TAN(PI()/4)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNFunc('PI', RPNNumber(4, @@ -791,7 +790,7 @@ begin // arctan(1) inc(Row); value := 1.0; - Worksheet.WriteUTF8Text(Row, 0, '=ATAN(1)'); + Worksheet.WriteText(Row, 0, '=ATAN(1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('ATAN', @@ -804,7 +803,7 @@ begin // sinh inc(Row); value := 3; - Worksheet.WriteUTF8Text(Row, 0, '=SINH(3)'); + Worksheet.WriteText(Row, 0, '=SINH(3)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('SINH', @@ -814,7 +813,7 @@ begin // arcsinh =ASIN(0.5) inc(Row); value := 0.5; - Worksheet.WriteUTF8Text(Row, 0, Format('=ASINH(%.1f)', [value], fs)); + Worksheet.WriteText(Row, 0, Format('=ASINH(%.1f)', [value], fs)); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('ASINH', @@ -824,7 +823,7 @@ begin // cosh inc(Row); value := 3; - Worksheet.WriteUTF8Text(Row, 0, '=COSH(3)'); + Worksheet.WriteText(Row, 0, '=COSH(3)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('COSH', @@ -834,7 +833,7 @@ begin // arccosh inc(Row); value := 10; - Worksheet.WriteUTF8Text(Row, 0, '=ACOSH(10)'); + Worksheet.WriteText(Row, 0, '=ACOSH(10)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('ACOSH', @@ -844,7 +843,7 @@ begin // tanh inc(Row); value := 3; - Worksheet.WriteUTF8Text(Row, 0, '=TANH(3)'); + Worksheet.WriteText(Row, 0, '=TANH(3)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('TANH', @@ -854,7 +853,7 @@ begin // arctanh =ATANH(0.5) inc(Row); value := 0.5; - Worksheet.WriteUTF8Text(Row, 0, Format('=ATANH(%.1f)', [value], fs)); + Worksheet.WriteText(Row, 0, Format('=ATANH(%.1f)', [value], fs)); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('ATANH', @@ -865,7 +864,7 @@ begin // sqrt(2.0); inc(Row); value := 2.0; - Worksheet.WriteUTF8Text(Row, 0, '=SQRT(2)'); + Worksheet.WriteText(Row, 0, '=SQRT(2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('SQRT', @@ -875,7 +874,7 @@ begin // exp(2) inc(Row); value := 2.0; - Worksheet.WriteUTF8Text(Row, 0, '=EXP(2)'); + Worksheet.WriteText(Row, 0, '=EXP(2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('EXP', @@ -885,7 +884,7 @@ begin // ln(2) inc(Row); value := 2.0; - Worksheet.WriteUTF8Text(Row, 0, '=LN(2)'); + Worksheet.WriteText(Row, 0, '=LN(2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('LN', @@ -895,7 +894,7 @@ begin // log to any basis =LOG(256, 2) inc(Row); value := 256; - Worksheet.WriteUTF8Text(Row, 0, Format('=LOG(256%s 2)', [ls])); + Worksheet.WriteText(Row, 0, Format('=LOG(256%s 2)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNNumber(2, @@ -906,7 +905,7 @@ begin // log10(100) inc(Row); value := 100; - Worksheet.WriteUTF8Text(Row, 0, '=LOG10(100)'); + Worksheet.WriteText(Row, 0, '=LOG10(100)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('LOG10', @@ -916,7 +915,7 @@ begin // log10(0.01) inc(Row); value := 0.01; - Worksheet.WriteUTF8Text(Row, 0, Format('=LOG10(%.2f)', [value], fs)); + Worksheet.WriteText(Row, 0, Format('=LOG10(%.2f)', [value], fs)); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNNumber(value, RPNFunc('LOG10', @@ -927,12 +926,12 @@ begin inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Rounding'); + Worksheet.WriteText(Row, 0, 'Rounding'); Worksheet.WriteFont(Row, 0, BOLD_FONTINDEX); // Round positive number to 1 decimal =ROUND($F$1, 1) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=ROUND($F$1%s 1)', [ls])); + Worksheet.WriteText(Row, 0, Format('=ROUND($F$1%s 1)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('$F$1', RPNNumber(1, @@ -942,7 +941,7 @@ begin // Round negative number to 1 decimal =ROUND(G1, 1) inc(Row); - Worksheet.WriteUTF8Text(Row, 0, Format('=ROUND(G1%s 1)', [ls])); + Worksheet.WriteText(Row, 0, Format('=ROUND(G1%s 1)', [ls])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G1', RPNNumber(1, @@ -952,7 +951,7 @@ begin // integer part of positive number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=INT(F1)'); + Worksheet.WriteText(Row, 0, '=INT(F1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('F1', RPNFunc('INT', @@ -961,7 +960,7 @@ begin // integer part of negative number inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=INT(G1)'); + Worksheet.WriteText(Row, 0, '=INT(G1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G1', RPNFunc('INT', @@ -972,13 +971,13 @@ begin inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Lookup/reference functions'); + Worksheet.WriteText(Row, 0, 'Lookup/reference functions'); Worksheet.WriteUsedFormatting(Row, 0, [uffBold]); // Column of cell inc(Row); cellAddr := 'AB100'; - Worksheet.WriteUTF8Text(Row, 0, Format('=COLUMN(%s)',[cellAddr])); + Worksheet.WriteText(Row, 0, Format('=COLUMN(%s)',[cellAddr])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRef(cellAddr, // note: CellRef instead of CellValue! RPNFunc(fekCOLUMN, 1, @@ -988,7 +987,7 @@ begin // Column count of cell block inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=COLUMNS(A1:C5)'); + Worksheet.WriteText(Row, 0, '=COLUMNS(A1:C5)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRange('A1:C5', RPNFunc(fekCOLUMNS, @@ -1000,7 +999,7 @@ begin // Row of cell inc(Row); cellAddr := 'AB100'; - Worksheet.WriteUTF8Text(Row, 0, Format('=ROW(%s)', [cellAddr])); + Worksheet.WriteText(Row, 0, Format('=ROW(%s)', [cellAddr])); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRef(cellAddr, // note: CellRef instead of CellValue! RPNFunc(fekROW, 1, @@ -1009,7 +1008,7 @@ begin Worksheet.WriteNumber(Row, 2, r+1); // +1 because Excel index is 1-based inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ROWS(A1:C5)'); + Worksheet.WriteText(Row, 0, '=ROWS(A1:C5)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellRange('A1:C5', RPNFunc(fekROWS, @@ -1021,7 +1020,7 @@ begin inc(Row); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, 'Info functions'); + Worksheet.WriteText(Row, 0, 'Info functions'); Worksheet.WriteUsedFormatting(Row, 0, [uffBold]); // Note: looks as if some of these functions are not updated when loading. @@ -1029,7 +1028,7 @@ begin // Cell is blank inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISBLANK(G1)'); + Worksheet.WriteText(Row, 0, '=ISBLANK(G1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G1', RPNFunc(fekIsBLANK, @@ -1037,50 +1036,50 @@ begin Worksheet.WriteUTF8Text(Row, 2, 'FALSE'); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISBLANK(G2)'); + Worksheet.WriteText(Row, 0, '=ISBLANK(G2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G2', RPNFunc(fekIsBLANK, nil)))); - Worksheet.WriteUTF8Text(Row, 2, 'TRUE'); + Worksheet.WriteText(Row, 2, 'TRUE'); // Cell is in error inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISERR(G1)'); + Worksheet.WriteText(Row, 0, '=ISERR(G1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G1', RPNFunc(fekIsERR, nil)))); - Worksheet.WriteUTF8Text(Row, 2, 'FALSE'); + Worksheet.WriteText(Row, 2, 'FALSE'); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISERR(G2)'); + Worksheet.WriteText(Row, 0, '=ISERR(G2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G2', RPNFunc(fekIsERR, nil)))); - Worksheet.WriteUTF8Text(Row, 2, 'FALSE'); + Worksheet.WriteText(Row, 2, 'FALSE'); // Cell is in error inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISERROR(G1)'); + Worksheet.WriteText(Row, 0, '=ISERROR(G1)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G1', RPNFunc(fekIsERROR, nil)))); - Worksheet.WriteUTF8Text(Row, 2, 'FALSE'); + Worksheet.WriteText(Row, 2, 'FALSE'); inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISERROR(G2)'); + Worksheet.WriteText(Row, 0, '=ISERROR(G2)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('G2', RPNFunc(fekIsERROR, nil)))); - Worksheet.WriteUTF8Text(Row, 2, 'FALSE'); + Worksheet.WriteText(Row, 2, 'FALSE'); // Cell is logical inc(Row); - Worksheet.WriteUTF8Text(Row, 0, '=ISLOGICAL(B30)'); + Worksheet.WriteText(Row, 0, '=ISLOGICAL(B30)'); Worksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellValue('B30', RPNFunc(fekIsLOGICAL, diff --git a/components/fpspreadsheet/unit-tests/common/singleformulatests.pas b/components/fpspreadsheet/unit-tests/common/singleformulatests.pas index 39e888216..d5ddb0f03 100644 --- a/components/fpspreadsheet/unit-tests/common/singleformulatests.pas +++ b/components/fpspreadsheet/unit-tests/common/singleformulatests.pas @@ -9,8 +9,7 @@ uses // Instead, add .. to unit search path Classes, SysUtils, fpcunit, testregistry, fpstypes, fpspreadsheet, fpsexprparser, - xlsbiff8 {and a project requirement for lclbase for utf8 handling}, - testsutility; + xlsbiff8; type TFormulaTestKind = (ftkConstants, ftkCellConstant, ftkCells, ftkCellRange, diff --git a/components/fpspreadsheet/unit-tests/common/sortingtests.pas b/components/fpspreadsheet/unit-tests/common/sortingtests.pas index f53af4e61..3b9b4b9ef 100644 --- a/components/fpspreadsheet/unit-tests/common/sortingtests.pas +++ b/components/fpspreadsheet/unit-tests/common/sortingtests.pas @@ -183,7 +183,7 @@ begin // in cell defined by CommentIsSortedToXXXIndex (XXX = Number/String) if AFormat <> sfExcel8 then // Comments not implemented for writing Excel8 - MyWorksheet.WriteComment(0, 0, 'Test comment'); + {%H-}MyWorksheet.WriteComment(0, 0, 'Test comment'); MyWorksheet.WriteHyperlink(0, 0, 'http://www.google.com'); MyWorkBook.WriteToFile(TempFile, AFormat, true); @@ -196,7 +196,7 @@ begin // Read spreadsheet file... MyWorkbook.ReadFromFile(TempFile, AFormat); if AFormat = sfExcel2 then - MyWorksheet := MyWorkbook.GetFirstWorksheet + {%H-}MyWorksheet := MyWorkbook.GetFirstWorksheet else MyWorksheet := GetWorksheetByName(MyWorkBook, SortingTestSheet); if MyWorksheet = nil then @@ -244,7 +244,7 @@ begin CheckEquals(expectednumber, actualnumber, 'Sorted cell number mismatch, cell '+CellNotation(MyWorksheet, row, col)); if AFormat <> sfExcel8 then // Comments are not written for sfExcel8 --> ignore - CheckEquals( + {%H-}CheckEquals( i=CommentIsSortedToNumberIndex, MyWorksheet.HasComment(cell), 'Sorted comment position mismatch, cell '+CellNotation(MyWorksheet, row, col)); @@ -260,7 +260,7 @@ begin CheckEquals(expectedstring, actualstring, 'Sorted cell string mismatch, cell '+CellNotation(MyWorksheet, row, col)); if AFormat <> sfExcel8 then // Comments are not written for sfExcel8 --> ignore - CheckEquals( + {%H-}CheckEquals( i=CommentIsSortedToStringIndex, MyWorksheet.HasComment(cell), 'Sorted comment position mismatch, cell '+CellNotation(MyWorksheet, row, col)); @@ -353,7 +353,7 @@ begin // Read spreadsheet file... MyWorkbook.ReadFromFile(TempFile, AFormat); if AFormat = sfExcel2 then - MyWorksheet := MyWorkbook.GetFirstWorksheet + {%H-}MyWorksheet := MyWorkbook.GetFirstWorksheet else MyWorksheet := GetWorksheetByName(MyWorkBook, SortingTestSheet); if MyWorksheet = nil then diff --git a/components/fpspreadsheet/unit-tests/common/spreadtestgui.lpi b/components/fpspreadsheet/unit-tests/common/spreadtestgui.lpi index 4f93414eb..0934346dd 100644 --- a/components/fpspreadsheet/unit-tests/common/spreadtestgui.lpi +++ b/components/fpspreadsheet/unit-tests/common/spreadtestgui.lpi @@ -218,8 +218,8 @@ - - + + diff --git a/components/fpspreadsheet/unit-tests/common/ssttests.pas b/components/fpspreadsheet/unit-tests/common/ssttests.pas index 134d31f06..06c61b66f 100644 --- a/components/fpspreadsheet/unit-tests/common/ssttests.pas +++ b/components/fpspreadsheet/unit-tests/common/ssttests.pas @@ -89,7 +89,7 @@ type implementation uses - Math, LazUTF8; + LazUTF8; const SST_Sheet = 'SST'; @@ -124,18 +124,18 @@ var currentText: string; currentRtParams: TsRichTextParams; currentFont: TsFont; - expectedText: array of string; - expectedRtParams: array of TsRichTextParams; + expectedText: array of string = nil; + expectedRtParams: array of TsRichTextParams = nil; expectedFont: Array[0..1] of TsFont; expectedFontIndex: Array[0..1] of Integer; i, j: Integer; col, row: Cardinal; - fnt: TsFont; function CreateString(ALen: Integer): String; var i: Integer; begin + Result := ''; SetLength(Result, ALen); for i:=1 to ALen do Result[i] := char((i-1) mod 26 + ord('A')); @@ -145,6 +145,7 @@ var var i: Integer; begin + Result := nil; SetLength(Result, AStrLen div 2); for i := 0 to High(Result) do begin Result[i].FirstIndex := i*2 + 1; @@ -159,8 +160,6 @@ begin MyWorkbook := TsWorkbook.Create; try - fnt := MyWorkbook.GetDefaultFont; - expectedFontIndex[0] := 1; expectedFontIndex[1] := 2; for j:=0 to 1 do diff --git a/components/fpspreadsheet/unit-tests/common/stringtests.pas b/components/fpspreadsheet/unit-tests/common/stringtests.pas index d5b49ae46..023f34b4b 100644 --- a/components/fpspreadsheet/unit-tests/common/stringtests.pas +++ b/components/fpspreadsheet/unit-tests/common/stringtests.pas @@ -24,8 +24,8 @@ interface uses // Not using lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, - fpstypes, fpsallformats, fpsutils, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, + Classes, SysUtils, fpcunit, testregistry, + fpstypes, {%H-}fpsallformats, fpsutils, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, testsutility; var @@ -190,9 +190,9 @@ begin MyWorkSheet:=MyWorkBook.AddWorksheet(StringsSheet); for Row := Low(SollStrings) to High(SollStrings) do begin - MyWorkSheet.WriteUTF8Text(Row,0,SollStrings[Row]); + MyWorkSheet.WriteText(Row,0,SollStrings[Row]); // Some checks inside worksheet itself - ActualString:=MyWorkSheet.ReadAsUTF8Text(Row,0); + ActualString:=MyWorkSheet.ReadAsText(Row,0); CheckEquals(SollStrings[Row],ActualString,'Test value mismatch cell '+CellNotation(MyWorkSheet,Row)); end; TempFile:=NewTempFile; @@ -212,7 +212,7 @@ begin // Read test data from A column & compare if written=original for Row := Low(SollStrings) to High(SollStrings) do begin - ActualString:=MyWorkSheet.ReadAsUTF8Text(Row,0); + ActualString:=MyWorkSheet.ReadAsText(Row,0); CheckEquals(SollStrings[Row],ActualString,'Test value mismatch, cell '+CellNotation(MyWorkSheet,Row)); end; finally @@ -256,9 +256,9 @@ begin // We could use CheckException but then you can't pass parameters TestResult:=true; try - MyWorkSheet.WriteUTF8Text(Row,0,LocalNormStrings[Row]); + MyWorkSheet.WriteText(Row,0,LocalNormStrings[Row]); // Some checks inside worksheet itself - ActualString:=MyWorkSheet.ReadAsUTF8Text(Row,0); + ActualString:=MyWorkSheet.ReadAsText(Row,0); CheckEquals(length(LocalNormStrings[Row]),length(ActualString), 'Test value mismatch cell '+CellNotation(MyWorkSheet,Row)+ ' for string length.'); @@ -316,7 +316,7 @@ begin // Read test data from A column & compare if written=original for Row := Low(LocalNormStrings) to High(LocalNormStrings) do begin - ActualString:=MyWorkSheet.ReadAsUTF8Text(Row,0); + ActualString:=MyWorkSheet.ReadAsText(Row,0); // Allow for truncation of excessive strings by fpspreadsheet if length(LocalNormStrings[Row])>MaxBytesBIFF8 then CheckEquals(MaxBytesBIFF8,length(ActualString), diff --git a/components/fpspreadsheet/unit-tests/common/testcases_calcrpnformula.inc b/components/fpspreadsheet/unit-tests/common/testcases_calcrpnformula.inc index 40feb9ef7..200f554e3 100644 --- a/components/fpspreadsheet/unit-tests/common/testcases_calcrpnformula.inc +++ b/components/fpspreadsheet/unit-tests/common/testcases_calcrpnformula.inc @@ -446,7 +446,7 @@ // Unary plus of cell value inc(Row); formula := '+(B2)'; - MyWorksheet.WriteUTF8Text(Row, 0, formula); + MyWorksheet.WriteText(Row, 0, formula); if UseRPNFormula then MyWorksheet.WriteRPNFormula(Row, 1, CreateRPNFormula( RPNCellvalue('B2', diff --git a/components/fpspreadsheet/unit-tests/common/virtualmodetests.pas b/components/fpspreadsheet/unit-tests/common/virtualmodetests.pas index b6aa08fa8..71faa4f6f 100644 --- a/components/fpspreadsheet/unit-tests/common/virtualmodetests.pas +++ b/components/fpspreadsheet/unit-tests/common/virtualmodetests.pas @@ -8,8 +8,8 @@ interface uses // Not using lazarus package as the user may be working with multiple versions // Instead, add .. to unit search path - Classes, SysUtils, fpcunit, testutils, testregistry, - fpstypes, fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, + Classes, SysUtils, fpcunit, testregistry, + fpstypes, {%H-}fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling}, fpsutils, testsutility; type diff --git a/components/fpspreadsheet/unit-tests/dataset/GuiTestProject.lpi b/components/fpspreadsheet/unit-tests/dataset/GuiTestProject.lpi index c74262882..ccd9d5c17 100644 --- a/components/fpspreadsheet/unit-tests/dataset/GuiTestProject.lpi +++ b/components/fpspreadsheet/unit-tests/dataset/GuiTestProject.lpi @@ -11,7 +11,6 @@ <ResourceType Value="res"/> <UseXPManifest Value="True"/> - <Icon Value="0"/> </General> <BuildModes Count="1"> <Item1 Name="Default" Default="True"/> diff --git a/components/fpspreadsheet/unit-tests/dataset/copyfromdatasetunit.pas b/components/fpspreadsheet/unit-tests/dataset/copyfromdatasetunit.pas index 3e9357874..42b3af021 100644 --- a/components/fpspreadsheet/unit-tests/dataset/copyfromdatasetunit.pas +++ b/components/fpspreadsheet/unit-tests/dataset/copyfromdatasetunit.pas @@ -5,9 +5,9 @@ unit CopyFromDatasetUnit; interface uses - Classes, SysUtils, fpcunit, testutils, testregistry, + Classes, SysUtils, fpcunit, {%H-}testutils, testregistry, DB, dbf, - fpspreadsheet, fpsDataset; + fpsDataset; type @@ -34,7 +34,6 @@ uses const DBF_FILE_NAME = 'testdata.dbf'; FILE_NAME = 'testfile.xlsx'; - SHEET_NAME = 'Sheet'; STRING_FIELD = 'StringCol'; INT_FIELD = 'IntegerCol'; @@ -80,7 +79,7 @@ begin dbf := CreateDbf; if DEBUG then - begin + {%H-}begin dbf.Close; dbf.Open; end; @@ -91,7 +90,7 @@ begin // Save for debugging if DEBUG then - begin + {%H-}begin dataset.Close; dataset.Open; end; diff --git a/components/fpspreadsheet/unit-tests/dataset/emptycolumnstestunit.pas b/components/fpspreadsheet/unit-tests/dataset/emptycolumnstestunit.pas index e508b26f9..e115ae0f0 100644 --- a/components/fpspreadsheet/unit-tests/dataset/emptycolumnstestunit.pas +++ b/components/fpspreadsheet/unit-tests/dataset/emptycolumnstestunit.pas @@ -137,7 +137,6 @@ const NumRows = 10; var r, c: Integer; - s: String; workbook: TsWorkbook; worksheet: TsWorksheet; begin diff --git a/components/fpspreadsheet/unit-tests/dataset/filtertestunit.pas b/components/fpspreadsheet/unit-tests/dataset/filtertestunit.pas index 80481cac8..4397e70bc 100644 --- a/components/fpspreadsheet/unit-tests/dataset/filtertestunit.pas +++ b/components/fpspreadsheet/unit-tests/dataset/filtertestunit.pas @@ -346,7 +346,7 @@ begin r := 1 + (i - Low(UNFILTERED)); worksheet.WriteNumber(r, INT_COL, UNFILTERED[i].IntValue, nfFixed, 0); worksheet.WriteText(r, STRING_COL, UNFILTERED[i].StringValue); - worksheet.WriteText(r, WIDESTRING_COL, UNFILTERED[i].WideStringValue); + worksheet.WriteText(r, WIDESTRING_COL, UTF8Encode(UNFILTERED[i].WideStringValue)); end; // Save diff --git a/components/fpspreadsheet/unit-tests/dataset/posttestunit.pas b/components/fpspreadsheet/unit-tests/dataset/posttestunit.pas index d3eea3641..a7d64c719 100644 --- a/components/fpspreadsheet/unit-tests/dataset/posttestunit.pas +++ b/components/fpspreadsheet/unit-tests/dataset/posttestunit.pas @@ -90,7 +90,7 @@ begin case ADataType of ftInteger : field.AsInteger := TestData[i].IntValue; ftString : field.AsString := TestData[i].StringValue; - ftWideString : field.AsString := UTF8Decode(TestData[i].WideStringValue); + ftWideString : field.AsString := UTF8Encode(TestData[i].WideStringValue); end; dataset.Post; end; diff --git a/components/fpspreadsheet/unit-tests/dataset/readfieldstestunit.pas b/components/fpspreadsheet/unit-tests/dataset/readfieldstestunit.pas index be94711e2..c0ce418a0 100644 --- a/components/fpspreadsheet/unit-tests/dataset/readfieldstestunit.pas +++ b/components/fpspreadsheet/unit-tests/dataset/readfieldstestunit.pas @@ -9,7 +9,7 @@ unit ReadFieldsTestUnit; interface uses - Classes, SysUtils, fpcunit, testutils, testregistry, + Classes, SysUtils, fpcunit, {%H-}testutils, testregistry, DB, fpspreadsheet, fpstypes, fpsdataset; @@ -201,7 +201,6 @@ var dt: TDateTime; workbook: TsWorkbook; worksheet: TsWorksheet; - n: Integer; begin dataset := CreateAndOpenDataset(AutoFieldDefs); try diff --git a/components/fpspreadsheet/unit-tests/dataset/searchtestunit.pas b/components/fpspreadsheet/unit-tests/dataset/searchtestunit.pas index 9faa5a264..132a55bff 100644 --- a/components/fpspreadsheet/unit-tests/dataset/searchtestunit.pas +++ b/components/fpspreadsheet/unit-tests/dataset/searchtestunit.pas @@ -1,11 +1,11 @@ unit SearchTestUnit; {$mode objfpc}{$H+} - +{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} interface uses - Classes, SysUtils, fpcunit, testutils, testregistry, + Classes, SysUtils, fpcunit, {%H-}testutils, testregistry, DB, fpspreadsheet, fpsTypes, fpsDataset;