cxgridexportlink.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,695 行 · 第 1/5 页
PAS
1,695 行
{*******************************************************************}
{ }
{ Developer Express Cross Platform Component Library }
{ ExpressQuantumGrid }
{ }
{ Copyright (c) 2001-2008 Developer Express Inc. }
{ ALL RIGHTS RESERVED }
{ }
{ The entire contents of this file is protected by U.S. and }
{ International Copyright Laws. Unauthorized reproduction, }
{ reverse-engineering, and distribution of all or any portion of }
{ the code contained in this file is strictly prohibited and may }
{ result in severe civil and criminal penalties and will be }
{ prosecuted to the maximum extent possible under the law. }
{ }
{ RESTRICTIONS }
{ }
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
{ LICENSED TO DISTRIBUTE THE EXPRESSQUANTUMGRID AND ALL }
{ ACCOMPANYING VCL AND CLX CONTROLS AS PART OF AN EXECUTABLE }
{ PROGRAM ONLY. }
{ }
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
{ }
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
{ ADDITIONAL RESTRICTIONS. }
{ }
{*******************************************************************}
unit cxGridExportLink;
{$I cxVer.inc}
interface
uses
{$IFDEF DELPHI6}
Types,
{$ENDIF}
Windows,
{$IFDEF DELPHI6}
Variants, FMTBcd, SqlTimSt,
{$ENDIF}
Classes, SysUtils, Graphics, cxGrid, cxExport, cxGridTableView, cxGridBandedTableView,
cxGridCustomView, cxCustomData, cxDBData, cxGridCustomTableView, cxStyles, DB,
cxGridCardView, cxGridLevel, cxEdit, cxImage, cxCalendar, cxCurrencyEdit, cxSpinEdit,
cxCalc, cxTimeEdit, cxGraphics, cxMaskEdit, cxClasses, cxGridStrs, cxDataUtils,
cxGridDBDataDefinitions, cxLookAndFeels, cxGridCommon, cxGridChartView,
cxLookAndFeelPainters, cxGeometry, cxControls, cxDataStorage, cxVariants;
const
cxGridFooterCellIndent: Integer = 0;
type
EcxGridExport = class(Exception);
{ TcxGridCustomExport }
TcxGridCustomExport = class
private
FColumns: TcxExportScale;
FDefaultRowHeight: Integer;
FDefaultStyle: TcxCacheCellStyle;
FDefaultStyleIndex: Integer;
FExpand: Boolean;
FExportType: Integer;
FFileName: string;
FGrid: TcxCustomGrid;
FGridView: TcxCustomGridView;
FInternalProvider: IcxCellInternalCache;
FInternalProviderSupported: Boolean;
FProvider: IcxExportProvider;
FRows: TcxExportScale;
FRecordsList: TList;
FSaveAll: Boolean;
FSaveGridModeFlag: Boolean;
FUseNativeFormat: Boolean;
FViewInfo: TcxCustomGridViewInfo;
function GetDataController: TcxCustomDataController;
function GetExpandButtonSize: Integer;
function GetRecord(ARecordIndex: Integer): TcxCustomGridRecord;
function GetRecordCount: Integer;
function GetViewInfo: TcxCustomGridViewInfo;
protected
procedure BeforeCommit; virtual;
function CalculateViewViewInfo(AGridView: TcxCustomGridView; ABounds: TRect): TcxCustomGridViewInfo; virtual;
function CheckNativeValue(AProperties: TcxCustomEditProperties; AItem: TcxCustomGridTableItem; const AValue: Variant): Variant;
procedure CreateExportCache; virtual;
procedure CreateExportCells; virtual;
procedure ExpandRecords(AFullExpand: Boolean); virtual;
procedure ExportCells; virtual;
procedure ExtractRowsForExport; virtual;
procedure FillArea(const ABounds: TRect; AStyleIndex: Integer;
ABorderColor: TColor = clDefault; ABorders: TcxBorders = cxBordersAll);
procedure FillRealArea(const ABounds: TRect; AStyleIndex: Integer;
ABorderColor: TColor = clDefault; ABorders: TcxBorders = cxBordersAll);
procedure Finalize; virtual;
function GetContentParams(ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
out AParams: TcxViewParams; ABorders: TcxBorders = []; ABorderColor: TColor = clDefault): TcxCacheCellStyle;
function GetViewItemValue(ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem): Variant;
function GetViewItemValueEx(ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AProperties: TcxCustomEditProperties): Variant; virtual;
function HasSelectedChildren(ARecord: TcxCustomGridRecord): Boolean;
function HasSelectedRecords(AView: TcxCustomGridView): Boolean;
procedure Initialize; virtual;
function IsCurrencyItem(AItem: TcxCustomGridTableItem): Boolean;
function IsCurrencyProperties(AProperties: TcxCustomEditProperties): Boolean;
function IsEmpty: Boolean;
function IsNativeFormatProperties(AProperties: TcxCustomEditProperties; AItem: TcxCustomGridTableItem): Boolean; virtual;
procedure RealBoundsToLogicalBounds(const ABounds: TRect; out ALogicalBounds: TRect);
procedure RealBoundsToLogicalBoundsEx(const ABounds, ASearchArea: TRect; out ALogicalBounds: TRect);
function RegisterContentParams(ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AParams: TcxViewParams): Integer;
function RegisterSolidStyle(AStyleIndex: Integer; AData: TObject = nil): Integer;
function RegisterSolidStyleEx(AColor: TColor): Integer;
procedure RegisterStyles; virtual;
function RegisterViewParams(const AViewParams: TcxViewParams; const AAlignment: TAlignment = taLeftJustify): Integer;
function SetCellAsGraphic(AColumn, ARow: Integer; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem): Boolean;
procedure SetCellValueAndStyle(AColumn, ARow: Integer;
const AValue: Variant; const AStyle: TcxCacheCellStyle);
procedure SetRealCellStyle(const ARealBounds, ASearchArea: TRect; AStyleIndex: Integer);
procedure SetRealCellStyleAndValue(const ARealBounds, ASearchArea: TRect; AStyleIndex: Integer; const AValue: Variant);
procedure SetRealCellStyleAndValueEx(const ARealBounds, ASearchArea: TRect;
AStyleIndex: Integer; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem);
function TextHeight(AFont: TFont): Integer;
function TextHeightEx(const AViewParams: TcxViewParams): Integer;
function TextWidth(AFont: TFont; const AText: string): Integer;
function TextWidthEx(const AViewParams: TcxViewParams; const AText: string): Integer;
procedure ViewParamsToExportStyle(const AViewParams: TcxViewParams;
var AExportStyle: TcxCacheCellStyle; const AAlignment: TAlignment = taLeftJustify;
ABorders: TcxBorders = []; ABorderColor: TColor = clDefault);
property DataController: TcxCustomDataController read GetDataController;
property DefaultRowHeight: Integer read FDefaultRowHeight write FDefaultRowHeight;
property DefaultStyle: TcxCacheCellStyle read FDefaultStyle write FDefaultStyle;
property DefaultStyleIndex: Integer read FDefaultStyleIndex write FDefaultStyleIndex;
property ExportType: Integer read FExportType;
property RecordsList: TList read FRecordsList;
public
constructor Create(AFileName: string; AExportType: Integer; AGridView: TcxCustomGridView;
AGrid: TcxCustomGrid; AViewInfo: TcxCustomGridViewInfo); virtual;
constructor CreateFrom(AMasterExport: TcxGridCustomExport;
AGridView: TcxCustomGridView; AViewInfo: TcxCustomGridViewInfo); virtual;
destructor Destroy; override;
procedure AddSeparators(const ASeparators: array of string);
procedure DoExport; virtual;
property Columns: TcxExportScale read FColumns;
property Expand: Boolean read FExpand write FExpand;
property ExpandButtonSize: Integer read GetExpandButtonSize;
property FileName: string read FFileName;
property Grid: TcxCustomGrid read FGrid;
property GridView: TcxCustomGridView read FGridView;
property InternalProvider: IcxCellInternalCache read FInternalProvider;
property InternalProviderSupported: Boolean read FInternalProviderSupported;
property Provider: IcxExportProvider read FProvider;
property RecordCount: Integer read GetRecordCount;
property Records[ARecordIndex: Integer]: TcxCustomGridRecord read GetRecord;
property Rows: TcxExportScale read FRows;
property SaveAll: Boolean read FSaveAll write FSaveAll;
property UseNativeFormat: Boolean read FUseNativeFormat write FUseNativeFormat;
property ViewInfo: TcxCustomGridViewInfo read GetViewInfo;
end;
TcxGridCustomExportClass = class of TcxGridCustomExport;
TcxExportVisualItem = class
public
Bounds: TRect;
Data: TObject;
Data2: TObject;
DisplayText: string;
Hidden: Boolean;
IsBackground: Boolean;
Style: Integer;
Slave: Boolean;
Value: Variant;
function GetBoundsRelativeTo(ATop, ALeft: Integer): TRect;
function IsColumn: Boolean;
end;
TcxExportGroupSummaryItem = class
public
Alignment: TAlignment;
Bounds: TRect;
Column: TcxGridColumn;
Index: Integer;
SummaryItem: TcxGridTableSummaryItem;
Text: string;
Value: Variant;
ViewParams: TcxViewParams;
procedure InitWidth;
end;
TcxExportVisualItemClass = class of TcxExportVisualItem;
{ TcxGridTableViewExport }
TcxGridTableViewExport = class(TcxGridCustomExport)
private
FGroupSummaryItemsList: TcxObjectList;
FRecordHeight: Integer;
FRecordRowCount: Integer;
FRecordWidth: Integer;
FPatternsList: TcxObjectList;
FVisualItemsList: TcxObjectList;
function GetFooterCellBorderColor: TColor;
function GetGridLineColor: TColor;
function GetGridLines: TcxBorders;
function GetGridView: TcxGridTableView;
function GetGroupSummaryCount: Integer;
function GetGroupSummaryItem(AIndex: Integer): TcxExportGroupSummaryItem;
function GetHasPreview(ARow: TcxCustomGridRecord): Boolean;
function GetIndicatorWidth: Integer;
function GetLeftPos: Integer;
function GetOptionsView: TcxGridTableOptionsView;
function GetPattern(AIndex: Integer): TcxExportVisualItem;
function GetPatternCount: Integer;
function GetPreviewPlace: TcxGridPreviewPlace;
function GetStyles: TcxGridTableViewStyles;
function GetViewInfo: TcxGridTableViewInfo;
function GetVisualItem(AIndex: Integer): TcxExportVisualItem;
function GetVisualItemCount: Integer;
procedure SetLeftPos(AValue: Integer);
protected
procedure AddDataRow(var ATop, ALeft: Integer; ARow: TcxGridDataRow); virtual;
procedure AddFooterCells(var ATop, ALeft: Integer; ARow: TcxCustomGridRow;
ALevel, ADataLevel: Integer; AItems: TcxDataSummaryItems; AValues: PVariant; AIsFooter: Boolean); virtual;
procedure AddGroupRow(var ATop, ALeft: Integer; ARow: TcxGridGroupRow); virtual;
function AddIndents(ATop, ARowHeight: Integer; ARow: TcxCustomGridRecord; AHasButton: Boolean; ALevel: Integer = -1): Integer; virtual;
procedure AddMasterDataRow(var ATop, ALeft: Integer; ARow: TcxGridMasterDataRow); virtual;
procedure AddRowFooter(var ATop, ALeft: Integer; ADataLevel, ALevel: Integer; ARow: TcxCustomGridRecord); virtual;
procedure AddRowFooters(var ATop, ALeft: Integer; ARow: TcxCustomGridRecord); virtual;
procedure AddRowPreview(var ATop, ALeft: Integer; ARow: TcxCustomGridRecord); virtual;
function AddVisualDataItem(const AItemBounds: TRect; AStyle: Integer;
ARecord: TcxCustomGridRecord; AColumn: TcxGridColumn): TcxExportVisualItem;
function AddVisualItem(AItemClass: TcxExportVisualItemClass; const ABounds: TRect): TcxExportVisualItem; virtual;
function AddVisualItemEx(const AItemBounds: TRect; const ADisplayText: string;
const AViewParams: TcxViewParams; AAlignment: TAlignment; ABorders: TcxBorders;
ABorderColor: TColor = clDefault; AIsBackground: Boolean = False): TcxExportVisualItem; overload;
function AddVisualItemEx(const AItemBounds: TRect; const ADisplayText: string;
AStyle: Integer; AIsBackground: Boolean = False): TcxExportVisualItem; overload;
function AddPattern(const ABounds: TRect; AData: TObject; AOffset: Integer = 0): TcxExportVisualItem;
function CanShowMultiSummaries(AIsFooter: Boolean): Boolean;
procedure CreateContent(var ATop, ALeft: Integer); virtual;
procedure CreateFooter(var ATop, ALeft: Integer); virtual;
procedure CreateHeader(var ATop, ALeft: Integer); virtual;
procedure CreateExportCells; override;
procedure CreateRecordFromPattern(var ATop, ALeft: Integer; ARecord: TcxCustomGridRecord);
function DoMergeCell(AMasterItem, ASlaveItem: TcxExportVisualItem): Boolean;
procedure ExportCells; override;
procedure ExportDetailCell(ACell: TcxExportVisualItem); virtual;
procedure Finalize; override;
function GetColumnOffset(AColumn: TcxGridColumn): Integer; virtual;
function GetExpandButtonParams(ABorders: TcxBorders): TcxCacheCellStyle;
function GetFooterCellCount(AItems: TcxDataSummaryItems): Integer;
function GetFooterItemBounds(AIndex, ALineIndex: Integer; const AOrigin: TRect; AIsFooter: Boolean): TRect;
function GetFooterLineCount(AItems: TcxDataSummaryItems): Integer;
function GetGroupRowColumnIntersection(const ARowBounds: TRect; AColumn: TcxGridColumn): TRect;
function GetIsSummaryUnderColumns: Boolean; virtual;
function GetPatternParams(ARecord: TcxCustomGridRecord; AItem: TcxExportVisualItem): TcxViewParams; virtual;
function GetPreviewHeight(ARow: TcxCustomGridRecord): Integer;
function HasFooter(ARow: TcxCustomGridRecord; var ALevel: Integer): Boolean; virtual;
procedure Initialize; override;
procedure MergeCells; virtual;
procedure ProcessGroupSummaryItem(ARow: TcxGridGroupRow; AValues: PVariant;
AIndex: Integer; const ABounds: TRect; const ARowViewParams: TcxViewParams);
procedure ProcessGroupSummaryItems(ARow: TcxGridGroupRow; ABounds: TRect);
procedure ProduceHeadersContainer(var ATop, ALeft: Integer;
AViewInfo: TcxGridColumnContainerViewInfo);
procedure SetPatternsBounds(ATop, ABottom: Integer);
property GroupSummaryItemCount: Integer read GetGroupSummaryCount;
property GroupSummaryItems[Index: Integer]: TcxExportGroupSummaryItem read GetGroupSummaryItem;
property GroupSummaryItemsList: TcxObjectList read FGroupSummaryItemsList;
property LeftPos: Integer read GetLeftPos write SetLeftPos;
property PatternCount: Integer read GetPatternCount;
property Patterns[Index: Integer]: TcxExportVisualItem read GetPattern;
property PatternsList: TcxObjectList read FPatternsList;
public
property FooterCellBorderColor: TColor read GetFooterCellBorderColor;
property GridLineColor: TColor read GetGridLineColor;
property GridLines: TcxBorders read GetGridLines;
property GridView: TcxGridTableView read GetGridView;
property HasPreview[ARow: TcxCustomGridRecord]: Boolean read GetHasPreview;
property IndicatorWidth: Integer read GetIndicatorWidth;
property IsSummaryUnderColumns: Boolean read GetIsSummaryUnderColumns;
property OptionsView: TcxGridTableOptionsView read GetOptionsView;
property PreviewPlace: TcxGridPreviewPlace read GetPreviewPlace;
property RecordHeight: Integer read FRecordHeight write FRecordHeight;
property RecordRowCount: Integer read FRecordRowCount;
property RecordWidth: Integer read FRecordWidth write FRecordHeight;
property Styles: TcxGridTableViewStyles read GetStyles;
property ViewInfo: TcxGridTableViewInfo read GetViewInfo;
property VisualItemCount: Integer read GetVisualItemCount;
property VisualItems[Index: Integer]: TcxExportVisualItem read GetVisualItem;
property VisualItemsList: TcxObjectList read FVisualItemsList;
end;
{ TcxGridBandedTableViewExport }
TcxGridBandedTableViewExport = class(TcxGridTableViewExport)
private
function GetGridView: TcxGridBandedTableView;
function GetOptionsView: TcxGridBandedTableOptionsView;
function GetViewInfo: TcxGridBandedTableViewInfo;
protected
procedure CreateBandHeaders(var ATop: Integer; AForRootBands: Boolean); virtual;
procedure CreateHeader(var ATop, ALeft: Integer); override;
function GetColumnOffset(AColumn: TcxGridColumn): Integer; override;
function GetContentOffset: TPoint; virtual;
function GetIsSummaryUnderColumns: Boolean; override;
function GetParentBandOffset(ABand: TcxGridBand): Integer;
function GetPatternByBand(ABand: TcxGridBand): TcxExportVisualItem;
function GetPatternParams(ARecord: TcxCustomGridRecord; AItem: TcxExportVisualItem): TcxViewParams; override;
function ProduceColumnsContainer(AContainer: TcxGridColumnContainerViewInfo; ATop, ALeft: Integer): Integer;
public
property ContentOffset: TPoint read GetContentOffset;
property GridView: TcxGridBandedTableView read GetGridView;
property OptionsView: TcxGridBandedTableOptionsView read GetOptionsView;
property ViewInfo: TcxGridBandedTableViewInfo read GetViewInfo;
end;
{ TcxGridCardViewExport }
TcxExportCard = class;
TcxGridCardViewExport = class;
TcxExportCardRow = class
private
FHasSeparator: Boolean;
FOwner: TcxExportCard;
function GetCaptionBounds: TRect;
function GetCaptionStyle: TcxViewParams;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?