home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 October / Chip_2002-10_cd1.bin / zkuste / delphi / kolekce / d56 / FLEXCEL.ZIP / XLSAdapter / UXlsNotes.pas < prev    next >
Pascal/Delphi Source File  |  2002-07-03  |  3KB  |  137 lines

  1. unit UXlsNotes;
  2.  
  3. interface
  4. uses sysutils, UXlsBaseRecords, UXlsRowColEntries, UxlsBaseRecordLists,
  5.     UXlsEscher, UEscherRecords, XlsMessages;
  6. type
  7.   TNoteRecord = class (TBaseRowColRecord)
  8.   private
  9.     Dwg: TEscherClientDataRecord;
  10.     function GetText: Widestring;
  11.     procedure SetText(const Value: Widestring);
  12.   protected
  13.     function DoCopyTo: TBaseRecord; override;
  14.   public
  15.     destructor Destroy;override;
  16.     procedure ArrangeCopy(const NewRow: Word);override;
  17.     procedure ArrangeInsert(const aPos, aCount: integer; const SheetInfo: TSheetInfo); override;
  18.     procedure FixDwgIds(const Drawing: TDrawing);
  19.  
  20.     property Text: Widestring read GetText write SetText;
  21.   end;
  22.  
  23.   TNoteRecordList = class (TBaseRowColRecordList)
  24.     {$INCLUDE inc\TNoteRecordListHdr.inc}
  25.     procedure FixDwgIds(const Drawing: TDrawing);
  26.   end;
  27.  
  28.   TNoteList = class (TBaseRowColList) //records are TNoteRecordList
  29.     {$INCLUDE inc\TNoteListHdr.inc}
  30.     constructor Create;
  31.     procedure FixDwgIds(const Drawing: TDrawing);
  32.   end;
  33.  
  34.  
  35.  
  36. implementation
  37. uses UXlsClientData, UEscherOtherRecords;
  38. { TNoteRecord }
  39.  
  40. procedure TNoteRecord.ArrangeCopy(const NewRow: Word);
  41. begin
  42.   if Dwg<>nil then
  43.   begin
  44.     //We only copy DWG if we are copying rows, when we copy sheets we dont have to
  45.     Dwg:=Dwg.CopyDwg(NewRow-Row) as TEscherClientDataRecord;
  46.     SetWord(Data, 6, Dwg.ObjId);
  47.   end;
  48.   inherited; //This must be last, so we dont modify row
  49. end;
  50.  
  51. procedure TNoteRecord.ArrangeInsert(const aPos, aCount: integer;
  52.   const SheetInfo: TSheetInfo);
  53. begin
  54.   inherited;
  55.   if (Dwg<>nil) and (Dwg.FindRoot<>nil) then Dwg.FindRoot.ArrangeInsert(aPos, aCount, SheetInfo, true);
  56. end;
  57.  
  58. destructor TNoteRecord.Destroy;
  59. begin
  60.   if Dwg<>nil then
  61.   begin
  62.     if (Dwg.Patriarch=nil) then raise Exception.Create(ErrLoadingEscher);
  63.     Dwg.Patriarch.ContainedRecords.Remove(Dwg.FindRoot);
  64.   end;
  65.   inherited;
  66. end;
  67.  
  68. function TNoteRecord.DoCopyTo: TBaseRecord;
  69. begin
  70.   Result:=Inherited DoCopyTo;
  71.   (Result as TNoteRecord).Dwg:=Dwg;
  72. end;
  73.  
  74. procedure TNoteRecord.FixDwgIds(const Drawing: TDrawing);
  75. begin
  76.   Dwg:= Drawing.FindObjId(GetWord(Data, 6));
  77. end;
  78.  
  79. function TNoteRecord.GetText: Widestring;
  80. var
  81.   R:TEscherRecord;
  82. begin
  83.   if (Dwg=nil) then Result:='' else
  84.   begin
  85.     R:=Dwg.FindRoot;
  86.     if R=nil then Result:='' else
  87.     begin
  88.       R:= Dwg.FindRoot.FindRec(TEscherClientTextBoxRecord);
  89.       if R=nil then Result:='' else Result:= (R as TEscherClientTextBoxRecord).Value;
  90.     end;
  91.   end;
  92. end;
  93.  
  94. procedure TNoteRecord.SetText(const Value: Widestring);
  95. var
  96.   R:TEscherRecord;
  97. begin
  98.   if (Dwg=nil) then exit else
  99.   begin
  100.     R:=Dwg.FindRoot;
  101.     if R=nil then exit else
  102.     begin
  103.       R:= Dwg.FindRoot.FindRec(TEscherClientTextBoxRecord);
  104.       if R=nil then exit else (R as TEscherClientTextBoxRecord).Value:=Value;
  105.     end;
  106.   end;
  107. end;
  108.  
  109.  
  110.  
  111.  
  112. { TNoteRecordList }
  113. {$INCLUDE inc\TNoteRecordListImp.inc}
  114.  
  115. procedure TNoteRecordList.FixDwgIds(const Drawing: TDrawing);
  116. var
  117.   i: integer;
  118. begin
  119.   for i:=0 to Count-1 do Items[i].FixDwgIds(Drawing);
  120. end;
  121.  
  122. { TNoteList }
  123. {$INCLUDE inc\TNoteListImp.inc}
  124. constructor TNoteList.Create;
  125. begin
  126.   inherited Create(TNoteRecordList);
  127. end;
  128.  
  129. procedure TNoteList.FixDwgIds(const Drawing: TDrawing);
  130. var
  131.   i: integer;
  132. begin
  133.   for i:=0 to Count-1 do Items[i].FixDwgIds(Drawing);
  134. end;
  135.  
  136. end.
  137.