fpspreadsheet: Remove deprecated TsWorksheetChartSource.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9033 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2023-11-21 11:16:16 +00:00
parent 9ff480ce60
commit f6d1cde434
11 changed files with 1 additions and 607 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

View File

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<VersionInfo>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T &apos;Lazarus Run Output&apos; -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default">
<local>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T &apos;Lazarus Run Output&apos; -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</Mode0>
</Modes>
</RunParams>
<RequiredPackages Count="4">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
</Item1>
<Item2>
<PackageName Value="TAChartLazarusPkg"/>
<MinVersion Major="1" Valid="True"/>
</Item2>
<Item3>
<PackageName Value="laz_fpspreadsheet_visual"/>
</Item3>
<Item4>
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="fpschart.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="mainform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="FPSChartForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="fpschart"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -1,21 +0,0 @@
program fpschart;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, tachartlazaruspkg, mainform, laz_fpspreadsheet_visual,
laz_fpspreadsheet;
{$R *.res}
begin
Application.Title:='';
Application.Initialize;
Application.CreateForm(TFPSChartForm, FPSChartForm);
Application.Run;
end.

View File

@ -1,192 +0,0 @@
object FPSChartForm: TFPSChartForm
Left = 259
Height = 382
Top = 146
Width = 697
Caption = 'FPSpreadsheet Chart Example'
ClientHeight = 382
ClientWidth = 697
OnCreate = FormCreate
LCLVersion = '1.7'
object MyChart: TChart
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = editXAxis
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 352
Height = 263
Top = 111
Width = 337
AxisList = <
item
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
Marks.LabelFont.Orientation = 900
Marks.Format = '%2:s'
Marks.Source = FPSChartSource
Marks.Style = smsLabel
Minors = <>
end>
BackColor = clWhite
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'TAChart'
)
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
object MyChartBarSeries1: TBarSeries
BarBrush.Color = clRed
Source = FPSChartSource
end
end
object WorksheetGrid: TsWorksheetGrid
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = editXAxis
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel1
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 263
Top = 111
Width = 336
FrozenCols = 0
FrozenRows = 0
ReadFormulas = False
TextOverflow = True
WorkbookSource = WorksheetGrid.internal
Anchors = [akTop, akLeft, akRight, akBottom]
AutoAdvance = aaDown
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
ColCount = 27
DefaultColWidth = 64
DefaultRowHeight = 22
ExtendedSelect = False
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goThumbTracking]
RowCount = 101
TabOrder = 1
end
object btnCreateGraphic: TButton
Left = 464
Height = 25
Top = 48
Width = 128
Caption = 'Create Graphic'
OnClick = btnCreateGraphicClick
TabOrder = 2
end
object Label1: TLabel
Left = 14
Height = 42
Top = 4
Width = 678
Anchors = [akTop, akLeft, akRight]
AutoSize = False
Caption = 'Please add data to the grid or load it from a file, then choose the location of the data for the X and Y axises and click on the button "Create Graphic" to generate a chart.'
ParentColor = False
WordWrap = True
end
object editSourceFile: TFileNameEdit
Left = 152
Height = 23
Top = 48
Width = 136
FileName = 't1.xls'
DialogOptions = []
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
MaxLength = 0
TabOrder = 3
Text = 't1.xls'
end
object Label2: TLabel
Left = 14
Height = 15
Top = 51
Width = 106
Caption = 'Source Spreadsheet:'
ParentColor = False
end
object btnLoadSpreadsheet: TButton
Left = 320
Height = 25
Top = 48
Width = 75
Caption = 'Load'
OnClick = btnLoadSpreadsheetClick
TabOrder = 4
end
object editXAxis: TLabeledEdit
Left = 64
Height = 23
Top = 80
Width = 80
EditLabel.AnchorSideTop.Control = editXAxis
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = editXAxis
EditLabel.AnchorSideBottom.Control = editXAxis
EditLabel.AnchorSideBottom.Side = asrBottom
EditLabel.Left = 25
EditLabel.Height = 15
EditLabel.Top = 84
EditLabel.Width = 36
EditLabel.Caption = 'X-Axis:'
EditLabel.ParentColor = False
LabelPosition = lpLeft
TabOrder = 5
Text = 'A3:A14'
end
object EditYAxis: TLabeledEdit
Left = 208
Height = 23
Top = 80
Width = 80
EditLabel.AnchorSideTop.Control = EditYAxis
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = EditYAxis
EditLabel.AnchorSideBottom.Control = EditYAxis
EditLabel.AnchorSideBottom.Side = asrBottom
EditLabel.Left = 169
EditLabel.Height = 15
EditLabel.Top = 84
EditLabel.Width = 36
EditLabel.Caption = 'Y-Axis:'
EditLabel.ParentColor = False
LabelPosition = lpLeft
TabOrder = 6
Text = 'B3:B14'
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
Left = 344
Height = 50
Top = 83
Width = 8
Shape = bsSpacer
end
object FPSChartSource: TsWorksheetChartSource
PointsNumber = 5
YFirstCellCol = 1
XSelectionDirection = fpsVerticalSelection
YSelectionDirection = fpsVerticalSelection
left = 512
top = 200
end
end

