From 6beb21eab91e11a8b8ad59d71414516dcfb333a2 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 23 Oct 2023 15:24:11 +0000 Subject: [PATCH] fpspreadsheet: Add missing fpspreadsheet_chart.inc git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8974 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/common/fpspreadsheet_chart.inc | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 components/fpspreadsheet/source/common/fpspreadsheet_chart.inc diff --git a/components/fpspreadsheet/source/common/fpspreadsheet_chart.inc b/components/fpspreadsheet/source/common/fpspreadsheet_chart.inc new file mode 100644 index 000000000..6e3a2a673 --- /dev/null +++ b/components/fpspreadsheet/source/common/fpspreadsheet_chart.inc @@ -0,0 +1,45 @@ +{ Included by fpspreadsheet.pas } + +{ Chart support } + +{@@ ---------------------------------------------------------------------------- + Creates a chart object with its top/left corner in the specified row/colum and + having the specified width (in workbook units). + Inserts the chart in the FCharts list of the workbook and returns the chart + instance. +-------------------------------------------------------------------------------} +function TsWorkbook.AddChart(ASheet: TsBasicWorksheet; ARow, ACol: Cardinal; + AWidth, AHeight: Double; AOffsetX: Double = 0.0; AOffsetY: Double = 0.0): TsChart; +begin + Result := TsChart.Create; + if (ASheet = nil) then + raise Exception.Create('To do: Insert chart as new ChartSheet'); + Result.SheetIndex := GetWorksheetIndex(ASheet); + Result.Row := ARow; + Result.Col := ACol; + Result.OffsetX := AOffsetX; + Result.OffsetY := AOffsetY; + Result.Width := AWidth; + Result.Height := AHeight; + Result.Index := FCharts.Add(Result); +end; + +{@@ ---------------------------------------------------------------------------- + Returns the chart having the given index in the worksheet's chart list +-------------------------------------------------------------------------------} +function TsWorkbook.GetChartByIndex(AIndex: Integer): TsChart; +begin + if (AIndex >= 0) and (AIndex < FCharts.Count) then + Result := FCharts[AIndex] + else + Result := nil; +end; + +{@@ ---------------------------------------------------------------------------- + Returns the number of charts embedded on this sheet +-------------------------------------------------------------------------------} +function TsWorkbook.GetChartCount: Integer; +begin + Result := FCharts.Count; +end; +