fpspreadsheet: Move "AddDefaultFormats" to xlscommon. No regression.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2989 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-02 19:02:24 +00:00
parent 1676d31702
commit 3eac7b8066
4 changed files with 24 additions and 50 deletions

View File

@ -89,7 +89,6 @@ type
procedure WriteXFFieldsForFormattingStyles(AStream: TStream); procedure WriteXFFieldsForFormattingStyles(AStream: TStream);
procedure WriteXFRecords(AStream: TStream); procedure WriteXFRecords(AStream: TStream);
protected protected
procedure AddDefaultFormats(); override;
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override; procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override;
procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); override; procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); override;
procedure WriteLabel(AStream: TStream; const ARow, ACol: Cardinal; const AValue: string; ACell: PCell); override; procedure WriteLabel(AStream: TStream; const ARow, ACol: Cardinal; const AValue: string; ACell: PCell); override;
@ -642,20 +641,6 @@ end;
{ TsSpreadBIFF2Writer } { TsSpreadBIFF2Writer }
procedure TsSpreadBIFF2Writer.AddDefaultFormats();
begin
NextXFIndex := 16; //21;
SetLength(FFormattingStyles, 1);
// XF0..XF14: Normal style, Row Outline level 1..7,
// Column Outline level 1..7.
// XF15 - Default cell format, no formatting (4.6.2)
FFormattingStyles[0].UsedFormattingFields := [];
FFormattingStyles[0].Row := 15;
end;
function TsSpreadBIFF2Writer.FindXFIndex(ACell: PCell): Word; function TsSpreadBIFF2Writer.FindXFIndex(ACell: PCell): Word;
var var
i: Integer; i: Integer;
@ -830,7 +815,8 @@ var
lHorAlign: TsHorAlignment; lHorAlign: TsHorAlignment;
fmt: String; fmt: String;
begin begin
// The first style was already added (see AddDefaultFormats) // The loop starts with the first style added manually.
// First style was already added (see AddDefaultFormats)
for i := 1 to Length(FFormattingStyles) - 1 do begin for i := 1 to Length(FFormattingStyles) - 1 do begin
// Default styles // Default styles
lFontIndex := 0; lFontIndex := 0;

View File

@ -108,7 +108,6 @@ type
private private
WorkBookEncoding: TsEncoding; WorkBookEncoding: TsEncoding;
protected protected
procedure AddDefaultFormats; override;
{ Record writing methods } { Record writing methods }
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal;
ACell: PCell); override; ACell: PCell); override;
@ -332,20 +331,6 @@ const
{ TsSpreadBIFF5Writer } { TsSpreadBIFF5Writer }
procedure TsSpreadBIFF5Writer.AddDefaultFormats();
begin
NextXFIndex := 16;
SetLength(FFormattingStyles, 1);
// XF0..XF14: Normal style, Row Outline level 1..7,
// Column Outline level 1..7.
// XF15 - Default cell format, no formatting (4.6.2)
FFormattingStyles[0].UsedFormattingFields := [];
FFormattingStyles[0].Row := 15;
end;
{******************************************************************* {*******************************************************************
* TsSpreadBIFF5Writer.WriteToFile () * TsSpreadBIFF5Writer.WriteToFile ()
* *

View File

@ -110,7 +110,6 @@ type
procedure WriteXFIndex(AStream: TStream; ACell: PCell); procedure WriteXFIndex(AStream: TStream; ACell: PCell);
procedure WriteXFFieldsForFormattingStyles(AStream: TStream); procedure WriteXFFieldsForFormattingStyles(AStream: TStream);
protected protected
procedure AddDefaultFormats(); override;
{ Record writing methods } { Record writing methods }
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal;
ACell: PCell); override; ACell: PCell); override;
@ -473,24 +472,6 @@ begin
end; end;
end; end;
{@@
These are default style formats which are added as XF fields regardless of being used
in the document or not.
}
procedure TsSpreadBIFF8Writer.AddDefaultFormats();
begin
NextXFIndex := 16;
SetLength(FFormattingStyles, 1);
// XF0..XF14: Normal style, Row Outline level 1..7,
// Column Outline level 1..7.
// XF15 - Default cell format, no formatting (4.6.2)
FFormattingStyles[0].UsedFormattingFields := [];
FFormattingStyles[0].Row := 15;
end;
{******************************************************************* {*******************************************************************
* TsSpreadBIFF8Writer.WriteToFile () * TsSpreadBIFF8Writer.WriteToFile ()
* *

View File

@ -364,6 +364,7 @@ type
FDateMode: TDateMode; FDateMode: TDateMode;
FLastRow: Integer; FLastRow: Integer;
FLastCol: Word; FLastCol: Word;
procedure AddDefaultFormats; override;
procedure GetLastRowCallback(ACell: PCell; AStream: TStream); procedure GetLastRowCallback(ACell: PCell; AStream: TStream);
function GetLastRowIndex(AWorksheet: TsWorksheet): Integer; function GetLastRowIndex(AWorksheet: TsWorksheet): Integer;
procedure GetLastColCallback(ACell: PCell; AStream: TStream); procedure GetLastColCallback(ACell: PCell; AStream: TStream);
@ -865,6 +866,27 @@ begin
inherited Destroy; inherited Destroy;
end; end;
{ These are default style formats which are added as XF fields regardless of
being used in the document or not.
Currently, only one additional default format is supported ("bold").
Here are the changes to be made when extending this list:
- SetLength(FFormattingstyles, <number of predefined styles>)
}
procedure TsSpreadBIFFWriter.AddDefaultFormats();
begin
SetLength(FFormattingStyles, 1);
// XF0..XF14: Normal style, Row Outline level 1..7,
// Column Outline level 1..7.
// XF15 - Default cell format, no formatting (4.6.2)
FFormattingStyles[0].UsedFormattingFields := [];
FFormattingStyles[0].Row := 15;
NextXFIndex := 15 + Length(FFormattingStyles);
// "15" is the index of the last pre-defined xf record
end;
function TsSpreadBIFFWriter.FormulaElementKindToExcelTokenID( function TsSpreadBIFFWriter.FormulaElementKindToExcelTokenID(
AElementKind: TFEKind; out ASecondaryID: Word): Word; AElementKind: TFEKind; out ASecondaryID: Word): Word;
const const