View File

@ -1,75 +0,0 @@
unit mainform;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, EditBtn, ExtCtrls,
fpspreadsheetchart, fpspreadsheetgrid,
TAGraph, TASeries;
type
{ TFPSChartForm }
TFPSChartForm = class(TForm)
Bevel1: TBevel;
btnCreateGraphic: TButton;
btnLoadSpreadsheet: TButton;
editSourceFile: TFileNameEdit;
Label1: TLabel;
Label2: TLabel;
editXAxis: TLabeledEdit;
EditYAxis: TLabeledEdit;
MyChart: TChart;
FPSChartSource: TsWorksheetChartSource;
MyChartBarSeries1: TBarSeries;
WorksheetGrid: TsWorksheetGrid;
procedure btnCreateGraphicClick(Sender: TObject);
procedure btnLoadSpreadsheetClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
FPSChartForm: TFPSChartForm;
implementation
uses
// FPSpreadsheet and supported formats
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument;
{$R *.lfm}
{ TFPSChartForm }
procedure TFPSChartForm.btnCreateGraphicClick(Sender: TObject);
begin
FPSChartSource.LoadPropertiesFromStrings(editXAxis.Text, editYAxis.Text, '', '', '');
FPSChartSource.LoadFromWorksheetGrid(WorksheetGrid);
end;
procedure TFPSChartForm.btnLoadSpreadsheetClick(Sender: TObject);
begin
WorksheetGrid.LoadFromSpreadsheetFile(editSourceFile.Text);
end;
procedure TFPSChartForm.FormCreate(Sender: TObject);
begin
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
// Property Text is not published in older versions of Lazarus
editSourceFile.Text := 't1.xls';
end;
initialization
// Property Text is not published in older versions of Lazarus
RegisterPropertyToSkip(TFileNameEdit, 'Text', 'Not used in Laz 1.0', '');
end.

View File

@ -1,2 +0,0 @@
This demo shows usage of the TsWorksheetChartSource component for
creating charts from spreadsheet data.

View File

@ -36,7 +36,6 @@ begin
]);
RegisterComponents('Chart', [
TsWorksheetChartSource,
TsWorkbookChartSource
]);

View File

