You've already forked lazarus-ccr
fpspreadsheet: Beginning to generalize writing of rpn formulas for biff
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3264 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -125,6 +125,7 @@ type
|
|||||||
const AValue: string; ACell: PCell); override;
|
const AValue: string; ACell: PCell); override;
|
||||||
procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal;
|
procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Cardinal;
|
||||||
const AFormula: TsRPNFormula; ACell: PCell); override;
|
const AFormula: TsRPNFormula; ACell: PCell); override;
|
||||||
|
function WriteString_8bitLen(AStream: TStream; AString: String): Integer; override;
|
||||||
procedure WriteStringRecord(AStream: TStream; AString: string);
|
procedure WriteStringRecord(AStream: TStream; AString: string);
|
||||||
procedure WriteStyle(AStream: TStream);
|
procedure WriteStyle(AStream: TStream);
|
||||||
procedure WriteWindow2(AStream: TStream; ASheet: TsWorksheet);
|
procedure WriteWindow2(AStream: TStream; ASheet: TsWorksheet);
|
||||||
@@ -927,12 +928,16 @@ begin
|
|||||||
INT_EXCEL_TOKEN_TSTR: { fekString }
|
INT_EXCEL_TOKEN_TSTR: { fekString }
|
||||||
begin
|
begin
|
||||||
// string constant is stored as widestring in BIFF8
|
// string constant is stored as widestring in BIFF8
|
||||||
|
// Writing is done by the virtual method WriteString_8bitLen.
|
||||||
|
Inc(RPNLength, WriteString_8bitLen(AStream, AFormula[i].StringValue));
|
||||||
|
{
|
||||||
wideStr := UTF8Decode(AFormula[i].StringValue);
|
wideStr := UTF8Decode(AFormula[i].StringValue);
|
||||||
len := Length(wideStr);
|
len := Length(wideStr);
|
||||||
AStream.WriteByte(len); // char count in 1 byte
|
AStream.WriteByte(len); // char count in 1 byte
|
||||||
AStream.WriteByte(1); // Widestring flags, 1=regular unicode LE string
|
AStream.WriteByte(1); // Widestring flags, 1=regular unicode LE string
|
||||||
AStream.WriteBuffer(WideStringToLE(wideStr)[1], len * Sizeof(WideChar));
|
AStream.WriteBuffer(WideStringToLE(wideStr)[1], len * Sizeof(WideChar));
|
||||||
Inc(RPNLength, 1 + 1 + len*SizeOf(WideChar));
|
Inc(RPNLength, 1 + 1 + len*SizeOf(WideChar));
|
||||||
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
INT_EXCEL_TOKEN_TBOOL: { fekBool }
|
INT_EXCEL_TOKEN_TBOOL: { fekBool }
|
||||||
@@ -990,6 +995,24 @@ begin
|
|||||||
WriteStringRecord(AStream, ACell^.UTF8StringValue);
|
WriteStringRecord(AStream, ACell^.UTF8StringValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ Helper function for writing a string with 8-bit length. Overridden version
|
||||||
|
for BIFF8. Called for writing rpn formula string tokens.
|
||||||
|
Returns the count of bytes written}
|
||||||
|
function TsSpreadBIFF8Writer.WriteString_8BitLen(AStream: TStream;
|
||||||
|
AString: String): Integer;
|
||||||
|
var
|
||||||
|
len: Integer;
|
||||||
|
wideStr: WideString;
|
||||||
|
begin
|
||||||
|
// string constant is stored as widestring in BIFF8
|
||||||
|
wideStr := UTF8Decode(AString);
|
||||||
|
len := Length(wideStr);
|
||||||
|
AStream.WriteByte(len); // char count in 1 byte
|
||||||
|
AStream.WriteByte(1); // Widestring flags, 1=regular unicode LE string
|
||||||
|
AStream.WriteBuffer(WideStringToLE(wideStr)[1], len * Sizeof(WideChar));
|
||||||
|
Result := 1 + 1 + len * SizeOf(WideChar);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsSpreadBIFF8Writer.WriteStringRecord(AStream: TStream;
|
procedure TsSpreadBIFF8Writer.WriteStringRecord(AStream: TStream;
|
||||||
AString: String);
|
AString: String);
|
||||||
var
|
var
|
||||||
|
@@ -448,6 +448,8 @@ type
|
|||||||
procedure GetLastColCallback(ACell: PCell; AStream: TStream);
|
procedure GetLastColCallback(ACell: PCell; AStream: TStream);
|
||||||
function GetLastColIndex(AWorksheet: TsWorksheet): Word;
|
function GetLastColIndex(AWorksheet: TsWorksheet): Word;
|
||||||
function FormulaElementKindToExcelTokenID(AElementKind: TFEKind; out ASecondaryID: Word): Word;
|
function FormulaElementKindToExcelTokenID(AElementKind: TFEKind; out ASecondaryID: Word): Word;
|
||||||
|
// Helper function for writing a string with 8-bit length }
|
||||||
|
function WriteString_8BitLen(AStream: TStream; AString: String): Integer; virtual;
|
||||||
|
|
||||||
// Write out BLANK cell record
|
// Write out BLANK cell record
|
||||||
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal;
|
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal;
|
||||||
@@ -2141,6 +2143,23 @@ begin
|
|||||||
AStream.WriteWord(WordToLE(flags));
|
AStream.WriteWord(WordToLE(flags));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ Helper function for writing a string with 8-bit length. Here, we implement the
|
||||||
|
version for ansistrings since it is valid for all BIFF versions except BIFF8
|
||||||
|
where it has to overridden. Is called for writing a string rpn token.
|
||||||
|
Returns the count of bytes written. }
|
||||||
|
function TsSpreadBIFFWriter.WriteString_8bitLen(AStream: TStream;
|
||||||
|
AString: String): Integer;
|
||||||
|
var
|
||||||
|
len: Byte;
|
||||||
|
s: ansistring;
|
||||||
|
begin
|
||||||
|
s := AString;
|
||||||
|
len := Length(s);
|
||||||
|
AStream.WriteByte(len);
|
||||||
|
AStream.WriteBuffer(s[1], len);
|
||||||
|
Result := 1 + len;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Writes an Excel 5/8 WINDOW1 record
|
{ Writes an Excel 5/8 WINDOW1 record
|
||||||
This record contains general settings for the document window and
|
This record contains general settings for the document window and
|
||||||
global workbook settings.
|
global workbook settings.
|
||||||
|
Reference in New Issue
Block a user