diff --git a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
index 9f93b143b..3be3feee6 100644
--- a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
+++ b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
@@ -105,7 +105,6 @@
-
@@ -113,6 +112,7 @@
+
diff --git a/components/fpspreadsheet/examples/fpsgrid/mainform.lfm b/components/fpspreadsheet/examples/fpsgrid/mainform.lfm
index 031d7d794..fbd945fc3 100644
--- a/components/fpspreadsheet/examples/fpsgrid/mainform.lfm
+++ b/components/fpspreadsheet/examples/fpsgrid/mainform.lfm
@@ -4,7 +4,7 @@ object Form1: TForm1
Top = 248
Width = 884
Caption = 'fpsGrid'
- ClientHeight = 624
+ ClientHeight = 629
ClientWidth = 884
Menu = MainMenu
OnActivate = FormActivate
@@ -14,7 +14,7 @@ object Form1: TForm1
object Panel1: TPanel
Left = 0
Height = 85
- Top = 539
+ Top = 544
Width = 884
Align = alBottom
BevelOuter = bvNone
@@ -23,9 +23,9 @@ object Form1: TForm1
TabOrder = 0
object CbShowHeaders: TCheckBox
Left = 8
- Height = 24
+ Height = 19
Top = 8
- Width = 116
+ Width = 93
Caption = 'Show headers'
Checked = True
OnClick = CbShowHeadersClick
@@ -34,9 +34,9 @@ object Form1: TForm1
end
object CbShowGridLines: TCheckBox
Left = 8
- Height = 24
+ Height = 19
Top = 32
- Width = 125
+ Width = 100
Caption = 'Show grid lines'
Checked = True
OnClick = CbShowGridLinesClick
@@ -45,7 +45,7 @@ object Form1: TForm1
end
object EdFrozenCols: TSpinEdit
Left = 389
- Height = 28
+ Height = 23
Top = 8
Width = 52
OnChange = EdFrozenColsChange
@@ -53,7 +53,7 @@ object Form1: TForm1
end
object EdFrozenRows: TSpinEdit
Left = 389
- Height = 28
+ Height = 23
Top = 39
Width = 52
OnChange = EdFrozenRowsChange
@@ -61,37 +61,37 @@ object Form1: TForm1
end
object Label1: TLabel
Left = 304
- Height = 20
+ Height = 15
Top = 13
- Width = 77
+ Width = 62
Caption = 'Frozen cols:'
FocusControl = EdFrozenCols
ParentColor = False
end
object Label2: TLabel
Left = 304
- Height = 20
+ Height = 15
Top = 40
- Width = 82
+ Width = 66
Caption = 'Frozen rows:'
FocusControl = EdFrozenRows
ParentColor = False
end
object CbReadFormulas: TCheckBox
Left = 8
- Height = 24
+ Height = 19
Top = 56
- Width = 120
+ Width = 96
Caption = 'Read formulas'
OnChange = CbReadFormulasChange
TabOrder = 4
end
object CbHeaderStyle: TComboBox
Left = 152
- Height = 28
+ Height = 23
Top = 8
Width = 116
- ItemHeight = 20
+ ItemHeight = 15
ItemIndex = 2
Items.Strings = (
'Lazarus'
@@ -106,7 +106,7 @@ object Form1: TForm1
end
object PageControl1: TPageControl
Left = 0
- Height = 460
+ Height = 465
Top = 79
Width = 884
ActivePage = TabSheet1
@@ -116,11 +116,11 @@ object Form1: TForm1
OnChange = PageControl1Change
object TabSheet1: TTabSheet
Caption = 'Sheet1'
- ClientHeight = 427
+ ClientHeight = 437
ClientWidth = 876
object WorksheetGrid: TsWorksheetGrid
Left = 0
- Height = 427
+ Height = 437
Top = 0
Width = 876
FrozenCols = 0
@@ -136,7 +136,7 @@ object Form1: TForm1
TitleStyle = tsNative
OnSelection = WorksheetGridSelection
ColWidths = (
- 56
+ 42
64
64
64
@@ -244,19 +244,19 @@ object Form1: TForm1
end
object FontComboBox: TComboBox
Left = 52
- Height = 28
+ Height = 23
Top = 2
Width = 127
- ItemHeight = 20
+ ItemHeight = 15
OnSelect = FontComboBoxSelect
TabOrder = 0
end
object FontSizeComboBox: TComboBox
Left = 179
- Height = 28
+ Height = 23
Top = 2
Width = 48
- ItemHeight = 20
+ ItemHeight = 15
Items.Strings = (
'8'
'9'
diff --git a/components/fpspreadsheet/examples/fpsgrid/mainform.pas b/components/fpspreadsheet/examples/fpsgrid/mainform.pas
index fd4bc2cb6..fbb46349b 100644
--- a/components/fpspreadsheet/examples/fpsgrid/mainform.pas
+++ b/components/fpspreadsheet/examples/fpsgrid/mainform.pas
@@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
- StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids, graphutil,
+ StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids,
ColorBox, fpspreadsheetgrid, fpspreadsheet, fpsallformats;
type
@@ -873,7 +873,6 @@ var
cell: PCell;
r,c: Cardinal;
found: Boolean;
- t: Integer;
begin
with WorksheetGrid do begin
r := GetWorksheetRow(Row);
@@ -885,7 +884,6 @@ begin
nf := cell^.NumberFormat;
for i:=0 to ActionList.ActionCount-1 do begin
ac := TAction(ActionList.Actions[i]);
- t := ac.Tag;
if (ac.Tag >= NUMFMT_TAG) and (ac.Tag < NUMFMT_TAG + 200) then begin
found := ((ac.Tag - NUMFMT_TAG) div 10 = ord(nf));
if nf = nfCustom then
@@ -921,12 +919,10 @@ var
i: Integer;
ac: TAction;
vert_align: TsVertAlignment;
- t: Integer;
begin
with WorksheetGrid do vert_align := VertAlignments[Selection];
for i:=0 to ActionList.ActionCount-1 do begin
ac := TAction(ActionList.Actions[i]);
- t := ac.tag;
if (ac.Tag >= VERTALIGN_TAG) and (ac.Tag < VERTALIGN_TAG+10) then
ac.Checked := ((ac.Tag - VERTALIGN_TAG) = ord(vert_align));
end;
diff --git a/components/fpspreadsheet/fpsnumformatparser.pas b/components/fpspreadsheet/fpsnumformatparser.pas
index 2abfc46e9..38a43cdf2 100644
--- a/components/fpspreadsheet/fpsnumformatparser.pas
+++ b/components/fpspreadsheet/fpsnumformatparser.pas
@@ -129,15 +129,15 @@ type
out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor);
function IsCurrencyAt(ASection: Integer; out ANumFormat: TsNumberFormat;
out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor): Boolean;
- function IsDateAt(ASection,AIndex: Integer; var ANumberFormat: TsNumberFormat;
+ function IsDateAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
var ANextIndex: Integer): Boolean;
- function IsNumberAt(ASection,AIndex: Integer; var ANumberFormat: TsNumberFormat;
- var ADecimals: Byte; var ANextIndex: Integer): Boolean;
- function IsSciAt(ASection, AIndex: Integer; var ANumberFormat: TsNumberFormat;
- var ADecimals: Byte; var ANextIndex: Integer): Boolean;
+ function IsNumberAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
+ out ADecimals: Byte; out ANextIndex: Integer): Boolean;
+ function IsSciAt(ASection, AIndex: Integer; out ANumberFormat: TsNumberFormat;
+ out ADecimals: Byte; out ANextIndex: Integer): Boolean;
function IsTextAt(AText: string; ASection, AIndex: Integer): Boolean;
- function IsTimeAt(ASection,AIndex: Integer; var ANumberFormat: TsNumberFormat;
- var ANextIndex: Integer): Boolean;
+ function IsTimeAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
+ out ANextIndex: Integer): Boolean;
function IsTokenAt(AToken: TsNumFormatToken; ASection,AIndex: Integer): Boolean;
public
@@ -309,10 +309,8 @@ function TsNumFormatParser.BuildFormatStringFromSection(ASection: Integer;
var
element: TsNumFormatElement;
i: Integer;
- colorAdded: Boolean;
begin
Result := '';
- colorAdded := false;
if (ASection < 0) and (ASection >= GetParsedSectionCount) then
exit;
@@ -382,17 +380,9 @@ begin
scCyan : Result := '[cyan]';
else Result := Format('[Color%d]', [element.IntValue]);
end;
- colorAdded := true;
end;
end;
end;
- {
- if (ADialect = nfdExcel)
- and (not colorAdded) and
- (FSections[ASection].NumFormat in [nfCurrencyRed, nfAccountingRed])
- then
- Result := '[red]'+Result;
- }
end;
procedure TsNumFormatParser.CheckSections;
@@ -406,7 +396,6 @@ end;
procedure TsNumFormatParser.CheckSection(ASection: Integer);
var
i, j: Integer;
- ok: Boolean;
// Finds the previous date/time element skipping spaces, date/time sep etc.
function PrevDateTimeElement(j: Integer): Integer;
@@ -564,10 +553,7 @@ procedure TsNumFormatParser.EvalNumFormatOfSection(ASection: Integer;
out AColor: TsColor);
var
nf: TsNumberFormat;
- decs: Byte;
- cs: String;
- next: Integer;
- ampm: Boolean;
+ next: Integer = 0;
begin
ANumFormat := nfCustom;
ADecimals := 0;
@@ -761,7 +747,6 @@ var
isAccounting : Boolean;
hasCurrSymbol: Boolean;
hasColor: Boolean;
- next: Integer;
el: Integer;
begin
Result := false;
@@ -772,6 +757,7 @@ begin
AColor := scNotDefined;
isAccounting := false;
hasColor := false;
+ hasCurrSymbol := false;
// Looking for the currency symbol: it is the unique identifier of the
// currency format.
@@ -804,7 +790,10 @@ begin
nftRepeat:
isAccounting := true;
nftCurrSymbol:
- ACurrencySymbol := FSections[ASection].Elements[el].TextValue;
+ begin
+ ACurrencySymbol := FSections[ASection].Elements[el].TextValue;
+ hasCurrSymbol := true;
+ end;
nftOptDigit:
if IsNumberAt(ASection, el, ANumFormat, ADecimals, el) then
dec(el)
@@ -837,49 +826,10 @@ begin
end;
end else
ANumFormat := nfCustom;
-
- (*
- if IsTokenAt(nftColor, ASection, AIndex) then begin
- AIndex := AIndex + 1;
- AColor := FSections[ASection].Elements[AIndex].IntValue;
- end;
-
- isAccounting := false;
- hasCurrSymbol := false;
- while (AIndex < Length(FSections[ASection].Elements)) do begin
- case FSections[ASection].Elements[AIndex].Token of
- nftRepeat:
- isAccounting := true;
- nftCurrSymbol:
- begin
- hasCurrSymbol := true;
- ACurrencySymbol := FSections[ASection].Elements[AIndex].TextValue;
- end;
- nftOptDigit:
- if IsNumberAt(ASection, AIndex, ANumFormat, ADecimals, next) then
- AIndex := next-1
- else
- exit;
- end;
- inc(AIndex);
- end;
-
- Result := hasCurrSymbol and (ANumFormat = nfFixedTh);
- if Result then begin
- if isAccounting then begin
- if AColor = scNotDefined then ANumFormat := nfAccounting else
- if AColor = scRed then ANumFormat := nfAccountingRed;
- end else begin
- if AColor = scNotDefined then ANumFormat := nfCurrency else
- if AColor = scRed then ANumFormat := nfCurrencyRed;
- end;
- end else
- ANumFormat := nfCustom;
- *)
end;
function TsNumFormatParser.IsDateAt(ASection,AIndex: Integer;
- var ANumberFormat: TsNumberFormat; var ANextIndex: Integer): Boolean;
+ out ANumberFormat: TsNumberFormat; var ANextIndex: Integer): Boolean;
function CheckFormat(AFmtStr: String; var idx: Integer): Boolean;
var
@@ -936,8 +886,6 @@ function TsNumFormatParser.IsDateAt(ASection,AIndex: Integer;
ANextIndex := idx;
end;
-var
- i: Integer;
begin
if FWorkbook = nil then begin
Result := false;
@@ -979,16 +927,13 @@ end;
at standard number format, like nfFixed, nfPercentage etc.
Returns TRUE if it does. }
function TsNumFormatParser.IsNumberAt(ASection,AIndex: Integer;
- var ANumberFormat: TsNumberFormat; var ADecimals: Byte;
- var ANextIndex: Integer): Boolean;
-var
- nElem: Integer;
+ out ANumberFormat: TsNumberFormat; out ADecimals: Byte;
+ out ANextIndex: Integer): Boolean;
begin
Result := false;
ANumberFormat := nfGeneral;
ADecimals := 0;
ANextIndex := MaxInt;
- nElem := Length(FSections[ASection].Elements);
// Let's look for digit tokens ('0') first
if IsTokenAt(nftDigit, ASection, AIndex) then begin // '0'
if IsTokenAt(nftDecSep, ASection, AIndex+1) and // '.'
@@ -1035,7 +980,7 @@ begin
end;
function TsNumFormatParser.IsSciAt(ASection, AIndex: Integer;
- var ANumberFormat: TsNumberFormat; var ADecimals: Byte; var ANextIndex: Integer): Boolean;
+ out ANumberFormat: TsNumberFormat; out ADecimals: Byte; out ANextIndex: Integer): Boolean;
begin
if IsTokenAt(nftOptDigit, ASection, AIndex) and // '#'
IsTokenAt(nftOptDigit, ASection, Aindex+1) and // '#'
@@ -1061,10 +1006,10 @@ begin
end;
function TsNumFormatParser.IsTimeAt(ASection,AIndex: Integer;
- var ANumberFormat: TsNumberFormat; var ANextIndex: Integer): Boolean;
+ out ANumberFormat: TsNumberFormat; out ANextIndex: Integer): Boolean;
function CheckFormat(AFmtStr: String; var idx: Integer;
- var AMPM, IsInterval: boolean): Boolean;
+ out AMPM, IsInterval: boolean): Boolean;
var
i: Integer;
s: String;
@@ -1143,7 +1088,6 @@ function TsNumFormatParser.IsTimeAt(ASection,AIndex: Integer;
end;
end;
Result := true;
- ANextIndex := idx;
end;
var
@@ -1252,12 +1196,9 @@ begin
end;
function TsNumFormatParser.NextToken: Char;
-var
- delta: Integer;
begin
if FCurrent < FEnd then begin
inc(FCurrent);
- delta := integer(FCurrent - FStart);
Result := FCurrent^;
end else
Result := #0;
@@ -1337,6 +1278,7 @@ var
n: Integer;
prevtoken: Char;
begin
+ s := '';
FToken := NextToken; // Cursor was at '['
while (FCurrent < FEnd) and (FStatus = psOK) do begin
case FToken of
@@ -1471,10 +1413,8 @@ procedure TsNumFormatParser.ScanDateTime;
var
n: Integer;
token: Char;
- delta: Integer;
begin
while (FCurrent < FEnd) and (FStatus = psOK) do begin
- delta := Integer(FCurrent - FStart);
case FToken of
'\': // means that the next character is taken literally
begin
@@ -1603,24 +1543,12 @@ end;
procedure TsNumFormatParser.ScanNumber;
var
hasDecSep: Boolean;
- hasThSep: Boolean;
- hasExp: Boolean;
n: Integer;
-
- delta: Integer;
begin
hasDecSep := false;
- hasThSep := false;
- hasExp := false;
while (FCurrent < FEnd) and (FStatus = psOK) do begin
-
- delta := integer(FCurrent - FStart);
-
case FToken of
- ',': begin
- AddElement(nftThSep, ',');
- hasThSep := true;
- end;
+ ',': AddElement(nftThSep, ',');
'.': begin
AddElement(nftDecSep, '.');
hasDecSep := true;
diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas
index bb87baf3c..3ca679ed2 100755
--- a/components/fpspreadsheet/fpsopendocument.pas
+++ b/components/fpspreadsheet/fpsopendocument.pas
@@ -108,11 +108,11 @@ type
procedure ReadNumFormats(AStylesNode: TDOMNode);
procedure ReadStyles(AStylesNode: TDOMNode);
{ Record writing methods }
- procedure ReadBlank(ARow, ACol: Word; ACellNode: TDOMNode);
+ procedure ReadBlank(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
procedure ReadDateTime(ARow, ACol: Word; ACellNode: TDOMNode);
- procedure ReadFormula(ARow, ACol: Word; ACellNode: TDOMNode);
- procedure ReadLabel(ARow, ACol: Word; ACellNode: TDOMNode);
- procedure ReadNumber(ARow, ACol: Word; ACellNode: TDOMNode);
+ procedure ReadFormula(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
+ procedure ReadLabel(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
+ procedure ReadNumber(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
public
{ General reading methods }
constructor Create(AWorkbook: TsWorkbook); override;
@@ -1248,7 +1248,6 @@ var
cell: PCell;
formula: String;
stylename: String;
- txtValue: String;
floatValue: Double;
fs: TFormatSettings;
valueType: String;
@@ -1470,7 +1469,7 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
procedure ReadNumberStyle(ANumFormatNode: TDOMNode; ANumFormatName: String);
var
node, childNode: TDOMNode;
- fmtName, nodeName: String;
+ nodeName: String;
fmt: String;
nf: TsNumberFormat;
decs: Byte;
@@ -1478,8 +1477,6 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
grouping: Boolean;
nex: Integer;
cs: String;
- color: TsColorValue;
- idx: Integer;
hasColor: Boolean;
begin
fmt := '';
@@ -1655,7 +1652,6 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
nf: TsNumberFormat;
fmt: String;
nodeName: String;
- s: String;
begin
fmt := '';
node := ANumFormatNode.FirstChild;
@@ -1729,15 +1725,13 @@ var
cellNode, rowNode: TDOMNode;
paramValueType, paramFormula, tableStyleName: String;
paramColsRepeated, paramRowsRepeated: String;
- colsRepeated, rowsRepeated: Integer;
+ rowsRepeated: Integer;
rowStyleName: String;
rowStyleIndex: Integer;
rowStyle: TRowStyleData;
rowHeight: Single;
autoRowHeight: Boolean;
i: Integer;
- lRow: PRow;
- s: String;
begin
rowsRepeated := 0;
row := 0;
@@ -1860,8 +1854,6 @@ var
style: TCellStyleData;
styleNode: TDOMNode;
styleChildNode: TDOMNode;
- colStyle: TColumnStyleData;
- colWidth: Double;
family: String;
styleName: String;
styleIndex: Integer;
@@ -1884,7 +1876,6 @@ var
var
L: TStringList;
i: Integer;
- isSolid: boolean;
s: String;
wid: Double;
linestyle: String;
@@ -2405,22 +2396,7 @@ begin
end;
procedure TsSpreadOpenDocWriter.WriteWorksheet(CurSheet: TsWorksheet);
-var
- j, k: Integer;
- CurCell: PCell;
- CurRow: array of PCell;
- LastColIndex: Cardinal;
- LCell: TCell;
- AVLNode: TAVLTreeNode;
- defFontSize: Single;
- h, h_mm: Double;
- styleName: String;
- rowStyleData: TRowStyleData;
- row: PRow;
begin
- LastColIndex := CurSheet.GetLastColIndex;
- defFontSize := Workbook.GetFont(0).Size;
-
// Header
FContent := FContent +
' ' + LineEnding;
@@ -2495,7 +2471,6 @@ end;
function TsSpreadOpenDocWriter.WriteColStylesXMLAsString: string;
var
i: Integer;
- s: String;
colstyle: TColumnStyleData;
begin
Result := '';
@@ -2608,10 +2583,7 @@ var
rowsRepeatedStr: String;
lastCol, lastRow: Cardinal;
rowStyleData: TRowStyleData;
- colData: TColumnData;
- colStyleData: TColumnStyleData;
defFontSize: Single;
- sameRowStyle: Boolean;
begin
Result := '';
@@ -2716,7 +2688,6 @@ end;
function TsSpreadOpenDocWriter.WriteRowStylesXMLAsString: string;
var
i: Integer;
- s: String;
rowstyle: TRowStyleData;
begin
Result := '';
diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas
index 9a1a5b6fa..476209da2 100755
--- a/components/fpspreadsheet/fpspreadsheet.pas
+++ b/components/fpspreadsheet/fpspreadsheet.pas
@@ -601,7 +601,7 @@ type
{ Base methods }
constructor Create;
destructor Destroy; override;
- class function GetFormatFromFileName(const AFileName: TFileName; var SheetType: TsSpreadsheetFormat): Boolean;
+ class function GetFormatFromFileName(const AFileName: TFileName; out SheetType: TsSpreadsheetFormat): Boolean;
function CreateSpreadReader(AFormat: TsSpreadsheetFormat): TsCustomSpreadReader;
function CreateSpreadWriter(AFormat: TsSpreadsheetFormat): TsCustomSpreadWriter;
procedure ReadFromFile(AFileName: string; AFormat: TsSpreadsheetFormat); overload;
@@ -968,15 +968,15 @@ type
const
FEProps: array[TFEKind] of TFEProp = (
{ Operands }
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCell
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellRef
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellRange
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellNum
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellInteger
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellString
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellBool
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellErr
- (Symbol:''; MinParams:-1; MaxParams:-1), // fekCellMissingArg
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCell
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellRef
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellRange
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellNum
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellInteger
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellString
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellBool
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellErr
+ (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellMissingArg
{ Basic operations }
(Symbol:'+'; MinParams:2; MaxParams:2), // fekAdd
(Symbol:'-'; MinParams:2; MaxParams:2), // fekSub
@@ -1587,7 +1587,6 @@ function TsWorksheet.ReadAsUTF8Text(ACell: PCell): ansistring;
var
fs: TFormatSettings;
left, right: String;
- i: Integer;
begin
fs := FWorkbook.FormatSettings;
if IsNan(Value) then
@@ -1670,7 +1669,6 @@ end;
function TsWorksheet.ReadAsNumber(ARow, ACol: Cardinal): Double;
var
ACell: PCell;
- Str: string;
begin
Result := 0.0;
ACell := FindCell(ARow, ACol);
@@ -1695,7 +1693,6 @@ end;
function TsWorksheet.ReadAsDateTime(ARow, ACol: Cardinal; out AResult: TDateTime): Boolean;
var
ACell: PCell;
- Str: string;
begin
ACell := FindCell(ARow, ACol);
@@ -1724,7 +1721,6 @@ end;
function TsWorksheet.ReadRPNFormulaAsString(ACell: PCell): String;
var
fs: TFormatSettings;
- formula: TsRPNFormula;
elem: TsFormulaElement;
i, j: Integer;
L: TStringList;
@@ -1958,8 +1954,6 @@ end;
the file. }
procedure TsWorksheet.WriteNumber(ARow, ACol: Cardinal; ANumber: Double;
AFormat: TsNumberFormat; AFormatString: String);
-var
- ACell: PCell;
begin
WriteNumber(GetCell(ARow, ACol), ANumber, AFormat, AFormatString);
end;
@@ -2118,7 +2112,6 @@ procedure TsWorksheet.WriteDateTime(ACell: PCell; AValue: TDateTime;
AFormat: TsNumberFormat = nfShortDateTime; AFormatStr: String = '');
var
parser: TsNumFormatParser;
- nf: TsNumberFormat;
begin
if ACell <> nil then begin
ACell^.ContentType := cctDateTime;
@@ -2512,7 +2505,6 @@ end;
function TsWorksheet.CalcAutoRowHeight(ARow: Cardinal): Single;
var
cell: PCell;
- fnt: TsFont;
col: Integer;
h0: Single;
begin
@@ -2743,7 +2735,8 @@ end;
Returns: True if the file matches any of the known formats, false otherwise
}
-class function TsWorkbook.GetFormatFromFileName(const AFileName: TFileName; var SheetType: TsSpreadsheetFormat): Boolean;
+class function TsWorkbook.GetFormatFromFileName(const AFileName: TFileName;
+ out SheetType: TsSpreadsheetFormat): Boolean;
var
suffix: String;
begin
@@ -2863,6 +2856,7 @@ var
SheetType: TsSpreadsheetFormat;
lException: Exception;
begin
+ SheetType := sfExcel8;
while (SheetType in [sfExcel2..sfExcel8]) and (lException <> nil) do
begin
try
@@ -3143,7 +3137,7 @@ end;
}
procedure TsWorkbook.RemoveAllFonts;
var
- i, n: Integer;
+ i: Integer;
fnt: TsFont;
begin
for i:=FFontList.Count-1 downto 0 do begin
@@ -3215,8 +3209,6 @@ end;
The color must in little-endian notation (like TColor of the graphics units)
}
function TsWorkbook.AddColorToPalette(AColorValue: TsColorValue): TsColor;
-var
- i: Integer;
begin
// Look look for the color. Is it already in the existing palette?
if Length(FPalette) > 0 then
@@ -3427,8 +3419,6 @@ begin
end;
function TsCustomNumFormatList.AddFormat(AFormatCell: PCell): Integer;
-var
- item: TsNumFormatData;
begin
if AFormatCell = nil then
raise Exception.Create('TsCustomNumFormat.Add: No nil pointers please');
@@ -3469,7 +3459,6 @@ var
fmt: String;
lFormatData: TsNumFormatData;
i: Integer;
- nf: TsNumberFormat;
begin
i := FindByIndex(AFormatIndex);
if i > 0 then begin
@@ -3478,8 +3467,6 @@ begin
end else
fmt := AFormatString;
- nf := nfGeneral;
-
// Analyzes the format string and tries to convert it to fpSpreadsheet format.
parser := TsNumFormatParser.Create(Workbook, fmt); //, nf, cdToFPSpreadsheet);
try
@@ -3512,8 +3499,6 @@ procedure TsCustomNumFormatList.AnalyzeAndAdd(AFormatIndex: Integer;
AFormatString: String);
var
nf: TsNumberFormat;
- decs: Byte;
- currsym: String;
begin
if FindByIndex(AFormatIndex) > -1 then
exit;
diff --git a/components/fpspreadsheet/fpspreadsheetchart.pas b/components/fpspreadsheet/fpspreadsheetchart.pas
index 38da395e4..09eda1331 100644
--- a/components/fpspreadsheet/fpspreadsheetchart.pas
+++ b/components/fpspreadsheet/fpspreadsheetchart.pas
@@ -13,7 +13,7 @@ unit fpspreadsheetchart;
interface
uses
- Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Grids,
+ Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
// TChart
{tasources,} TACustomSource,
// FPSpreadsheet Visual
diff --git a/components/fpspreadsheet/fpspreadsheetgrid.pas b/components/fpspreadsheet/fpspreadsheetgrid.pas
index bd29c9064..424f9dde0 100644
--- a/components/fpspreadsheet/fpspreadsheetgrid.pas
+++ b/components/fpspreadsheet/fpspreadsheetgrid.pas
@@ -117,7 +117,7 @@ type
procedure DrawSelection;
procedure DrawTextInCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
function GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer;
- var ABorderStyle: TsCellBorderStyle): Boolean;
+ out ABorderStyle: TsCellBorderStyle): Boolean;
function GetCellHeight(ACol, ARow: Integer): Integer;
function GetCellText(ACol, ARow: Integer): String;
function GetEditText(ACol, ARow: Integer): String; override;
@@ -333,7 +333,7 @@ procedure Register;
implementation
uses
- Types, LCLType, LCLIntf, Math, fpCanvas, GraphUtil, fpsUtils;
+ Types, LCLType, LCLIntf, Math, fpCanvas, fpsUtils;
const
HOR_ALIGNMENTS: array[haLeft..haRight] of TAlignment = (
@@ -548,7 +548,6 @@ end;
Row/Col coordinates are in worksheet units here! }
procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
var
- h: Integer;
lRow: PRow;
begin
if (FWorksheet <> nil) then begin
@@ -860,7 +859,6 @@ end;
procedure TsCustomWorksheetGrid.DrawSelection;
var
P1, P2: TPoint;
- selrect: TRect;
begin
// Cosmetics at the edges of the grid to avoid spurious rests
P1 := CellRect(Selection.Left, Selection.Top).TopLeft;
@@ -890,14 +888,7 @@ procedure TsCustomWorksheetGrid.DrawTextInCell(ACol, ARow: Integer; ARect: TRect
AState: TGridDrawState);
var
ts: TTextStyle;
- flags: Cardinal;
txt: String;
- txtL, txtR: String;
- txtRect: TRect;
- P: TPoint;
- w, h, h0, hline: Integer;
- i: Integer;
- L: TStrings;
c, r: Integer;
wrapped: Boolean;
horAlign: TsHorAlignment;
@@ -1204,7 +1195,7 @@ end;
matching color in the palette. }
function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor;
- procedure ColorToHSL(RGB: TColor; var H, S, L : double);
+ procedure ColorToHSL(RGB: TColor; out H, S, L : double);
// Taken from https://code.google.com/p/thtmlviewer/source/browse/trunk/source/HSLUtils.pas?r=277
// The procedure in GraphUtils is crashing for some colors in Laz < 1.3
var
@@ -1247,8 +1238,6 @@ function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor;
end;
function ColorDistance(color1, color2: TColor): Double;
- type
- TRGBA = packed record R,G,B,A: Byte end;
var
H1,S1,L1, H2,S2,L2: Double;
begin
@@ -1662,7 +1651,7 @@ end;
ADeltaCol and ADeltaRow (one of them must be 0, the other one can only be +/-1).
ACol and ARow are in grid units. }
function TsCustomWorksheetGrid.GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer;
- var ABorderStyle: TsCellBorderStyle): Boolean;
+ out ABorderStyle: TsCellBorderStyle): Boolean;
var
cell, neighborcell: PCell;
border, neighborborder: TsCellBorder;
@@ -1936,13 +1925,11 @@ var
ts: TTextStyle;
flags: Cardinal;
txt: String;
- txtL, txtR: String;
txtRect: TRect;
P: TPoint;
w, h, h0, hline: Integer;
i: Integer;
L: TStrings;
- c, r: Integer;
wrapped: Boolean;
begin
wrapped := ATextWrap or (ATextRot = rtStacked);
@@ -2462,7 +2449,6 @@ var
i: Integer;
lCol: PCol;
lRow: PRow;
- fc, fr: Integer;
begin
if (FWorksheet = nil) or (FWorksheet.GetCellCount = 0) then begin
if ShowHeaders then begin
diff --git a/components/fpspreadsheet/fpsutils.pas b/components/fpspreadsheet/fpsutils.pas
index 18e4636e3..9262e4e76 100644
--- a/components/fpspreadsheet/fpsutils.pas
+++ b/components/fpspreadsheet/fpsutils.pas
@@ -46,19 +46,19 @@ function LongRGBToExcelPhysical(const RGB: DWord): DWord;
// Other routines
function ParseIntervalString(const AStr: string;
- var AFirstCellRow, AFirstCellCol, ACount: Integer;
- var ADirection: TsSelectionDirection): Boolean;
+ out AFirstCellRow, AFirstCellCol, ACount: Integer;
+ out ADirection: TsSelectionDirection): Boolean;
function ParseCellRangeString(const AStr: string;
- var AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer;
- var AFlags: TsRelFlags): Boolean;
+ out AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer;
+ out AFlags: TsRelFlags): Boolean;
function ParseCellString(const AStr: string;
- var ACellRow, ACellCol: Integer; var AFlags: TsRelFlags): Boolean; overload;
+ out ACellRow, ACellCol: Integer; out AFlags: TsRelFlags): Boolean; overload;
function ParseCellString(const AStr: string;
- var ACellRow, ACellCol: Integer): Boolean; overload;
+ out ACellRow, ACellCol: Integer): Boolean; overload;
function ParseCellRowString(const AStr: string;
- var AResult: Integer): Boolean;
+ out AResult: Integer): Boolean;
function ParseCellColString(const AStr: string;
- var AResult: Integer): Boolean;
+ out AResult: Integer): Boolean;
function GetColString(AColIndex: Integer): String;
function GetCellString(ARow,ACol: Cardinal; AFlags: TsRelFlags): String;
@@ -94,7 +94,7 @@ function MakeShortDateFormat(AShortDateFormat: String): String;
function SpecialDateTimeFormat(ACode: String;
const AFormatSettings: TFormatSettings; ForWriting: Boolean): String;
function SplitAccountingFormatString(const AFormatString: String; ASection: ShortInt;
- var ALeft, ARight: String): Byte;
+ out ALeft, ARight: String): Byte;
procedure SplitFormatString(const AFormatString: String; out APositivePart,
ANegativePart, AZeroPart: String);
@@ -248,8 +248,8 @@ end;
Parses strings like A5:A10 into an selection interval information
}
function ParseIntervalString(const AStr: string;
- var AFirstCellRow, AFirstCellCol, ACount: Integer;
- var ADirection: TsSelectionDirection): Boolean;
+ out AFirstCellRow, AFirstCellCol, ACount: Integer;
+ out ADirection: TsSelectionDirection): Boolean;
var
//Cells: TStringList;
LastCellRow, LastCellCol: Integer;
@@ -303,8 +303,8 @@ end;
Returns in AFlags also information on relative/absolute cells.
}
function ParseCellRangeString(const AStr: string;
- var AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer;
- var AFlags: TsRelFlags): Boolean;
+ out AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer;
+ out AFlags: TsRelFlags): Boolean;
var
p: Integer;
s: String;
@@ -339,8 +339,8 @@ end;
Example "AMP$200" --> (rel) column 1029 (= 26*26*1 + 26*16 + 26 - 1)
(abs) row = 199 (abs)
}
-function ParseCellString(const AStr: String; var ACellRow, ACellCol: Integer;
- var AFlags: TsRelFlags): Boolean;
+function ParseCellString(const AStr: String; out ACellRow, ACellCol: Integer;
+ out AFlags: TsRelFlags): Boolean;
function Scan(AStartPos: Integer): Boolean;
const
@@ -410,14 +410,14 @@ end;
{ for compatibility with old version which does not return flags for relative
cell addresses }
function ParseCellString(const AStr: string;
- var ACellRow, ACellCol: Integer): Boolean;
+ out ACellRow, ACellCol: Integer): Boolean;
var
flags: TsRelFlags;
begin
- ParseCellString(AStr, ACellRow, ACellCol, flags);
+ Result := ParseCellString(AStr, ACellRow, ACellCol, flags);
end;
-function ParseCellRowString(const AStr: string; var AResult: Integer): Boolean;
+function ParseCellRowString(const AStr: string; out AResult: Integer): Boolean;
begin
try
AResult := StrToInt(AStr) - 1;
@@ -427,7 +427,7 @@ begin
Result := True;
end;
-function ParseCellColString(const AStr: string; var AResult: Integer): Boolean;
+function ParseCellColString(const AStr: string; out AResult: Integer): Boolean;
const
INT_NUM_LETTERS = 26;
begin
@@ -607,8 +607,6 @@ end;
and "msz" (for "mm:ss.z"). }
function BuildDateTimeFormatString(ANumberFormat: TsNumberFormat;
const AFormatSettings: TFormatSettings; AFormatString: String = '') : string;
-var
- fmt: String;
begin
case ANumberFormat of
nfShortDateTime:
@@ -932,7 +930,7 @@ end;
and right part and returns 1 if the format string is in the left, and 2 if
it is in the right part. Additionally removes Excel format codes '_' }
function SplitAccountingFormatString(const AFormatString: String; ASection: ShortInt;
- var ALeft, ARight: String): Byte;
+ out ALeft, ARight: String): Byte;
var
P: PChar;
PStart, PEnd: PChar;
diff --git a/components/fpspreadsheet/tests/datetests.pas b/components/fpspreadsheet/tests/datetests.pas
index 0c8bdd484..df5619d55 100644
--- a/components/fpspreadsheet/tests/datetests.pas
+++ b/components/fpspreadsheet/tests/datetests.pas
@@ -214,6 +214,7 @@ type
procedure TestWriteReadDates_BIFF2;
procedure TestWriteReadDates_BIFF5;
procedure TestWriteReadDates_BIFF8;
+ procedure TestWriteReadDates_ODS;
end;
@@ -358,6 +359,11 @@ begin
TestWriteReadDates(sfExcel8);
end;
+procedure TSpreadWriteReadDateTests.TestWriteReadDates_ODS;
+begin
+ TestWriteReadDates(sfOpenDocument);
+end;
+
{ TSpreadReadDateTests }
diff --git a/components/fpspreadsheet/tests/emptycelltests.pas b/components/fpspreadsheet/tests/emptycelltests.pas
index a57312ec5..25a9aa262 100644
--- a/components/fpspreadsheet/tests/emptycelltests.pas
+++ b/components/fpspreadsheet/tests/emptycelltests.pas
@@ -150,7 +150,6 @@ var
row, col: Integer;
MyCell: PCell;
TempFile: string; //write xls/xml to this file and read back from it
- i: Integer;
L: TStringList;
s: String;
begin
diff --git a/components/fpspreadsheet/tests/fonttests.pas b/components/fpspreadsheet/tests/fonttests.pas
index 988b51edc..a80ff97bf 100644
--- a/components/fpspreadsheet/tests/fonttests.pas
+++ b/components/fpspreadsheet/tests/fonttests.pas
@@ -131,8 +131,6 @@ var
row, col: Integer;
MyCell: PCell;
TempFile: string; //write xls/xml to this file and read back from it
- currValue: String;
- expectedValue: String;
begin
TempFile:=GetTempFileName;
{// Not needed: use workbook.writetofile with overwrite=true
diff --git a/components/fpspreadsheet/tests/formattests.pas b/components/fpspreadsheet/tests/formattests.pas
index d80a78a1f..b740c149b 100644
--- a/components/fpspreadsheet/tests/formattests.pas
+++ b/components/fpspreadsheet/tests/formattests.pas
@@ -531,7 +531,6 @@ var
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
MyCell: PCell;
- ActualColWidth: Single;
col: Integer;
expected: String;
current: String;
@@ -611,7 +610,6 @@ var
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
MyCell: PCell;
- ActualColWidth: Single;
row, col: Integer;
b: TsCellBorder;
expected: Integer;
@@ -788,7 +786,6 @@ var
MyWorkbook: TsWorkbook;
ActualRowHeight: Single;
Row: Integer;
- lpRow: PRow;
TempFile: string; //write xls/xml to this file and read back from it
begin
TempFile:=GetTempFileName;
@@ -856,7 +853,6 @@ var
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
MyCell: PCell;
- ActualColWidth: Single;
tr: TsTextRotation;
row: Integer;
TempFile: string; //write xls/xml to this file and read back from it
diff --git a/components/fpspreadsheet/tests/formulatests.pas b/components/fpspreadsheet/tests/formulatests.pas
index 3aeff45e8..74102ad9f 100644
--- a/components/fpspreadsheet/tests/formulatests.pas
+++ b/components/fpspreadsheet/tests/formulatests.pas
@@ -57,20 +57,16 @@ const
var
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
- ActualString: String;
- Row, Col: Integer;
+ Row: Integer;
TempFile: string; //write xls/xml to this file and read back from it
expected: String;
actual: String;
cell: PCell;
- fs: TFormatSettings;
begin
TempFile := GetTempFileName;
// Create test workbook
MyWorkbook := TsWorkbook.Create;
-// MyWorkbook.FormatSettings.DecimalSeparator := '.';
-// MyWorkbook.FormatSettings.ShortDateFormat := 'yyyy-mm-dd';
MyWorkSheet:= MyWorkBook.AddWorksheet(SHEET);
// Write out all test formulas
diff --git a/components/fpspreadsheet/tests/internaltests.pas b/components/fpspreadsheet/tests/internaltests.pas
index 747c8a912..46a5fd9fb 100644
--- a/components/fpspreadsheet/tests/internaltests.pas
+++ b/components/fpspreadsheet/tests/internaltests.pas
@@ -55,7 +55,6 @@ procedure TSpreadInternalTests.GetSheetByIndex;
var
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
- Row: Cardinal;
begin
MyWorkbook := TsWorkbook.Create;
MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet);
@@ -71,7 +70,6 @@ const
var
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
- Row: Cardinal;
begin
MyWorkbook := TsWorkbook.Create;
MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet);
@@ -128,7 +126,6 @@ procedure TSpreadInternalTests.ReadDateAsUTF8;
var
ActualDT: TDateTime;
ActualDTString: string; //Result from ReadAsUTF8Text
- Cell: PCell;
MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook;
Row,Column: Cardinal;
diff --git a/components/fpspreadsheet/tests/manualtests.pas b/components/fpspreadsheet/tests/manualtests.pas
index 3f696e441..2332cb3eb 100644
--- a/components/fpspreadsheet/tests/manualtests.pas
+++ b/components/fpspreadsheet/tests/manualtests.pas
@@ -66,7 +66,6 @@ type
implementation
uses
- Math, StrUtils,
fpsUtils, rpnFormulaUnit;
const
diff --git a/components/fpspreadsheet/tests/rpnformulaunit.pas b/components/fpspreadsheet/tests/rpnformulaunit.pas
index 1d4721a8a..b615c8490 100644
--- a/components/fpspreadsheet/tests/rpnformulaunit.pas
+++ b/components/fpspreadsheet/tests/rpnformulaunit.pas
@@ -28,7 +28,6 @@ const
SBaseCells = 'Data cells:';
SHelloWorld = 'Hello world!';
var
- Cell: PCell;
Row: Integer;
value: Double;
r,c: integer;
diff --git a/components/fpspreadsheet/tests/spreadtestgui.lpi b/components/fpspreadsheet/tests/spreadtestgui.lpi
index f6cc33bad..467e13640 100644
--- a/components/fpspreadsheet/tests/spreadtestgui.lpi
+++ b/components/fpspreadsheet/tests/spreadtestgui.lpi
@@ -47,9 +47,6 @@
-
-
-
@@ -79,7 +76,6 @@
-
@@ -104,7 +100,6 @@
-
@@ -129,7 +124,6 @@
-
@@ -169,9 +163,6 @@
-
-
-
diff --git a/components/fpspreadsheet/uvirtuallayer_types.pas b/components/fpspreadsheet/uvirtuallayer_types.pas
index fa06efe79..cb0b43858 100644
--- a/components/fpspreadsheet/uvirtuallayer_types.pas
+++ b/components/fpspreadsheet/uvirtuallayer_types.pas
@@ -168,18 +168,21 @@ end;
function TVirtualLayer_Item.GetAttributesHumanReadable: UTF8String;
var
- T: UTF8String;
+ T: UTF8String = '';
A: TVirtualLayer_CustomAttributes;
+ fs: TFormatSettings;
begin
- A:=Attributes;
+ Result := '';
+ A := Attributes;
if A=nil then Exit;
- Result:=Result+'Regular attributes: ';
+ fs := DefaultFormatSettings;
+ Result := Result+'Regular attributes: ';
if A.IsReadOnly then T:=T+'Read Only,';
if A.IsHidden then T:=T+'Hidden,';
if A.IsSystem then T:=T+'System file,';
T:=LeftStr(T,Length(T)-1);
Result:=Result+T+#13+#10;
- Result:=Result+'Last modification: '+FormatDateTime(LongDateFormat+' '+LongTimeFormat,A.LastModification)+#13+#10;
+ Result:=Result+'Last modification: '+FormatDateTime(fs.LongDateFormat+' '+fs.LongTimeFormat,A.LastModification)+#13+#10;
end;
function TVirtualLayer_Item.GetAttributes: TVirtualLayer_CustomAttributes;
diff --git a/components/fpspreadsheet/wikitable.pas b/components/fpspreadsheet/wikitable.pas
index f550fbe37..4bacb3a4b 100644
--- a/components/fpspreadsheet/wikitable.pas
+++ b/components/fpspreadsheet/wikitable.pas
@@ -30,7 +30,7 @@ interface
uses
Classes, SysUtils,
fpimage, fgl,
- fpspreadsheet, xlscommon, fpsutils, lconvencoding;
+ fpspreadsheet, fpsutils, lconvencoding;
type
@@ -378,7 +378,6 @@ procedure TsWikiTableWriter.WriteToStrings_WikiMedia(AStrings: TStrings);
var
i, j: Integer;
lCurStr: string = '';
- lCurCell: PCell;
lCurUsedFormatting: TsUsedFormattingFields;
lCurColor: TsColor;
lColorStr: String;
diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas
index a427ef944..deec829dc 100755
--- a/components/fpspreadsheet/xlsbiff2.pas
+++ b/components/fpspreadsheet/xlsbiff2.pas
@@ -42,11 +42,11 @@ type
TsBIFF2NumFormatList = class(TsCustomNumFormatList)
protected
procedure AddBuiltinFormats; override;
+ public
+ constructor Create(AWorkbook: TsWorkbook);
procedure ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat); override;
function FindFormatOf(AFormatCell: PCell): Integer; override;
- public
- constructor Create(AWorkbook: TsWorkbook);
end;
{ TsSpreadBIFF2Reader }
@@ -56,7 +56,6 @@ type
WorkBookEncoding: TsEncoding;
FWorksheet: TsWorksheet;
FFont: TsFont;
- FFmtIndex: Integer;
protected
procedure ApplyCellFormatting(ARow, ACol: Cardinal; XFIndex: Word); override;
procedure CreateNumFormatList; override;
@@ -177,9 +176,10 @@ end;
procedure TsBIFF2NumFormatList.AddBuiltinFormats;
var
fs: TFormatSettings;
- ds, ts, cs: string;
+ cs: string;
begin
fs := FWorkbook.FormatSettings;
+ cs := fs.CurrencyString;
AddFormat( 0, '', nfGeneral);
AddFormat( 1, '0', nfFixed);
AddFormat( 2, '0.00', nfFixed);
@@ -210,7 +210,6 @@ end;
procedure TsBIFF2NumFormatList.ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat);
var
- fmt: String;
parser: TsNumFormatParser;
begin
if AFormatString = '' then
@@ -230,7 +229,6 @@ end;
function TsBIFF2NumFormatList.FindFormatOf(AFormatCell: PCell): Integer;
var
- fmt: String;
parser: TsNumFormatParser;
decs: Integer;
dt: string;
@@ -273,7 +271,6 @@ procedure TsSpreadBIFF2Reader.ApplyCellFormatting(ARow, ACol: Cardinal;
var
lCell: PCell;
xfData: TXFListData;
- style: Byte;
begin
lCell := FWorksheet.GetCell(ARow, ACol);
@@ -467,13 +464,11 @@ var
ARow, ACol: Cardinal;
XF: Word;
ok: Boolean;
- formulaResult: Double;
+ formulaResult: Double = 0.0;
// rpnFormula: TsRPNFormula;
Data: array [0..7] of byte;
dt: TDateTime;
nf: TsNumberFormat;
- nd: Byte;
- ncs: String;
nfs: String;
err: TsErrorValue;
cell: PCell;
@@ -573,11 +568,9 @@ procedure TsSpreadBIFF2Reader.ReadNumber(AStream: TStream);
var
ARow, ACol: Cardinal;
XF: Word;
- value: Double;
+ value: Double = 0.0;
dt: TDateTime;
nf: TsNumberFormat;
- nd: Byte;
- ncs: String;
nfs: String;
begin
{ BIFF Record row/column/style }
@@ -601,7 +594,7 @@ procedure TsSpreadBIFF2Reader.ReadInteger(AStream: TStream);
var
ARow, ACol: Cardinal;
XF: Word;
- AWord : Word;
+ AWord : Word = 0;
begin
{ BIFF Record row/column/style }
ReadRowColXF(AStream, ARow, ACol, XF);
@@ -699,12 +692,10 @@ end;
"show sheet headers", "panes are frozen", etc. }
procedure TsSpreadBIFF2Reader.ReadWindow2(AStream: TStream);
var
- b: byte;
- w: Word;
rgb: DWord;
begin
// Show formulas, not results
- b := AStream.ReadByte;
+ AStream.ReadByte;
// Show grid lines
if AStream.ReadByte <> 0 then
@@ -725,16 +716,16 @@ begin
FWorksheet.Options := FWorksheet.Options - [soHasFrozenPanes];
// Show zero values
- b := AStream.ReadByte;
+ AStream.ReadByte;
// Index to first visible row
- w := WordLEToN(AStream.ReadWord);
+ WordLEToN(AStream.ReadWord);
// Indoex to first visible column
- w := WordLEToN(AStream.ReadWord);
+ WordLEToN(AStream.ReadWord);
// Use automatic grid line color (0= manual)
- b := AStream.ReadByte;
+ AStream.ReadByte;
// Manual grid line line color (rgb)
rgb := DWordToLE(AStream.ReadDWord);
@@ -869,8 +860,6 @@ procedure TsSpreadBIFF2Writer.WriteCellFormatting(AStream: TStream; ACell: PCell
XFIndex: Word);
var
b: Byte;
- xf: Word;
- i: Integer;
begin
if ACell^.UsedFormattingFields = [] then
begin
@@ -1096,7 +1085,6 @@ var
lBorders: TsCellBorders;
lAddBackground: Boolean;
lHorAlign: TsHorAlignment;
- fmt: String;
begin
// The loop starts with the first style added manually.
// First style was already added (see AddDefaultFormats)
diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas
index 824798539..b33c46255 100755
--- a/components/fpspreadsheet/xlsbiff5.pas
+++ b/components/fpspreadsheet/xlsbiff5.pas
@@ -1022,9 +1022,6 @@ var
optns: Word;
b: Byte;
dw1, dw2: DWord;
- XFOptions: Word;
- XFAlignment: byte;
- XFBorderDWord1, XFBorderDWord2: DWord;
begin
{ BIFF Record header }
AStream.WriteWord(WordToLE(INT_EXCEL_ID_XF));
@@ -1098,7 +1095,6 @@ var
lHorAlign: TsHorAlignment;
lVertAlign: TsVertAlignment;
lWordWrap: Boolean;
- fmt: String;
begin
// The first style was already added
for i := 1 to Length(FFormattingStyles) - 1 do begin
diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas
index 92bd4e5b2..fc12e36f8 100755
--- a/components/fpspreadsheet/xlsbiff8.pas
+++ b/components/fpspreadsheet/xlsbiff8.pas
@@ -85,10 +85,10 @@ type
procedure ReadLabelSST(const AStream: TStream);
// procedure ReadNumber() --> xlscommon
procedure ReadRichString(const AStream: TStream);
- procedure ReadRPNCellAddress(AStream: TStream; var ARow, ACol: Cardinal;
- var AFlags: TsRelFlags); override;
+ procedure ReadRPNCellAddress(AStream: TStream; out ARow, ACol: Cardinal;
+ out AFlags: TsRelFlags); override;
procedure ReadRPNCellRangeAddress(AStream: TStream;
- var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags); override;
+ out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags); override;
procedure ReadSST(const AStream: TStream);
function ReadString_8bitLen(AStream: TStream): String; override;
procedure ReadStringRecord(AStream: TStream); override;
@@ -294,7 +294,6 @@ var
lHorAlign: TsHorAlignment;
lVertAlign: TsVertAlignment;
lWordWrap: Boolean;
- fmt: String;
begin
// The first style was already added --> begin loop with 1
for i := 1 to Length(FFormattingStyles) - 1 do begin
@@ -389,12 +388,10 @@ procedure TsSpreadBIFF8Writer.WriteToStream(AStream: TStream);
const
isBIFF8 = true;
var
- MyData: TMemoryStream;
CurrentPos: Int64;
Boundsheets: array of Int64;
sheet: TsWorksheet;
- i, j, len: Integer;
- col: PCol;
+ i, len: Integer;
begin
{ Write workbook globals }
@@ -1382,7 +1379,6 @@ function TsSpreadBIFF8Reader.ReadWideString(const AStream: TStream;
const AUse8BitLength: Boolean): WideString;
var
Len: Word;
- WideName: WideString;
begin
if AUse8BitLength then
Len := AStream.ReadByte()
@@ -1606,11 +1602,9 @@ end;
procedure TsSpreadBIFF8Reader.ReadLabel(AStream: TStream);
var
L: Word;
- StringFlags: BYTE;
ARow, ACol: Cardinal;
XF: Word;
WideStrValue: WideString;
- AnsiStrValue: AnsiString;
begin
{ BIFF Record data: Row, Column, XF Index }
ReadRowColXF(AStream, ARow, ACol, XF);
@@ -1659,7 +1653,7 @@ end;
bits to distinguish between absolute and relative addresses.
Overriding the implementation in xlscommon. }
procedure TsSpreadBIFF8Reader.ReadRPNCellAddress(AStream: TStream;
- var ARow, ACol: Cardinal; var AFlags: TsRelFlags);
+ out ARow, ACol: Cardinal; out AFlags: TsRelFlags);
var
c: word;
begin
@@ -1680,7 +1674,7 @@ end;
relative addresses.
Overriding the implementation in xlscommon. }
procedure TsSpreadBIFF8Reader.ReadRPNCellRangeAddress(AStream: TStream;
- var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags);
+ out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags);
var
c1, c2: word;
begin
@@ -1922,7 +1916,6 @@ var
lColor: Word;
lWeight: Word;
Len: Byte;
- lFontName: UTF8String;
font: TsFont;
begin
font := TsFont.Create;
diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas
index bfcd614fe..5e648a058 100644
--- a/components/fpspreadsheet/xlscommon.pas
+++ b/components/fpspreadsheet/xlscommon.pas
@@ -357,9 +357,9 @@ type
TsBIFFNumFormatList = class(TsCustomNumFormatList)
protected
procedure AddBuiltinFormats; override;
+ public
procedure ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat); override;
- public
end;
{ TsSpreadBIFFReader }
@@ -385,7 +385,7 @@ type
function FindNumFormatDataForCell(const AXFIndex: Integer): TsNumFormatData;
// Tries to find if a number cell is actually a date/datetime/time cell and retrieves the value
function IsDateTime(Number: Double; ANumberFormat: TsNumberFormat;
- ANumberFormatStr: String; var ADateTime: TDateTime): Boolean;
+ ANumberFormatStr: String; out ADateTime: TDateTime): Boolean;
// Here we can add reading of records which didn't change across BIFF5-8 versions
procedure ReadCodePage(AStream: TStream);
// Read column info
@@ -413,10 +413,10 @@ type
// Read row info
procedure ReadRowInfo(AStream: TStream); virtual;
// Read the array of RPN tokens of a formula
- procedure ReadRPNCellAddress(AStream: TStream; var ARow, ACol: Cardinal;
- var AFlags: TsRelFlags); virtual;
+ procedure ReadRPNCellAddress(AStream: TStream; out ARow, ACol: Cardinal;
+ out AFlags: TsRelFlags); virtual;
procedure ReadRPNCellRangeAddress(AStream: TStream;
- var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags); virtual;
+ out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags); virtual;
function ReadRPNFunc(AStream: TStream): Word; virtual;
function ReadRPNTokenArray(AStream: TStream; var AFormula: TsRPNFormula): Boolean;
function ReadRPNTokenArraySize(AStream: TStream): word; virtual;
@@ -437,8 +437,8 @@ type
TsSpreadBIFFWriter = class(TsCustomSpreadWriter)
protected
FDateMode: TDateMode;
- FLastRow: Integer;
- FLastCol: Word;
+ FLastRow: Cardinal;
+ FLastCol: Cardinal;
procedure AddDefaultFormats; override;
procedure CreateNumFormatList; override;
procedure GetLastRowCallback(ACell: PCell; AStream: TStream);
@@ -494,7 +494,7 @@ type
implementation
uses
- StrUtils, fpsNumFormatParser;
+ fpsNumFormatParser;
{ Helper table for rpn formulas:
Assignment of FormulaElementKinds (fekXXXX) to EXCEL_TOKEN IDs. }
@@ -762,7 +762,6 @@ procedure TsBIFFNumFormatList.ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat);
var
parser: TsNumFormatParser;
- fmt: String;
begin
parser := TsNumFormatParser.Create(Workbook, AFormatString, ANumFormat);
try
@@ -852,9 +851,6 @@ end;
formats.
Valid for BIFF5.BIFF8. Needs to be overridden for BIFF2. }
procedure TsSpreadBIFFReader.CreateNumFormatList;
-var
- i: Integer;
- item: TsNumFormatData;
begin
FreeAndNil(FNumFormatList);
FNumFormatList := TsBIFFNumFormatList.Create(Workbook);
@@ -927,7 +923,7 @@ end;
{ Convert the number to a date/time and return that if it is }
function TsSpreadBIFFReader.IsDateTime(Number: Double;
ANumberFormat: TsNumberFormat; ANumberFormatStr: String;
- var ADateTime: TDateTime): boolean;
+ out ADateTime: TDateTime): boolean;
var
parser: TsNumFormatParser;
begin
@@ -1064,16 +1060,12 @@ procedure TsSpreadBIFFReader.ReadFormula(AStream: TStream);
var
ARow, ACol: Cardinal;
XF: WORD;
- ResultFormula: Double;
+ ResultFormula: Double = 0.0;
Data: array [0..7] of byte;
Flags: WORD;
- i: Integer;
dt: TDateTime;
nf: TsNumberFormat;
- nd: Byte;
- ncs: String;
nfs: String;
- resultStr: String;
err: TsErrorValue;
ok: Boolean;
cell: PCell;
@@ -1178,9 +1170,7 @@ var
pending: integer;
RK: DWORD;
nf: TsNumberFormat;
- nd: Byte;
nfs: String;
- ncs: String;
begin
ARow := WordLEtoN(AStream.ReadWord);
fc := WordLEtoN(AStream.ReadWord);
@@ -1213,12 +1203,10 @@ procedure TsSpreadBIFFReader.ReadNumber(AStream: TStream);
var
ARow, ACol: Cardinal;
XF: WORD;
- value: Double;
+ value: Double = 0.0;
dt: TDateTime;
nf: TsNumberFormat;
- nd: Byte;
nfs: String;
- ncs: String;
begin
ReadRowColXF(AStream, ARow, ACol, XF);
@@ -1370,7 +1358,7 @@ end;
bits to distinguish between absolute and relative addresses.
Implemented here for BIFF2-BIFF5. BIFF8 must be overridden. }
procedure TsSpreadBIFFReader.ReadRPNCellAddress(AStream: TStream;
- var ARow, ACol: Cardinal; var AFlags: TsRelFlags);
+ out ARow, ACol: Cardinal; out AFlags: TsRelFlags);
var
r: word;
begin
@@ -1390,7 +1378,7 @@ end;
bits to distinguish between absolute and relative addresses.
Implemented here for BIFF2-BIFF5. BIFF8 must be overridden. }
procedure TsSpreadBIFFReader.ReadRPNCellRangeAddress(AStream: TStream;
- var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags);
+ out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags);
var
r1, r2: word;
begin
@@ -1426,8 +1414,7 @@ var
token: Byte;
rpnItem: PRPNItem;
supported: boolean;
- wordVal: Word; // 2 byte unsigned integer
- dblVal: Double; // IEEE 8 byte floating point number
+ dblVal: Double = 0.0; // IEEE 8 byte floating point number
flags: TsRelFlags;
r, c, r2, c2: Cardinal;
fek: TFEKind;