You've already forked lazarus-ccr
fpspreadsheet: HTML reader supports <font> and <span> tags
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4259 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -458,8 +458,9 @@ var
|
|||||||
f: Double;
|
f: Double;
|
||||||
defFntSize: Single;
|
defFntSize: Single;
|
||||||
begin
|
begin
|
||||||
// style tags
|
idx := FAttrList.IndexOfName('font-family'); // style tag
|
||||||
idx := FAttrList.IndexOfName('font-family');
|
if idx = -1 then
|
||||||
|
idx := FAttrList.IndexOfName('face'); // html tag
|
||||||
if idx > -1 then begin
|
if idx > -1 then begin
|
||||||
L := TStringList.Create;
|
L := TStringList.Create;
|
||||||
try
|
try
|
||||||
@ -472,6 +473,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
idx := FAttrList.IndexOfName('font-size');
|
idx := FAttrList.IndexOfName('font-size');
|
||||||
|
if idx = -1 then
|
||||||
|
idx := FAttrList.IndexOfName('size');
|
||||||
if idx > -1 then begin
|
if idx > -1 then begin
|
||||||
defFntSize := FWorkbook.GetDefaultFont.Size;
|
defFntSize := FWorkbook.GetDefaultFont.Size;
|
||||||
s := FAttrList[idx].Value;
|
s := FAttrList[idx].Value;
|
||||||
@ -710,7 +713,7 @@ begin
|
|||||||
ReadHorAlign;
|
ReadHorAlign;
|
||||||
ReadVertAlign;
|
ReadVertAlign;
|
||||||
ReadFont(FCellFont);
|
ReadFont(FCellFont);
|
||||||
if NoCaseTag[3] = 'H' then begin
|
if NoCaseTag[3] = 'H' then begin // for <TH>
|
||||||
Include(FCellFont.Style, fssBold);
|
Include(FCellFont.Style, fssBold);
|
||||||
FCurrCellFormat.HorAlignment := haCenter;
|
FCurrCellFormat.HorAlignment := haCenter;
|
||||||
Include(FCurrCellFormat.UsedFormattingFields, uffHorAlign);
|
Include(FCurrCellFormat.UsedFormattingFields, uffHorAlign);
|
||||||
@ -782,8 +785,19 @@ begin
|
|||||||
FCurrFont.Position := fpNormal else
|
FCurrFont.Position := fpNormal else
|
||||||
FCurrFont.Position := fpSuperscript;
|
FCurrFont.Position := fpSuperscript;
|
||||||
AddRichTextParam(FCurrFont);
|
AddRichTextParam(FCurrFont);
|
||||||
end
|
end else
|
||||||
else
|
if (pos('<FONT ', NoCaseTag) = 1) then
|
||||||
|
begin
|
||||||
|
FAttrList.Parse(ActualTag);
|
||||||
|
ReadFont(FCurrFont);
|
||||||
|
AddRichTextparam(FCurrFont);
|
||||||
|
end else
|
||||||
|
if (pos('<SPAN ', NoCaseTag) = 1) then
|
||||||
|
begin
|
||||||
|
FAttrList.Parse(ActualTag);
|
||||||
|
ReadFont(FCurrFont);
|
||||||
|
AddRichTextParam(FCurrFont);
|
||||||
|
end else
|
||||||
if ((NoCaseTag = '<BR>') or (pos('<BR ', NoCaseTag) = 1)) then
|
if ((NoCaseTag = '<BR>') or (pos('<BR ', NoCaseTag) = 1)) then
|
||||||
FCellText := FCellText + LineEnding;
|
FCellText := FCellText + LineEnding;
|
||||||
(*
|
(*
|
||||||
|
@ -521,19 +521,18 @@ begin
|
|||||||
begin
|
begin
|
||||||
case AStyle[i] of
|
case AStyle[i] of
|
||||||
':': begin // name-value separator
|
':': begin // name-value separator
|
||||||
inc(i); // skip ':'
|
inc(i); // skip ':' ...
|
||||||
while (i <= len) and (AStyle[i] = ' ') do inc(i); // skip white space
|
while (i <= len) and (AStyle[i] = ' ') do inc(i); // ... and white space
|
||||||
value := '';
|
value := '';
|
||||||
while (i <= len) and (AStyle[i] <> ';') do
|
while (i <= len) and (AStyle[i] <> ';') do
|
||||||
begin
|
begin
|
||||||
value := value + AStyle[i];
|
value := value + AStyle[i];
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
// inc(i); // skip final ';'
|
|
||||||
Add(TsHTMLAttr.Create(lowercase(trim(nam)), UnquoteStr(trim(value))));
|
Add(TsHTMLAttr.Create(lowercase(trim(nam)), UnquoteStr(trim(value))));
|
||||||
nam := '';
|
nam := '';
|
||||||
end;
|
end;
|
||||||
' ': ;
|
' ': ; // skip white space
|
||||||
else nam := nam + AStyle[i];
|
else nam := nam + AStyle[i];
|
||||||
end;
|
end;
|
||||||
inc(i);
|
inc(i);
|
||||||
|
Reference in New Issue
Block a user