fpspreadsheet: Make unit fpsnumformat.pas independent of fpspreadsheet.pas

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4169 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-05-31 16:41:34 +00:00
parent 750a0c68f5
commit a63c9ad4a5
2 changed files with 13 additions and 10 deletions

View File

@ -8,7 +8,7 @@ interface
uses uses
Classes, SysUtils, Classes, SysUtils,
fpstypes, fpspreadsheet; fpstypes;
type type
{ TsNumFormatList } { TsNumFormatList }
@ -19,11 +19,11 @@ type
function GetItem(AIndex: Integer): TsNumFormatParams; function GetItem(AIndex: Integer): TsNumFormatParams;
procedure SetItem(AIndex: Integer; const AValue: TsNumFormatParams); procedure SetItem(AIndex: Integer; const AValue: TsNumFormatParams);
protected protected
FWorkbook: TsWorkbook; FFormatSettings: TFormatSettings;
FClass: TsNumFormatParamsClass; FClass: TsNumFormatParamsClass;
procedure AddBuiltinFormats; virtual; procedure AddBuiltinFormats; virtual;
public public
constructor Create(AWorkbook: TsWorkbook; AOwnsData: Boolean); constructor Create(AFormatSettings: TFormatSettings; AOwnsData: Boolean);
destructor Destroy; override; destructor Destroy; override;
function AddFormat(ASections: TsNumFormatSections): Integer; overload; function AddFormat(ASections: TsNumFormatSections): Integer; overload;
function AddFormat(AFormatStr: String): Integer; overload; function AddFormat(AFormatStr: String): Integer; overload;
@ -35,7 +35,7 @@ type
{@@ Workbook from which the number formats are collected in the list. It is {@@ Workbook from which the number formats are collected in the list. It is
mainly needed to get access to the FormatSettings for easy localization of mainly needed to get access to the FormatSettings for easy localization of
some formatting strings. } some formatting strings. }
property Workbook: TsWorkbook read FWorkbook; // property Workbook: TsWorkbook read FWorkbook;
end; end;
@ -216,13 +216,16 @@ begin
end; end;
{ -----------------------------------------------------------------------------}
{ TsNumFormatList } { TsNumFormatList }
{ -----------------------------------------------------------------------------}
constructor TsNumFormatList.Create(AWorkbook: TsWorkbook; AOwnsData: Boolean); constructor TsNumFormatList.Create(AFormatSettings: TFormatSettings;
AOwnsData: Boolean);
begin begin
inherited Create; inherited Create;
FClass := TsNumFormatParams; FClass := TsNumFormatParams;
FWorkbook := AWorkbook; FFormatSettings := AFormatSettings;
FOwnsData := AOwnsData; FOwnsData := AOwnsData;
end; end;
@ -250,7 +253,7 @@ var
newSections: TsNumFormatSections; newSections: TsNumFormatSections;
i: Integer; i: Integer;
begin begin
parser := TsNumFormatParser.Create(AFormatStr, FWorkbook.FormatSettings); parser := TsNumFormatParser.Create(AFormatStr, FFormatSettings);
try try
SetLength(newSections, parser.ParsedSectionCount); SetLength(newSections, parser.ParsedSectionCount);
for i:=0 to High(newSections) do for i:=0 to High(newSections) do
@ -301,7 +304,7 @@ function TsNumFormatList.Find(AFormatStr: String): Integer;
var var
nfp: TsNumFormatParams; nfp: TsNumFormatParams;
begin begin
nfp := CreateNumFormatParams(AFormatStr, FWorkbook.FormatSettings); nfp := CreateNumFormatParams(AFormatStr, FFormatSettings);
if nfp = nil then if nfp = nil then
Result := -1 Result := -1
else else

View File

@ -6092,7 +6092,7 @@ begin
SetDefaultFont(DEFAULT_FONTNAME, DEFAULT_FONTSIZE); SetDefaultFont(DEFAULT_FONTNAME, DEFAULT_FONTSIZE);
InitFonts; InitFonts;
FNumFormatList := TsNumFormatList.Create(self, true); FNumFormatList := TsNumFormatList.Create(FormatSettings, true);
FCellFormatList := TsCellFormatList.Create(false); FCellFormatList := TsCellFormatList.Create(false);
// Add default cell format // Add default cell format