copy some items from RVE to another RVE

General TRichView support forum. Please post your questions here
Post Reply
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

copy some items from RVE to another RVE

Post by vit »

Hi!
I'm needed to copy some (not all!) items from rveSrc to rveTar. Is there simple way to make it?

I have write this method:

Code: Select all

procedure AssignRVData(Src, Tar: TCustomRVData);
var
  i: Integer;
  s: TCustomRVItemInfo;
  t: TCustomRVItemInfo;
  nc: TCustomRVItemInfoClass;
  r: Integer;
  c: Integer;
  stii: TRVTableItemInfo;
  ttii: TRVTableItemInfo;
begin
  Tar.Clear;
  for i := 0 to Src.ItemCount - 1 do
  begin
    s := Src.GetItem(i);
    if s is TRVTableItemInfo then
    begin
      stii := s as TRVTableItemInfo;
      ttii := TRVTableItemInfo.CreateEx(stii.RowCount, stii.ColCount, Tar);
      ttii.Assign(stii);
      ttii.AssignProperties(stii);
      ttii.BestWidth := stii.Width;
      Tar.AddItem('', ttii);
      for r := 0 to stii.RowCount - 1 do
        for c := 0 to stii.ColCount - 1 do
        begin
          AssignRVData(stii.Cells[r, c], ttii.Cells[r, c]);
          ttii.Cells[r, c].AssignAttributesFrom(stii.Cells[r, c], True, 1, 1);
        end;
    end
    else
    begin
      nc := TCustomRVItemInfoClass(s.ClassType);
      t := nc.Create(Src);
      t.Assign(s);
      Tar.AddItem(s.ItemText, t);
    end;
  end;
end;
(I'm don't needed to copy the controls)

And then call its:

AssignRVData(rveSrc.RVData, rveTar.RVData);
rveTar.Format;


But it's does't work correct (there is some troubles with bullets and lists). Or if is straightforward way not exist, how I should to modify my code for make its work more correct?

Thanks!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be it would be simpler to copy all items (SaveRVFToStream - LoadRVFFromStream), then delete some items (DeleteItems)?
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Well, its realy more simple. But is not very quickly with large documents (~100 pages).

Is there way to save in stream only concrete items (without selection its), not all?

Thank you for suggestion!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, no, only by copying as you do, with special processing of some item types.
I still suggest to consider copying+deleting, because it still will be very fast comparing to Format.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Thank you!
Post Reply