home *** CD-ROM | disk | FTP | other *** search
- unit UFlexCelReportNoDB;
- interface
- {$R IFlexcelNoDB.res}
- uses
- SysUtils, Classes, UCustomFlexCelReport, UXlsDB,
- contnrs,
- {$IFDEF ConditionalExpressions}{$if CompilerVersion >= 14} variants,{$IFEND}{$ENDIF} //Delphi 6 or above
- typinfo, UExcelAdapter, UFlxMessages, UFlxFullDataSets;
-
- type
- TFlexCelReportNoDB = class(TCustomFlexCelReport)
- private
- FDataModule: TComponent;
- FPagesDataSet: TFlxDataSet;
-
- procedure SetPagesDataSet(const Value: TFlxDataSet);
- procedure SetDataModule(const Value: TComponent);
-
- { Private declarations }
-
- protected
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- function GetDataSet(const DataSetName: string): IXlsDataSet; override;
- function GetPropertyInfo(const PropName: string): PPropInfo; override;
- function GetVariantProperty(const PropInfo: PPropInfo): variant; override;
- function GetPagesDataSet: IXlsDataSet; override;
-
- { Protected declarations }
-
- public
- constructor Create(AOwner:TComponent);override;
- destructor Destroy;override;
-
- function DesignDataModule: TComponent; override;
- { Public declarations }
-
- published
- property DataModule: TComponent read FDataModule write SetDataModule;
- property PagesDataSet: TFlxDataSet read FPagesDataSet write SetPagesDataSet;
-
- { Published declarations }
-
- end;
-
- ClassOfTFlexCelReportNoDB= class of TFlexCelReportNoDB;
- procedure Register;
-
- implementation
-
- procedure Register;
- begin
- RegisterComponents('FlexCel', [TFlexcelReportNoDB]);
- end;
-
-
- { TFlexCelReportNoDB }
-
- constructor TFlexCelReportNoDB.Create(AOwner: TComponent);
- begin
- inherited;
- FDataModule:=AOwner;
- end;
-
- destructor TFlexCelReportNoDB.Destroy;
- begin
- inherited;
- end;
-
- procedure TFlexCelReportNoDB.Notification(AComponent: TComponent; Operation: TOperation);
- begin
- inherited Notification(AComponent, Operation);
- if Operation = opRemove then
- begin
- if AComponent = FPagesDataSet then
- FPagesDataSet:= nil;
- if AComponent = FDataModule then
- FDataModule:= Owner;
- end;
- end;
-
- procedure TFlexCelReportNoDB.SetPagesDataSet(const Value: TFlxDataSet);
- var
- IDs: IXlsDataSet;
- begin
- if (Value<>nil) then
- if not Supports(Value, IXlsDataSet, IDs) then raise Exception.CreateFmt(ErrComponentIsNotXlsDataSet, [Value.Name]);
- FPagesDataSet := Value;
- end;
-
- procedure TFlexCelReportNoDB.SetDataModule(const Value: TComponent);
- begin
- if Value=nil then FDataModule := Owner else FDataModule:=Value;
- end;
-
- function TFlexCelReportNoDB.GetDataSet(const DataSetName: string): IXlsDataSet;
- var
- Ds: TComponent;
- begin
- Ds:=FDataModule.FindComponent(DataSetName);
- if (Ds=nil) then Result:=nil else
- if not Supports(Ds,IXlsDataSet, Result) then Result:=nil;
- end;
-
- function TFlexCelReportNoDB.GetPropertyInfo(const PropName: string): PPropInfo;
- begin
- Result:=GetPropInfo(FDataModule, PropName);
- end;
-
- function TFlexCelReportNoDB.GetVariantProperty(
- const PropInfo: PPropInfo): variant;
- begin
- Result:=GetVariantProp(FDataModule, PropInfo);
- end;
-
- function TFlexCelReportNoDB.GetPagesDataSet: IXlsDataSet;
- begin
- if FPagesDataSet=nil then Result:=nil else
- if not Supports(FPagesDataSet, IXlsDataSet, Result) then Result:=nil;
- end;
-
- function TFlexCelReportNoDB.DesignDataModule: TComponent;
- begin
- Result:=FDataModule;
- end;
-
- end.
-