You've already forked lazarus-ccr
fpspreadsheet: Prevent biff2 writing formulas containing fekCellOffset tokens (needed for shared formulas which are not supported by biff2 internally).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3495 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1074,7 +1074,7 @@ type
|
||||
procedure FixCellColors(ACell: PCell);
|
||||
function FixColor(AColor: TsColor): TsColor; virtual;
|
||||
procedure FixFormat(ACell: PCell); virtual;
|
||||
procedure FixRelativeReferences(ACell: PCell; var AElement: TsFormulaElement);
|
||||
procedure FixRelativeReferences(ACell: PCell; var AElement: TsFormulaElement); virtual;
|
||||
procedure GetSheetDimensions(AWorksheet: TsWorksheet;
|
||||
out AFirstRow, ALastRow, AFirstCol, ALastCol: Cardinal); virtual;
|
||||
procedure ListAllFormattingStylesCallback(ACell: PCell; AStream: TStream);
|
||||
|
@ -112,6 +112,7 @@ type
|
||||
procedure WriteXFRecords(AStream: TStream);
|
||||
protected
|
||||
procedure CreateNumFormatList; override;
|
||||
procedure FixRelativeReferences(ACell: PCell; var AElement: TsFormulaElement); override;
|
||||
procedure ListAllNumFormats; override;
|
||||
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override;
|
||||
procedure WriteFormat(AStream: TStream; AFormatData: TsNumFormatData;
|
||||
@ -992,6 +993,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Since BIFF2 does not support shared formulas it cannot handle the fekCellOffset
|
||||
token. It is replaced by a fekCellValue token and correct relative references. }
|
||||
procedure TsSpreadBIFF2Writer.FixRelativeReferences(ACell: PCell;
|
||||
var AElement: TsFormulaElement);
|
||||
begin
|
||||
inherited FixRelativeReferences(ACell, AElement);
|
||||
|
||||
if (ACell = nil) or (ACell^.SharedFormulaBase = nil) then
|
||||
exit;
|
||||
|
||||
if AElement.ElementKind = fekCellOffset then
|
||||
begin
|
||||
AElement.ElementKind := fekCell;
|
||||
if (rfRelRow in AElement.RelFlags) then
|
||||
AElement.Row := Integer(ACell^.Row) + Integer(AElement.Row); // AElement.Row means here: "RowOffsset"
|
||||
if (rfRelCol in AElement.RelFlags) then
|
||||
AElement.Col := Integer(ACell^.Col) + Integer(AElement.Col); // AElement.Col means here: "ColOffsset"
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Determines the cell attributes needed for writing a cell content record, such
|
||||
as WriteLabel, WriteNumber, etc.
|
||||
The cell attributes contain, in bit masks, xf record index, font index, borders, etc.}
|
||||
|
@ -1607,7 +1607,7 @@ begin
|
||||
end;
|
||||
|
||||
{ Reads the identifier for an RPN function with fixed argument count.
|
||||
Valid for BIFF4-BIFF8. Override in BIFF2-BIFF3 }
|
||||
Valid for BIFF4-BIFF8. Override in BIFF2-BIFF3 which read 1 byte only. }
|
||||
function TsSpreadBIFFReader.ReadRPNFunc(AStream: TStream): Word;
|
||||
begin
|
||||
Result := WordLEToN(AStream.ReadWord);
|
||||
|
Reference in New Issue
Block a user