You've already forked lazarus-ccr
fpspreadsheet: Fix Excel readers updating the workbook's default font.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5838 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -513,6 +513,7 @@ var
|
||||
lOptions: Word;
|
||||
Len: Byte;
|
||||
lFontName: UTF8String;
|
||||
isDefaultFont: Boolean;
|
||||
begin
|
||||
FFont := TsFont.Create;
|
||||
|
||||
@ -534,8 +535,13 @@ begin
|
||||
AStream.ReadBuffer(lFontName[1], Len);
|
||||
FFont.FontName := lFontName;
|
||||
|
||||
isDefaultFont := FFontList.Count = 0;
|
||||
|
||||
{ Add font to internal font list }
|
||||
FFontList.Add(FFont);
|
||||
|
||||
if isDefaultFont then
|
||||
Workbook.SetDefaultFont(FFont.FontName, FFont.Size);
|
||||
end;
|
||||
|
||||
procedure TsSpreadBIFF2Reader.ReadFONTCOLOR(AStream: TStream);
|
||||
|
@ -961,6 +961,7 @@ var
|
||||
Len: Byte;
|
||||
fontname: ansistring;
|
||||
font: TsFont;
|
||||
isDefaultFont: Boolean;
|
||||
begin
|
||||
font := TsFont.Create;
|
||||
|
||||
@ -1025,6 +1026,8 @@ begin
|
||||
AStream.ReadBuffer(fontname[1], Len);
|
||||
font.FontName := ConvertEncoding(fontname, FCodePage, encodingUTF8);
|
||||
|
||||
isDefaultFont := FFontList.Count = 0;
|
||||
|
||||
{ Add font to internal font list. Will be copied to workbook's font list later
|
||||
as the font index in the internal list may be different from the index in
|
||||
the workbook's list. }
|
||||
@ -1032,6 +1035,9 @@ begin
|
||||
|
||||
{ Excel does not have zero-based font #4! }
|
||||
if FFontList.Count = 4 then FFontList.Add(nil);
|
||||
|
||||
if isDefaultFont then
|
||||
FWorkbook.SetDefaultFont(font.FontName, font.Size);
|
||||
end;
|
||||
|
||||
// Read the FORMAT record for formatting numerical data
|
||||
|
@ -1792,6 +1792,7 @@ var
|
||||
Len: Byte;
|
||||
font: TsFont;
|
||||
rtParams: TsRichTextParams;
|
||||
isDefaultFont: Boolean;
|
||||
begin
|
||||
font := TsFont.Create;
|
||||
|
||||
@ -1849,6 +1850,8 @@ begin
|
||||
Len := AStream.ReadByte();
|
||||
font.FontName := ReadString(AStream, Len, rtParams); // rtParams is not used here.
|
||||
|
||||
isDefaultFont := FFontList.Count = 0;
|
||||
|
||||
{ Add font to internal font list; will be transferred to workbook later because
|
||||
the font index in the internal list (= index in file) is not the same as the
|
||||
index the font will have in the workbook's fontlist! }
|
||||
@ -1856,6 +1859,9 @@ begin
|
||||
|
||||
{ Excel does not have zero-based font #4! }
|
||||
if FFontList.Count = 4 then FFontList.Add(nil);
|
||||
|
||||
if isDefaultFont then
|
||||
Workbook.SetDefaultFont(font.FontName, font.Size);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
@ -1392,7 +1392,10 @@ var
|
||||
nodename: String;
|
||||
s: String;
|
||||
acceptDuplicates: Boolean;
|
||||
isDefaultFont: Boolean;
|
||||
begin
|
||||
isDefaultFont := FFontList.Count = 0;
|
||||
|
||||
fnt := Workbook.GetDefaultFont;
|
||||
if fnt <> nil then
|
||||
begin
|
||||
@ -1497,6 +1500,9 @@ begin
|
||||
fnt.Position := fntPos;
|
||||
|
||||
Result := FFontList.Add(fnt);
|
||||
|
||||
if isDefaultFont then
|
||||
Workbook.SetDefaultFont(fnt.FontName, fnt.Size);
|
||||
end;
|
||||
|
||||
procedure TsSpreadOOXMLReader.ReadFonts(ANode: TDOMNode);
|
||||
|
Reference in New Issue
Block a user