diff --git a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas index c5383658f..0aefda234 100644 --- a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas +++ b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas @@ -81,6 +81,8 @@ type FPointSeparatorSettings: TFormatSettings; FAxisID: array[TsChartAxisAlignment] of DWord; function GetChartFillAndLineXML(AIndent: Integer; AFill: TsChartFill; ALine: TsChartLine): String; + function GetChartFillXML(AIndent: Integer; AFill: TsChartFill): String; + function GetChartLineXML(AIndent: Integer; ALine: TsChartLine): String; function GetChartRangeXML(AIndent: Integer; ARange: TsChartRange): String; protected @@ -185,6 +187,15 @@ type end; +function HTMLColorStr(AValue: TsColor): string; +var + rgb: TRGBA absolute AValue; +begin + Result := Lowercase(Format('%.2x%.2x%.2x', [rgb.r, rgb.g, rgb.b])); +end; + + + { TsSpreadOOXMLChartReader } constructor TsSpreadOOXMLChartReader.Create(AReader: TsBasicSpreadReader); @@ -3121,21 +3132,74 @@ begin ); end; +{@@ ---------------------------------------------------------------------------- + Assembles the xml string for the children of a node (fill and line style) +-------------------------------------------------------------------------------} function TsSpreadOOXMLChartWriter.GetChartFillAndLineXML(AIndent: Integer; AFill: TsChartFill; ALine: TsChartLine): String; -var - ind: String; begin - ind := DupeString(' ', AIndent); - Result := - ind + '' + LE + - ind + ' ' + LE + - ind + ' ' + LE + - ind + ' ' + LE + - ind + ' ' + LE + - ind + ' '+ LE + - ind + '' + LE + GetChartFillXML(AIndent, AFill) + LE + + GetChartLineXML(AIndent, ALine); + // indent + ''; +end; + +function TsSpreadOOXMLChartWriter.GetChartFillXML(AIndent: Integer; + AFill: TsChartFill): String; +var + indent: String; +begin + indent := DupeString(' ', AIndent); + + if (AFill = nil) or (AFill.Style = cfsNoFill) then + Result := indent + '' + else + case AFill.Style of + cfsSolid: + Result := Format( + indent + '' + LE + + indent + ' ' + LE + + indent + '', + [ HtmlColorStr(AFill.Color) ] + ); + else + Result := indent + ''; + end; +end; + +function TsSpreadOOXMLChartWriter.GetChartLineXML(AIndent: Integer; + ALine: TsChartline): String; +var + indent: String; + noLine: Boolean; +begin + indent := DupeString(' ', AIndent); + + if (ALine <> nil) and (ALine.Style <> clsNoLine) then + Result := Format('', [ALine.Width * PTS_MULTIPLIER]) + else + Result := ''; + Result := indent + Result; + + noLine := false; + if (ALine <> nil) then + begin + if ALine.Style = clsSolid then + Result := Result + LE + Format( + indent + ' ' + LE + + indent + ' ' + LE + + indent + ' ' + LE + + indent + ' ', + [ HtmlColorStr(ALine.Color) ] + ) + else + noLine := true; + end; + + if noLine then + Result := Result + indent + ' '; + + Result := Result + indent + ''; end; function TsSpreadOOXMLChartWriter.GetChartRangeXML(AIndent: Integer; @@ -3322,11 +3386,14 @@ begin indent + ' ' + LE + indent + ' ' + LE + indent + ' ' + LE + + indent + ' ' + LE + + GetChartFillAndLineXML(AIndent + 8, ASeries.Fill, ASeries.Line) + LE + + indent + ' ' + LE + indent + ' ' + LE + - indent + ' ' + GetChartRangeXML(AIndent + 8, ASeries.XRange) + LE + + GetChartRangeXML(AIndent + 8, ASeries.XRange) + LE + indent + ' ' + LE + indent + ' ' + LE + - indent + ' ' + GetChartRangeXML(AIndent + 8, ASeries.YRange) + LE + + GetChartRangeXML(AIndent + 8, ASeries.YRange) + LE + indent + ' ' + LE + indent + ' ' + LE + indent + ' ' + LE +