home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 October
/
Chip_2002-10_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
FLEXCEL.ZIP
/
XLSAdapter
/
UXlsChart.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2002-07-01
|
4KB
|
123 lines
unit UXlsChart;
interface
uses UXlsBaseRecords, UXlsBaseRecordLists, UXlsOtherRecords,
XlsMessages, UXlsTokenArray, classes, sysutils, UXlsBaseList;
type
TChartRecord = class (TBaseRecord)
end;
TChartAIRecord = class (TChartRecord)
private
Flags, Flen: word;
procedure ArrangeTokensInsertRow(const InsPos, InsOffset, CopyOffset: integer; const SheetInfo: TSheetInfo);
public
constructor Create(const aId: word; const aData: PArrayOfByte; const aDataSize: integer);override;
procedure ArrangeInsert(const aPos, aCount:integer; const SheetInfo: TSheetInfo);
procedure ArrangeCopy(const NewRow, OldRow: Word);
end;
TChartAIRecordCache = class (TBaseList)
{$INCLUDE inc\TChartAIRecordCacheHdr.inc}
constructor Create;
procedure ArrangeInsert(const aPos, aCount:integer; const SheetInfo: TSheetInfo);
end;
TChartRecordList = class (TBaseRecordList)
private
AICache: TChartAIRecordCache;
protected
procedure Notify(Ptr: Pointer; Action: TListNotification);override;
public
constructor Create;
destructor Destroy;override;
procedure ArrangeInsert(const aPos, aCount:integer; const SheetInfo: TSheetInfo);
end;
implementation
{ TChartAIRecordCache }
{$INCLUDE inc\TChartAIRecordCacheImp.inc}
constructor TChartAIRecordCache.Create;
begin
inherited Create(False) //We don't own the objects
end;
procedure TChartAIRecordCache.ArrangeInsert(const aPos, aCount: integer;
const SheetInfo: TSheetInfo);
var
i: integer;
begin
for i:=0 to Count-1 do Items[i].ArrangeInsert(aPos, aCount,SheetInfo);
end;
{ TChartAIRecord }
//This doesn't make sense... all ranges in charts are absolute. But, anyway...
procedure TChartAIRecord.ArrangeCopy(const NewRow, OldRow: Word);
const
SheetInfo: TSheetInfo=(InsSheet:-1;FormulaSheet:-1;GetSheet:nil;SetSheet:nil);
begin
if Flen>0 then ArrangeTokensInsertRow(0, 0, NewRow - OldRow, SheetInfo); //Sheet info doesn't have meaninig on copy
end;
procedure TChartAIRecord.ArrangeTokensInsertRow(const InsPos, InsOffset,
CopyOffset: integer; const SheetInfo: TSheetInfo);
begin
try
UXlsTokenArray.ArrangeInsertRows(Data, 8, 8+FLen, InsPos, InsOffset, CopyOffset, SheetInfo);
except
on e: ETokenException do raise Exception.CreateFmt(ErrBadChartFormula,[e.Token]);
else raise;
end; //Except
end;
constructor TChartAIRecord.Create(const aId: word; const aData: PArrayOfByte;
const aDataSize: integer);
begin
inherited;
Flags:=GetWord(Data, 0);
FLen:=GetWord(Data, 6);
end;
procedure TChartAIRecord.ArrangeInsert(const aPos, aCount: integer;
const SheetInfo: TSheetInfo);
begin
if Flen>0 then ArrangeTokensInsertRow(aPos, aCount, 0, SheetInfo);
end;
{ TChartRecordList }
constructor TChartRecordList.Create;
begin
inherited;
AICache:= TChartAIRecordCache.Create;
end;
destructor TChartRecordList.Destroy;
begin
FreeAndNil(AICache);
inherited;
end;
procedure TChartRecordList.ArrangeInsert(const aPos, aCount: integer;
const SheetInfo: TSheetInfo);
begin
AICache.ArrangeInsert(aPos, aCount, SheetInfo);
end;
procedure TChartRecordList.Notify(Ptr: Pointer; Action: TListNotification);
begin
if (Action = lnDeleted) and (AICache<>nil) then if (TBaseRecord(Ptr) is TChartAIRecord) then
AICache.Delete(AICache.IndexOf(TBaseRecord(Ptr)));
if Action = lnAdded then if (TBaseRecord(Ptr) is TChartAIRecord) then
AICache.Add(TChartAIRecord(Ptr));
inherited Notify(Ptr, Action);
end;
end.