@ -33,50 +33,6 @@ type
The data can be loaded from a TsWorksheetGrid Grid component or
directly from a TsWorksheet FPSpreadsheet Worksheet }
{ TsWorksheetChartSource }
{ DEPRECTATED - use TsWorkbookChartSource instead! }
TsWorksheetChartSource = class(TCustomChartSource)
private
FInternalWorksheet: TsWorksheet;
FPointsNumber: Integer;
FXSelectionDirection: TsSelectionDirection;
FYSelectionDirection: TsSelectionDirection;
FXFirstCellCol: Cardinal;
FXFirstCellRow: Cardinal;
FYFirstCellCol: Cardinal;
FYFirstCellRow: Cardinal;
procedure SetPointsNumber(const AValue: Integer);
procedure SetXSelectionDirection(const AValue: TsSelectionDirection);
procedure SetYSelectionDirection(const AValue: TsSelectionDirection);
procedure SetXFirstCellCol(const AValue: Cardinal);
procedure SetXFirstCellRow(const AValue: Cardinal);
procedure SetYFirstCellCol(const AValue: Cardinal);
procedure SetYFirstCellRow(const AValue: Cardinal);
protected
FDataWorksheet: TsWorksheet;
FCurItem: TChartDataItem;
function GetCount: Integer; override;
function GetItem(AIndex: Integer): PChartDataItem; override;
procedure SetYCount(AValue: Cardinal); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure LoadPropertiesFromStrings(AXInterval, AYInterval, AXTitle, AYTitle, ATitle: string);
public
procedure LoadFromWorksheetGrid(const AValue: TsWorksheetGrid);
published
property PointsNumber: Integer read FPointsNumber write SetPointsNumber default 0;
property XFirstCellCol: Cardinal read FXFirstCellCol write SetXFirstCellCol default 0;
property XFirstCellRow: Cardinal read FXFirstCellRow write SetXFirstCellRow default 0;
property YFirstCellCol: Cardinal read FYFirstCellCol write SetYFirstCellCol default 0;
property YFirstCellRow: Cardinal read FYFirstCellRow write SetYFirstCellRow default 0;
property XSelectionDirection: TsSelectionDirection read FXSelectionDirection write SetXSelectionDirection;
property YSelectionDirection: TsSelectionDirection read FYSelectionDirection write SetYSelectionDirection;
end deprecated 'Use TsWorkBOOKChartSource instead of TsWorkSHEETChartSource.';
{ TsWorkbookChartSource }
TsXYLRange = (rngX, rngY, rngLabel);
@ -122,183 +78,11 @@ type
end;
//procedure Register;
implementation
uses
Math;
{
procedure Register;
begin
RegisterComponents('Chart', [TsWorksheetChartSource, TsWorkbookChartSource]);
end;
}
{ TsWorksheetChartSource }
procedure TsWorksheetChartSource.SetPointsNumber(const AValue: Integer);
begin
if FPointsNumber = AValue then exit;
FPointsNumber := AValue;
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.SetXSelectionDirection(
const AValue: TsSelectionDirection);
begin
if FXSelectionDirection=AValue then exit;
FXSelectionDirection:=AValue;
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.SetYSelectionDirection(
const AValue: TsSelectionDirection);
begin
if FYSelectionDirection=AValue then exit;
FYSelectionDirection:=AValue;
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.SetXFirstCellCol(const AValue: Cardinal);
begin
if FXFirstCellCol=AValue then exit;
FXFirstCellCol:=AValue;
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.SetXFirstCellRow(const AValue: Cardinal);
begin
if FXFirstCellRow=AValue then exit;
FXFirstCellRow:=AValue;
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.SetYFirstCellCol(const AValue: Cardinal);
begin
if FYFirstCellCol=AValue then exit;
FYFirstCellCol:=AValue;
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.SetYFirstCellRow(const AValue: Cardinal);
begin
if FYFirstCellRow=AValue then exit;
FYFirstCellRow:=AValue;
InvalidateCaches;
Notify;
end;
function TsWorksheetChartSource.GetCount: Integer;
begin
Result := FPointsNumber;
end;
function TsWorksheetChartSource.GetItem(AIndex: Integer): PChartDataItem;
var
XRow, XCol, YRow, YCol: Integer;
cell: PCell;
begin
// First calculate the cell position
if XSelectionDirection = fpsVerticalSelection then
begin
XRow := Integer(FXFirstCellRow) + AIndex;
XCol := FXFirstCellCol;
end
else
begin
XRow := FXFirstCellRow;
XCol := Integer(FXFirstCellCol) + AIndex;
end;
if YSelectionDirection = fpsVerticalSelection then
begin
YRow := Integer(FYFirstCellRow) + AIndex;
YCol := FYFirstCellCol;
end
else
begin
YRow := FYFirstCellRow;
YCol := Integer(FYFirstCellCol) + AIndex;
end;
cell := FDataWorksheet.FindCell(XRow, XCol);
if cell = nil then
begin
FCurItem.X := NaN;
FCurITem.Text := '';
end else
if cell^.ContentType = cctUTF8String then begin
FCurItem.X := AIndex;
FCurItem.Text := FDataWorksheet.ReadAsText(cell);
end else
begin
FCurItem.X := FDataWorksheet.ReadAsNumber(cell);
FCurItem.Text := '';
end;
cell := FDataWorksheet.FindCell(YRow, YCol);
if cell = nil then
FCurItem.Y := NaN
else
FCurItem.Y := FDataWorksheet.ReadAsNumber(cell);
FCurItem.Color := clDefault;
Result := @FCurItem;
end;
constructor TsWorksheetChartSource.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FInternalWorksheet := TsWorksheet.Create;
FDataWorksheet := FInternalWorksheet;
end;
destructor TsWorksheetChartSource.Destroy;
begin
if FInternalWorksheet <> nil then FInternalWorksheet.Free;
inherited Destroy;
end;
procedure TsWorksheetChartSource.LoadFromWorksheetGrid(const AValue: TsWorksheetGrid);
begin
if AValue = nil then Exit;
FDataWorksheet := AValue.Worksheet;
// AValue.SaveToWorksheet(FDataWorksheet);
InvalidateCaches;
Notify;
end;
procedure TsWorksheetChartSource.LoadPropertiesFromStrings(AXInterval,
AYInterval, AXTitle, AYTitle, ATitle: string);
var
lXCount, lYCount: Cardinal;
begin
Unused(AXTitle, AYTitle, ATitle);
ParseIntervalString(AXInterval, FXFirstCellRow, FXFirstCellCol, lXCount, FXSelectionDirection);
ParseIntervalString(AYInterval, FYFirstCellRow, FYFirstCellCol, lYCount, FYSelectionDirection);
if lXCount <> lYCount then raise Exception.Create(
'TsWorksheetChartSource.LoadPropertiesFromStrings: Interval sizes don''t match');
FPointsNumber := lXCount;
end;
procedure TsWorksheetChartSource.SetYCount(AValue: Cardinal);
begin
FYCount := AValue;
end;
{------------------------------------------------------------------------------}
{ TsWorkbookChartSource }
{------------------------------------------------------------------------------}

View File

@ -1,5 +1,5 @@
{@@ ----------------------------------------------------------------------------
Unit fpspreadsheet implements a **grid** component which can load and
Unit fpSpreadsheetGrid implements a **grid** component which can load and
write data from/to FPSpreadsheet documents.
Can either be used alone or in combination with a TsWorkbookSource component.