From 940295ae28c5ef2ee76fc4b238f84f87bc6bf131 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 29 Nov 2023 16:47:46 +0000 Subject: [PATCH] fpspreadsheet: Fix border when drawing data point marks. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9060 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../visual/fpschart/fpschartlink/main.lfm | 1 + .../source/common/fpsopendocumentchart.pas | 50 +++++++++---------- .../source/visual/fpspreadsheetchart.pas | 2 +- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm b/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm index 46e6786c4..914abd04e 100644 --- a/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm +++ b/components/fpspreadsheet/examples/visual/fpschart/fpschartlink/main.lfm @@ -24,6 +24,7 @@ object Form1: TForm1 AutoAdvance = aaDown DefaultColWidth = 64 DefaultRowHeight = 22 + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll] TabOrder = 0 end object Splitter1: TSplitter diff --git a/components/fpspreadsheet/source/common/fpsopendocumentchart.pas b/components/fpspreadsheet/source/common/fpsopendocumentchart.pas index 02a0df967..585c44e3d 100644 --- a/components/fpspreadsheet/source/common/fpsopendocumentchart.pas +++ b/components/fpspreadsheet/source/common/fpsopendocumentchart.pas @@ -28,6 +28,7 @@ type function FindStyleNode(AStyleNodes: TDOMNode; AStyleName: String): TDOMNode; procedure GetChartFillProps(ANode: TDOMNode; AChart: TsChart; AFill: TsChartFill); procedure GetChartLineProps(ANode: TDOMNode; AChart: TsChart; ALine: TsChartLine); + procedure GetChartTextProps(ANode: TDOMNode; AFont: TsFont); procedure ReadChartAxisGrid(ANode, AStyleNode: TDOMNode; AChart: TsChart; Axis: TsChartAxis); procedure ReadChartAxisProps(ANode, AStyleNode: TDOMNode; AChart: TsChart); @@ -146,6 +147,8 @@ const OPENDOC_PATH_CHART_CONTENT = 'Object %d/content.xml'; OPENDOC_PATH_CHART_STYLES = 'Object %d/styles.xml'; + DEFAULT_FONT_NAME = 'Liberation Sans'; + CHART_TYPE_NAMES: array[TsChartType] of string = ( '', 'bar', 'line', 'area', 'barLine', 'scatter', 'bubble', 'radar', 'filled-radar', 'circle', 'ring' @@ -519,25 +522,13 @@ begin ALine.Transparency := 1.0 - value*0.01; end; - (* -function TsSpreadOpenDocChartWriter.GetChartBackgroundStyleAsXML( - AChart: TsChart; AFill: TsChartFill; ABorder: TsChartLine; - AIndent, AStyleID: Integer): String; -var - indent: String; - fillStr: String = ''; - borderStr: String = ''; +procedure TsSpreadOpenDocChartReader.GetChartTextProps(ANode: TDOMNode; + AFont: TsFont); begin - fillStr := GetChartFillStyleGraphicPropsAsXML(AChart, AFill); - borderStr := GetChartLineStyleGraphicPropsAsXML(AChart, ABorder); - indent := DupeString(' ', AIndent); - Result := Format( - indent + '' + LE + - indent + ' ' + LE + - indent + '' + LE, - [ AStyleID, fillStr, borderStr ] - ); -end; *) + TsSpreadOpenDocReader(Reader).ReadFont(ANode, AFont); + if AFont.FontName = '' then + AFont.FontName := DEFAULT_FONT_NAME; +end; procedure TsSpreadOpenDocChartReader.ReadChart(AChartNode, AStyleNode: TDOMNode; AChart: TsChart); @@ -692,7 +683,7 @@ begin nodeName := AStyleNode.NodeName; case nodeName of 'style:text-properties': - TsSpreadOpenDocReader(Reader).ReadFont(AStyleNode, Axis.LabelFont); + GetChartTextProps(AStyleNode, Axis.LabelFont); 'style:graphic-properties': GetChartLineProps(AStyleNode, AChart, Axis.AxisLine); 'style:chart-properties': @@ -1051,7 +1042,7 @@ begin GetChartFillProps(AStyleNode, AChart, AChart.Legend.Background); end; 'style:text-properties': - TsSpreadOpenDocReader(Reader).ReadFont(AStyleNode, AChart.Legend.Font); + GetChartTextProps(AStyleNode, AChart.Legend.Font); end; AStyleNode := AStyleNode.NextSibling; end; @@ -1087,7 +1078,7 @@ begin GetChartFillProps(AStyleNode, AChart, series.Regression.Equation.Fill); end; 'style:text-properties': - odsReader.ReadFont(AStyleNode, series.Regression.Equation.Font); + GetChartTextProps(AStyleNode, series.Regression.Equation.Font); 'style:chart-properties': begin s := GetAttrValue(AStyleNode, 'loext:regression-x-name'); @@ -1286,6 +1277,10 @@ var dataLabels: TsChartDataLabels = []; childNode1, childNode2, childNode3: TDOMNode; begin + // Defaults + ASeries.LabelBorder.Style := clsNoLine; + ASeries.LabelBackground.Style := cfsNoFill; + nodeName := AStyleNode.NodeName; s := GetAttrValue(AStyleNode, 'style:data-style-name'); if s <> '' then @@ -1304,7 +1299,7 @@ begin GetChartFillProps(AStyleNode, AChart, ASeries.Fill); end; 'style:text-properties': - TsSpreadOpenDocReader(Reader).ReadFont(AStyleNode, ASeries.LabelFont); + GetChartTextProps(AStyleNode, ASeries.LabelFont); 'style:chart-properties': begin s := GetAttrValue(AStyleNode, 'chart:label-position'); @@ -1318,10 +1313,11 @@ begin if s <> '' then ASeries.LabelBorder.Color := HTMLColorStrToColor(s); s := GetAttrValue(AStyleNode, 'loext:label-stroke'); - case s of - 'none': ASeries.LabelBorder.Style := clsNoLine; - else ASeries.LabelBorder.Style := clsSolid; - end; + if s <> '' then + case s of + 'none': ASeries.LabelBorder.Style := clsNoLine; + else ASeries.LabelBorder.Style := clsSolid; + end; s := GetAttrValue(AStyleNode, 'chart:data-label-number'); if s <> '' then @@ -1480,7 +1476,7 @@ begin GetChartFillProps(AStyleNode, AChart, ATitle.Background); end; 'style:text-properties': - TsSpreadOpenDocReader(Reader).ReadFont(AStyleNode, ATitle.Font); + GetChartTextProps(AStyleNode, ATitle.Font); end; AStyleNode := AStyleNode.NextSibling; end; diff --git a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas index 7180550d7..49b928cb9 100644 --- a/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas +++ b/components/fpspreadsheet/source/visual/fpspreadsheetchart.pas @@ -1906,7 +1906,7 @@ begin TextFormat(tfHtml). Get; if AWorkbookSeries.Regression.DisplayRSquare then - s := s + LineEnding + 'R² = ' + FormatFloat('0.00', ser.FitStatistics.R2); + s := s + LineEnding + 'R2 = ' + FormatFloat('0.00', ser.FitStatistics.R2); if s <> '' then ser.Title := ser.Title + LineEnding + s; // ser.Legend.Format := '%0:s' + LineEnding + '%2:s';