fpspreadsheet: Fix xlsx chart reader sometimes ignoring colors.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9203 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-02-03 10:17:21 +00:00
parent 9137a34697
commit 289d74c7bb
2 changed files with 57 additions and 47 deletions

View File

@ -2,6 +2,11 @@
<CONFIG> <CONFIG>
<ProjectGroup FileVersion="2"> <ProjectGroup FileVersion="2">
<Targets> <Targets>
<Target FileName="areachart_write_demo.lpi">
<BuildModes>
<Mode Name="Default"/>
</BuildModes>
</Target>
<Target FileName="barchart_write_demo.lpi"> <Target FileName="barchart_write_demo.lpi">
<BuildModes> <BuildModes>
<Mode Name="Default"/> <Mode Name="Default"/>

View File

@ -211,7 +211,7 @@ function HTMLColorStr(AValue: TsColor): string;
var var
rgb: TRGBA absolute AValue; rgb: TRGBA absolute AValue;
begin begin
Result := Lowercase(Format('%.2x%.2x%.2x', [rgb.r, rgb.g, rgb.b])); Result := Format('%.2x%.2x%.2x', [rgb.r, rgb.g, rgb.b]);
end; end;
@ -587,62 +587,63 @@ var
n: Integer; n: Integer;
child: TDOMNode; child: TDOMNode;
begin begin
if ANode = nil then while Assigned(ANode) do
exit; begin
nodeName := ANode.NodeName;
nodeName := ANode.NodeName; case nodeName of
case nodeName of 'a:schemeClr':
'a:schemeClr':
begin
s := GetAttrValue(ANode, 'val');
if (s <> '') then
begin begin
idx := FColors.IndexOf(ColorAlias(s)); s := GetAttrValue(ANode, 'val');
if idx > -1 then if (s <> '') then
begin begin
AColor := FColors.Data[idx]; idx := FColors.IndexOf(ColorAlias(s));
child := ANode.FirstChild; if idx > -1 then
while Assigned(child) do
begin begin
nodeName := child.NodeName; AColor := FColors.Data[idx];
s := GetAttrValue(child, 'val'); child := ANode.FirstChild;
case nodeName of while Assigned(child) do
'a:tint': begin
if TryStrToInt(s, n) then nodeName := child.NodeName;
AColor := TintedColor(AColor, n/FACTOR_MULTIPLIER); s := GetAttrValue(child, 'val');
'a:lumMod': // luminance modulated case nodeName of
if TryStrToInt(s, n) then 'a:tint':
AColor := LumModColor(AColor, n/FACTOR_MULTIPLIER); if TryStrToInt(s, n) then
'a:lumOff': AColor := TintedColor(AColor, n/FACTOR_MULTIPLIER);
if TryStrToInt(s, n) then 'a:lumMod': // luminance modulated
AColor := LumOffsetColor(AColor, n/FACTOR_MULTIPLIER); if TryStrToInt(s, n) then
'a:alpha': AColor := LumModColor(AColor, n/FACTOR_MULTIPLIER);
if TryStrToInt(s, n) then 'a:lumOff':
Alpha := n / 100000; if TryStrToInt(s, n) then
AColor := LumOffsetColor(AColor, n/FACTOR_MULTIPLIER);
'a:alpha':
if TryStrToInt(s, n) then
Alpha := n / 100000;
end;
child := child.NextSibling;
end; end;
child := child.NextSibling;
end; end;
end; end;
end; end;
end; 'a:srgbClr':
'a:srgbClr':
begin
s := GetAttrValue(ANode, 'val');
if s <> '' then
AColor := HTMLColorStrToColor(s);
child := ANode.FirstChild;
while Assigned(child) do
begin begin
nodeName := child.NodeName; s := GetAttrValue(ANode, 'val');
s := GetAttrValue(child, 'val'); if s <> '' then
case nodeName of AColor := HTMLColorStrToColor(s);
'a:alpha': child := ANode.FirstChild;
if TryStrToInt(s, n) then while Assigned(child) do
Alpha := n / FACTOR_MULTIPLIER; begin
nodeName := child.NodeName;
s := GetAttrValue(child, 'val');
case nodeName of
'a:alpha':
if TryStrToInt(s, n) then
Alpha := n / FACTOR_MULTIPLIER;
end;
child := child.NextSibling;
end; end;
child := child.NextSibling;
end; end;
end; end;
ANode := ANode.NextSibling;
end; end;
end; end;
@ -3235,12 +3236,16 @@ begin
Result := Format( Result := Format(
indent + '<%0:s sz="%d" spc="-1" %s%s%s%s>' + LE + indent + '<%0:s sz="%d" spc="-1" %s%s%s%s>' + LE +
indent + ' <a:solidFill>' + LE +
indent + ' <a:srgbClr val="%s"/>' + LE +
indent + ' </a:solidFill>' + LE +
indent + ' <a:latin typeface="%s"/>' + LE + indent + ' <a:latin typeface="%s"/>' + LE +
indent + '</%0:s>', indent + '</%0:s>',
[ [
ANodeName, ANodeName,
round(AFont.Size * 100), round(AFont.Size * 100),
bold, italic, strike, underline, bold, italic, strike, underline,
HTMLColorStr(AFont.Color),
fontName fontName
] ]
); );