home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd1.bin / zkuste / delphi / kolekce / d567 / FLEXCEL.ZIP / FlexCel / UFlexCelReportNoDB.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-10-03  |  3.4 KB  |  127 lines

  1. unit UFlexCelReportNoDB;
  2. interface
  3. {$R IFlexcelNoDB.res}
  4. uses
  5.   SysUtils, Classes, UCustomFlexCelReport, UXlsDB,
  6.   contnrs, 
  7.   {$IFDEF ConditionalExpressions}{$if CompilerVersion >= 14} variants,{$IFEND}{$ENDIF} //Delphi 6 or above
  8.   typinfo, UExcelAdapter, UFlxMessages, UFlxFullDataSets;
  9.  
  10. type
  11.   TFlexCelReportNoDB = class(TCustomFlexCelReport)
  12.   private
  13.     FDataModule: TComponent;
  14.     FPagesDataSet: TFlxDataSet; 
  15.  
  16.     procedure SetPagesDataSet(const Value: TFlxDataSet);
  17.     procedure SetDataModule(const Value: TComponent);
  18.  
  19.     { Private declarations }
  20.  
  21.   protected
  22.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  23.     function GetDataSet(const DataSetName: string): IXlsDataSet; override;
  24.     function GetPropertyInfo(const PropName: string): PPropInfo; override;
  25.     function GetVariantProperty(const PropInfo: PPropInfo): variant; override;
  26.     function GetPagesDataSet: IXlsDataSet; override;
  27.  
  28.     { Protected declarations }
  29.  
  30.   public
  31.     constructor Create(AOwner:TComponent);override;
  32.     destructor Destroy;override;
  33.  
  34.     function DesignDataModule: TComponent; override;
  35.     { Public declarations }
  36.  
  37.   published
  38.     property DataModule: TComponent read FDataModule write SetDataModule;
  39.     property PagesDataSet: TFlxDataSet read FPagesDataSet write SetPagesDataSet;
  40.  
  41.     { Published declarations }
  42.  
  43.   end;
  44.  
  45.   ClassOfTFlexCelReportNoDB= class of TFlexCelReportNoDB;
  46. procedure Register;
  47.  
  48. implementation
  49.  
  50. procedure Register;
  51. begin
  52.   RegisterComponents('FlexCel', [TFlexcelReportNoDB]);
  53. end;
  54.  
  55.  
  56. { TFlexCelReportNoDB }
  57.  
  58. constructor TFlexCelReportNoDB.Create(AOwner: TComponent);
  59. begin
  60.   inherited;
  61.   FDataModule:=AOwner;
  62. end;
  63.  
  64. destructor TFlexCelReportNoDB.Destroy;
  65. begin
  66.   inherited;
  67. end;
  68.  
  69. procedure TFlexCelReportNoDB.Notification(AComponent: TComponent; Operation: TOperation);
  70. begin
  71.   inherited Notification(AComponent, Operation);
  72.   if Operation = opRemove then
  73.   begin
  74.     if AComponent = FPagesDataSet then
  75.         FPagesDataSet:= nil;
  76.     if AComponent = FDataModule then
  77.         FDataModule:= Owner;
  78.   end;
  79. end;
  80.  
  81. procedure TFlexCelReportNoDB.SetPagesDataSet(const Value: TFlxDataSet);
  82. var
  83.   IDs: IXlsDataSet;
  84. begin
  85.   if (Value<>nil) then
  86.    if not Supports(Value, IXlsDataSet, IDs) then raise Exception.CreateFmt(ErrComponentIsNotXlsDataSet, [Value.Name]);
  87.   FPagesDataSet := Value;
  88. end;
  89.  
  90. procedure TFlexCelReportNoDB.SetDataModule(const Value: TComponent);
  91. begin
  92.   if Value=nil then FDataModule := Owner else FDataModule:=Value;
  93. end;
  94.  
  95. function TFlexCelReportNoDB.GetDataSet(const DataSetName: string): IXlsDataSet;
  96. var
  97.   Ds: TComponent;
  98. begin
  99.   Ds:=FDataModule.FindComponent(DataSetName);
  100.   if (Ds=nil) then Result:=nil else
  101.   if not Supports(Ds,IXlsDataSet, Result) then Result:=nil;
  102. end;
  103.  
  104. function TFlexCelReportNoDB.GetPropertyInfo(const PropName: string): PPropInfo;
  105. begin
  106.   Result:=GetPropInfo(FDataModule, PropName);
  107. end;
  108.  
  109. function TFlexCelReportNoDB.GetVariantProperty(
  110.   const PropInfo: PPropInfo): variant;
  111. begin
  112.   Result:=GetVariantProp(FDataModule, PropInfo);
  113. end;
  114.  
  115. function TFlexCelReportNoDB.GetPagesDataSet: IXlsDataSet;
  116. begin
  117.   if FPagesDataSet=nil then Result:=nil else
  118.     if not Supports(FPagesDataSet, IXlsDataSet, Result) then Result:=nil;
  119. end;
  120.  
  121. function TFlexCelReportNoDB.DesignDataModule: TComponent;
  122. begin
  123.   Result:=FDataModule;
  124. end;
  125.  
  126. end.
  127.